The OptionAdd function add a command line option to a table of options.
The table of command line options is given by the argument opt which is a pointer to a structure. The command line option, without the leading "-" is given by the argument name. The type of the option is given by the argument type. If the command line option takes an argument, the decoded value of that argument is written to the location given by data.
The possible type codes are:
'x' | Flag |
'i' | Option takes an integer argument of type int . |
's' | Option takes an integer argument of type short . |
'l' | Option takes an integer argument of type long . |
'f' | Option takes a floating point argument of type float . |
'd' | Option takes a floating point argument of type double . |
't' | Option takes a text string as an argument. |
'a' | Option can takes a text string as an argument and occur multiple times. |
If the option type code is 't' , then data should point to a pointer of type char * . The value of the pointer should be initialized to NULL . When the command line options are parsed, memory will be allocated to store the zero-terminated text string and its location will be stored in this pointer. The memory allocated should be freed when the text string is no longer required.
If the option type code is 'a' , then data should point to a pointer of type struct OptionText * . When the command line options are parsed, memory will be allocated for this structure and it will be populated. The memory should be freed when the structure is no longer required by calling the function OptionFreeText .
|