Ecore_Getopt.h

Langue: en

Version: 383694 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

Ecore_Getopt.h -

Contains powerful getopt replacement.

SYNOPSIS


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.

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 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.

Translation of help strings (description), metavar, usage, license and copyright may be translated, standard/global gettext() call will be applied on them if ecore was compiled with such support.

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.

Author

Generated automatically by Doxygen for Ecore from the source code.