![]() | ![]() | ![]() | [Insert name here] Reference Manual | ![]() |
---|
#define CLI_HOOK #define CFG_HOOK #define WIDE_HOOK #define prelude_option_success #define prelude_option_end #define prelude_option_error enum prelude_option_argument_t; #define option_run_last #define option_run_first #define option_run_no_order void prelude_option_set_priority (prelude_option_t *option, int priority); void prelude_option_print (int flags, int descoff); prelude_msg_t* prelude_option_wide_get_msg (void); void prelude_option_destroy (prelude_option_t *option); int prelude_option_parse_arguments (prelude_option_t *option, const char *filename, int argc, char **argv); prelude_option_t* prelude_option_add (prelude_option_t *parent, int flags, char shortopt, const char *longopt, const char *desc, prelude_option_argument_t has_arg, int (*set) (prelude_option_t *opt, const char *optarg), int (*get) (char *buf, size_t size)); #define OPT_INVAL #define OPT_INVAL_ARG void prelude_option_set_warnings (int flags, int *old_flags); char prelude_option_get_shortname (prelude_option_t *opt); const char* prelude_option_get_longname (prelude_option_t *opt); void prelude_option_set_private_data (prelude_option_t *opt, void *data); void* prelude_option_get_private_data (prelude_option_t *opt);
typedef enum { required_argument, optionnal_argument, no_argument } prelude_option_argument_t;
void prelude_option_set_priority (prelude_option_t *option, int priority);
option : | |
priority : |
|
void prelude_option_print (int flags, int descoff);
Dump option available in opt and hooked to the given flags. If opt is NULL, then the root of the option list is used.
flags : | Only option with specified flags will be printed. |
descoff : | offset from the begining of the line where the description should start. |
void prelude_option_destroy (prelude_option_t *option);
Destroy a prelude_option_t object and all data associated with it (including all suboption).
option : | Pointer on an option object. |
int prelude_option_parse_arguments (prelude_option_t *option, const char *filename, int argc, char **argv);
prelude_option_parse_arguments(), parse the given argument and try to match them against option in option. If an option match, it's associated callback function is called with the eventual option argument if any.
Option not matched on the command line are searched in the configuration file specified by filename.
if option is NULL, all system option will be matched against argc, and argv.
option : | A pointer on an option (list). |
filename : | Pointer to the config filename. |
argc : | Number of argument. |
argv : | Argument list. |
Returns : | 0 if parsing the option succeed (including the case where one of the callback returned -1 to request interruption of parsing), -1 if an error occured. |
prelude_option_t* prelude_option_add (prelude_option_t *parent, int flags, char shortopt, const char *longopt, const char *desc, prelude_option_argument_t has_arg, int (*set) (prelude_option_t *opt, const char *optarg), int (*get) (char *buf, size_t size));
prelude_option_add() create a new option. The option is set to be the child of parent, unless it is NULL. In this case the option is a root option.
The flags parameters can be set to CLI_HOOK (telling the option may be searched on the command line only) or CFG_HOOk (telling the option may be searched in the configuration file only) or both.
parent : | Pointer on a parent option. |
flags : | bitfields. |
shortopt : | Short option name. |
longopt : | Long option name. |
desc : | Description of the option. |
has_arg : | Define if the option has argument. |
set : | Callback to be called when the value for this option change. |
get : | Callback to be called to get the value for this option. |
Returns : | Pointer on the option object, or NULL if an error occured. |
void prelude_option_set_warnings (int flags, int *old_flags);
Set current warnings flags to flags (unless flags is 0).
Uppon return, the variable pointed to by old_flags is updated to contain the old flags unless it point to NULL.
flags : | bitwise OR of flags. |
old_flags : | Pointer to an integer where to store old flags to. |
char prelude_option_get_shortname (prelude_option_t *opt);
opt : | |
Returns : |
|
const char* prelude_option_get_longname (prelude_option_t *opt);
opt : | |
Returns : |
|
void prelude_option_set_private_data (prelude_option_t *opt, void *data);
opt : | |
data : |
|
void* prelude_option_get_private_data (prelude_option_t *opt);
opt : |
|
<<< ssl-gencrypto | idmef-tree-func >>> |