Product SiteDocumentation Site

15.2.2.5. Parsing the Command-Line Options

Once you have set up a poptGetContext, you need to iterate over all the command-line parameters. To do this, call poptGetNextOpt:
int poptGetNextOpt(poptContext context);
If an error occurs, poptGetNextOpt returns a negative error code. If the context is at the end of the options, poptGetNextOpt returns –1. Table 16-7 lists the error codes:
Table 16-7 Error codes from poptGetNextOpt
Code
Meaning
POPT_ERROR_NOARG
Option requires an argument, but it is missing
POPT_ERROR_BADOPT
Argument could not be parsed
POPT_ERROR_OPTSTOODEEP
Aliases are nested too deeply
POPT_ERROR_BADQUOTE
Start and end quotation marks don't match
POPT_ERROR_BADNUMBER
Argument could not be converted to a number
POPT_ERROR_OVERFLOW
Argument number was too big or too small
POPT_ERROR_ERRNO
A system call returned an error in errno