]> granicus.if.org Git - sudo/commitdiff
Convert to ANSI C
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 5 Mar 2010 01:18:22 +0000 (20:18 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 5 Mar 2010 01:18:22 +0000 (20:18 -0500)
14 files changed:
src/Makefile.in
src/aix.c
src/alloc.c
src/atobool.c
src/error.c
src/fileops.c
src/lbuf.c
src/list.c
src/pty.c
src/sesh.c
src/sudo.c
src/sudo_edit.c
src/term.c
src/zero_bytes.c

index 2feec155f3a611854d299a8f6f9f5d6e9f75cec2..2fb34dd3c47b989e5817c4768d0dea7f8856fbd4 100644 (file)
@@ -28,7 +28,6 @@ compat = $(top_srcdir)/compat
 
 # Compiler & tools to use
 CC = @CC@
-NROFF = nroff -Tascii
 
 # Our install program supports extra flags...
 INSTALL = $(SHELL) $(top_srcdir)/install-sh -c
index aa615681937b2e89d88bfc455ca39321724cce2f..f7ea50a8cecce8acfb386a8ebdb1ef9239ba9946 100644 (file)
--- a/src/aix.c
+++ b/src/aix.c
@@ -63,10 +63,7 @@ static struct aix_limit aix_limits[] = {
 };
 
 static int
-aix_getlimit(user, lim, valp)
-    char *user;
-    char *lim;
-    rlim64_t *valp;
+aix_getlimit(char *user, char *lim, rlim64_t *valp)
 {
     int val;
 
@@ -79,8 +76,7 @@ aix_getlimit(user, lim, valp)
 }
 
 void
-aix_setlimits(user)
-    char *user;
+aix_setlimits(char *user)
 {
     struct rlimit64 rlim;
     rlim64_t val;
index 465b24d9ff2350a1fc4216185073295ba2f1541e..0811ef71ec1f365024e0a8bb9b64aa93b935cc6c 100644 (file)
@@ -46,7 +46,9 @@
 # include <inttypes.h>
 #endif
 
-#include "sudo.h"
+#include "compat.h"
+#include "alloc.h"
+#include "error.h"
 
 /*
  * If there is no SIZE_MAX or SIZE_T_MAX we have to assume that size_t
@@ -67,8 +69,7 @@
  * malloc(3) fails.
  */
 void *
-emalloc(size)
-    size_t size;
+emalloc(size_t size)
 {
     void *ptr;
 
@@ -85,9 +86,7 @@ emalloc(size)
  * if overflow would occur or if the system malloc(3) fails.
  */
 void *
-emalloc2(nmemb, size)
-    size_t nmemb;
-    size_t size;
+emalloc2(size_t nmemb, size_t size)
 {
     void *ptr;
 
@@ -108,9 +107,7 @@ emalloc2(nmemb, size)
  * if the system realloc(3) does not support this.
  */
 void *
-erealloc(ptr, size)
-    void *ptr;
-    size_t size;
+erealloc(void *ptr, size_t size)
 {
 
     if (size == 0)
@@ -129,10 +126,7 @@ erealloc(ptr, size)
  * does not support this.
  */
 void *
-erealloc3(ptr, nmemb, size)
-    void *ptr;
-    size_t nmemb;
-    size_t size;
+erealloc3(void *ptr, size_t nmemb, size_t size)
 {
 
     if (nmemb == 0 || size == 0)
@@ -152,8 +146,7 @@ erealloc3(ptr, nmemb, size)
  * malloc(3) fails.  NOTE: unlike strdup(3), estrdup(NULL) is legal.
  */
 char *
-estrdup(src)
-    const char *src;
+estrdup(const char *src)
 {
     char *dst = NULL;
     size_t len;
@@ -172,9 +165,7 @@ estrdup(src)
  * malloc(3) fails.  NOTE: unlike strdup(3), estrdup(NULL) is legal.
  */
 char *
-estrndup(src, maxlen)
-    const char *src;
-    size_t maxlen;
+estrndup(const char *src, size_t maxlen)
 {
     char *dst = NULL;
     size_t len;
@@ -213,10 +204,7 @@ easprintf(char **ret, const char *fmt, ...)
  * returns -1 (out of memory).
  */
 int
-evasprintf(ret, format, args)
-    char **ret;
-    const char *format;
-    va_list args;
+evasprintf(char **ret, const char *format, va_list args)
 {
     int len;
 
@@ -229,8 +217,7 @@ evasprintf(ret, format, args)
  * Wrapper for free(3) so we can depend on C89 semantics.
  */
 void
-efree(ptr)
-    void *ptr;
+efree(void *ptr)
 {
     if (ptr != NULL)
        free(ptr);
index d8d637a1ac8039573e829218858a8d975be4f2d9..9f02ebe0d68b2e8888275e1371d5d82211b47724 100644 (file)
 # endif
 #endif /* HAVE_STRING_H */
 
-#include "sudo.h"
+#include "compat.h"
+#include "missing.h"
 
 int
 atobool(const char *str)
 {
     if (strcasecmp(str, "true") == 0 || strcmp(str, "1") == 0)
-       return TRUE;
+       return 1;
     if (strcasecmp(str, "false") == 0 || strcmp(str, "0") == 0)
-       return FALSE;
+       return 0;
     return -1;
 }
index 0f33cde49dc02b721c4278e176ae2502a2ea557f..e6963af0a5f89204b7c0292b7870767916294dcf 100644 (file)
@@ -67,10 +67,7 @@ warningx(const char *fmt, ...)
 }
 
 static void
-_warning(use_errno, fmt, ap)
-       int use_errno;
-       const char *fmt;
-       va_list ap;
+_warning(int use_errno, const char *fmt, va_list ap)
 {
        int serrno = errno;
 
index 5e9d31dd67c6323c5a7ebf5da58f40735f7929fb..af942c5119d5708dea3836d5f64b6f62670dac50 100644 (file)
@@ -47,7 +47,7 @@
 # include <emul/timespec.h>
 #endif
 
-#include "sudo.h"
+#include "sudo.h" /* XXX - for SUDO_LOCK and friends */
 
 #ifndef LINE_MAX
 # define LINE_MAX 2048
  * Update the access and modify times on an fd or file.
  */
 int
-touch(fd, path, tsp)
-    int fd;
-    char *path;
-    struct timespec *tsp;
+touch(int fd, char *path, struct timespec *tsp)
 {
     struct timeval times[2];
 
@@ -85,9 +82,7 @@ touch(fd, path, tsp)
  */
 #ifdef HAVE_LOCKF
 int
-lock_file(fd, lockit)
-    int fd;
-    int lockit;
+lock_file(int fd, int lockit)
 {
     int op = 0;
 
@@ -106,9 +101,7 @@ lock_file(fd, lockit)
 }
 #elif HAVE_FLOCK
 int
-lock_file(fd, lockit)
-    int fd;
-    int lockit;
+lock_file(int fd, int lockit)
 {
     int op = 0;
 
@@ -127,9 +120,7 @@ lock_file(fd, lockit)
 }
 #else
 int
-lock_file(fd, lockit)
-    int fd;
-    int lockit;
+lock_file(int fd, int lockit)
 {
 #ifdef F_SETLK
     int func;
@@ -154,8 +145,7 @@ lock_file(fd, lockit)
  * and trailing spaces.  Returns static storage that is reused.
  */
 char *
-sudo_parseln(fp)
-    FILE *fp;
+sudo_parseln(FILE *fp)
 {
     size_t len;
     char *cp = NULL;
index b9ef3eaff577648a5a6871282f3dc49ebfad7632..d63433230aaf7cdb2991d9aeab127724e85a8943 100644 (file)
@@ -49,7 +49,9 @@
 # endif
 #endif
 
-#include "sudo.h"
+#include "compat.h"
+#include "alloc.h"
+#include "error.h"
 #include "missing.h"
 #include "lbuf.h"
 
@@ -60,7 +62,7 @@
 #endif
 
 int
-get_ttycols()
+get_ttycols(void)
 {
     char *p;
     int cols;
@@ -82,11 +84,7 @@ get_ttycols()
  */
 
 void
-lbuf_init(lbuf, buf, indent, continuation)
-    struct lbuf *lbuf;
-    char *buf;
-    int indent;
-    int continuation;
+lbuf_init(struct lbuf *lbuf, char *buf, int indent, int continuation)
 {
     lbuf->continuation = continuation;
     lbuf->indent = indent;
@@ -96,8 +94,7 @@ lbuf_init(lbuf, buf, indent, continuation)
 }
 
 void
-lbuf_destroy(lbuf)
-    struct lbuf *lbuf;
+lbuf_destroy(struct lbuf *lbuf)
 {
     efree(lbuf->buf);
     lbuf->buf = NULL;
@@ -189,8 +186,7 @@ lbuf_append(struct lbuf *lbuf, ...)
  * The lbuf is reset on return.
  */
 void
-lbuf_print(lbuf)
-    struct lbuf *lbuf;
+lbuf_print(struct lbuf *lbuf)
 {
     char *cp;
     int i, have, contlen;
index 1d8c2012ba29f603784c3aa299549fa5b16bbcf1..3d35ed48f1ccc9892e96b06666315bf86fbb254e 100644 (file)
 # endif
 #endif /* STDC_HEADERS */
 
-#include "sudo.h"
+#include "compat.h"
+#include "list.h"
+#ifdef DEBUG
+# include "error.h"
+#endif
 
 struct list_proto {
     struct list_proto *prev;
@@ -46,8 +50,7 @@ struct list_head_proto {
  * Returns the popped element.
  */
 void *
-tq_pop(vh)
-    void *vh;
+tq_pop(void *vh)
 {
     struct list_head_proto *h = (struct list_head_proto *)vh;
     void *last = NULL;
@@ -70,9 +73,7 @@ tq_pop(vh)
  * with a head node.
  */
 void
-list2tq(vh, vl)
-    void *vh;
-    void *vl;
+list2tq(void *vh, void *vl)
 {
     struct list_head_proto *h = (struct list_head_proto *)vh;
     struct list_proto *l = (struct list_proto *)vl;
@@ -98,9 +99,7 @@ list2tq(vh, vl)
  * circular properties of the prev pointer to simplify the logic.
  */
 void
-list_append(vl1, vl2)
-    void *vl1;
-    void *vl2;
+list_append(void *vl1, void *vl2)
 {
     struct list_proto *l1 = (struct list_proto *)vl1;
     struct list_proto *l2 = (struct list_proto *)vl2;
@@ -116,9 +115,7 @@ list_append(vl1, vl2)
  * e from a semi-circle queue to normal doubly-linked list. 
  */
 void
-tq_append(vh, vl)
-    void *vh;
-    void *vl;
+tq_append(void *vh, void *vl)
 {
     struct list_head_proto *h = (struct list_head_proto *)vh;
     struct list_proto *l = (struct list_proto *)vl;
@@ -136,9 +133,7 @@ tq_append(vh, vl)
  * Remove element from the tail_queue
  */
 void
-tq_remove(vh, vl)
-    void *vh;
-    void *vl;
+tq_remove(void *vh, void *vl)
 {
     struct list_head_proto *h = (struct list_head_proto *)vh;
     struct list_proto *l = (struct list_proto *)vl;
index bbb22f4e5492ba9ea12756ead78fbfcb46da98f7..180b887abc6509fff76c9a89ddc6a0f5a628bfea 100644 (file)
--- a/src/pty.c
+++ b/src/pty.c
@@ -94,8 +94,7 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t uid)
 #elif defined(HAVE_GRANTPT)
 # ifndef HAVE_POSIX_OPENPT
 static int
-posix_openpt(oflag)
-    int oflag;
+posix_openpt(int oflag)
 {
     int fd;
 
index 3195e25b9e8f429a315e7c203f8057376de7dab7..38a8349088064885bbf4c08ba5b259840b8f94a6 100644 (file)
@@ -30,7 +30,7 @@
 #include "compat.h"
 
 int
-main (int argc, char **argv)
+main (int argc, char *argv[])
 {
     char *cp, *cmnd;
 
index 7ff23eb4e56d34ef80b31e15ef4261494b5824e8..28210108ba3dab9c9601bba880f7b67ffafd319e 100644 (file)
@@ -583,8 +583,7 @@ disable_coredumps(void)
  * Cleanup hook for error()/errorx()
  */
 void
-cleanup(gotsignal)
-    int gotsignal;
+cleanup(int gotsignal)
 {
 #if 0 /* XXX */
     struct sudo_nss *nss;
index 079c449bd07308469b1cb87287a9076cfd26aaf5..347eed94cb97e71f12391de48e61e04fb93f62d3 100644 (file)
@@ -64,10 +64,7 @@ static char *find_editor();
  * Wrapper to allow users to edit privileged files with their own uid.
  */
 int
-sudo_edit(argc, argv, envp)
-    int argc;
-    char **argv;
-    char **envp;
+sudo_edit(int argc, char **argv, char **envp)
 {
     ssize_t nread, nwritten;
     pid_t kidpid, pid;
@@ -350,7 +347,7 @@ cleanup:
  * the uid of the invoking user, not the runas (privileged) user.
  */
 static char *
-find_editor()
+find_editor(void)
 {
     char *cp, *editor = NULL, **ev, *ev0[4];
 
index 221a28474e9ac1100417b8964d255a84daa24e25..bb5156b94dc5c47d98dba1f8d86da0b63ae56656 100644 (file)
@@ -105,9 +105,7 @@ int term_erase;
 int term_kill;
 
 int
-term_restore(fd, flush)
-    int fd;
-    int flush;
+term_restore(int fd, int flush)
 {
     if (changed) {
        int flags = TCSASOFT;
@@ -120,8 +118,7 @@ term_restore(fd, flush)
 }
 
 int
-term_noecho(fd)
-    int fd;
+term_noecho(int fd)
 {
     if (!changed && tcgetattr(fd, &oterm) != 0)
        return(0);
@@ -140,10 +137,7 @@ term_noecho(fd)
 #if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H)
 
 int
-term_raw(fd, opost, isig)
-    int fd;
-    int opost;
-    int isig;
+term_raw(int fd, int opost, int isig)
 {
     struct termios term;
 
@@ -168,8 +162,7 @@ term_raw(fd, opost, isig)
 }
 
 int
-term_cbreak(fd)
-    int fd;
+term_cbreak(int fd)
 {
     if (!changed && tcgetattr(fd, &oterm) != 0)
        return(0);
@@ -192,10 +185,7 @@ term_cbreak(fd)
 }
 
 int
-term_copy(src, dst, opost)
-    int src;
-    int dst;
-    int opost;
+term_copy(int src, int dst, int opost)
 {
     struct termios tt;
 
@@ -213,9 +203,7 @@ term_copy(src, dst, opost)
 #else /* SGTTY */
 
 int
-term_raw(fd, onlcr)
-    int fd;
-    int onlcr;
+term_raw(int fd, int onlcr)
 {
     if (!changed && ioctl(fd, TIOCGETP, &oterm) != 0)
        return(0);
@@ -234,8 +222,7 @@ term_raw(fd, onlcr)
 }
 
 int
-term_cbreak(fd)
-    int fd;
+term_cbreak(int fd)
 {
     if (!changed && ioctl(fd, TIOCGETP, &oterm) != 0)
        return(0);
@@ -253,10 +240,7 @@ term_cbreak(fd)
 }
 
 int
-term_copy(src, dst, onlcr)
-    int src;
-    int dst;
-    int onlcr;
+term_copy(int src, int dst, int onlcr)
 {
     struct sgttyb b;
     struct tchars tc;
index 7391780aa0c9a938a771455f54e89a02a7db968e..de14ece3973aed65ee1fa24ba3312c192bb63e05 100644 (file)
@@ -24,9 +24,7 @@
  * the compiler will not be able to optimize away this function.
  */
 void
-zero_bytes(v, n)
-    volatile void *v;
-    size_t n;
+zero_bytes(volatile void *v, size_t n)
 {
     volatile char *p, *ep;