• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/samba-3.0.13/source/popt/

Lines Matching refs:con

21 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) {
22 if (con->execPath) xfree(con->execPath);
23 con->execPath = xstrdup(path);
24 con->execAbsolute = allowAbsolute;
27 static void invokeCallbacks(poptContext con, const struct poptOption * table,
34 invokeCallbacks(con, opt->arg, post);
39 cb(con, post ? POPT_CALLBACK_REASON_POST : POPT_CALLBACK_REASON_PRE,
48 poptContext con = malloc(sizeof(*con));
50 memset(con, 0, sizeof(*con));
52 con->os = con->optionStack;
53 con->os->argc = argc;
54 con->os->argv = argv;
55 con->os->argb = NULL;
58 con->os->next = 1; /* skip argv[0] */
60 con->leftovers = calloc( (argc + 1), sizeof(char *) );
61 con->options = options;
62 con->aliases = NULL;
63 con->numAliases = 0;
64 con->flags = flags;
65 con->execs = NULL;
66 con->numExecs = 0;
67 con->finalArgvAlloced = argc * 2;
68 con->finalArgv = calloc( con->finalArgvAlloced, sizeof(*con->finalArgv) );
69 con->execAbsolute = 1;
70 con->arg_strip = NULL;
73 con->flags |= POPT_CONTEXT_POSIXMEHARDER;
76 con->appName = strcpy(malloc(strlen(name) + 1), name);
78 invokeCallbacks(con, con->options, 0);
80 return con;
99 void poptResetContext(poptContext con) {
102 while (con->os > con->optionStack) {
103 cleanOSE(con->os--);
105 if (con->os->argb) {
106 PBM_FREE(con->os->argb);
107 con->os->argb = NULL;
109 con->os->currAlias = NULL;
110 con->os->nextCharArg = NULL;
111 con->os->nextArg = NULL;
112 con->os->next = 1; /* skip argv[0] */
114 con->numLeftovers = 0;
115 con->nextLeftover = 0;
116 con->restLeftover = 0;
117 con->doExec = NULL;
119 for (i = 0; i < con->finalArgvCount; i++) {
120 if (con->finalArgv[i]) {
121 xfree(con->finalArgv[i]);
122 con->finalArgv[i] = NULL;
126 con->finalArgvCount = 0;
128 if (con->arg_strip) {
129 PBM_FREE(con->arg_strip);
130 con->arg_strip = NULL;
135 static int handleExec(poptContext con, char * longName, char shortName) {
138 i = con->numExecs - 1;
140 while (i >= 0 && (!con->execs[i].longName ||
141 strcmp(con->execs[i].longName, longName))) i--;
144 con->execs[i].shortName != shortName) i--;
149 if (con->flags & POPT_CONTEXT_NO_EXEC)
152 if (con->doExec == NULL) {
153 con->doExec = con->execs + i;
159 if ((con->finalArgvCount + 1) >= (con->finalArgvAlloced)) {
160 con->finalArgvAlloced += 10;
161 con->finalArgv = realloc(con->finalArgv,
162 sizeof(*con->finalArgv) * con->finalArgvAlloced);
165 i = con->finalArgvCount++;
171 con->finalArgv[i] = s;
178 static int handleAlias(poptContext con, const char * longName, char shortName,
182 if (con->os->currAlias && con->os->currAlias->longName && longName &&
183 !strcmp(con->os->currAlias->longName, longName))
185 if (con->os->currAlias && shortName &&
186 shortName == con->os->currAlias->shortName)
189 i = con->numAliases - 1;
191 while (i >= 0 && (!con->aliases[i].longName ||
192 strcmp(con->aliases[i].longName, longName))) i--;
195 con->aliases[i].shortName != shortName) i--;
200 if ((con->os - con->optionStack + 1) == POPT_OPTION_DEPTH)
204 con->os->nextCharArg = nextCharArg;
206 con->os++;
207 con->os->next = 0;
208 con->os->stuffed = 0;
209 con->os->nextArg = NULL;
210 con->os->nextCharArg = NULL;
211 con->os->currAlias = con->aliases + i;
212 poptDupArgv(con->os->currAlias->argc, con->os->currAlias->argv,
213 &con->os->argc, &con->os->argv);
214 con->os->argb = NULL;
219 static void execCommand(poptContext con) {
222 const char * script = con->doExec->script;
225 (6 + con->numLeftovers + con->finalArgvCount));
227 if (!con->execAbsolute && strchr(script, '/')) return;
229 if (!strchr(script, '/') && con->execPath) {
230 char *s = malloc(strlen(con->execPath) + strlen(script) + 2);
231 sprintf(s, "%s/%s", con->execPath, script);
238 argv[pos] = findProgramPath(con->os->argv[0]);
242 memcpy(argv + pos, con->finalArgv, sizeof(*argv) * con->finalArgvCount);
243 pos += con->finalArgvCount;
245 if (con->numLeftovers) {
247 memcpy(argv + pos, con->leftovers, sizeof(*argv) * con->numLeftovers);
248 pos += con->numLeftovers;
320 static const char *findNextArg(poptContext con, unsigned argx, int delete)
322 struct optionStackEntry * os = con->os;
328 while (os->next == os->argc && os > con->optionStack) os--;
329 if (os->next == os->argc && os == con->optionStack) break;
341 if (os > con->optionStack) os--;
346 static /*@only@*/ const char * expandNextArg(poptContext con, const char * s)
365 if ((a = findNextArg(con, 1, 1)) == NULL)
387 static void poptStripArg(poptContext con, int which)
389 if(con->arg_strip == NULL) {
390 con->arg_strip = PBM_ALLOC(con->optionStack[0].argc);
392 PBM_SET(which, con->arg_strip);
396 int poptGetNextOpt(poptContext con)
416 while (!con->os->nextCharArg && con->os->next == con->os->argc
417 && con->os > con->optionStack) {
418 cleanOSE(con->os--);
420 if (!con->os->nextCharArg && con->os->next == con->os->argc) {
421 invokeCallbacks(con, con->options, 1);
422 if (con->doExec) execCommand(con);
427 if (!con->os->nextCharArg) {
431 if (con->os->argb && PBM_ISSET(con->os->next, con->os->argb)) {
432 con->os->next++;
435 thisopt=con->os->next;
436 origOptString = con->os->argv[con->os->next++];
438 if (con->restLeftover || *origOptString != '-') {
439 con->leftovers[con->numLeftovers++] = origOptString;
440 if (con->flags & POPT_CONTEXT_POSIXMEHARDER)
441 con->restLeftover = 1;
454 con->restLeftover = 1;
467 if (handleAlias(con, optString, '\0', NULL))
469 if (handleExec(con, optString, '\0'))
481 opt = findOption(con->options, optString, '\0', &cb, &cbData,
488 con->os->nextCharArg = origOptString + 1;
490 if(con->os == con->optionStack &&
493 poptStripArg(con, thisopt);
499 if (con->os->nextCharArg) {
500 origOptString = con->os->nextCharArg;
502 con->os->nextCharArg = NULL;
504 if (handleAlias(con, NULL, *origOptString,
509 if (handleExec(con, NULL, *origOptString))
512 opt = findOption(con->options, NULL, *origOptString, &cb,
519 con->os->nextCharArg = origOptString;
528 if (con->os->nextArg) {
529 xfree(con->os->nextArg);
530 con->os->nextArg = NULL;
533 con->os->nextArg = expandNextArg(con, longArg);
534 } else if (con->os->nextCharArg) {
535 con->os->nextArg = expandNextArg(con, con->os->nextCharArg);
536 con->os->nextCharArg = NULL;
538 while (con->os->next == con->os->argc &&
539 con->os > con->optionStack) {
540 cleanOSE(con->os--);
542 if (con->os->next == con->os->argc)
547 if(con->os == con->optionStack &&
550 poptStripArg(con, con->os->next);
553 con->os->nextArg = expandNextArg(con, con->os->argv[con->os->next++]);
563 *((const char **) opt->arg) = xstrdup(con->os->nextArg);
568 aLong = strtol(con->os->nextArg, &end, 0);
592 cb(con, POPT_CALLBACK_REASON_OPTION, opt, con->os->nextArg, cbData);
596 if ((con->finalArgvCount + 2) >= (con->finalArgvAlloced)) {
597 con->finalArgvAlloced += 10;
598 con->finalArgv = realloc(con->finalArgv,
599 sizeof(*con->finalArgv) * con->finalArgvAlloced);
607 con->finalArgv[con->finalArgvCount++] = s;
612 con->finalArgv[con->finalArgvCount++] = xstrdup(con->os->nextArg);
619 const char * poptGetOptArg(poptContext con) {
620 const char * ret = con->os->nextArg;
621 con->os->nextArg = NULL;
625 const char * poptGetArg(poptContext con) {
626 if (con->numLeftovers == con->nextLeftover) return NULL;
627 return con->leftovers[con->nextLeftover++];
630 const char * poptPeekArg(poptContext con) {
631 if (con->numLeftovers == con->nextLeftover) return NULL;
632 return con->leftovers[con->nextLeftover];
635 const char ** poptGetArgs(poptContext con) {
636 if (con->numLeftovers == con->nextLeftover) return NULL;
639 con->leftovers[con->numLeftovers] = NULL;
641 return (con->leftovers + con->nextLeftover);
644 void poptFreeContext(poptContext con) {
647 poptResetContext(con);
648 if (con->os->argb) free(con->os->argb);
650 for (i = 0; i < con->numAliases; i++) {
651 if (con->aliases[i].longName) xfree(con->aliases[i].longName);
652 free(con->aliases[i].argv);
655 for (i = 0; i < con->numExecs; i++) {
656 if (con->execs[i].longName) xfree(con->execs[i].longName);
657 xfree(con->execs[i].script);
659 if (con->execs) xfree(con->execs);
661 free(con->leftovers);
662 free(con->finalArgv);
663 if (con->appName) xfree(con->appName);
664 if (con->aliases) free(con->aliases);
665 if (con->otherHelp) xfree(con->otherHelp);
666 if (con->execPath) xfree(con->execPath);
667 if (con->arg_strip) PBM_FREE(con->arg_strip);
669 free(con);
672 int poptAddAlias(poptContext con, struct poptAlias newAlias,
675 int aliasNum = con->numAliases++;
679 if (!con->aliases)
680 con->aliases = malloc(sizeof(newAlias) * con->numAliases);
682 con->aliases = realloc(con->aliases,
683 sizeof(newAlias) * con->numAliases);
684 alias = con->aliases + aliasNum;
696 const char * poptBadOption(poptContext con, int flags) {
700 os = con->optionStack;
702 os = con->os;
734 int poptStuffArgs(poptContext con, const char ** argv) {
737 if ((con->os - con->optionStack) == POPT_OPTION_DEPTH)
743 con->os++;
744 con->os->next = 0;
745 con->os->nextArg = NULL;
746 con->os->nextCharArg = NULL;
747 con->os->currAlias = NULL;
748 poptDupArgv(argc, argv, &con->os->argc, &con->os->argv);
749 con->os->argb = NULL;
750 con->os->stuffed = 1;
755 const char * poptGetInvocationName(poptContext con) {
756 return con->os->argv[0];
759 int poptStrippedArgv(poptContext con, int argc, char **argv)
764 if(PBM_ISSET(i, con->arg_strip)) {
770 if(PBM_ISSET(i, con->arg_strip)) {