Node:Suboptions, Next:Suboptions Example, Previous:Argp, Up:Parsing Program Arguments
Having a single level of options is sometimes not enough. There might be too many options which have to be available or a set of options is closely related.
For this case some programs use suboptions. One of the most prominent
programs is certainly mount
(8). The -o
option take one
argument which itself is a comma separated list of options. To ease the
programming of code like this the function getsubopt
is
available.
int getsubopt (char **optionp, const char* const *tokens, char **valuep) | Function |
The optionp parameter must be a pointer to a variable containing
the address of the string to process. When the function returns the
reference is updated to point to the next suboption or to the
terminating The tokens parameter references an array of strings containing the
known suboptions. All strings must be In case the suboption has an associated value introduced by a In case the next suboption in the string is not mentioned in the
tokens array the starting address of the suboption including a
possible value is returned in valuep and the return value of the
function is |