Ecore_Getopt.h File Reference

Contains powerful getopt replacement. More...

Data Structures

union  _Ecore_Getopt_Value
 
struct  _Ecore_Getopt_Desc_Store
 
struct  _Ecore_Getopt_Desc_Callback
 
struct  _Ecore_Getopt_Desc
 
struct  _Ecore_Getopt
 

Macros

#define EAPI
 
#define _ECORE_GETOPT_PREDEF   1
 
#define _ECORE_GETOPT_DESC_PREDEF   1
 
#define _ECORE_GETOPT_VALUE_PREDEF   1
 
#define ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE(shortname, longname, help, type)
 
#define ECORE_GETOPT_STORE_STR(shortname, longname, help)   ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_STR)
 
#define ECORE_GETOPT_STORE_BOOL(shortname, longname, help)   ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_BOOL)
 
#define ECORE_GETOPT_STORE_SHORT(shortname, longname, help)   ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_SHORT)
 
#define ECORE_GETOPT_STORE_INT(shortname, longname, help)   ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_INT)
 
#define ECORE_GETOPT_STORE_LONG(shortname, longname, help)   ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_LONG)
 
#define ECORE_GETOPT_STORE_USHORT(shortname, longname, help)   ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_USHORT)
 
#define ECORE_GETOPT_STORE_UINT(shortname, longname, help)   ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_UINT)
 
#define ECORE_GETOPT_STORE_ULONG(shortname, longname, help)   ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_ULONG)
 
#define ECORE_GETOPT_STORE_DOUBLE(shortname, longname, help)   ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_DOUBLE)
 
#define ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, type)
 
#define ECORE_GETOPT_STORE_METAVAR_STR(shortname, longname, help, metavar)   ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_STR)
 
#define ECORE_GETOPT_STORE_METAVAR_BOOL(shortname, longname, help, metavar)   ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_BOOL)
 
#define ECORE_GETOPT_STORE_METAVAR_SHORT(shortname, longname, help, metavar)   ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_SHORT)
 
#define ECORE_GETOPT_STORE_METAVAR_INT(shortname, longname, help, metavar)   ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_INT)
 
#define ECORE_GETOPT_STORE_METAVAR_LONG(shortname, longname, help, metavar)   ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_LONG)
 
#define ECORE_GETOPT_STORE_METAVAR_USHORT(shortname, longname, help, metavar)   ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_USHORT)
 
#define ECORE_GETOPT_STORE_METAVAR_UINT(shortname, longname, help, metavar)   ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_UINT)
 
#define ECORE_GETOPT_STORE_METAVAR_ULONG(shortname, longname, help, metavar)   ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_ULONG)
 
#define ECORE_GETOPT_STORE_METAVAR_DOUBLE(shortname, longname, help, metavar)   ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_DOUBLE)
 
#define ECORE_GETOPT_STORE_DEF(shortname, longname, help, type, default_value)
 
#define ECORE_GETOPT_STORE_DEF_STR(shortname, longname, help, default_value)
 
#define ECORE_GETOPT_STORE_DEF_BOOL(shortname, longname, help, default_value)
 
#define ECORE_GETOPT_STORE_DEF_SHORT(shortname, longname, help, default_value)
 
#define ECORE_GETOPT_STORE_DEF_INT(shortname, longname, help, default_value)
 
#define ECORE_GETOPT_STORE_DEF_LONG(shortname, longname, help, default_value)
 
#define ECORE_GETOPT_STORE_DEF_USHORT(shortname, longname, help, default_value)
 
#define ECORE_GETOPT_STORE_DEF_UINT(shortname, longname, help, default_value)
 
#define ECORE_GETOPT_STORE_DEF_ULONG(shortname, longname, help, default_value)
 
#define ECORE_GETOPT_STORE_DEF_DOUBLE(shortname, longname, help, default_value)
 
#define ECORE_GETOPT_STORE_FULL_STR(shortname, longname, help, metavar, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE_FULL_BOOL(shortname, longname, help, metavar, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE_FULL_SHORT(shortname, longname, help, metavar, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE_FULL_INT(shortname, longname, help, metavar, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE_FULL_LONG(shortname, longname, help, metavar, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE_FULL_USHORT(shortname, longname, help, metavar, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE_FULL_UINT(shortname, longname, help, metavar, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE_FULL_ULONG(shortname, longname, help, metavar, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE_FULL_DOUBLE(shortname, longname, help, metavar, arg_requirement, default_value)
 
#define ECORE_GETOPT_STORE_CONST(shortname, longname, help, value)
 
#define ECORE_GETOPT_STORE_TRUE(shortname, longname, help)
 
#define ECORE_GETOPT_STORE_FALSE(shortname, longname, help)
 
#define ECORE_GETOPT_CHOICE(shortname, longname, help, choices_array)
 
#define ECORE_GETOPT_CHOICE_METAVAR(shortname, longname, help, metavar, choices_array)
 
#define ECORE_GETOPT_APPEND(shortname, longname, help, sub_type)
 
#define ECORE_GETOPT_APPEND_METAVAR(shortname, longname, help, metavar, type)
 
#define ECORE_GETOPT_COUNT(shortname, longname, help)
 
#define ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, callback_func, callback_data, argument_requirement, default_value)
 
#define ECORE_GETOPT_CALLBACK_NOARGS(shortname, longname, help, callback_func, callback_data)
 
#define ECORE_GETOPT_CALLBACK_ARGS(shortname, longname, help, metavar, callback_func, callback_data)
 
#define ECORE_GETOPT_HELP(shortname, longname)
 
#define ECORE_GETOPT_VERSION(shortname, longname)
 
#define ECORE_GETOPT_COPYRIGHT(shortname, longname)
 
#define ECORE_GETOPT_LICENSE(shortname, longname)
 
#define ECORE_GETOPT_BREAK(shortname, longname)
 
#define ECORE_GETOPT_BREAK_STR(shortname, longname, help)
 
#define ECORE_GETOPT_SENTINEL   {0, NULL, NULL, NULL, 0, {.dummy = NULL}}
 
#define ECORE_GETOPT_VALUE_STR(val)   {.strp = &(val)}
 
#define ECORE_GETOPT_VALUE_BOOL(val)   {.boolp = &(val)}
 
#define ECORE_GETOPT_VALUE_SHORT(val)   {.shortp = &(val)}
 
#define ECORE_GETOPT_VALUE_INT(val)   {.intp = &(val)}
 
#define ECORE_GETOPT_VALUE_LONG(val)   {.longp = &(val)}
 
#define ECORE_GETOPT_VALUE_USHORT(val)   {.ushortp = &(val)}
 
#define ECORE_GETOPT_VALUE_UINT(val)   {.uintp = &(val)}
 
#define ECORE_GETOPT_VALUE_ULONG(val)   {.ulongp = &(val)}
 
#define ECORE_GETOPT_VALUE_DOUBLE(val)   {.doublep = &(val)}
 
#define ECORE_GETOPT_VALUE_PTR(val)   {.ptrp = &(val)}
 
#define ECORE_GETOPT_VALUE_PTR_CAST(val)   {.ptrp = (void **)&(val)}
 
#define ECORE_GETOPT_VALUE_LIST(val)   {.listp = &(val)}
 
#define ECORE_GETOPT_VALUE_NONE   {.ptrp = NULL}
 

Typedefs

typedef struct _Ecore_Getopt_Desc_Store Ecore_Getopt_Desc_Store
 
typedef struct _Ecore_Getopt_Desc_Callback Ecore_Getopt_Desc_Callback
 
typedef struct _Ecore_Getopt Ecore_Getopt
 
typedef struct _Ecore_Getopt_Desc Ecore_Getopt_Desc
 
typedef union _Ecore_Getopt_Value Ecore_Getopt_Value
 

Enumerations

enum  Ecore_Getopt_Action {
  ECORE_GETOPT_ACTION_STORE,
  ECORE_GETOPT_ACTION_STORE_CONST,
  ECORE_GETOPT_ACTION_STORE_TRUE,
  ECORE_GETOPT_ACTION_STORE_FALSE,
  ECORE_GETOPT_ACTION_CHOICE,
  ECORE_GETOPT_ACTION_APPEND,
  ECORE_GETOPT_ACTION_COUNT,
  ECORE_GETOPT_ACTION_CALLBACK,
  ECORE_GETOPT_ACTION_HELP,
  ECORE_GETOPT_ACTION_VERSION,
  ECORE_GETOPT_ACTION_COPYRIGHT,
  ECORE_GETOPT_ACTION_LICENSE,
  ECORE_GETOPT_ACTION_BREAK
}
 
enum  Ecore_Getopt_Type {
  ECORE_GETOPT_TYPE_STR,
  ECORE_GETOPT_TYPE_BOOL,
  ECORE_GETOPT_TYPE_SHORT,
  ECORE_GETOPT_TYPE_INT,
  ECORE_GETOPT_TYPE_LONG,
  ECORE_GETOPT_TYPE_USHORT,
  ECORE_GETOPT_TYPE_UINT,
  ECORE_GETOPT_TYPE_ULONG,
  ECORE_GETOPT_TYPE_DOUBLE
}
 
enum  Ecore_Getopt_Desc_Arg_Requirement {
  ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO = 0,
  ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES = 1,
  ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL = 3
}
 

Functions

EAPI void ecore_getopt_help (FILE *fp, const Ecore_Getopt *info)
 Show nicely formatted help message for the given parser. More...
 
EAPI Eina_Bool ecore_getopt_parser_has_duplicates (const Ecore_Getopt *parser)
 Check parser for duplicate entries, print them out. More...
 
EAPI int ecore_getopt_parse (const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int argc, char **argv)
 Parse command line parameters. More...
 
EAPI Eina_Listecore_getopt_list_free (Eina_List *list)
 Utility to free list and nodes allocated by ECORE_GETOPT_ACTION_APPEND. More...
 
EAPI Eina_Bool ecore_getopt_callback_geometry_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 (x:y:w:h). More...
 
EAPI Eina_Bool 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). More...
 

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.

Macro Definition Documentation

#define ECORE_GETOPT_STORE_FULL (   shortname,
  longname,
  help,
  metavar,
  type,
  arg_requirement,
  default_value 
)
Value:
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \
{.store = {type, arg_requirement, default_value}}}
#define ECORE_GETOPT_STORE (   shortname,
  longname,
  help,
  type 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \
ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {})
#define ECORE_GETOPT_STORE_METAVAR (   shortname,
  longname,
  help,
  metavar,
  type 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \
ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {})
#define ECORE_GETOPT_STORE_DEF (   shortname,
  longname,
  help,
  type,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \
ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL, \
default_value)
#define ECORE_GETOPT_STORE_DEF_STR (   shortname,
  longname,
  help,
  default_value 
)
Value:
ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
ECORE_GETOPT_TYPE_STR, \
{.strv = default_value})
#define ECORE_GETOPT_STORE_DEF_BOOL (   shortname,
  longname,
  help,
  default_value 
)
Value:
ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
ECORE_GETOPT_TYPE_BOOL, \
{.boolv = default_value})
#define ECORE_GETOPT_STORE_DEF_SHORT (   shortname,
  longname,
  help,
  default_value 
)
Value:
ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
ECORE_GETOPT_TYPE_SHORT, \
{.shortv = default_value})
#define ECORE_GETOPT_STORE_DEF_INT (   shortname,
  longname,
  help,
  default_value 
)
Value:
ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
ECORE_GETOPT_TYPE_INT, \
{.intv = default_value})
#define ECORE_GETOPT_STORE_DEF_LONG (   shortname,
  longname,
  help,
  default_value 
)
Value:
ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
ECORE_GETOPT_TYPE_LONG, \
{.longv = default_value})
#define ECORE_GETOPT_STORE_DEF_USHORT (   shortname,
  longname,
  help,
  default_value 
)
Value:
ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
ECORE_GETOPT_TYPE_USHORT, \
{.ushortv = default_value})
#define ECORE_GETOPT_STORE_DEF_UINT (   shortname,
  longname,
  help,
  default_value 
)
Value:
ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
ECORE_GETOPT_TYPE_UINT, \
{.uintv = default_value})
#define ECORE_GETOPT_STORE_DEF_ULONG (   shortname,
  longname,
  help,
  default_value 
)
Value:
ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
ECORE_GETOPT_TYPE_ULONG, \
{.ulongv = default_value})
#define ECORE_GETOPT_STORE_DEF_DOUBLE (   shortname,
  longname,
  help,
  default_value 
)
Value:
ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
ECORE_GETOPT_TYPE_DOUBLE, \
{.doublev = default_value})
#define ECORE_GETOPT_STORE_FULL_STR (   shortname,
  longname,
  help,
  metavar,
  arg_requirement,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_STR, \
arg_requirement, \
{.strv = default_value})
#define ECORE_GETOPT_STORE_FULL_BOOL (   shortname,
  longname,
  help,
  metavar,
  arg_requirement,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_BOOL, \
arg_requirement, \
{.boolv = default_value})
#define ECORE_GETOPT_STORE_FULL_SHORT (   shortname,
  longname,
  help,
  metavar,
  arg_requirement,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_SHORT, \
arg_requirement, \
{.shortv = default_value})
#define ECORE_GETOPT_STORE_FULL_INT (   shortname,
  longname,
  help,
  metavar,
  arg_requirement,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_INT, \
arg_requirement, \
{.intv = default_value})
#define ECORE_GETOPT_STORE_FULL_LONG (   shortname,
  longname,
  help,
  metavar,
  arg_requirement,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_LONG, \
arg_requirement, \
{.longv = default_value})
#define ECORE_GETOPT_STORE_FULL_USHORT (   shortname,
  longname,
  help,
  metavar,
  arg_requirement,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_USHORT, \
arg_requirement, \
{.ushortv = default_value})
#define ECORE_GETOPT_STORE_FULL_UINT (   shortname,
  longname,
  help,
  metavar,
  arg_requirement,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_UINT, \
arg_requirement, \
{.uintv = default_value})
#define ECORE_GETOPT_STORE_FULL_ULONG (   shortname,
  longname,
  help,
  metavar,
  arg_requirement,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_ULONG, \
arg_requirement, \
{.ulongv = default_value})
#define ECORE_GETOPT_STORE_FULL_DOUBLE (   shortname,
  longname,
  help,
  metavar,
  arg_requirement,
  default_value 
)
Value:
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_DOUBLE, \
arg_requirement, \
{.doublev = default_value})
#define ECORE_GETOPT_STORE_CONST (   shortname,
  longname,
  help,
  value 
)
Value:
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_CONST, \
{.store_const = value}}
#define ECORE_GETOPT_STORE_TRUE (   shortname,
  longname,
  help 
)
Value:
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_TRUE, \
{.dummy = NULL}}
#define ECORE_GETOPT_STORE_FALSE (   shortname,
  longname,
  help 
)
Value:
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_FALSE, \
{.dummy = NULL}}
#define ECORE_GETOPT_CHOICE (   shortname,
  longname,
  help,
  choices_array 
)
Value:
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_CHOICE, \
{.choices = choices_array}}
#define ECORE_GETOPT_CHOICE_METAVAR (   shortname,
  longname,
  help,
  metavar,
  choices_array 
)
Value:
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CHOICE, \
{.choices = choices_array}}
#define ECORE_GETOPT_APPEND (   shortname,
  longname,
  help,
  sub_type 
)
Value:
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_APPEND, \
{.append_type = sub_type}}
#define ECORE_GETOPT_APPEND_METAVAR (   shortname,
  longname,
  help,
  metavar,
  type 
)
Value:
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_APPEND, \
{.append_type = type}}
#define ECORE_GETOPT_COUNT (   shortname,
  longname,
  help 
)
Value:
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_COUNT, \
{.dummy = NULL}}
#define ECORE_GETOPT_CALLBACK_FULL (   shortname,
  longname,
  help,
  metavar,
  callback_func,
  callback_data,
  argument_requirement,
  default_value 
)
Value:
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CALLBACK, \
{.callback = {callback_func, callback_data, \
argument_requirement, default_value}}}
#define ECORE_GETOPT_CALLBACK_NOARGS (   shortname,
  longname,
  help,
  callback_func,
  callback_data 
)
Value:
ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, NULL, \
callback_func, callback_data, \
ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO, \
NULL)
#define ECORE_GETOPT_CALLBACK_ARGS (   shortname,
  longname,
  help,
  metavar,
  callback_func,
  callback_data 
)
Value:
ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, \
callback_func, callback_data, \
ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, \
NULL)
#define ECORE_GETOPT_HELP (   shortname,
  longname 
)
Value:
{shortname, longname, "show this message.", NULL, \
ECORE_GETOPT_ACTION_HELP, \
{.dummy = NULL}}
#define ECORE_GETOPT_VERSION (   shortname,
  longname 
)
Value:
{shortname, longname, "show program version.", NULL, \
ECORE_GETOPT_ACTION_VERSION, \
{.dummy = NULL}}
#define ECORE_GETOPT_COPYRIGHT (   shortname,
  longname 
)
Value:
{shortname, longname, "show copyright.", NULL, \
ECORE_GETOPT_ACTION_COPYRIGHT, \
{.dummy = NULL}}
#define ECORE_GETOPT_LICENSE (   shortname,
  longname 
)
Value:
{shortname, longname, "show license.", NULL, \
ECORE_GETOPT_ACTION_LICENSE, \
{.dummy = NULL}}
#define ECORE_GETOPT_BREAK (   shortname,
  longname 
)
Value:
{shortname, longname, "stop parsing options.", NULL, \
ECORE_GETOPT_ACTION_BREAK, \
{.dummy = NULL}}
#define ECORE_GETOPT_BREAK_STR (   shortname,
  longname,
  help 
)
Value:
{shortname, longname, help, NULL, \
ECORE_GETOPT_ACTION_BREAK, \
{.dummy = NULL}}

Function Documentation

EAPI void ecore_getopt_help ( FILE *  fp,
const Ecore_Getopt parser 
)

Show nicely formatted help message for the given parser.

Parameters
fpThe file the message will be printed on.
parserThe parser to be used.

References ecore_app_args_get(), EINA_MAIN_LOOP_CHECK_RETURN, and _Ecore_Getopt::prog.

EAPI Eina_Bool ecore_getopt_parser_has_duplicates ( const Ecore_Getopt parser)

Check parser for duplicate entries, print them out.

Returns
EINA_TRUE if there are duplicates, EINA_FALSE otherwise.
Parameters
parserThe parser to be checked.

References EINA_FALSE, EINA_TRUE, _Ecore_Getopt_Desc::longname, and _Ecore_Getopt_Desc::shortname.

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
parserdescription of how to work.
valueswhere to store values, it is assumed that this is a vector of the same size as parser->descs. Values should be previously initialized.
argchow many elements in argv. If not provided it will be retrieved with ecore_app_args_get().
argvcommand line parameters.
Returns
index of first non-option parameter or -1 on error.
Examples:
ecore_thread_example.c.

References ecore_app_args_get(), _Ecore_Getopt_Desc::longname, _Ecore_Getopt::prog, and _Ecore_Getopt_Desc::shortname.

EAPI Eina_List* ecore_getopt_list_free ( Eina_List list)

Utility to free list and nodes allocated by ECORE_GETOPT_ACTION_APPEND.

Parameters
listpointer to list to be freed.
Returns
always NULL, so you can easily make your list head NULL.

References EINA_LIST_FREE.

EAPI Eina_Bool ecore_getopt_callback_geometry_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 (x:y:w:h).

Parameters
parserThis parameter isn't in use.
descThis parameter isn't in use.
strGeometry value
dataThis parameter isn't in use.
storagemust be a pointer to Eina_Rectangle and will be used to store the four values passed in the given string.
Returns
EINA_TRUE on success, EINA_FALSE on incorrect geometry value.

callback_data value is ignored, you can safely use NULL.

References EINA_FALSE, EINA_TRUE, _Eina_Rectangle::h, _Eina_Rectangle::w, _Eina_Rectangle::x, and _Eina_Rectangle::y.

EAPI Eina_Bool 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).

Parameters
parserThis parameter isn't in use.
descThis parameter isn't in use.
strsize value
dataThis parameter isn't in use.
storagemust 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.
Returns
EINA_TRUE on success, EINA_FALSE on incorrect size value.

callback_data value is ignored, you can safely use NULL.

References EINA_FALSE, EINA_TRUE, _Eina_Rectangle::h, _Eina_Rectangle::w, _Eina_Rectangle::x, and _Eina_Rectangle::y.