rbb         99/11/22 06:52:18

  Modified:    src/lib/apr/include apr_general.h apr_getopt.h
               src/lib/apr/misc/beos getopt.c
               src/lib/apr/misc/os2 getopt.c
               src/lib/apr/misc/unix getopt.c
               src/lib/apr/misc/win32 getopt.c
               src/lib/apr/test testargs.c
               src/main http_main.c
  Log:
  Clean up the getopt stuff a bit.  Basically, I am removing the #define's,
  and changing the names in the getopt.c file so that we are sure there is
  no namespace collision between regular getopt's, and APR's getopt.
  
  Revision  Changes    Path
  1.10      +0 -3      apache-2.0/src/lib/apr/include/apr_general.h
  
  Index: apr_general.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_general.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- apr_general.h     1999/11/09 09:01:14     1.9
  +++ apr_general.h     1999/11/22 14:52:10     1.10
  @@ -241,9 +241,6 @@
   ap_status_t ap_send_signal(ap_signum_t, ap_context_t *);
   ap_status_t ap_setup_signal(ap_signum_t, Sigfunc *, ap_context_t *);
   
  -ap_status_t ap_getopt(ap_context_t *, ap_int32_t, char *const *, const char 
*,
  -                      ap_int32_t *); 
  -
   #ifdef __cplusplus
   }
   #endif
  
  
  
  1.2       +9 -17     apache-2.0/src/lib/apr/include/apr_getopt.h
  
  Index: apr_getopt.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_getopt.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apr_getopt.h      1999/11/20 22:05:23     1.1
  +++ apr_getopt.h      1999/11/22 14:52:11     1.2
  @@ -56,24 +56,16 @@
   #ifndef APR_GETOPT_H
   #define APR_GETOPT_H
   
  -/* Rename all interfaces to prevent a name clash with system libraries */
  -#define opterr   apr_opterr
  -#define optind   apr_optind
  -#define optopt   apr_optopt
  -#define optreset apr_optreset
  -#define optarg   apr_optarg
  -#define getopt   apr_getopt
  +API_VAR_IMPORT int
  +    ap_opterr,                          /* if error message should be 
printed */
  +    ap_optind,                          /* index into parent argv vector */
  +    ap_optopt,                          /* character checked for validity */
  +    ap_optreset;                        /* reset getopt */
  +API_VAR_IMPORT char *
  +    ap_optarg;                          /* argument associated with option */
   
  -extern int
  -    opterr,                          /* if error message should be printed */
  -    optind,                          /* index into parent argv vector */
  -    optopt,                          /* character checked for validity */
  -    optreset;                        /* reset getopt */
  -extern char *
  -    optarg;                          /* argument associated with option */
  -
  -extern int
  -    getopt(int _argc, char *const _argv[], const char *_opts);
  +ap_status_t ap_getopt(ap_context_t *, ap_int32_t, char *const *, const char 
*,
  +                      ap_int32_t *);
   
   #endif  /* ! APR_GETOPT_H */
   
  
  
  
  1.2       +30 -30    apache-2.0/src/lib/apr/misc/beos/getopt.c
  
  Index: getopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/beos/getopt.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- getopt.c  1999/09/07 13:16:44     1.1
  +++ getopt.c  1999/11/22 14:52:13     1.2
  @@ -36,11 +36,11 @@
   #include <string.h>
   #include "misc.h"
   
  -int opterr = 1,                      /* if error message should be printed */
  -    optind = 1,                      /* index into parent argv vector */
  -    optopt,                          /* character checked for validity */
  -    optreset;                        /* reset getopt */
  -char *optarg;                        /* argument associated with option */
  +int ap_opterr = 1,                      /* if error message should be 
printed */
  +    ap_optind = 1,                      /* index into parent argv vector */
  +    ap_optopt,                          /* character checked for validity */
  +    ap_optreset;                        /* reset getopt */
  +char *ap_optarg = "";                   /* argument associated with option */
   
   #define EMSG    ""
   
  @@ -70,73 +70,73 @@
       static char *place = EMSG;   /* option letter processing */
       char *oli;                   /* option letter list index */
   
  -    if (optreset || !*place) {   /* update scanning pointer */
  -        optreset = 0;
  -        if (optind >= nargc || *(place = nargv[optind]) != '-') {
  +    if (ap_optreset || !*place) {   /* update scanning pointer */
  +        ap_optreset = 0;
  +        if (ap_optind >= nargc || *(place = nargv[ap_optind]) != '-') {
               place = EMSG;
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_EOF);
           }
           if (place[1] && *++place == '-') {        /* found "--" */
  -            ++optind;
  +            ++ap_optind;
               place = EMSG;
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_EOF);
           }
       }                                /* option letter okay? */
  -    if ((optopt = (int) *place++) == (int) ':' ||
  -        !(oli = strchr(ostr, optopt))) {
  +    if ((ap_optopt = (int) *place++) == (int) ':' ||
  +        !(oli = strchr(ostr, ap_optopt))) {
           /*
            * if the user didn't specify '-' as an option,
            * assume it means -1.
            */
  -        if (optopt == (int) '-')
  -            *rv = optopt;
  +        if (ap_optopt == (int) '-')
  +            *rv = ap_optopt;
               return (APR_EOF);
           if (!*place)
  -            ++optind;
  -        if (opterr && *ostr != ':') {
  +            ++ap_optind;
  +        if (ap_opterr && *ostr != ':') {
               if (!(p = strrchr(*nargv, '/')))
                   p = *nargv;
               else
                   ++p;
               (void) fprintf(stderr,
  -                           "%s: illegal option -- %c\n", p, optopt);
  +                           "%s: illegal option -- %c\n", p, ap_optopt);
           }
  -        *rv = optopt;
  +        *rv = ap_optopt;
           return APR_BADCH;
       }
       if (*++oli != ':') {        /* don't need argument */
  -        optarg = NULL;
  +        ap_optarg = NULL;
           if (!*place)
  -            ++optind;
  +            ++ap_optind;
       }
       else {                        /* need an argument */
           if (*place)                /* no white space */
  -            optarg = place;
  -        else if (nargc <= ++optind) {        /* no arg */
  +            ap_optarg = place;
  +        else if (nargc <= ++ap_optind) {        /* no arg */
               place = EMSG;
               if (*ostr == ':')
  -                *rv = optopt;
  +                *rv = ap_optopt;
                   return (APR_BADARG);
  -            if (opterr) {
  +            if (ap_opterr) {
                   if (!(p = strrchr(*nargv, '/')))
                       p = *nargv;
                   else
                       ++p;
                   (void) fprintf(stderr,
                                  "%s: option requires an argument -- %c\n",
  -                               p, optopt);
  +                               p, ap_optopt);
               }
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_BADCH);
           }
           else                        /* white space */
  -            optarg = nargv[optind];
  +            ap_optarg = nargv[ap_optind];
           place = EMSG;
  -        ++optind;
  +        ++ap_optind;
       }
  -    *rv = optopt;
  +    *rv = ap_optopt;
       return APR_SUCCESS;
   }
   
  
  
  
  1.2       +30 -30    apache-2.0/src/lib/apr/misc/os2/getopt.c
  
  Index: getopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/os2/getopt.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- getopt.c  1999/08/29 12:28:54     1.1
  +++ getopt.c  1999/11/22 14:52:14     1.2
  @@ -36,11 +36,11 @@
   #include <string.h>
   #include "misc.h"
   
  -int opterr = 1,                      /* if error message should be printed */
  -    optind = 1,                      /* index into parent argv vector */
  -    optopt,                          /* character checked for validity */
  -    optreset;                        /* reset getopt */
  -char *optarg;                        /* argument associated with option */
  +int ap_opterr = 1,                      /* if error message should be 
printed */
  +    ap_optind = 1,                      /* index into parent argv vector */
  +    ap_optopt,                          /* character checked for validity */
  +    ap_optreset;                        /* reset getopt */
  +char *ap_optarg = "";                   /* argument associated with option */
   
   #define EMSG    ""
   
  @@ -70,73 +70,73 @@
       static char *place = EMSG;   /* option letter processing */
       char *oli;                   /* option letter list index */
   
  -    if (optreset || !*place) {   /* update scanning pointer */
  -        optreset = 0;
  -        if (optind >= nargc || *(place = nargv[optind]) != '-') {
  +    if (ap_optreset || !*place) {   /* update scanning pointer */
  +        ap_optreset = 0;
  +        if (ap_optind >= nargc || *(place = nargv[ap_optind]) != '-') {
               place = EMSG;
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_EOF);
           }
           if (place[1] && *++place == '-') {        /* found "--" */
  -            ++optind;
  +            ++ap_optind;
               place = EMSG;
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_EOF);
           }
       }                                /* option letter okay? */
  -    if ((optopt = (int) *place++) == (int) ':' ||
  -        !(oli = strchr(ostr, optopt))) {
  +    if ((ap_optopt = (int) *place++) == (int) ':' ||
  +        !(oli = strchr(ostr, ap_optopt))) {
           /*
            * if the user didn't specify '-' as an option,
            * assume it means -1.
            */
  -        if (optopt == (int) '-')
  -            *rv = optopt;
  +        if (ap_optopt == (int) '-')
  +            *rv = ap_optopt;
               return (APR_EOF);
           if (!*place)
  -            ++optind;
  -        if (opterr && *ostr != ':') {
  +            ++ap_optind;
  +        if (ap_opterr && *ostr != ':') {
               if (!(p = strrchr(*nargv, '/')))
                   p = *nargv;
               else
                   ++p;
               (void) fprintf(stderr,
  -                           "%s: illegal option -- %c\n", p, optopt);
  +                           "%s: illegal option -- %c\n", p, ap_optopt);
           }
  -        *rv = optopt;
  +        *rv = ap_optopt;
           return APR_BADCH;
       }
       if (*++oli != ':') {        /* don't need argument */
  -        optarg = NULL;
  +        ap_optarg = NULL;
           if (!*place)
  -            ++optind;
  +            ++ap_optind;
       }
       else {                        /* need an argument */
           if (*place)                /* no white space */
  -            optarg = place;
  -        else if (nargc <= ++optind) {        /* no arg */
  +            ap_optarg = place;
  +        else if (nargc <= ++ap_optind) {        /* no arg */
               place = EMSG;
               if (*ostr == ':')
  -                *rv = optopt;
  +                *rv = ap_optopt;
                   return (APR_BADARG);
  -            if (opterr) {
  +            if (ap_opterr) {
                   if (!(p = strrchr(*nargv, '/')))
                       p = *nargv;
                   else
                       ++p;
                   (void) fprintf(stderr,
                                  "%s: option requires an argument -- %c\n",
  -                               p, optopt);
  +                               p, ap_optopt);
               }
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_BADCH);
           }
           else                        /* white space */
  -            optarg = nargv[optind];
  +            ap_optarg = nargv[ap_optind];
           place = EMSG;
  -        ++optind;
  +        ++ap_optind;
       }
  -    *rv = optopt;
  +    *rv = ap_optopt;
       return APR_SUCCESS;
   }
   
  
  
  
  1.2       +30 -30    apache-2.0/src/lib/apr/misc/unix/getopt.c
  
  Index: getopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/unix/getopt.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- getopt.c  1999/08/17 15:59:42     1.1
  +++ getopt.c  1999/11/22 14:52:15     1.2
  @@ -36,11 +36,11 @@
   #include <string.h>
   #include "misc.h"
   
  -int opterr = 1,                      /* if error message should be printed */
  -    optind = 1,                      /* index into parent argv vector */
  -    optopt,                          /* character checked for validity */
  -    optreset;                        /* reset getopt */
  -char *optarg;                        /* argument associated with option */
  +int ap_opterr = 1,                      /* if error message should be 
printed */
  +    ap_optind = 1,                      /* index into parent argv vector */
  +    ap_optopt,                          /* character checked for validity */
  +    ap_optreset;                        /* reset getopt */
  +char *ap_optarg = "";                   /* argument associated with option */
   
   #define EMSG    ""
   
  @@ -70,73 +70,73 @@
       static char *place = EMSG;   /* option letter processing */
       char *oli;                   /* option letter list index */
   
  -    if (optreset || !*place) {   /* update scanning pointer */
  -        optreset = 0;
  -        if (optind >= nargc || *(place = nargv[optind]) != '-') {
  +    if (ap_optreset || !*place) {   /* update scanning pointer */
  +        ap_optreset = 0;
  +        if (ap_optind >= nargc || *(place = nargv[ap_optind]) != '-') {
               place = EMSG;
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_EOF);
           }
           if (place[1] && *++place == '-') {        /* found "--" */
  -            ++optind;
  +            ++ap_optind;
               place = EMSG;
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_EOF);
           }
       }                                /* option letter okay? */
  -    if ((optopt = (int) *place++) == (int) ':' ||
  -        !(oli = strchr(ostr, optopt))) {
  +    if ((ap_optopt = (int) *place++) == (int) ':' ||
  +        !(oli = strchr(ostr, ap_optopt))) {
           /*
            * if the user didn't specify '-' as an option,
            * assume it means -1.
            */
  -        if (optopt == (int) '-')
  -            *rv = optopt;
  +        if (ap_optopt == (int) '-')
  +            *rv = ap_optopt;
               return (APR_EOF);
           if (!*place)
  -            ++optind;
  -        if (opterr && *ostr != ':') {
  +            ++ap_optind;
  +        if (ap_opterr && *ostr != ':') {
               if (!(p = strrchr(*nargv, '/')))
                   p = *nargv;
               else
                   ++p;
               (void) fprintf(stderr,
  -                           "%s: illegal option -- %c\n", p, optopt);
  +                           "%s: illegal option -- %c\n", p, ap_optopt);
           }
  -        *rv = optopt;
  +        *rv = ap_optopt;
           return APR_BADCH;
       }
       if (*++oli != ':') {        /* don't need argument */
  -        optarg = NULL;
  +        ap_optarg = NULL;
           if (!*place)
  -            ++optind;
  +            ++ap_optind;
       }
       else {                        /* need an argument */
           if (*place)                /* no white space */
  -            optarg = place;
  -        else if (nargc <= ++optind) {        /* no arg */
  +            ap_optarg = place;
  +        else if (nargc <= ++ap_optind) {        /* no arg */
               place = EMSG;
               if (*ostr == ':')
  -                *rv = optopt;
  +                *rv = ap_optopt;
                   return (APR_BADARG);
  -            if (opterr) {
  +            if (ap_opterr) {
                   if (!(p = strrchr(*nargv, '/')))
                       p = *nargv;
                   else
                       ++p;
                   (void) fprintf(stderr,
                                  "%s: option requires an argument -- %c\n",
  -                               p, optopt);
  +                               p, ap_optopt);
               }
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_BADCH);
           }
           else                        /* white space */
  -            optarg = nargv[optind];
  +            ap_optarg = nargv[ap_optind];
           place = EMSG;
  -        ++optind;
  +        ++ap_optind;
       }
  -    *rv = optopt;
  +    *rv = ap_optopt;
       return APR_SUCCESS;
   }
   
  
  
  
  1.2       +30 -30    apache-2.0/src/lib/apr/misc/win32/getopt.c
  
  Index: getopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/win32/getopt.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- getopt.c  1999/08/17 15:59:42     1.1
  +++ getopt.c  1999/11/22 14:52:15     1.2
  @@ -36,11 +36,11 @@
   #include <string.h>
   #include "misc.h"
   
  -int opterr = 1,                      /* if error message should be printed */
  -    optind = 1,                      /* index into parent argv vector */
  -    optopt,                          /* character checked for validity */
  -    optreset;                        /* reset getopt */
  -char *optarg = "";                        /* argument associated with option 
*/
  +int ap_opterr = 1,                      /* if error message should be 
printed */
  +    ap_optind = 1,                      /* index into parent argv vector */
  +    ap_optopt,                          /* character checked for validity */
  +    ap_optreset;                        /* reset getopt */
  +char *ap_optarg = "";                   /* argument associated with option */
   
   #define EMSG    ""
   
  @@ -70,73 +70,73 @@
       static char *place = EMSG;   /* option letter processing */
       char *oli;                   /* option letter list index */
   
  -    if (optreset || !*place) {   /* update scanning pointer */
  -        optreset = 0;
  -        if (optind >= nargc || *(place = nargv[optind]) != '-') {
  +    if (ap_optreset || !*place) {   /* update scanning pointer */
  +        ap_optreset = 0;
  +        if (ap_optind >= nargc || *(place = nargv[ap_optind]) != '-') {
               place = EMSG;
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_EOF);
           }
           if (place[1] && *++place == '-') {        /* found "--" */
  -            ++optind;
  +            ++ap_optind;
               place = EMSG;
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_EOF);
           }
       }                                /* option letter okay? */
  -    if ((optopt = (int) *place++) == (int) ':' ||
  -        !(oli = strchr(ostr, optopt))) {
  +    if ((ap_optopt = (int) *place++) == (int) ':' ||
  +        !(oli = strchr(ostr, ap_optopt))) {
           /*
            * if the user didn't specify '-' as an option,
            * assume it means -1.
            */
  -        if (optopt == (int) '-')
  -            *rv = optopt;
  +        if (ap_optopt == (int) '-')
  +            *rv = ap_optopt;
               return (APR_EOF);
           if (!*place)
  -            ++optind;
  -        if (opterr && *ostr != ':') {
  +            ++ap_optind;
  +        if (ap_opterr && *ostr != ':') {
               if (!(p = strrchr(*nargv, '/')))
                   p = *nargv;
               else
                   ++p;
               (void) fprintf(stderr,
  -                           "%s: illegal option -- %c\n", p, optopt);
  +                           "%s: illegal option -- %c\n", p, ap_optopt);
           }
  -        *rv = optopt;
  +        *rv = ap_optopt;
           return APR_BADCH;
       }
       if (*++oli != ':') {        /* don't need argument */
  -        optarg = NULL;
  +        ap_optarg = NULL;
           if (!*place)
  -            ++optind;
  +            ++ap_optind;
       }
       else {                        /* need an argument */
           if (*place)                /* no white space */
  -            optarg = place;
  -        else if (nargc <= ++optind) {        /* no arg */
  +            ap_optarg = place;
  +        else if (nargc <= ++ap_optind) {        /* no arg */
               place = EMSG;
               if (*ostr == ':')
  -                *rv = optopt;
  +                *rv = ap_optopt;
                   return (APR_BADARG);
  -            if (opterr) {
  +            if (ap_opterr) {
                   if (!(p = strrchr(*nargv, '/')))
                       p = *nargv;
                   else
                       ++p;
                   (void) fprintf(stderr,
                                  "%s: option requires an argument -- %c\n",
  -                               p, optopt);
  +                               p, ap_optopt);
               }
  -            *rv = optopt;
  +            *rv = ap_optopt;
               return (APR_BADCH);
           }
           else                        /* white space */
  -            optarg = nargv[optind];
  +            ap_optarg = nargv[ap_optind];
           place = EMSG;
  -        ++optind;
  +        ++ap_optind;
       }
  -    *rv = optopt;
  +    *rv = ap_optopt;
       return APR_SUCCESS;
   }
   
  
  
  
  1.6       +3 -4      apache-2.0/src/lib/apr/test/testargs.c
  
  Index: testargs.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/test/testargs.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- testargs.c        1999/11/22 13:48:06     1.5
  +++ testargs.c        1999/11/22 14:52:16     1.6
  @@ -57,13 +57,12 @@
   #include "apr_errno.h"
   #include "apr_general.h"
   #include "apr_lib.h"
  +#include "apr_getopt.h"
   #include <stdio.h>
   #ifdef BEOS
   #include <unistd.h>
   #endif
   
  -API_VAR_IMPORT char *optarg;                        /* argument associated 
with option */
  -
   int main(int argc, char * const argv[])
   {
       ap_context_t *context;
  @@ -78,12 +77,12 @@
                   printf("option %c\n", data);
                   break;
               case 'c':
  -                printf("option %c with %s\n", data, optarg);
  +                printf("option %c with %s\n", data, ap_optarg);
                   break;
               case 'd':
                   printf("option %c", data);
                   if (optarg) {
  -                    printf(" with %s\n", optarg);
  +                    printf(" with %s\n", ap_optarg);
                   }
                   else {
                       printf("\n");
  
  
  
  1.22      +4 -6      apache-2.0/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_main.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- http_main.c       1999/11/21 22:10:22     1.21
  +++ http_main.c       1999/11/22 14:52:17     1.22
  @@ -265,8 +265,6 @@
   
   ap_context_t *g_pHookPool;
   
  -API_VAR_IMPORT char *optarg;
  -
   #ifdef WIN32
   API_EXPORT_NONSTD(int) apache_main(int argc, char *argv[])
   #else
  @@ -303,17 +301,17 @@
           switch (c) {
        case 'c':
            new = (char **)ap_push_array(ap_server_post_read_config);
  -         *new = ap_pstrdup(pcommands, optarg);
  +         *new = ap_pstrdup(pcommands, ap_optarg);
            break;
        case 'C':
            new = (char **)ap_push_array(ap_server_pre_read_config);
  -         *new = ap_pstrdup(pcommands, optarg);
  +         *new = ap_pstrdup(pcommands, ap_optarg);
            break;
        case 'd':
  -         def_server_root = optarg;
  +         def_server_root = ap_optarg;
            break;
        case 'f':
  -         confname = optarg;
  +         confname = ap_optarg;
            break;
        case 'v':
            printf("Server version: %s\n", ap_get_server_version());
  
  
  

Reply via email to