getopt() . These suboptions must be separated by commas and can consist of either a single token or a pair of token values separated by an equals sign. Because commas are used to delimit suboptions in the option string, they must not be part of the suboption or the value of a suboption. Similarly, a token must not contain an equals sign, because tokens and associated values are separated by equals signs. getsubopt() receives the address of a pointer to the option string which represents an array of possible tokens and the address of a pointer to a value string. The index of the token that corresponds to the suboption from the transferred string is returned; if no corresponding suboption is found, -1 is returned. If the option string under *optionp only contains one suboption, getsubopt() updates *optionp such that the null byte at the end of the string is pointed to; otherwise, the suboption is isolated through replacement of the separating comma being with a null byte, and *optionp points to the beginning of the next suboption. If the suboption is assigned a value, getsubopt() updates *valuep such that the first character of the value is pointed to. Otherwise, *valuep is set to zero. The token array is organized as a sequence of pointers to null-terminated strings. The end of the token array is identified by a null pointer. If valuep is not zero, getsubopt() returns the suboption to which a value was assigned. The calling program can use this information to determine whether the presence or the omission of a value for this suboption represents an error. If getsubopt() does not find a suboption in the tokens array, the calling program should decide whether this means an error or whether the non-recognized option should be passed to another program. |