Top | ![]() |
![]() |
![]() |
![]() |
enum | prelude_option_type_t |
enum | prelude_option_input_type_t |
typedef | prelude_option_t |
typedef | prelude_option_context_t |
enum | prelude_option_argument_t |
enum | prelude_option_priority_t |
enum | prelude_option_warning_t |
int (*prelude_option_destroy_callback_t) (prelude_option_t *opt
,prelude_string_t *out
,void *context
);
int (*prelude_option_commit_callback_t) (prelude_option_t *opt
,prelude_string_t *out
,void *context
);
int (*prelude_option_get_callback_t) (prelude_option_t *opt
,prelude_string_t *out
,void *context
);
int (*prelude_option_set_callback_t) (prelude_option_t *opt
,const char *optarg
,prelude_string_t *err
,void *context
);
void prelude_option_set_priority (prelude_option_t *option
,prelude_option_priority_t priority
);
prelude_option_set_priority() can be used to associate a priority with an option. This can be used to solve dependancies problem within differents options.
A priority of -1 mean an option will always be executed last (with all other option with a -1 priority).
The default priority for an option is 0, the caller is responssible for the way it assign priority (knowing that highest priority are always executed first).
void prelude_option_print (prelude_option_t *opt
,prelude_option_type_t type
,int descoff
,FILE *fd
);
Dump option available in opt
and hooked to the given types.
If opt
is NULL, then the root of the option list is used.
int prelude_option_wide_send_msg (prelude_msgbuf_t *msgbuf
,void *context
);
void
prelude_option_destroy (prelude_option_t *option
);
Destroy a prelude_option_t object and all data associated with it (including all suboption).
int prelude_option_read (prelude_option_t *option
,const char **filename
,int *argc
,char **argv
,prelude_string_t **err
,void *context
);
prelude_option_read(), 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. |
|
err |
Pointer to a prelude_string_t object where to store an error string. |
|
context |
Pointer to an optional option context. |
int prelude_option_add (prelude_option_t *parent
,prelude_option_t **retopt
,prelude_option_type_t type
,char shortopt
,const char *longopt
,const char *desc
,prelude_option_argument_t has_arg
,int (*set) (prelude_option_t *opt, const char *optarg, prelude_string_t *err, void *context)
,int (*get) (prelude_option_t *opt, prelude_string_t *out, void *context)
);
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 type
parameters can be set to PRELUDE_OPTION_TYPE_CLI (telling the
option may be searched on the command line), PRELUDE_OPTION_TYPE_CFG (telling
the option may be searched in the configuration file) or both.
parent |
Pointer on a parent option. |
|
retopt |
Pointer where to store the created option. |
|
type |
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. |
void prelude_option_set_type (prelude_option_t *opt
,prelude_option_type_t type
);
void prelude_option_set_warnings (prelude_option_warning_t new_warnings
,prelude_option_warning_t *old_warnings
);
void *
prelude_option_context_get_data (prelude_option_context_t *oc
);
void prelude_option_context_set_data (prelude_option_context_t *oc
,void *data
);
int prelude_option_invoke_commit (prelude_option_t *opt
,const char *ctname
,prelude_string_t *value
,void *context
);
int prelude_option_invoke_set (prelude_option_t *opt
,const char *ctname
,prelude_string_t *value
,void **context
);
int prelude_option_invoke_get (prelude_option_t *opt
,const char *ctname
,prelude_string_t *value
,void *context
);
int prelude_option_invoke_destroy (prelude_option_t *opt
,const char *ctname
,prelude_string_t *value
,void *context
);
void prelude_option_set_longopt (prelude_option_t *opt
,const char *longopt
);
void prelude_option_set_description (prelude_option_t *opt
,const char *description
);
const char *
prelude_option_get_description (prelude_option_t *opt
);
void prelude_option_set_has_arg (prelude_option_t *opt
,prelude_option_argument_t has_arg
);
prelude_option_argument_t
prelude_option_get_has_arg (prelude_option_t *opt
);
void prelude_option_set_value (prelude_option_t *opt
,const char *value
);
void prelude_option_set_input_validation_regex (prelude_option_t *opt
,const char *regex
);
const char *
prelude_option_get_input_validation_regex
(prelude_option_t *opt
);
void prelude_option_set_input_type (prelude_option_t *opt
,prelude_option_input_type_t input_type
);
prelude_option_input_type_t
prelude_option_get_input_type (prelude_option_t *opt
);
prelude_option_t * prelude_option_get_next (prelude_option_t *start
,prelude_option_t *cur
);
void prelude_option_set_destroy_callback (prelude_option_t *opt
,prelude_option_destroy_callback_t destroy
);
prelude_option_destroy_callback_t
prelude_option_get_destroy_callback (prelude_option_t *opt
);
void prelude_option_set_set_callback (prelude_option_t *opt
,prelude_option_set_callback_t set
);
prelude_option_set_callback_t
prelude_option_get_set_callback (prelude_option_t *opt
);
void prelude_option_set_get_callback (prelude_option_t *opt
,int (*get) (prelude_option_t *opt, prelude_string_t *out, void *context)
);
prelude_option_get_callback_t
prelude_option_get_get_callback (prelude_option_t *opt
);
void prelude_option_set_commit_callback (prelude_option_t *opt
,prelude_option_commit_callback_t commit
);
prelude_option_commit_callback_t
prelude_option_get_commit_callback (prelude_option_t *opt
);
void prelude_option_set_default_context (prelude_option_t *opt
,void *context
);
int prelude_option_new_context (prelude_option_t *opt
,prelude_option_context_t **ctx
,const char *name
,void *data
);
void
prelude_option_context_destroy (prelude_option_context_t *oc
);
prelude_option_t * prelude_option_search (prelude_option_t *parent
,const char *name
,prelude_option_type_t type
,prelude_bool_t walk_children
);
prelude_option_context_t * prelude_option_search_context (prelude_option_t *opt
,const char *name
);