]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/options.c
Convert to ANSI C
[ppp.git] / pppd / options.c
index e08c1080e738fa3ee2059bf4c632210d4baf58d2..c45f7cc552cbe1eba97b374b6fcd5e86259210dc 100644 (file)
@@ -40,9 +40,8 @@
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#define RCSID  "$Id: options.c,v 1.102 2008/06/15 06:53:06 paulus Exp $"
-
 #include <ctype.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
@@ -76,7 +75,7 @@
 #include "pathnames.h"
 
 #if defined(ultrix) || defined(NeXT)
-char *strdup __P((char *));
+char *strdup(char *);
 #endif
 
 
@@ -154,35 +153,35 @@ static char logfile_name[MAXPATHLEN];     /* name of log file */
 /*
  * Prototypes
  */
-static int setdomain __P((char **));
-static int readfile __P((char **));
-static int callfile __P((char **));
-static int showversion __P((char **));
-static int showhelp __P((char **));
-static void usage __P((void));
-static int setlogfile __P((char **));
+static int setdomain(char **);
+static int readfile(char **);
+static int callfile(char **);
+static int showversion(char **);
+static int showhelp(char **);
+static void usage(void);
+static int setlogfile(char **);
 #ifdef PLUGIN
-static int loadplugin __P((char **));
+static int loadplugin(char **);
 #endif
 
 #ifdef PPP_FILTER
-static int setpassfilter __P((char **));
-static int setactivefilter __P((char **));
+static int setpassfilter(char **);
+static int setactivefilter(char **);
 #endif
 
 #ifdef MAXOCTETS
-static int setmodir __P((char **));
+static int setmodir(char **);
 #endif
 
-static int user_setenv __P((char **));
-static void user_setprint __P((option_t *, printer_func, void *));
-static int user_unsetenv __P((char **));
-static void user_unsetprint __P((option_t *, printer_func, void *));
+static int user_setenv(char **);
+static void user_setprint(option_t *, printer_func, void *);
+static int user_unsetenv(char **);
+static void user_unsetprint(option_t *, printer_func, void *);
 
-static option_t *find_option __P((const char *name));
-static int process_option __P((option_t *, char *, char **));
-static int n_arguments __P((option_t *));
-static int number_option __P((char *, u_int32_t *, int));
+static option_t *find_option(char *name);
+static int process_option(option_t *, char *, char **);
+static int n_arguments(option_t *);
+static int number_option(char *, u_int32_t *, int);
 
 /*
  * Structure to store extra lists of options.
@@ -385,9 +384,7 @@ See pppd(8) for more options.\n\
  * parse_args - parse a string of arguments from the command line.
  */
 int
-parse_args(argc, argv)
-    int argc;
-    char **argv;
+parse_args(int argc, char **argv)
 {
     char *arg;
     option_t *opt;
@@ -423,11 +420,7 @@ parse_args(argc, argv)
  * and interpret them.
  */
 int
-options_from_file(filename, must_exist, check_prot, priv)
-    char *filename;
-    int must_exist;
-    int check_prot;
-    int priv;
+options_from_file(char *filename, int must_exist, int check_prot, int priv)
 {
     FILE *f;
     int i, newline, ret, err;
@@ -500,7 +493,7 @@ err:
  * and if so, interpret options from it.
  */
 int
-options_from_user()
+options_from_user(void)
 {
     char *user, *path, *file;
     int ret;
@@ -531,7 +524,7 @@ options_from_user()
  * files a lower priority than the command line.
  */
 int
-options_for_tty()
+options_for_tty(void)
 {
     char *dev, *path, *p;
     int ret;
@@ -561,9 +554,7 @@ options_for_tty()
  * options_from_list - process a string of options in a wordlist.
  */
 int
-options_from_list(w, priv)
-    struct wordlist *w;
-    int priv;
+options_from_list(struct wordlist *w, int priv)
 {
     char *argv[MAXARGS];
     option_t *opt;
@@ -607,18 +598,15 @@ err:
  * match_option - see if this option matches an option_t structure.
  */
 static int
-match_option(name, opt, dowild)
-    char *name;
-    option_t *opt;
-    int dowild;
+match_option(char *name, option_t *opt, int dowild)
 {
-       int (*match) __P((char *, char **, int));
+       int (*match)(char *, char **, int);
 
        if (dowild != (opt->type == o_wild))
                return 0;
        if (!dowild)
                return strcmp(name, opt->name) == 0;
-       match = (int (*) __P((char *, char **, int))) opt->addr;
+       match = (int (*)(char *, char **, int)) opt->addr;
        return (*match)(name, NULL, 0);
 }
 
@@ -628,8 +616,7 @@ match_option(name, opt, dowild)
  * This could be optimized by using a hash table.
  */
 static option_t *
-find_option(name)
-    const char *name;
+find_option(char *name)
 {
        option_t *opt;
        struct option_list *list;
@@ -662,16 +649,13 @@ find_option(name)
  * process_option - process one new-style option.
  */
 static int
-process_option(opt, cmd, argv)
-    option_t *opt;
-    char *cmd;
-    char **argv;
+process_option(option_t *opt, char *cmd, char **argv)
 {
     u_int32_t v;
     int iv, a;
     char *sv;
-    int (*parser) __P((char **));
-    int (*wildp) __P((char *, char **, int));
+    int (*parser)(char **);
+    int (*wildp)(char *, char **, int);
     char *optopt = (opt->type == o_wild)? "": " option";
     int prio = option_priority;
     option_t *mainopt = opt;
@@ -810,7 +794,7 @@ process_option(opt, cmd, argv)
 
     case o_special_noarg:
     case o_special:
-       parser = (int (*) __P((char **))) opt->addr;
+       parser = (int (*)(char **)) opt->addr;
        curopt = opt;
        if (!(*parser)(argv))
            return 0;
@@ -834,7 +818,7 @@ process_option(opt, cmd, argv)
        break;
 
     case o_wild:
-       wildp = (int (*) __P((char *, char **, int))) opt->addr;
+       wildp = (int (*)(char *, char **, int)) opt->addr;
        if (!(*wildp)(cmd, argv, 1))
            return 0;
        break;
@@ -861,10 +845,7 @@ process_option(opt, cmd, argv)
  * and source of the option value.  Otherwise returns 0.
  */
 int
-override_value(option, priority, source)
-    const char *option;
-    int priority;
-    const char *source;
+override_value(char *option, int priority, const char *source)
 {
        option_t *opt;
 
@@ -885,8 +866,7 @@ override_value(option, priority, source)
  * n_arguments - tell how many arguments an option takes
  */
 static int
-n_arguments(opt)
-    option_t *opt;
+n_arguments(option_t *opt)
 {
        return (opt->type == o_bool || opt->type == o_special_noarg
                || (opt->flags & OPT_NOARG))? 0: 1;
@@ -896,8 +876,7 @@ n_arguments(opt)
  * add_options - add a list of options to the set we grok.
  */
 void
-add_options(opt)
-    option_t *opt;
+add_options(option_t *opt)
 {
     struct option_list *list;
 
@@ -913,7 +892,7 @@ add_options(opt)
  * check_options - check that options are valid and consistent.
  */
 void
-check_options()
+check_options(void)
 {
        if (logfile_fd >= 0 && logfile_fd != log_to_fd)
                close(logfile_fd);
@@ -923,10 +902,7 @@ check_options()
  * print_option - print out an option and its value
  */
 static void
-print_option(opt, mainopt, printer, arg)
-    option_t *opt, *mainopt;
-    printer_func printer;
-    void *arg;
+print_option(option_t *opt, option_t *mainopt, printer_func printer, void *arg)
 {
        int i, v;
        char *p;
@@ -988,9 +964,9 @@ print_option(opt, mainopt, printer, arg)
                        printer(arg, " ");
                }
                if (opt->flags & OPT_A2PRINTER) {
-                       void (*oprt) __P((option_t *, printer_func, void *));
-                       oprt = (void (*) __P((option_t *, printer_func,
-                                        void *)))opt->addr2;
+                       void (*oprt)(option_t *, printer_func, void *);
+                       oprt = (void (*)(option_t *, printer_func, void *))
+                               opt->addr2;
                        (*oprt)(opt, printer, arg);
                } else if (opt->flags & OPT_A2STRVAL) {
                        p = (char *) opt->addr2;
@@ -1025,10 +1001,7 @@ print_option(opt, mainopt, printer, arg)
  * array of options.
  */
 static void
-print_option_list(opt, printer, arg)
-    option_t *opt;
-    printer_func printer;
-    void *arg;
+print_option_list(option_t *opt, printer_func printer, void *arg)
 {
        while (opt->name != NULL) {
                if (opt->priority != OPRIO_DEFAULT
@@ -1044,9 +1017,7 @@ print_option_list(opt, printer, arg)
  * print_options - print out what options are in effect.
  */
 void
-print_options(printer, arg)
-    printer_func printer;
-    void *arg;
+print_options(printer_func printer, void *arg)
 {
        struct option_list *list;
        int i;
@@ -1065,7 +1036,7 @@ print_options(printer, arg)
  * usage - print out a message telling how to use the program.
  */
 static void
-usage()
+usage(void)
 {
     if (phase == PHASE_INITIALIZE)
        fprintf(stderr, usage_string, VERSION, progname);
@@ -1075,8 +1046,7 @@ usage()
  * showhelp - print out usage message and exit.
  */
 static int
-showhelp(argv)
-    char **argv;
+showhelp(char **argv)
 {
     if (phase == PHASE_INITIALIZE) {
        usage();
@@ -1089,8 +1059,7 @@ showhelp(argv)
  * showversion - print out the version number and exit.
  */
 static int
-showversion(argv)
-    char **argv;
+showversion(char **argv)
 {
     if (phase == PHASE_INITIALIZE) {
        fprintf(stdout, "pppd version %s\n", VERSION);
@@ -1105,18 +1074,12 @@ showversion(argv)
  * stderr if phase == PHASE_INITIALIZE.
  */
 void
-option_error __V((char *fmt, ...))
+option_error(char *fmt, ...)
 {
     va_list args;
     char buf[1024];
 
-#if defined(__STDC__)
     va_start(args, fmt);
-#else
-    char *fmt;
-    va_start(args);
-    fmt = va_arg(args, char *);
-#endif
     vslprintf(buf, sizeof(buf), fmt, args);
     va_end(args);
     if (phase == PHASE_INITIALIZE)
@@ -1129,8 +1092,7 @@ option_error __V((char *fmt, ...))
  * readable - check if a file is readable by the real user.
  */
 int
-readable(fd)
-    int fd;
+readable(int fd)
 {
     uid_t uid;
     int i;
@@ -1159,11 +1121,7 @@ readable(fd)
  * \<newline> is ignored.
  */
 int
-getword(f, word, newlinep, filename)
-    FILE *f;
-    char *word;
-    int *newlinep;
-    char *filename;
+getword(FILE *f, char *word, int *newlinep, char *filename)
 {
     int c, len, escape;
     int quoted, comment;
@@ -1405,10 +1363,7 @@ getword(f, word, newlinep, filename)
  * number_option - parse an unsigned numeric parameter for an option.
  */
 static int
-number_option(str, valp, base)
-    char *str;
-    u_int32_t *valp;
-    int base;
+number_option(char *str, u_int32_t *valp, int base)
 {
     char *ptr;
 
@@ -1428,9 +1383,7 @@ number_option(str, valp, base)
  * if there is an error.
  */
 int
-int_option(str, valp)
-    char *str;
-    int *valp;
+int_option(char *str, int *valp)
 {
     u_int32_t v;
 
@@ -1449,8 +1402,7 @@ int_option(str, valp)
  * readfile - take commands from a file.
  */
 static int
-readfile(argv)
-    char **argv;
+readfile(char **argv)
 {
     return options_from_file(*argv, 1, 1, privileged_option);
 }
@@ -1460,8 +1412,7 @@ readfile(argv)
  * Name may not contain /../, start with / or ../, or end in /..
  */
 static int
-callfile(argv)
-    char **argv;
+callfile(char **argv)
 {
     char *fname, *arg, *p;
     int l, ok;
@@ -1503,8 +1454,7 @@ callfile(argv)
  * setpassfilter - Set the pass filter for packets
  */
 static int
-setpassfilter(argv)
-    char **argv;
+setpassfilter(char **argv)
 {
     pcap_t *pc;
     int ret = 1;
@@ -1524,8 +1474,7 @@ setpassfilter(argv)
  * setactivefilter - Set the active filter for packets
  */
 static int
-setactivefilter(argv)
-    char **argv;
+setactivefilter(char **argv)
 {
     pcap_t *pc;
     int ret = 1;
@@ -1546,8 +1495,7 @@ setactivefilter(argv)
  * setdomain - Set domain name to append to hostname 
  */
 static int
-setdomain(argv)
-    char **argv;
+setdomain(char **argv)
 {
     gethostname(hostname, MAXNAMELEN);
     if (**argv != 0) {
@@ -1561,8 +1509,7 @@ setdomain(argv)
 }
 
 static int
-setlogfile(argv)
-    char **argv;
+setlogfile(char **argv)
 {
     int fd, err;
     uid_t euid;
@@ -1594,8 +1541,7 @@ setlogfile(argv)
 
 #ifdef MAXOCTETS
 static int
-setmodir(argv)
-    char **argv;
+setmodir(char **argv)
 {
     if(*argv == NULL)
        return 0;
@@ -1614,13 +1560,12 @@ setmodir(argv)
 
 #ifdef PLUGIN
 static int
-loadplugin(argv)
-    char **argv;
+loadplugin(char **argv)
 {
     char *arg = *argv;
     void *handle;
     const char *err;
-    void (*init) __P((void));
+    void (*init)(void);
     char *path = arg;
     const char *vers;
 
@@ -1672,8 +1617,7 @@ loadplugin(argv)
  * Set an environment variable specified by the user.
  */
 static int
-user_setenv(argv)
-    char **argv;
+user_setenv(char **argv)
 {
     char *arg = argv[0];
     char *eqp;
@@ -1725,10 +1669,7 @@ user_setenv(argv)
 }
 
 static void
-user_setprint(opt, printer, arg)
-    option_t *opt;
-    printer_func printer;
-    void *arg;
+user_setprint(option_t *opt, printer_func printer, void *arg)
 {
     struct userenv *uep, *uepnext;
 
@@ -1748,8 +1689,7 @@ user_setprint(opt, printer, arg)
 }
 
 static int
-user_unsetenv(argv)
-    char **argv;
+user_unsetenv(char **argv)
 {
     struct userenv *uep, **insp;
     char *arg = argv[0];
@@ -1797,10 +1737,7 @@ user_unsetenv(argv)
 }
 
 static void
-user_unsetprint(opt, printer, arg)
-    option_t *opt;
-    printer_func printer;
-    void *arg;
+user_unsetprint(option_t *opt, printer_func printer, void *arg)
 {
     struct userenv *uep, *uepnext;