MCPcopy Index your code
hub / github.com/RsyncProject/rsync / poptGetNextOpt

Function poptGetNextOpt

popt/popt.c:1209–1469  ·  view source on GitHub ↗

returns 'val' element, -1 on last item, POPT_ERROR_* on error */

Source from the content-addressed store, hash-verified

1207
1208/* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
1209int poptGetNextOpt(poptContext con)
1210{
1211 const struct poptOption * opt = NULL;
1212 int done = 0;
1213
1214 if (con == NULL)
1215 return -1;
1216 while (!done) {
1217 const char * origOptString = NULL;
1218 poptCallbackType cb = NULL;
1219 const void * cbData = NULL;
1220 const char * longArg = NULL;
1221 int canstrip = 0;
1222 int shorty = 0;
1223
1224 while (!con->os->nextCharArg && con->os->next == con->os->argc
1225 && con->os > con->optionStack) {
1226 cleanOSE(con->os--);
1227 }
1228 if (!con->os->nextCharArg && con->os->next == con->os->argc) {
1229 invokeCallbacksPOST(con, con->options);
1230
1231 if (con->maincall) {
1232 (void) (*con->maincall) (con->finalArgvCount, con->finalArgv);
1233 return -1;
1234 }
1235
1236 if (con->doExec) return execCommand(con);
1237 return -1;
1238 }
1239
1240 /* Process next long option */
1241 if (!con->os->nextCharArg) {
1242 const char * optString;
1243 size_t optStringLen;
1244 int thisopt;
1245
1246 if (con->os->argb && PBM_ISSET(con->os->next, con->os->argb)) {
1247 con->os->next++;
1248 continue;
1249 }
1250 thisopt = con->os->next;
1251 if (con->os->argv != NULL) /* XXX can't happen */
1252 origOptString = con->os->argv[con->os->next++];
1253
1254 if (origOptString == NULL) /* XXX can't happen */
1255 return POPT_ERROR_BADOPT;
1256
1257 if (con->restLeftover || *origOptString != '-' ||
1258 (*origOptString == '-' && origOptString[1] == '\0'))
1259 {
1260 if (con->flags & POPT_CONTEXT_POSIXMEHARDER)
1261 con->restLeftover = 1;
1262 if (con->flags & POPT_CONTEXT_ARG_OPTS) {
1263 con->os->nextArg = xstrdup(origOptString);
1264 return 0;
1265 }
1266 if (con->leftovers != NULL) { /* XXX can't happen */

Callers 3

parse_argumentsFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 14

cleanOSEFunction · 0.85
invokeCallbacksPOSTFunction · 0.85
execCommandFunction · 0.85
handleAliasFunction · 0.85
handleExecFunction · 0.85
findOptionFunction · 0.85
poptStripArgFunction · 0.85
poptArgInfoFunction · 0.85
poptSaveIntFunction · 0.85
_freeFunction · 0.85
expandNextArgFunction · 0.85
poptSaveArgFunction · 0.85

Tested by 1

mainFunction · 0.68