Convert to ANSI C

This commit is contained in:
Todd C. Miller
2010-02-27 09:29:59 -05:00
parent 841807dd66
commit 7ec040b541
5 changed files with 4 additions and 134 deletions

View File

@@ -171,22 +171,11 @@ estrdup(src)
* returns -1 (out of memory). * returns -1 (out of memory).
*/ */
int int
#ifdef __STDC__
easprintf(char **ret, const char *fmt, ...) easprintf(char **ret, const char *fmt, ...)
#else
easprintf(ret, fmt, va_alist)
char **ret;
const char *fmt;
va_dcl
#endif
{ {
int len; int len;
va_list ap; va_list ap;
#ifdef __STDC__
va_start(ap, fmt); va_start(ap, fmt);
#else
va_start(ap);
#endif
len = vasprintf(ret, fmt, ap); len = vasprintf(ret, fmt, ap);
va_end(ap); va_end(ap);

View File

@@ -26,11 +26,7 @@
# include <stdlib.h> # include <stdlib.h>
# endif # endif
#endif /* STDC_HEADERS */ #endif /* STDC_HEADERS */
#ifdef __STDC__ #include <stdarg.h>
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include "compat.h" #include "compat.h"
#include "logging.h" #include "logging.h"
@@ -40,12 +36,7 @@
#endif #endif
void void
#ifdef __STDC__
audit_success(char **exec_args) audit_success(char **exec_args)
#else
audit_success(exec_args)
const char **exec_args;
#endif
{ {
#ifdef HAVE_BSM_AUDIT #ifdef HAVE_BSM_AUDIT
bsm_audit_success(exec_args); bsm_audit_success(exec_args);
@@ -53,22 +44,11 @@ audit_success(exec_args)
} }
void void
#ifdef __STDC__
audit_failure(char **exec_args, char const *const fmt, ...) audit_failure(char **exec_args, char const *const fmt, ...)
#else
audit_failure(exec_args, fmt, va_alist)
const char **exec_args;
char const *const fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
#ifdef __STDC__
va_start(ap, fmt); va_start(ap, fmt);
#else
va_start(ap);
#endif
#ifdef HAVE_BSM_AUDIT #ifdef HAVE_BSM_AUDIT
bsm_audit_failure(exec_args, fmt, ap); bsm_audit_failure(exec_args, fmt, ap);
#endif #endif

View File

@@ -23,25 +23,14 @@
#include <compat.h> #include <compat.h>
#include "error.h" #include "error.h"
static void _warning __P((int, const char *, va_list)); static void _warning(int, const char *, va_list);
void cleanup __P((int)); void cleanup(int);
void void
#ifdef __STDC__
error(int eval, const char *fmt, ...) error(int eval, const char *fmt, ...)
#else
error(eval, fmt, va_alist)
int eval;
const char *fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
#ifdef __STDC__
va_start(ap, fmt); va_start(ap, fmt);
#else
va_start(ap);
#endif
_warning(1, fmt, ap); _warning(1, fmt, ap);
va_end(ap); va_end(ap);
cleanup(0); cleanup(0);
@@ -49,21 +38,10 @@ error(eval, fmt, va_alist)
} }
void void
#ifdef __STDC__
errorx(int eval, const char *fmt, ...) errorx(int eval, const char *fmt, ...)
#else
errorx(eval, fmt, va_alist)
int eval;
const char *fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
#ifdef __STDC__
va_start(ap, fmt); va_start(ap, fmt);
#else
va_start(ap);
#endif
_warning(0, fmt, ap); _warning(0, fmt, ap);
va_end(ap); va_end(ap);
cleanup(0); cleanup(0);
@@ -71,39 +49,19 @@ errorx(eval, fmt, va_alist)
} }
void void
#ifdef __STDC__
warning(const char *fmt, ...) warning(const char *fmt, ...)
#else
warning(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
#ifdef __STDC__
va_start(ap, fmt); va_start(ap, fmt);
#else
va_start(ap);
#endif
_warning(1, fmt, ap); _warning(1, fmt, ap);
va_end(ap); va_end(ap);
} }
void void
#ifdef __STDC__
warningx(const char *fmt, ...) warningx(const char *fmt, ...)
#else
warningx(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
#ifdef __STDC__
va_start(ap, fmt); va_start(ap, fmt);
#else
va_start(ap);
#endif
_warning(0, fmt, ap); _warning(0, fmt, ap);
va_end(ap); va_end(ap);
} }

View File

@@ -107,24 +107,13 @@ lbuf_destroy(lbuf)
* Append strings to the buffer, expanding it as needed. * Append strings to the buffer, expanding it as needed.
*/ */
void void
#ifdef __STDC__
lbuf_append_quoted(struct lbuf *lbuf, const char *set, ...) lbuf_append_quoted(struct lbuf *lbuf, const char *set, ...)
#else
lbuf_append_quoted(lbuf, set, va_alist)
struct lbuf *lbuf;
const char *set;
va_dcl
#endif
{ {
va_list ap; va_list ap;
int len = 0; int len = 0;
char *cp, *s; char *cp, *s;
#ifdef __STDC__
va_start(ap, set); va_start(ap, set);
#else
va_start(ap);
#endif
while ((s = va_arg(ap, char *)) != NULL) { while ((s = va_arg(ap, char *)) != NULL) {
len += strlen(s); len += strlen(s);
for (cp = s; (cp = strpbrk(cp, set)) != NULL; cp++) for (cp = s; (cp = strpbrk(cp, set)) != NULL; cp++)
@@ -140,11 +129,7 @@ lbuf_append_quoted(lbuf, set, va_alist)
lbuf->buf = erealloc(lbuf->buf, lbuf->size); lbuf->buf = erealloc(lbuf->buf, lbuf->size);
} }
#ifdef __STDC__
va_start(ap, set); va_start(ap, set);
#else
va_start(ap);
#endif
/* Append each string. */ /* Append each string. */
while ((s = va_arg(ap, char *)) != NULL) { while ((s = va_arg(ap, char *)) != NULL) {
while ((cp = strpbrk(s, set)) != NULL) { while ((cp = strpbrk(s, set)) != NULL) {
@@ -169,23 +154,13 @@ lbuf_append_quoted(lbuf, set, va_alist)
* Append strings to the buffer, expanding it as needed. * Append strings to the buffer, expanding it as needed.
*/ */
void void
#ifdef __STDC__
lbuf_append(struct lbuf *lbuf, ...) lbuf_append(struct lbuf *lbuf, ...)
#else
lbuf_append(lbuf, va_alist)
struct lbuf *lbuf;
va_dcl
#endif
{ {
va_list ap; va_list ap;
int len = 0; int len = 0;
char *s; char *s;
#ifdef __STDC__
va_start(ap, lbuf); va_start(ap, lbuf);
#else
va_start(ap);
#endif
while ((s = va_arg(ap, char *)) != NULL) while ((s = va_arg(ap, char *)) != NULL)
len += strlen(s); len += strlen(s);
va_end(ap); va_end(ap);
@@ -198,11 +173,7 @@ lbuf_append(lbuf, va_alist)
lbuf->buf = erealloc(lbuf->buf, lbuf->size); lbuf->buf = erealloc(lbuf->buf, lbuf->size);
} }
#ifdef __STDC__
va_start(ap, lbuf); va_start(ap, lbuf);
#else
va_start(ap);
#endif
/* Append each string. */ /* Append each string. */
while ((s = va_arg(ap, char *)) != NULL) { while ((s = va_arg(ap, char *)) != NULL) {
len = strlen(s); len = strlen(s);

View File

@@ -20,11 +20,7 @@
#ifndef HAVE_TIMESPEC #ifndef HAVE_TIMESPEC
# include <time.h> # include <time.h>
#endif #endif
#ifdef __STDC__ #include <stdarg.h>
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include <compat.h> #include <compat.h>
@@ -46,8 +42,6 @@ extern int errno;
return(-1); \ return(-1); \
} }
#ifdef __STDC__
#define DUMMY2(fn, t1, t2) \ #define DUMMY2(fn, t1, t2) \
int \ int \
fn(t1 a1, t2 a2) \ fn(t1 a1, t2 a2) \
@@ -63,28 +57,6 @@ int \
fn(t1 a1, t2 a2, ...) \ fn(t1 a1, t2 a2, ...) \
DUMMY_BODY DUMMY_BODY
#else /* !__STDC__ */
#define DUMMY2(fn, t1, t2) \
int \
fn(a1, a2) \
t1 a1; t2 a2; \
DUMMY_BODY
#define DUMMY3(fn, t1, t2, t3) \
int \
fn(a1, a2, a3) \
t1 a1; t2 a2; t3 a3; \
DUMMY_BODY
#define DUMMY_VA(fn, t1, t2) \
int \
fn(a1, a2, va_alist) \
t1 a1; t2 a2; va_dcl \
DUMMY_BODY
#endif /* !__STDC__ */
DUMMY_VA(execl, const char *, const char *) DUMMY_VA(execl, const char *, const char *)
DUMMY_VA(_execl, const char *, const char *) DUMMY_VA(_execl, const char *, const char *)
DUMMY_VA(__execl, const char *, const char *) DUMMY_VA(__execl, const char *, const char *)