Ecore_Getopt.h File Reference
Contains powerful getopt replacement. More...
Functions | |
EAPI void | ecore_getopt_help (FILE *fp, const Ecore_Getopt *info) |
Show nicely formatted help message for the given parser. | |
EAPI unsigned char | ecore_getopt_parser_has_duplicates (const Ecore_Getopt *parser) |
Check parser for duplicate entries, print them out. | |
EAPI int | ecore_getopt_parse (const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int argc, char **argv) |
Parse command line parameters. | |
EAPI Eina_List * | ecore_getopt_list_free (Eina_List *list) |
Utility to free list and nodes allocated by ECORE_GETOPT_ACTION_APPEND. | |
EAPI unsigned char | ecore_getopt_callback_size_parse (const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage) |
Helper ecore_getopt callback to parse geometry size (WxH). |
Detailed Description
Contains powerful getopt replacement.This replacement handles both short (-X) or long options (--ABC) options, with various actions supported, like storing one value and already converting to required type, counting number of occurrences, setting true or false values, show help, license, copyright and even support user-defined callbacks.
It is provided a set of C Pre Processor macros so definition is straightforward.
Values will be stored elsewhere indicated by an array of pointers to values, it is given in separate to parser description so you can use multiple values with the same parser.
Function Documentation
EAPI unsigned char ecore_getopt_callback_size_parse | ( | const Ecore_Getopt * | parser, | |
const Ecore_Getopt_Desc * | desc, | |||
const char * | str, | |||
void * | data, | |||
Ecore_Getopt_Value * | storage | |||
) |
Helper ecore_getopt callback to parse geometry size (WxH).
Storage must be a pointer to Eina_Rectangle
and will be used to store the two values passed in the given string and 0 in the x and y fields.
callback_data
value is ignored, you can safely use NULL
.
EAPI void ecore_getopt_help | ( | FILE * | fp, | |
const Ecore_Getopt * | parser | |||
) |
Show nicely formatted help message for the given parser.
Message will be print to stderr.
References ecore_app_args_get().
EAPI Eina_List* ecore_getopt_list_free | ( | Eina_List * | list | ) |
Utility to free list and nodes allocated by ECORE_GETOPT_ACTION_APPEND.
- Parameters:
-
list pointer to list to be freed.
- Returns:
- always NULL, so you can easily make your list head NULL.
EAPI int ecore_getopt_parse | ( | const Ecore_Getopt * | parser, | |
Ecore_Getopt_Value * | values, | |||
int | argc, | |||
char ** | argv | |||
) |
Parse command line parameters.
Walks the command line parameters and parse them based on parser description, doing actions based on parser->descs->action
, like showing help text, license, copyright, storing values in values and so on.
It is expected that values is of the same size than parser->descs
, options that do not need a value it will be left untouched.
All values are expected to be initialized before use. Options with action ECORE_GETOPT_ACTION_STORE
and non required arguments (others than ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES
), are expected to provide a value in def
to be used.
The following actions will store 1 on value as a boolean (value->boolp
) if it's not NULL to indicate these actions were executed:
ECORE_GETOPT_ACTION_HELP
ECORE_GETOPT_ACTION_VERSION
ECORE_GETOPT_ACTION_COPYRIGHT
ECORE_GETOPT_ACTION_LICENSE
Just ECORE_GETOPT_ACTION_APPEND
will allocate memory and thus need to be freed. For consistency between all of appended subtypes, eina_list->data
will contain an allocated memory with the value, that is, for ECORE_GETOPT_TYPE_STR
it will contain a copy of the argument, ECORE_GETOPT_TYPE_INT
a pointer to an allocated integer and so on.
If parser is in strict mode (see Ecore_Getopt->strict
), then any error will abort parsing and -1 is returned. Otherwise it will try to continue as far as possible.
This function may reorder argv elements.
- Parameters:
-
parser description of how to work. value where to store values, it is assumed that this is a vector of the same size as parser->descs
. Values should be previously initialized.argc how many elements in argv. If not provided it will be retrieved with ecore_app_args_get(). argv command line parameters.
- Returns:
- index of first non-option parameter or -1 on error.
References ecore_app_args_get().
EAPI unsigned char ecore_getopt_parser_has_duplicates | ( | const Ecore_Getopt * | parser | ) |
Check parser for duplicate entries, print them out.
- Returns:
- 1 if there are duplicates, 0 otherwise.