popt/popt.c

説明を見る。
00001 /** \ingroup popt
00002  * \file popt/popt.c
00003  */
00004 
00005 /* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING
00006    file accompanying popt source distributions, available from
00007    ftp://ftp.rpm.org/pub/rpm/dist */
00008 
00009 #undef  MYDEBUG
00010 
00011 #include "system.h"
00012 
00013 #if HAVE_FLOAT_H
00014 #include <float.h>
00015 #endif
00016 #include <math.h>
00017 
00018 #include "findme.h"
00019 #include "poptint.h"
00020 
00021 #ifdef  MYDEBUG
00022 /*@unchecked@*/
00023 int _popt_debug = 0;
00024 #endif
00025 
00026 #ifndef HAVE_STRERROR
00027 static char * strerror(int errno) {
00028     extern int sys_nerr;
00029     extern char * sys_errlist[];
00030 
00031     if ((0 <= errno) && (errno < sys_nerr))
00032         return sys_errlist[errno];
00033     else
00034         return POPT_("unknown errno");
00035 }
00036 #endif
00037 
00038 #ifdef MYDEBUG
00039 /*@unused@*/ static void prtcon(const char *msg, poptContext con)
00040 {
00041     if (msg) fprintf(stderr, "%s", msg);
00042     fprintf(stderr, "\tcon %p os %p nextCharArg \"%s\" nextArg \"%s\" argv[%d] \"%s\"\n",
00043         con, con->os,
00044         (con->os->nextCharArg ? con->os->nextCharArg : ""),
00045         (con->os->nextArg ? con->os->nextArg : ""),
00046         con->os->next,
00047         (con->os->argv && con->os->argv[con->os->next]
00048                 ? con->os->argv[con->os->next] : ""));
00049 }
00050 #endif
00051 
00052 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00053 {
00054     con->execPath = (const char *)_free(con->execPath);
00055     con->execPath = xstrdup(path);
00056     con->execAbsolute = allowAbsolute;
00057     /*@-nullstate@*/ /* LCL: con->execPath can be NULL? */
00058     return;
00059     /*@=nullstate@*/
00060 }
00061 
00062 static void invokeCallbacksPRE(poptContext con, const struct poptOption * opt)
00063         /*@globals internalState@*/
00064         /*@modifies internalState@*/
00065 {
00066     if (opt != NULL)
00067     for (; opt->longName || opt->shortName || opt->arg; opt++) {
00068         if (opt->arg == NULL) continue;         /* XXX program error. */
00069         if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
00070             /* Recurse on included sub-tables. */
00071             invokeCallbacksPRE(con, (const struct poptOption *)opt->arg);
00072         } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
00073                    (opt->argInfo & POPT_CBFLAG_PRE))
00074         {   /*@-castfcnptr@*/
00075             poptCallbackType cb = (poptCallbackType)opt->arg;
00076             /*@=castfcnptr@*/
00077             /* Perform callback. */
00078             /*@-moduncon -noeffectuncon @*/
00079             cb(con, POPT_CALLBACK_REASON_PRE, NULL, NULL, opt->descrip);
00080             /*@=moduncon =noeffectuncon @*/
00081         }
00082     }
00083 }
00084 
00085 static void invokeCallbacksPOST(poptContext con, const struct poptOption * opt)
00086         /*@globals internalState@*/
00087         /*@modifies internalState@*/
00088 {
00089     if (opt != NULL)
00090     for (; opt->longName || opt->shortName || opt->arg; opt++) {
00091         if (opt->arg == NULL) continue;         /* XXX program error. */
00092         if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
00093             /* Recurse on included sub-tables. */
00094             invokeCallbacksPOST(con, (const struct poptOption *)opt->arg);
00095         } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
00096                    (opt->argInfo & POPT_CBFLAG_POST))
00097         {   /*@-castfcnptr@*/
00098             poptCallbackType cb = (poptCallbackType)opt->arg;
00099             /*@=castfcnptr@*/
00100             /* Perform callback. */
00101             /*@-moduncon -noeffectuncon @*/
00102             cb(con, POPT_CALLBACK_REASON_POST, NULL, NULL, opt->descrip);
00103             /*@=moduncon =noeffectuncon @*/
00104         }
00105     }
00106 }
00107 
00108 static void invokeCallbacksOPTION(poptContext con,
00109                                   const struct poptOption * opt,
00110                                   const struct poptOption * myOpt,
00111                                   /*@null@*/ const void * myData, int shorty)
00112         /*@globals internalState@*/
00113         /*@modifies internalState@*/
00114 {
00115     const struct poptOption * cbopt = NULL;
00116 
00117     if (opt != NULL)
00118     for (; opt->longName || opt->shortName || opt->arg; opt++) {
00119         if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
00120             /* Recurse on included sub-tables. */
00121             if (opt->arg != NULL)       /* XXX program error */
00122                 invokeCallbacksOPTION(con, (const struct poptOption *)opt->arg,
00123                                       myOpt, myData, shorty);
00124         } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
00125                   !(opt->argInfo & POPT_CBFLAG_SKIPOPTION)) {
00126             /* Save callback info. */
00127             cbopt = opt;
00128         } else if (cbopt != NULL &&
00129                    ((myOpt->shortName && opt->shortName && shorty &&
00130                         myOpt->shortName == opt->shortName) ||
00131                     (myOpt->longName && opt->longName &&
00132                 /*@-nullpass@*/         /* LCL: opt->longName != NULL */
00133                         !strcmp(myOpt->longName, opt->longName)))
00134                 /*@=nullpass@*/
00135                    )
00136         {   /*@-castfcnptr@*/
00137             poptCallbackType cb = (poptCallbackType)cbopt->arg;
00138             /*@=castfcnptr@*/
00139             const void * cbData = (cbopt->descrip ? cbopt->descrip : myData);
00140             /* Perform callback. */
00141             if (cb != NULL) {   /* XXX program error */
00142                 /*@-moduncon -noeffectuncon @*/
00143                 cb(con, POPT_CALLBACK_REASON_OPTION, myOpt,
00144                         con->os->nextArg, cbData);
00145                 /*@=moduncon =noeffectuncon @*/
00146             }
00147             /* Terminate (unless explcitly continuing). */
00148             if (!(cbopt->argInfo & POPT_CBFLAG_CONTINUE))
00149                 return;
00150         }
00151     }
00152 }
00153 
00154 poptContext poptGetContext(const char * name, int argc, const char ** argv,
00155                            const struct poptOption * options, int flags)
00156 {
00157     poptContext con = (poptContext)malloc(sizeof(*con));
00158 
00159     if (con == NULL) return NULL;       /* XXX can't happen */
00160     memset(con, 0, sizeof(*con));
00161 
00162     con->os = con->optionStack;
00163     con->os->argc = argc;
00164     /*@-dependenttrans -assignexpose@*/ /* FIX: W2DO? */
00165     con->os->argv = argv;
00166     /*@=dependenttrans =assignexpose@*/
00167     con->os->argb = NULL;
00168 
00169     if (!(flags & POPT_CONTEXT_KEEP_FIRST))
00170         con->os->next = 1;                      /* skip argv[0] */
00171 
00172     con->leftovers = (const char **)calloc( (argc + 1),
00173                                             sizeof(*con->leftovers) );
00174     /*@-dependenttrans -assignexpose@*/ /* FIX: W2DO? */
00175     con->options = options;
00176     /*@=dependenttrans =assignexpose@*/
00177     con->aliases = NULL;
00178     con->numAliases = 0;
00179     con->flags = flags;
00180     con->execs = NULL;
00181     con->numExecs = 0;
00182     con->finalArgvAlloced = argc * 2;
00183     con->finalArgv = (const char **)calloc( con->finalArgvAlloced,
00184                                             sizeof(*con->finalArgv) );
00185     con->execAbsolute = 1;
00186     con->arg_strip = NULL;
00187 
00188     if (getenv("POSIXLY_CORRECT") || getenv("POSIX_ME_HARDER"))
00189         con->flags |= POPT_CONTEXT_POSIXMEHARDER;
00190 
00191     if (name) {
00192         char * t = (char *)malloc(strlen(name) + 1);
00193         if (t) con->appName = strcpy(t, name);
00194     }
00195 
00196     /*@-internalglobs@*/
00197     invokeCallbacksPRE(con, con->options);
00198     /*@=internalglobs@*/
00199 
00200     return con;
00201 }
00202 
00203 static void cleanOSE(/*@special@*/ struct optionStackEntry *os)
00204         /*@uses os @*/
00205         /*@releases os->nextArg, os->argv, os->argb @*/
00206         /*@modifies os @*/
00207 {
00208     os->nextArg = (const char *)_free(os->nextArg);
00209     os->argv = (const char **)_free(os->argv);
00210     os->argb = (pbm_set *)PBM_FREE(os->argb);
00211 }
00212 
00213 /*@-boundswrite@*/
00214 void poptResetContext(poptContext con)
00215 {
00216     int i;
00217 
00218     if (con == NULL) return;
00219     while (con->os > con->optionStack) {
00220         cleanOSE(con->os--);
00221     }
00222     con->os->argb = (pbm_set *)PBM_FREE(con->os->argb);
00223     con->os->currAlias = NULL;
00224     con->os->nextCharArg = NULL;
00225     con->os->nextArg = NULL;
00226     con->os->next = 1;                  /* skip argv[0] */
00227 
00228     con->numLeftovers = 0;
00229     con->nextLeftover = 0;
00230     con->restLeftover = 0;
00231     con->doExec = NULL;
00232 
00233     if (con->finalArgv != NULL)
00234     for (i = 0; i < con->finalArgvCount; i++) {
00235         /*@-unqualifiedtrans@*/         /* FIX: typedef double indirection. */
00236         con->finalArgv[i] = (const char *)_free(con->finalArgv[i]);
00237         /*@=unqualifiedtrans@*/
00238     }
00239 
00240     con->finalArgvCount = 0;
00241     con->arg_strip = ( pbm_set *)PBM_FREE(con->arg_strip);
00242     /*@-nullstate@*/    /* FIX: con->finalArgv != NULL */
00243     return;
00244     /*@=nullstate@*/
00245 }
00246 /*@=boundswrite@*/
00247 
00248 /* Only one of longName, shortName should be set, not both. */
00249 /*@-boundswrite@*/
00250 static int handleExec(/*@special@*/ poptContext con,
00251                 /*@null@*/ const char * longName, char shortName)
00252         /*@uses con->execs, con->numExecs, con->flags, con->doExec,
00253                 con->finalArgv, con->finalArgvAlloced, con->finalArgvCount @*/
00254         /*@modifies con @*/
00255 {
00256     poptItem item;
00257     int i;
00258 
00259     if (con->execs == NULL || con->numExecs <= 0) /* XXX can't happen */
00260         return 0;
00261 
00262     for (i = con->numExecs - 1; i >= 0; i--) {
00263         item = con->execs + i;
00264         if (longName && !(item->option.longName &&
00265                         !strcmp(longName, item->option.longName)))
00266             continue;
00267         else if (shortName != item->option.shortName)
00268             continue;
00269         break;
00270     }
00271     if (i < 0) return 0;
00272 
00273 
00274     if (con->flags & POPT_CONTEXT_NO_EXEC)
00275         return 1;
00276 
00277     if (con->doExec == NULL) {
00278         con->doExec = con->execs + i;
00279         return 1;
00280     }
00281 
00282     /* We already have an exec to do; remember this option for next
00283        time 'round */
00284     if ((con->finalArgvCount + 1) >= (con->finalArgvAlloced)) {
00285         con->finalArgvAlloced += 10;
00286         con->finalArgv = (const char **)realloc(con->finalArgv,
00287                         sizeof(*con->finalArgv) * con->finalArgvAlloced);
00288     }
00289 
00290     i = con->finalArgvCount++;
00291     if (con->finalArgv != NULL) /* XXX can't happen */
00292     {   char *s  = (char *)malloc((longName ? strlen(longName) : 0) + 3);
00293         if (s != NULL) {        /* XXX can't happen */
00294             if (longName)
00295                 sprintf(s, "--%s", longName);
00296             else
00297                 sprintf(s, "-%c", shortName);
00298             con->finalArgv[i] = s;
00299         } else
00300             con->finalArgv[i] = NULL;
00301     }
00302 
00303     /*@-nullstate@*/    /* FIX: con->finalArgv[] == NULL */
00304     return 1;
00305     /*@=nullstate@*/
00306 }
00307 /*@=boundswrite@*/
00308 
00309 /* Only one of longName, shortName may be set at a time */
00310 static int handleAlias(/*@special@*/ poptContext con,
00311                 /*@null@*/ const char * longName, char shortName,
00312                 /*@exposed@*/ /*@null@*/ const char * nextCharArg)
00313         /*@uses con->aliases, con->numAliases, con->optionStack, con->os,
00314                 con->os->currAlias, con->os->currAlias->option.longName @*/
00315         /*@modifies con @*/
00316 {
00317     poptItem item = con->os->currAlias;
00318     int rc;
00319     int i;
00320 
00321     if (item) {
00322         if (longName && (item->option.longName &&
00323                 !strcmp(longName, item->option.longName)))
00324             return 0;
00325         if (shortName && shortName == item->option.shortName)
00326             return 0;
00327     }
00328 
00329     if (con->aliases == NULL || con->numAliases <= 0) /* XXX can't happen */
00330         return 0;
00331 
00332     for (i = con->numAliases - 1; i >= 0; i--) {
00333         item = con->aliases + i;
00334         if (longName && !(item->option.longName &&
00335                         !strcmp(longName, item->option.longName)))
00336             continue;
00337         else if (shortName != item->option.shortName)
00338             continue;
00339         break;
00340     }
00341     if (i < 0) return 0;
00342 
00343     if ((con->os - con->optionStack + 1) == POPT_OPTION_DEPTH)
00344         return POPT_ERROR_OPTSTOODEEP;
00345 
00346 /*@-boundsread@*/
00347     if (nextCharArg && *nextCharArg)
00348         con->os->nextCharArg = nextCharArg;
00349 /*@=boundsread@*/
00350 
00351     con->os++;
00352     con->os->next = 0;
00353     con->os->stuffed = 0;
00354     con->os->nextArg = NULL;
00355     con->os->nextCharArg = NULL;
00356     con->os->currAlias = con->aliases + i;
00357     rc = poptDupArgv(con->os->currAlias->argc, con->os->currAlias->argv,
00358                 &con->os->argc, &con->os->argv);
00359     con->os->argb = NULL;
00360 
00361     return (rc ? rc : 1);
00362 }
00363 
00364 /*@-bounds -boundswrite @*/
00365 static int execCommand(poptContext con)
00366         /*@globals internalState @*/
00367         /*@modifies internalState @*/
00368 {
00369     poptItem item = con->doExec;
00370     const char ** argv;
00371     int argc = 0;
00372     int rc;
00373 
00374     if (item == NULL) /*XXX can't happen*/
00375         return POPT_ERROR_NOARG;
00376 
00377     if (item->argv == NULL || item->argc < 1 ||
00378         (!con->execAbsolute && strchr(item->argv[0], '/')))
00379             return POPT_ERROR_NOARG;
00380 
00381     argv = (const char **)malloc(
00382             sizeof(*argv) * (6 + item->argc + con->numLeftovers + con->finalArgvCount));
00383     if (argv == NULL) return POPT_ERROR_MALLOC; /* XXX can't happen */
00384 
00385     if (!strchr(item->argv[0], '/') && con->execPath) {
00386         char *s = (char *)alloca(
00387                 strlen(con->execPath) + strlen(item->argv[0]) + sizeof("/"));
00388         sprintf(s, "%s/%s", con->execPath, item->argv[0]);
00389         argv[argc] = s;
00390     } else {
00391         argv[argc] = findProgramPath(item->argv[0]);
00392     }
00393     if (argv[argc++] == NULL) return POPT_ERROR_NOARG;
00394 
00395     if (item->argc > 1) {
00396         memcpy(argv + argc, item->argv + 1, sizeof(*argv) * (item->argc - 1));
00397         argc += (item->argc - 1);
00398     }
00399 
00400     if (con->finalArgv != NULL && con->finalArgvCount > 0) {
00401         memcpy(argv + argc, con->finalArgv,
00402                 sizeof(*argv) * con->finalArgvCount);
00403         argc += con->finalArgvCount;
00404     }
00405 
00406     if (con->leftovers != NULL && con->numLeftovers > 0) {
00407 #if 0
00408         argv[argc++] = "--";
00409 #endif
00410         memcpy(argv + argc, con->leftovers, sizeof(*argv) * con->numLeftovers);
00411         argc += con->numLeftovers;
00412     }
00413 
00414     argv[argc] = NULL;
00415 
00416 #ifdef __hpux
00417     rc = setresuid(getuid(), getuid(),-1);
00418     if (rc) return POPT_ERROR_ERRNO;
00419 #else
00420 /*
00421  * XXX " ... on BSD systems setuid() should be preferred over setreuid()"
00422  * XXX  sez' Timur Bakeyev <mc@bat.ru>
00423  * XXX  from Norbert Warmuth <nwarmuth@privat.circular.de>
00424  */
00425 #if defined(HAVE_SETUID)
00426     rc = setuid(getuid());
00427     if (rc) return POPT_ERROR_ERRNO;
00428 #elif defined (HAVE_SETREUID)
00429     rc = setreuid(getuid(), getuid()); /*hlauer: not portable to hpux9.01 */
00430     if (rc) return POPT_ERROR_ERRNO;
00431 #else
00432     ; /* Can't drop privileges */
00433 #endif
00434 #endif
00435 
00436     if (argv[0] == NULL)
00437         return POPT_ERROR_NOARG;
00438 
00439 #ifdef  MYDEBUG
00440 if (_popt_debug)
00441     {   const char ** avp;
00442         fprintf(stderr, "==> execvp(%s) argv[%d]:", argv[0], argc);
00443         for (avp = argv; *avp; avp++)
00444             fprintf(stderr, " '%s'", *avp);
00445         fprintf(stderr, "\n");
00446     }
00447 #endif
00448 
00449     rc = execvp(argv[0], (char *const *)argv);
00450     /* notreached */
00451     if (rc) {
00452         return POPT_ERROR_ERRNO;
00453     }
00454  
00455     return 0;
00456 }
00457 /*@=bounds =boundswrite @*/
00458 
00459 /*@-boundswrite@*/
00460 /*@observer@*/ /*@null@*/ static const struct poptOption *
00461 findOption(const struct poptOption * opt, /*@null@*/ const char * longName,
00462                 char shortName,
00463                 /*@null@*/ /*@out@*/ poptCallbackType * callback,
00464                 /*@null@*/ /*@out@*/ const void ** callbackData,
00465                 int singleDash)
00466         /*@modifies *callback, *callbackData */
00467 {
00468     const struct poptOption * cb = NULL;
00469 
00470     /* This happens when a single - is given */
00471     if (singleDash && !shortName && (longName && *longName == '\0'))
00472         shortName = '-';
00473 
00474     for (; opt->longName || opt->shortName || opt->arg; opt++) {
00475 
00476         if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
00477             const struct poptOption * opt2;
00478 
00479             /* Recurse on included sub-tables. */
00480             if (opt->arg == NULL) continue;     /* XXX program error */
00481             opt2 = findOption((const struct poptOption *)opt->arg, longName,
00482                               shortName, callback,
00483                               callbackData, singleDash);
00484             if (opt2 == NULL) continue;
00485             /* Sub-table data will be inheirited if no data yet. */
00486             if (!(callback && *callback)) return opt2;
00487             if (!(callbackData && *callbackData == NULL)) return opt2;
00488             /*@-observertrans -dependenttrans @*/
00489             *callbackData = opt->descrip;
00490             /*@=observertrans =dependenttrans @*/
00491             return opt2;
00492         } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK) {
00493             cb = opt;
00494         } else if (longName && opt->longName &&
00495                    (!singleDash || (opt->argInfo & POPT_ARGFLAG_ONEDASH)) &&
00496                 /*@-nullpass@*/         /* LCL: opt->longName != NULL */
00497                    !strcmp(longName, opt->longName))
00498                 /*@=nullpass@*/
00499         {
00500             break;
00501         } else if (shortName && shortName == opt->shortName) {
00502             break;
00503         }
00504     }
00505 
00506     if (!opt->longName && !opt->shortName)
00507         return NULL;
00508     /*@-modobserver -mods @*/
00509     if (callback) *callback = NULL;
00510     if (callbackData) *callbackData = NULL;
00511     if (cb) {
00512         if (callback)
00513         /*@-castfcnptr@*/
00514             *callback = (poptCallbackType)cb->arg;
00515         /*@=castfcnptr@*/
00516         if (!(cb->argInfo & POPT_CBFLAG_INC_DATA)) {
00517             if (callbackData)
00518                 /*@-observertrans@*/    /* FIX: typedef double indirection. */
00519                 *callbackData = cb->descrip;
00520                 /*@=observertrans@*/
00521         }
00522     }
00523     /*@=modobserver =mods @*/
00524 
00525     return opt;
00526 }
00527 /*@=boundswrite@*/
00528 
00529 static const char * findNextArg(/*@special@*/ poptContext con,
00530                 unsigned argx, int delete_arg)
00531         /*@uses con->optionStack, con->os,
00532                 con->os->next, con->os->argb, con->os->argc, con->os->argv @*/
00533         /*@modifies con @*/
00534 {
00535     struct optionStackEntry * os = con->os;
00536     const char * arg;
00537 
00538     do {
00539         int i;
00540         arg = NULL;
00541         while (os->next == os->argc && os > con->optionStack) os--;
00542         if (os->next == os->argc && os == con->optionStack) break;
00543         if (os->argv != NULL)
00544         for (i = os->next; i < os->argc; i++) {
00545             /*@-sizeoftype@*/
00546             if (os->argb && PBM_ISSET(i, os->argb))
00547                 /*@innercontinue@*/ continue;
00548             if (*os->argv[i] == '-')
00549                 /*@innercontinue@*/ continue;
00550             if (--argx > 0)
00551                 /*@innercontinue@*/ continue;
00552             arg = os->argv[i];
00553             if (delete_arg) {
00554                 if (os->argb == NULL) os->argb = (pbm_set *)PBM_ALLOC(os->argc);
00555                 if (os->argb != NULL)   /* XXX can't happen */
00556                 PBM_SET(i, os->argb);
00557             }
00558             /*@innerbreak@*/ break;
00559             /*@=sizeoftype@*/
00560         }
00561         if (os > con->optionStack) os--;
00562     } while (arg == NULL);
00563     return arg;
00564 }
00565 
00566 /*@-boundswrite@*/
00567 static /*@only@*/ /*@null@*/ const char *
00568 expandNextArg(/*@special@*/ poptContext con, const char * s)
00569         /*@uses con->optionStack, con->os,
00570                 con->os->next, con->os->argb, con->os->argc, con->os->argv @*/
00571         /*@modifies con @*/
00572 {
00573     const char * a = NULL;
00574     size_t alen;
00575     char *t, *te;
00576     size_t tn = strlen(s) + 1;
00577     char c;
00578 
00579     te = t = (char *)malloc(tn);;
00580     if (t == NULL) return NULL;         /* XXX can't happen */
00581     while ((c = *s++) != '\0') {
00582         switch (c) {
00583 #if 0   /* XXX can't do this */
00584         case '\\':      /* escape */
00585             c = *s++;
00586             /*@switchbreak@*/ break;
00587 #endif
00588         case '!':
00589             if (!(s[0] == '#' && s[1] == ':' && s[2] == '+'))
00590                 /*@switchbreak@*/ break;
00591             /* XXX Make sure that findNextArg deletes only next arg. */
00592             if (a == NULL) {
00593                 if ((a = findNextArg(con, 1, 1)) == NULL)
00594                     /*@switchbreak@*/ break;
00595             }
00596             s += 3;
00597 
00598             alen = strlen(a);
00599             tn += alen;
00600             *te = '\0';
00601             t = (char *)realloc(t, tn);
00602             te = t + strlen(t);
00603             strncpy(te, a, alen); te += alen;
00604             continue;
00605             /*@notreached@*/ /*@switchbreak@*/ break;
00606         default:
00607             /*@switchbreak@*/ break;
00608         }
00609         *te++ = c;
00610     }
00611     *te = '\0';
00612     t = (char *)realloc(t, strlen(t) + 1); /* XXX memory leak, hard to plug */
00613     return t;
00614 }
00615 /*@=boundswrite@*/
00616 
00617 static void poptStripArg(/*@special@*/ poptContext con, int which)
00618         /*@uses con->arg_strip, con->optionStack @*/
00619         /*@defines con->arg_strip @*/
00620         /*@modifies con @*/
00621 {
00622     /*@-sizeoftype@*/
00623     if (con->arg_strip == NULL)
00624         con->arg_strip = (pbm_set *)PBM_ALLOC(con->optionStack[0].argc);
00625     if (con->arg_strip != NULL)         /* XXX can't happen */
00626     PBM_SET(which, con->arg_strip);
00627     /*@=sizeoftype@*/
00628     /*@-compdef@*/ /* LCL: con->arg_strip udefined? */
00629     return;
00630     /*@=compdef@*/
00631 }
00632 
00633 int poptSaveLong(long * arg, int argInfo, long aLong)
00634 {
00635     /* XXX Check alignment, may fail on funky platforms. */
00636     if (arg == NULL || (((unsigned long)arg) & (sizeof(*arg)-1)))
00637         return POPT_ERROR_NULLARG;
00638 
00639     if (argInfo & POPT_ARGFLAG_NOT)
00640         aLong = ~aLong;
00641     switch (argInfo & POPT_ARGFLAG_LOGICALOPS) {
00642     case 0:
00643         *arg = aLong;
00644         break;
00645     case POPT_ARGFLAG_OR:
00646         *arg |= aLong;
00647         break;
00648     case POPT_ARGFLAG_AND:
00649         *arg &= aLong;
00650         break;
00651     case POPT_ARGFLAG_XOR:
00652         *arg ^= aLong;
00653         break;
00654     default:
00655         return POPT_ERROR_BADOPERATION;
00656         /*@notreached@*/ break;
00657     }
00658     return 0;
00659 }
00660 
00661 int poptSaveInt(/*@null@*/ int * arg, int argInfo, long aLong)
00662 {
00663     /* XXX Check alignment, may fail on funky platforms. */
00664     if (arg == NULL || (((unsigned long)arg) & (sizeof(*arg)-1)))
00665         return POPT_ERROR_NULLARG;
00666 
00667     if (argInfo & POPT_ARGFLAG_NOT)
00668         aLong = ~aLong;
00669     switch (argInfo & POPT_ARGFLAG_LOGICALOPS) {
00670     case 0:
00671         *arg = aLong;
00672         break;
00673     case POPT_ARGFLAG_OR:
00674         *arg |= aLong;
00675         break;
00676     case POPT_ARGFLAG_AND:
00677         *arg &= aLong;
00678         break;
00679     case POPT_ARGFLAG_XOR:
00680         *arg ^= aLong;
00681         break;
00682     default:
00683         return POPT_ERROR_BADOPERATION;
00684         /*@notreached@*/ break;
00685     }
00686     return 0;
00687 }
00688 
00689 /*@-boundswrite@*/
00690 /* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
00691 int poptGetNextOpt(poptContext con)
00692 {
00693     const struct poptOption * opt = NULL;
00694     int done = 0;
00695 
00696     if (con == NULL)
00697         return -1;
00698     while (!done) {
00699         const char * origOptString = NULL;
00700         poptCallbackType cb = NULL;
00701         const void * cbData = NULL;
00702         const char * longArg = NULL;
00703         int canstrip = 0;
00704         int shorty = 0;
00705 
00706         while (!con->os->nextCharArg && con->os->next == con->os->argc
00707                 && con->os > con->optionStack) {
00708             cleanOSE(con->os--);
00709         }
00710         if (!con->os->nextCharArg && con->os->next == con->os->argc) {
00711             /*@-internalglobs@*/
00712             invokeCallbacksPOST(con, con->options);
00713             /*@=internalglobs@*/
00714             if (con->doExec) return execCommand(con);
00715             return -1;
00716         }
00717 
00718         /* Process next long option */
00719         if (!con->os->nextCharArg) {
00720             char * localOptString, * optString;
00721             int thisopt;
00722 
00723             /*@-sizeoftype@*/
00724             if (con->os->argb && PBM_ISSET(con->os->next, con->os->argb)) {
00725                 con->os->next++;
00726                 continue;
00727             }
00728             /*@=sizeoftype@*/
00729             thisopt = con->os->next;
00730             if (con->os->argv != NULL)  /* XXX can't happen */
00731             origOptString = con->os->argv[con->os->next++];
00732 
00733             if (origOptString == NULL)  /* XXX can't happen */
00734                 return POPT_ERROR_BADOPT;
00735 
00736             if (con->restLeftover || *origOptString != '-') {
00737                 if (con->flags & POPT_CONTEXT_POSIXMEHARDER)
00738                     con->restLeftover = 1;
00739                 if (con->flags & POPT_CONTEXT_ARG_OPTS) {
00740                     con->os->nextArg = xstrdup(origOptString);
00741                     return 0;
00742                 }
00743                 if (con->leftovers != NULL)     /* XXX can't happen */
00744                     con->leftovers[con->numLeftovers++] = origOptString;
00745                 continue;
00746             }
00747 
00748             /* Make a copy we can hack at */
00749             localOptString = optString =
00750                 strcpy((char *)alloca(strlen(origOptString) + 1),
00751                        origOptString);
00752 
00753             if (optString[0] == '\0')
00754                 return POPT_ERROR_BADOPT;
00755 
00756             if (optString[1] == '-' && !optString[2]) {
00757                 con->restLeftover = 1;
00758                 continue;
00759             } else {
00760                 char *oe;
00761                 int singleDash;
00762 
00763                 optString++;
00764                 if (*optString == '-')
00765                     singleDash = 0, optString++;
00766                 else
00767                     singleDash = 1;
00768 
00769                 /* XXX aliases with arg substitution need "--alias=arg" */
00770                 if (handleAlias(con, optString, '\0', NULL))
00771                     continue;
00772 
00773                 if (handleExec(con, optString, '\0'))
00774                     continue;
00775 
00776                 /* Check for "--long=arg" option. */
00777                 for (oe = optString; *oe && *oe != '='; oe++)
00778                     {};
00779                 if (*oe == '=') {
00780                     *oe++ = '\0';
00781                     /* XXX longArg is mapped back to persistent storage. */
00782                     longArg = origOptString + (oe - localOptString);
00783                 }
00784 
00785                 opt = findOption(con->options, optString, '\0', &cb, &cbData,
00786                                  singleDash);
00787                 if (!opt && !singleDash)
00788                     return POPT_ERROR_BADOPT;
00789             }
00790 
00791             if (!opt) {
00792                 con->os->nextCharArg = origOptString + 1;
00793             } else {
00794                 if (con->os == con->optionStack &&
00795                    opt->argInfo & POPT_ARGFLAG_STRIP)
00796                 {
00797                     canstrip = 1;
00798                     poptStripArg(con, thisopt);
00799                 }
00800                 shorty = 0;
00801             }
00802         }
00803 
00804         /* Process next short option */
00805         /*@-branchstate@*/              /* FIX: W2DO? */
00806         if (con->os->nextCharArg) {
00807             origOptString = con->os->nextCharArg;
00808 
00809             con->os->nextCharArg = NULL;
00810 
00811             if (handleAlias(con, NULL, *origOptString, origOptString + 1))
00812                 continue;
00813 
00814             if (handleExec(con, NULL, *origOptString)) {
00815                 /* Restore rest of short options for further processing */
00816                 origOptString++;
00817                 if (*origOptString != '\0')
00818                     con->os->nextCharArg = origOptString;
00819                 continue;
00820             }
00821 
00822             opt = findOption(con->options, NULL, *origOptString, &cb,
00823                              &cbData, 0);
00824             if (!opt)
00825                 return POPT_ERROR_BADOPT;
00826             shorty = 1;
00827 
00828             origOptString++;
00829             if (*origOptString != '\0')
00830                 con->os->nextCharArg = origOptString;
00831         }
00832         /*@=branchstate@*/
00833 
00834         if (opt == NULL) return POPT_ERROR_BADOPT;      /* XXX can't happen */
00835         if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE) {
00836             if (poptSaveInt((int *)opt->arg, opt->argInfo, 1L))
00837                 return POPT_ERROR_BADOPERATION;
00838         } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL) {
00839             if (opt->arg) {
00840                 if (poptSaveInt((int *)opt->arg, opt->argInfo, (long)opt->val))
00841                     return POPT_ERROR_BADOPERATION;
00842             }
00843         } else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) {
00844             con->os->nextArg = (const char *)_free(con->os->nextArg);
00845             /*@-usedef@*/       /* FIX: W2DO? */
00846             if (longArg) {
00847             /*@=usedef@*/
00848                 longArg = expandNextArg(con, longArg);
00849                 con->os->nextArg = longArg;
00850             } else if (con->os->nextCharArg) {
00851                 longArg = expandNextArg(con, con->os->nextCharArg);
00852                 con->os->nextArg = longArg;
00853                 con->os->nextCharArg = NULL;
00854             } else {
00855                 while (con->os->next == con->os->argc &&
00856                        con->os > con->optionStack) {
00857                     cleanOSE(con->os--);
00858                 }
00859                 if (con->os->next == con->os->argc) {
00860                     if (!(opt->argInfo & POPT_ARGFLAG_OPTIONAL))
00861                         /*@-compdef@*/  /* FIX: con->os->argv not defined */
00862                         return POPT_ERROR_NOARG;
00863                         /*@=compdef@*/
00864                     con->os->nextArg = NULL;
00865                 } else {
00866 
00867                     /*
00868                      * Make sure this isn't part of a short arg or the
00869                      * result of an alias expansion.
00870                      */
00871                     if (con->os == con->optionStack &&
00872                         (opt->argInfo & POPT_ARGFLAG_STRIP) &&
00873                         canstrip) {
00874                         poptStripArg(con, con->os->next);
00875                     }
00876                 
00877                     if (con->os->argv != NULL) {        /* XXX can't happen */
00878                         /* XXX watchout: subtle side-effects live here. */
00879                         longArg = con->os->argv[con->os->next++];
00880                         longArg = expandNextArg(con, longArg);
00881                         con->os->nextArg = longArg;
00882                     }
00883                 }
00884             }
00885             longArg = NULL;
00886 
00887             if (opt->arg) {
00888                 switch (opt->argInfo & POPT_ARG_MASK) {
00889                 case POPT_ARG_STRING:
00890                     /* XXX memory leak, hard to plug */
00891                     *((const char **) opt->arg) = (con->os->nextArg)
00892                         ? xstrdup(con->os->nextArg) : NULL;
00893                     /*@switchbreak@*/ break;
00894 
00895                 case POPT_ARG_INT:
00896                 case POPT_ARG_LONG:
00897                 {   long aLong = 0;
00898                     char *end;
00899 
00900                     if (con->os->nextArg) {
00901                         aLong = strtol(con->os->nextArg, &end, 0);
00902                         if (!(end && *end == '\0'))
00903                             return POPT_ERROR_BADNUMBER;
00904                     }
00905 
00906                     if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_LONG) {
00907                         if (aLong == LONG_MIN || aLong == LONG_MAX)
00908                             return POPT_ERROR_OVERFLOW;
00909                         if (poptSaveLong((long *)opt->arg, opt->argInfo, aLong))
00910                             return POPT_ERROR_BADOPERATION;
00911                     } else {
00912                         if (aLong > INT_MAX || aLong < INT_MIN)
00913                             return POPT_ERROR_OVERFLOW;
00914                         if (poptSaveInt((int *)opt->arg, opt->argInfo, aLong))
00915                             return POPT_ERROR_BADOPERATION;
00916                     }
00917                 }   /*@switchbreak@*/ break;
00918 
00919                 case POPT_ARG_FLOAT:
00920                 case POPT_ARG_DOUBLE:
00921                 {   double aDouble = 0.0;
00922                     char *end;
00923 
00924                     if (con->os->nextArg) {
00925                         /*@-mods@*/
00926                         int saveerrno = errno;
00927                         errno = 0;
00928                         aDouble = strtod(con->os->nextArg, &end);
00929                         if (errno == ERANGE)
00930                             return POPT_ERROR_OVERFLOW;
00931                         errno = saveerrno;
00932                         /*@=mods@*/
00933                         if (*end != '\0')
00934                             return POPT_ERROR_BADNUMBER;
00935                     }
00936 
00937                     if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_DOUBLE) {
00938                         *((double *) opt->arg) = aDouble;
00939                     } else {
00940 #ifndef _ABS
00941 #define _ABS(a) ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))
00942 #endif
00943                         if ((_ABS(aDouble) - FLT_MAX) > DBL_EPSILON)
00944                             return POPT_ERROR_OVERFLOW;
00945                         if ((FLT_MIN - _ABS(aDouble)) > DBL_EPSILON)
00946                             return POPT_ERROR_OVERFLOW;
00947                         *((float *) opt->arg) = aDouble;
00948                     }
00949                 }   /*@switchbreak@*/ break;
00950                 default:
00951                     fprintf(stdout,
00952                         POPT_("option type (%d) not implemented in popt\n"),
00953                         (opt->argInfo & POPT_ARG_MASK));
00954                     exit(EXIT_FAILURE);
00955                     /*@notreached@*/ /*@switchbreak@*/ break;
00956                 }
00957             }
00958         }
00959 
00960         if (cb) {
00961             /*@-internalglobs@*/
00962             invokeCallbacksOPTION(con, con->options, opt, cbData, shorty);
00963             /*@=internalglobs@*/
00964         } else if (opt->val && ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL))
00965             done = 1;
00966 
00967         if ((con->finalArgvCount + 2) >= (con->finalArgvAlloced)) {
00968             con->finalArgvAlloced += 10;
00969             con->finalArgv = (const char **)realloc(con->finalArgv,
00970                             sizeof(*con->finalArgv) * con->finalArgvAlloced);
00971         }
00972 
00973         if (con->finalArgv != NULL)
00974         {   char *s = (char *)malloc(
00975                 (opt->longName ? strlen(opt->longName) : 0) + 3);
00976             if (s != NULL) {    /* XXX can't happen */
00977                 if (opt->longName)
00978                     sprintf(s, "%s%s",
00979                         ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"),
00980                         opt->longName);
00981                 else
00982                     sprintf(s, "-%c", opt->shortName);
00983                 con->finalArgv[con->finalArgvCount++] = s;
00984             } else
00985                 con->finalArgv[con->finalArgvCount++] = NULL;
00986         }
00987 
00988         if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE)
00989             /*@-ifempty@*/ ; /*@=ifempty@*/
00990         else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL)
00991             /*@-ifempty@*/ ; /*@=ifempty@*/
00992         else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) {
00993             if (con->finalArgv != NULL && con->os->nextArg)
00994                 con->finalArgv[con->finalArgvCount++] =
00995                         /*@-nullpass@*/ /* LCL: con->os->nextArg != NULL */
00996                         xstrdup(con->os->nextArg);
00997                         /*@=nullpass@*/
00998         }
00999     }
01000 
01001     return (opt ? opt->val : -1);       /* XXX can't happen */
01002 }
01003 /*@=boundswrite@*/
01004 
01005 const char * poptGetOptArg(poptContext con)
01006 {
01007     const char * ret = NULL;
01008     /*@-branchstate@*/
01009     if (con) {
01010         ret = con->os->nextArg;
01011         con->os->nextArg = NULL;
01012     }
01013     /*@=branchstate@*/
01014     return ret;
01015 }
01016 
01017 const char * poptGetArg(poptContext con)
01018 {
01019     const char * ret = NULL;
01020     if (con && con->leftovers != NULL && con->nextLeftover < con->numLeftovers)
01021         ret = con->leftovers[con->nextLeftover++];
01022     return ret;
01023 }
01024 
01025 const char * poptPeekArg(poptContext con)
01026 {
01027     const char * ret = NULL;
01028     if (con && con->leftovers != NULL && con->nextLeftover < con->numLeftovers)
01029         ret = con->leftovers[con->nextLeftover];
01030     return ret;
01031 }
01032 
01033 /*@-boundswrite@*/
01034 const char ** poptGetArgs(poptContext con)
01035 {
01036     if (con == NULL ||
01037         con->leftovers == NULL || con->numLeftovers == con->nextLeftover)
01038         return NULL;
01039 
01040     /* some apps like [like RPM ;-) ] need this NULL terminated */
01041     con->leftovers[con->numLeftovers] = NULL;
01042 
01043     /*@-nullret -nullstate @*/  /* FIX: typedef double indirection. */
01044     return (con->leftovers + con->nextLeftover);
01045     /*@=nullret =nullstate @*/
01046 }
01047 /*@=boundswrite@*/
01048 
01049 poptContext poptFreeContext(poptContext con)
01050 {
01051     poptItem item;
01052     int i;
01053 
01054     if (con == NULL) return con;
01055     poptResetContext(con);
01056     con->os->argb = (pbm_set *)_free(con->os->argb);
01057 
01058     if (con->aliases != NULL)
01059     for (i = 0; i < con->numAliases; i++) {
01060         item = con->aliases + i;
01061         /*@-modobserver -observertrans -dependenttrans@*/
01062         item->option.longName = (const char *)_free(item->option.longName);
01063         item->option.descrip = (const char *)_free(item->option.descrip);
01064         item->option.argDescrip = (const char *)_free(item->option.argDescrip);
01065         /*@=modobserver =observertrans =dependenttrans@*/
01066         item->argv = (const char **)_free(item->argv);
01067     }
01068     con->aliases = (poptItem)_free(con->aliases);
01069 
01070     if (con->execs != NULL)
01071     for (i = 0; i < con->numExecs; i++) {
01072         item = con->execs + i;
01073         /*@-modobserver -observertrans -dependenttrans@*/
01074         item->option.longName = (const char *)_free(item->option.longName);
01075         item->option.descrip = (const char *)_free(item->option.descrip);
01076         item->option.argDescrip = (const char *)_free(item->option.argDescrip);
01077         /*@=modobserver =observertrans =dependenttrans@*/
01078         item->argv = (const char **)_free(item->argv);
01079     }
01080     con->execs = (poptItem)_free(con->execs);
01081 
01082     con->leftovers = (const char **)_free(con->leftovers);
01083     con->finalArgv = (const char **)_free(con->finalArgv);
01084     con->appName = (const char *)_free(con->appName);
01085     con->otherHelp = (const char *)_free(con->otherHelp);
01086     con->execPath = (const char *)_free(con->execPath);
01087     con->arg_strip = (pbm_set *)PBM_FREE(con->arg_strip);
01088     
01089     con = (poptContext)_free(con);
01090     return con;
01091 }
01092 
01093 int poptAddAlias(poptContext con, struct poptAlias alias,
01094                 /*@unused@*/ int flags)
01095 {
01096     poptItem item = (poptItem)alloca(sizeof(*item));
01097     memset(item, 0, sizeof(*item));
01098     item->option.longName = alias.longName;
01099     item->option.shortName = alias.shortName;
01100     item->option.argInfo = POPT_ARGFLAG_DOC_HIDDEN;
01101     item->option.arg = 0;
01102     item->option.val = 0;
01103     item->option.descrip = NULL;
01104     item->option.argDescrip = NULL;
01105     item->argc = alias.argc;
01106     item->argv = alias.argv;
01107     return poptAddItem(con, item, 0);
01108 }
01109 
01110 /*@-boundswrite@*/
01111 /*@-mustmod@*/ /* LCL: con not modified? */
01112 int poptAddItem(poptContext con, poptItem newItem, int flags)
01113 {
01114     poptItem * items, item;
01115     int * nitems;
01116 
01117     switch (flags) {
01118     case 1:
01119         items = &con->execs;
01120         nitems = &con->numExecs;
01121         break;
01122     case 0:
01123         items = &con->aliases;
01124         nitems = &con->numAliases;
01125         break;
01126     default:
01127         return 1;
01128         /*@notreached@*/ break;
01129     }
01130 
01131     *items = (poptItem)realloc((*items), ((*nitems) + 1) * sizeof(**items));
01132     if ((*items) == NULL)
01133         return 1;
01134 
01135     item = (*items) + (*nitems);
01136 
01137     item->option.longName =
01138         (newItem->option.longName ? xstrdup(newItem->option.longName) : NULL);
01139     item->option.shortName = newItem->option.shortName;
01140     item->option.argInfo = newItem->option.argInfo;
01141     item->option.arg = newItem->option.arg;
01142     item->option.val = newItem->option.val;
01143     item->option.descrip =
01144         (newItem->option.descrip ? xstrdup(newItem->option.descrip) : NULL);
01145     item->option.argDescrip =
01146        (newItem->option.argDescrip ? xstrdup(newItem->option.argDescrip) : NULL);
01147     item->argc = newItem->argc;
01148     item->argv = newItem->argv;
01149 
01150     (*nitems)++;
01151 
01152     return 0;
01153 }
01154 /*@=mustmod@*/
01155 /*@=boundswrite@*/
01156 
01157 const char * poptBadOption(poptContext con, int flags)
01158 {
01159     struct optionStackEntry * os = NULL;
01160 
01161     if (con != NULL)
01162         os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
01163 
01164     /*@-nullderef@*/    /* LCL: os->argv != NULL */
01165     return (os && os->argv ? os->argv[os->next - 1] : NULL);
01166     /*@=nullderef@*/
01167 }
01168 
01169 const char *poptStrerror(const int error)
01170 {
01171     switch (error) {
01172       case POPT_ERROR_NOARG:
01173         return POPT_("missing argument");
01174       case POPT_ERROR_BADOPT:
01175         return POPT_("unknown option");
01176       case POPT_ERROR_BADOPERATION:
01177         return POPT_("mutually exclusive logical operations requested");
01178       case POPT_ERROR_NULLARG:
01179         return POPT_("opt->arg should not be NULL");
01180       case POPT_ERROR_OPTSTOODEEP:
01181         return POPT_("aliases nested too deeply");
01182       case POPT_ERROR_BADQUOTE:
01183         return POPT_("error in parameter quoting");
01184       case POPT_ERROR_BADNUMBER:
01185         return POPT_("invalid numeric value");
01186       case POPT_ERROR_OVERFLOW:
01187         return POPT_("number too large or too small");
01188       case POPT_ERROR_MALLOC:
01189         return POPT_("memory allocation failed");
01190       case POPT_ERROR_ERRNO:
01191         return strerror(errno);
01192       default:
01193         return POPT_("unknown error");
01194     }
01195 }
01196 
01197 int poptStuffArgs(poptContext con, const char ** argv)
01198 {
01199     int argc;
01200     int rc;
01201 
01202     if ((con->os - con->optionStack) == POPT_OPTION_DEPTH)
01203         return POPT_ERROR_OPTSTOODEEP;
01204 
01205     for (argc = 0; argv[argc]; argc++)
01206         {};
01207 
01208     con->os++;
01209     con->os->next = 0;
01210     con->os->nextArg = NULL;
01211     con->os->nextCharArg = NULL;
01212     con->os->currAlias = NULL;
01213     rc = poptDupArgv(argc, argv, &con->os->argc, &con->os->argv);
01214     con->os->argb = NULL;
01215     con->os->stuffed = 1;
01216 
01217     return rc;
01218 }
01219 
01220 const char * poptGetInvocationName(poptContext con)
01221 {
01222     return (con->os->argv ? con->os->argv[0] : "");
01223 }
01224 
01225 /*@-boundswrite@*/
01226 int poptStrippedArgv(poptContext con, int argc, char ** argv)
01227 {
01228     int numargs = argc;
01229     int j = 1;
01230     int i;
01231     
01232     /*@-sizeoftype@*/
01233     if (con->arg_strip)
01234     for (i = 1; i < argc; i++) {
01235         if (PBM_ISSET(i, con->arg_strip))
01236             numargs--;
01237     }
01238     
01239     for (i = 1; i < argc; i++) {
01240         if (con->arg_strip && PBM_ISSET(i, con->arg_strip))
01241             continue;
01242         argv[j] = (j < numargs) ? argv[i] : NULL;
01243         j++;
01244     }
01245     /*@=sizeoftype@*/
01246     
01247     return numargs;
01248 }
01249 /*@=boundswrite@*/

Sambaに対してSat Aug 29 21:23:13 2009に生成されました。  doxygen 1.4.7