|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
Options builder API for flexible command-line option configuration. More...
Go to the source code of this file.
Data Structures | |
| struct | option_descriptor_t |
| Option descriptor. More... | |
| struct | option_dependency_t |
| Option dependency. More... | |
| struct | positional_arg_descriptor_t |
| Positional argument descriptor. More... | |
| struct | options_config_t |
| Options configuration. More... | |
| struct | options_builder_t |
| Options builder. More... | |
Enumerations | |
| enum | option_type_t { OPTION_TYPE_BOOL , OPTION_TYPE_INT , OPTION_TYPE_STRING , OPTION_TYPE_DOUBLE , OPTION_TYPE_CALLBACK , OPTION_TYPE_ACTION } |
| Option value types. More... | |
| enum | dependency_type_t { DEPENDENCY_REQUIRES , DEPENDENCY_CONFLICTS , DEPENDENCY_IMPLIES } |
| Option dependency types. More... | |
Functions | |
| options_builder_t * | options_builder_create (size_t struct_size) |
| Create empty options builder. | |
| options_builder_t * | options_builder_from_preset (const options_config_t *preset) |
| Create builder from preset config. | |
| void | options_builder_destroy (options_builder_t *builder) |
| Free options builder. | |
| options_config_t * | options_builder_build (options_builder_t *builder) |
| Build immutable options config. | |
| void | options_config_destroy (options_config_t *config) |
| Free options config. | |
| void | options_builder_add_bool (options_builder_t *builder, const char *long_name, char short_name, size_t offset, bool default_value, const char *help_text, const char *group, bool required, const char *env_var_name) |
| Add boolean flag option. | |
| void | options_builder_add_int (options_builder_t *builder, const char *long_name, char short_name, size_t offset, int default_value, const char *help_text, const char *group, bool required, const char *env_var_name, bool(*validate)(const void *options_struct, char **error_msg)) |
| Add integer option. | |
| void | options_builder_add_string (options_builder_t *builder, const char *long_name, char short_name, size_t offset, const char *default_value, const char *help_text, const char *group, bool required, const char *env_var_name, bool(*validate)(const void *options_struct, char **error_msg)) |
| Add string option. | |
| void | options_builder_add_double (options_builder_t *builder, const char *long_name, char short_name, size_t offset, double default_value, const char *help_text, const char *group, bool required, const char *env_var_name, bool(*validate)(const void *options_struct, char **error_msg)) |
| Add double/float option. | |
| void | options_builder_add_callback (options_builder_t *builder, const char *long_name, char short_name, size_t offset, const void *default_value, size_t value_size, bool(*parse_fn)(const char *arg, void *dest, char **error_msg), const char *help_text, const char *group, bool required, const char *env_var_name) |
| Add option with custom callback parser. | |
| void | options_builder_add_callback_optional (options_builder_t *builder, const char *long_name, char short_name, size_t offset, const void *default_value, size_t value_size, bool(*parse_fn)(const char *arg, void *dest, char **error_msg), const char *help_text, const char *group, bool required, const char *env_var_name, bool optional_arg) |
| Add option with custom callback parser that supports optional arguments. | |
| void | options_builder_add_action (options_builder_t *builder, const char *long_name, char short_name, void(*action_fn)(void), const char *help_text, const char *group) |
| Add action option (executes action and may exit) | |
| void | options_builder_add_descriptor (options_builder_t *builder, const option_descriptor_t *descriptor) |
| Add full option descriptor (advanced) | |
| void | options_builder_add_dependency_requires (options_builder_t *builder, const char *option_name, const char *depends_on, const char *error_message) |
| Add dependency: if option_name is set, depends_on must be set. | |
| void | options_builder_add_dependency_conflicts (options_builder_t *builder, const char *option_name, const char *conflicts_with, const char *error_message) |
| Add anti-dependency: if option_name is set, conflicts_with must NOT be set. | |
| void | options_builder_add_dependency_implies (options_builder_t *builder, const char *option_name, const char *implies, const char *error_message) |
| Add implication: if option_name is set, implies defaults to true. | |
| void | options_builder_add_dependency (options_builder_t *builder, const option_dependency_t *dependency) |
| Add full dependency (advanced) | |
| void | options_builder_mark_binary_only (options_builder_t *builder, const char *option_name) |
| Mark an option as binary-level only (hide from mode-specific help) | |
| void | options_builder_add_positional (options_builder_t *builder, const char *name, const char *help_text, bool required, const char *section_heading, const char **examples, size_t num_examples, int(*parse_fn)(const char *arg, void *config, char **remaining, int num_remaining, char **error_msg)) |
| Add positional argument descriptor. | |
| asciichat_error_t | options_config_parse_positional (const options_config_t *config, int remaining_argc, char **remaining_argv, void *options_struct) |
| Parse positional arguments. | |
| const options_config_t * | options_preset_binary (const char *program_name, const char *description) |
| Get binary-level options preset. | |
| const options_config_t * | options_preset_server (const char *program_name, const char *description) |
| Get server mode options preset. | |
| const options_config_t * | options_preset_client (const char *program_name, const char *description) |
| Get client mode options preset. | |
| const options_config_t * | options_preset_mirror (const char *program_name, const char *description) |
| Get mirror mode options preset. | |
| const options_config_t * | options_preset_acds (const char *program_name, const char *description) |
| Get acds mode options preset. | |
| asciichat_error_t | options_config_set_defaults (const options_config_t *config, void *options_struct) |
| Set default values in options struct. | |
| asciichat_error_t | options_config_parse (const options_config_t *config, int argc, char **argv, void *options_struct, int *remaining_argc, char ***remaining_argv) |
| Parse command-line arguments. | |
| asciichat_error_t | options_config_validate (const options_config_t *config, const void *options_struct, char **error_message) |
| Validate options struct. | |
| void | options_config_print_usage (const options_config_t *config, FILE *stream) |
| Print usage/help text. | |
| void | options_config_cleanup (const options_config_t *config, void *options_struct) |
| Clean up memory owned by options struct. | |
Options builder API for flexible command-line option configuration.
This module provides a builder pattern for constructing option configurations that can be used by library consumers to create custom tools based on ascii-chat modes or build entirely custom option sets from scratch.
Features:
Usage Pattern:
Definition in file builder.h.
| enum dependency_type_t |
Option dependency types.
Defines relationships between options.
| Enumerator | |
|---|---|
| DEPENDENCY_REQUIRES | If A is set, B must be set. |
| DEPENDENCY_CONFLICTS | If A is set, B must NOT be set. |
| DEPENDENCY_IMPLIES | If A is set, B defaults to true/enabled. |
Definition at line 59 of file builder.h.
| enum option_type_t |
Option value types.
Defines the type of value an option accepts.
Definition at line 45 of file builder.h.
| void options_builder_add_action | ( | options_builder_t * | builder, |
| const char * | long_name, | ||
| char | short_name, | ||
| void(*)(void) | action_fn, | ||
| const char * | help_text, | ||
| const char * | group | ||
| ) |
Add action option (executes action and may exit)
Action options execute a callback function when encountered during parsing. The callback may exit the program (e.g., –list-webcams, –version).
| builder | Builder to add to |
| long_name | Long option name |
| short_name | Short option char (or '\0') |
| action_fn | Action callback to execute |
| help_text | Help description |
| group | Group name for help |
Definition at line 532 of file builder.c.
References options_builder_t::descriptors, option_descriptor_t::long_name, options_builder_t::num_descriptors, and OPTION_TYPE_ACTION.
Referenced by options_preset_acds(), options_preset_client(), options_preset_mirror(), and options_preset_server().
| void options_builder_add_bool | ( | options_builder_t * | builder, |
| const char * | long_name, | ||
| char | short_name, | ||
| size_t | offset, | ||
| bool | default_value, | ||
| const char * | help_text, | ||
| const char * | group, | ||
| bool | required, | ||
| const char * | env_var_name | ||
| ) |
Add boolean flag option.
| builder | Builder to add to |
| long_name | Long option name (e.g., "verbose") |
| short_name | Short option char (e.g., 'v', or '\0' if none) |
| offset | offsetof(struct, field) |
| default_value | Default value |
| help_text | Help description |
| group | Group name for help (e.g., "OUTPUT OPTIONS") |
| required | If true, option must be provided |
| env_var_name | Environment variable fallback (or NULL) |
Definition at line 344 of file builder.c.
References options_builder_t::descriptors, option_descriptor_t::long_name, options_builder_t::num_descriptors, and OPTION_TYPE_BOOL.
Referenced by options_preset_acds(), options_preset_binary(), options_preset_client(), and options_preset_server().
| void options_builder_add_callback | ( | options_builder_t * | builder, |
| const char * | long_name, | ||
| char | short_name, | ||
| size_t | offset, | ||
| const void * | default_value, | ||
| size_t | value_size, | ||
| bool(*)(const char *arg, void *dest, char **error_msg) | parse_fn, | ||
| const char * | help_text, | ||
| const char * | group, | ||
| bool | required, | ||
| const char * | env_var_name | ||
| ) |
Add option with custom callback parser.
| builder | Builder to add to |
| long_name | Long option name |
| short_name | Short option char (or '\0') |
| offset | offsetof(struct, field) |
| default_value | Pointer to default value (or NULL) |
| value_size | sizeof(field_type) |
| parse_fn | Custom parser function |
| help_text | Help description |
| group | Group name for help |
| required | If true, option must be provided |
| env_var_name | Environment variable fallback (or NULL) |
| void options_builder_add_callback_optional | ( | options_builder_t * | builder, |
| const char * | long_name, | ||
| char | short_name, | ||
| size_t | offset, | ||
| const void * | default_value, | ||
| size_t | value_size, | ||
| bool(*)(const char *arg, void *dest, char **error_msg) | parse_fn, | ||
| const char * | help_text, | ||
| const char * | group, | ||
| bool | required, | ||
| const char * | env_var_name, | ||
| bool | optional_arg | ||
| ) |
Add option with custom callback parser that supports optional arguments.
Allows the callback to receive NULL if no argument is provided (when next arg is a flag).
| builder | Builder to add to |
| long_name | Long option name |
| short_name | Short option char (or '\0') |
| offset | offsetof(struct, field) |
| default_value | Pointer to default value (or NULL) |
| value_size | sizeof(field_type) |
| parse_fn | Custom parser function (receives NULL if arg not provided) |
| help_text | Help description |
| group | Group name for help |
| required | If true, option must be provided |
| env_var_name | Environment variable fallback (or NULL) |
| optional_arg | If true, argument is optional for this callback |
| void options_builder_add_dependency | ( | options_builder_t * | builder, |
| const option_dependency_t * | dependency | ||
| ) |
Add full dependency (advanced)
| builder | Builder to add to |
| dependency | Dependency to copy |
Definition at line 599 of file builder.c.
References options_builder_t::dependencies, and options_builder_t::num_dependencies.
Referenced by options_builder_from_preset().
| void options_builder_add_dependency_conflicts | ( | options_builder_t * | builder, |
| const char * | option_name, | ||
| const char * | conflicts_with, | ||
| const char * | error_message | ||
| ) |
Add anti-dependency: if option_name is set, conflicts_with must NOT be set.
| builder | Builder to add to |
| option_name | Option that has the conflict |
| conflicts_with | Option it conflicts with |
| error_message | Custom error message (or NULL for default) |
Definition at line 577 of file builder.c.
References options_builder_t::dependencies, DEPENDENCY_CONFLICTS, options_builder_t::num_dependencies, and option_dependency_t::option_name.
Referenced by options_preset_client(), and options_preset_server().
| void options_builder_add_dependency_implies | ( | options_builder_t * | builder, |
| const char * | option_name, | ||
| const char * | implies, | ||
| const char * | error_message | ||
| ) |
Add implication: if option_name is set, implies defaults to true.
| builder | Builder to add to |
| option_name | Option that implies another |
| implies | Option that is implied |
| error_message | Custom message (rarely used, can be NULL) |
Definition at line 589 of file builder.c.
References options_builder_t::dependencies, DEPENDENCY_IMPLIES, options_builder_t::num_dependencies, and option_dependency_t::option_name.
| void options_builder_add_dependency_requires | ( | options_builder_t * | builder, |
| const char * | option_name, | ||
| const char * | depends_on, | ||
| const char * | error_message | ||
| ) |
Add dependency: if option_name is set, depends_on must be set.
| builder | Builder to add to |
| option_name | Option that has the dependency |
| depends_on | Option it depends on |
| error_message | Custom error message (or NULL for default) |
Definition at line 565 of file builder.c.
References options_builder_t::dependencies, DEPENDENCY_REQUIRES, options_builder_t::num_dependencies, and option_dependency_t::option_name.
Referenced by options_preset_client(), and options_preset_mirror().
| void options_builder_add_descriptor | ( | options_builder_t * | builder, |
| const option_descriptor_t * | descriptor | ||
| ) |
Add full option descriptor (advanced)
| builder | Builder to add to |
| descriptor | Descriptor to copy |
Definition at line 553 of file builder.c.
References options_builder_t::descriptors, and options_builder_t::num_descriptors.
Referenced by options_builder_from_preset().
| void options_builder_add_double | ( | options_builder_t * | builder, |
| const char * | long_name, | ||
| char | short_name, | ||
| size_t | offset, | ||
| double | default_value, | ||
| const char * | help_text, | ||
| const char * | group, | ||
| bool | required, | ||
| const char * | env_var_name, | ||
| bool(*)(const void *options_struct, char **error_msg) | validate | ||
| ) |
Add double/float option.
| builder | Builder to add to |
| long_name | Long option name |
| short_name | Short option char (or '\0') |
| offset | offsetof(struct, field) |
| default_value | Default value |
| help_text | Help description |
| group | Group name for help |
| required | If true, option must be provided |
| env_var_name | Environment variable fallback (or NULL) |
| validate | Validator function receiving full struct (or NULL) |
| void options_builder_add_int | ( | options_builder_t * | builder, |
| const char * | long_name, | ||
| char | short_name, | ||
| size_t | offset, | ||
| int | default_value, | ||
| const char * | help_text, | ||
| const char * | group, | ||
| bool | required, | ||
| const char * | env_var_name, | ||
| bool(*)(const void *options_struct, char **error_msg) | validate | ||
| ) |
Add integer option.
| builder | Builder to add to |
| long_name | Long option name |
| short_name | Short option char (or '\0') |
| offset | offsetof(struct, field) |
| default_value | Default value |
| help_text | Help description |
| group | Group name for help |
| required | If true, option must be provided |
| env_var_name | Environment variable fallback (or NULL) |
| validate | Validator function receiving full struct (or NULL) |
| void options_builder_add_positional | ( | options_builder_t * | builder, |
| const char * | name, | ||
| const char * | help_text, | ||
| bool | required, | ||
| const char * | section_heading, | ||
| const char ** | examples, | ||
| size_t | num_examples, | ||
| int(*)(const char *arg, void *config, char **remaining, int num_remaining, char **error_msg) | parse_fn | ||
| ) |
Add positional argument descriptor.
Positional arguments are parsed after getopt finishes, from the remaining argv elements that don't start with '-'. They are parsed in the order they are added to the builder.
Example (client mode):
Example (server mode):
| builder | Builder to add to |
| name | Name for help text (e.g., "address") |
| help_text | Description for usage message |
| required | If true, this positional arg must be provided |
| section_heading | Optional section heading for examples (e.g., "ADDRESS FORMATS") |
| examples | Optional array of example strings with descriptions |
| num_examples | Number of examples in array |
| parse_fn | Custom parser (receives arg, config, remaining args, error_msg) Returns number of args consumed (usually 1), or -1 on error |
Definition at line 627 of file builder.c.
References positional_arg_descriptor_t::name, options_builder_t::num_positional_args, and options_builder_t::positional_args.
Referenced by options_builder_from_preset(), options_preset_acds(), options_preset_client(), and options_preset_server().
| void options_builder_add_string | ( | options_builder_t * | builder, |
| const char * | long_name, | ||
| char | short_name, | ||
| size_t | offset, | ||
| const char * | default_value, | ||
| const char * | help_text, | ||
| const char * | group, | ||
| bool | required, | ||
| const char * | env_var_name, | ||
| bool(*)(const void *options_struct, char **error_msg) | validate | ||
| ) |
Add string option.
Strings are automatically strdup'd during parsing and freed during cleanup.
| builder | Builder to add to |
| long_name | Long option name |
| short_name | Short option char (or '\0') |
| offset | offsetof(struct, field) |
| default_value | Default value (will be strdup'd, or NULL) |
| help_text | Help description |
| group | Group name for help |
| required | If true, option must be provided |
| env_var_name | Environment variable fallback (or NULL) |
| validate | Validator function receiving full struct (or NULL) |
| options_config_t * options_builder_build | ( | options_builder_t * | builder | ) |
Build immutable options config.
Creates final config from builder. Builder is NOT consumed - you must still call options_builder_destroy().
| builder | Builder with options and dependencies |
Definition at line 265 of file builder.c.
References options_config_t::dependencies, options_builder_t::dependencies, options_config_t::description, options_builder_t::description, options_config_t::descriptors, options_builder_t::descriptors, ERROR_INVALID_PARAM, ERROR_MEMORY, options_config_t::num_dependencies, options_builder_t::num_dependencies, options_config_t::num_descriptors, options_builder_t::num_descriptors, options_config_t::num_owned_strings, options_config_t::num_positional_args, options_builder_t::num_positional_args, options_config_t::owned_strings, options_config_t::owned_strings_capacity, options_config_t::positional_args, options_builder_t::positional_args, options_config_t::program_name, options_builder_t::program_name, SAFE_FREE, SAFE_MALLOC, SET_ERRNO, options_config_t::struct_size, and options_builder_t::struct_size.
Referenced by options_preset_acds(), options_preset_binary(), options_preset_client(), options_preset_mirror(), and options_preset_server().
| options_builder_t * options_builder_create | ( | size_t | struct_size | ) |
Create empty options builder.
| struct_size | sizeof(your_options_t) for the target options struct |
Definition at line 184 of file builder.c.
References options_builder_t::dependencies, options_builder_t::dependency_capacity, options_builder_t::description, options_builder_t::descriptor_capacity, options_builder_t::descriptors, ERROR_MEMORY, INITIAL_DEPENDENCY_CAPACITY, INITIAL_DESCRIPTOR_CAPACITY, options_builder_t::num_dependencies, options_builder_t::num_descriptors, options_builder_t::num_positional_args, options_builder_t::positional_arg_capacity, options_builder_t::positional_args, options_builder_t::program_name, SAFE_FREE, SAFE_MALLOC, SET_ERRNO, and options_builder_t::struct_size.
Referenced by options_builder_from_preset(), options_preset_acds(), options_preset_binary(), options_preset_client(), options_preset_mirror(), and options_preset_server().
| void options_builder_destroy | ( | options_builder_t * | builder | ) |
Free options builder.
| builder | Builder to free (can be NULL) |
Definition at line 255 of file builder.c.
References options_builder_t::dependencies, options_builder_t::descriptors, options_builder_t::positional_args, and SAFE_FREE.
Referenced by options_preset_acds(), options_preset_binary(), options_preset_client(), options_preset_mirror(), and options_preset_server().
| options_builder_t * options_builder_from_preset | ( | const options_config_t * | preset | ) |
Create builder from preset config.
Copies all descriptors and dependencies from the preset.
| preset | Preset configuration to copy |
Definition at line 220 of file builder.c.
References options_config_t::dependencies, options_config_t::description, options_builder_t::description, options_config_t::descriptors, ERROR_INVALID_PARAM, positional_arg_descriptor_t::examples, positional_arg_descriptor_t::help_text, positional_arg_descriptor_t::name, options_config_t::num_dependencies, options_config_t::num_descriptors, positional_arg_descriptor_t::num_examples, options_config_t::num_positional_args, options_builder_add_dependency(), options_builder_add_descriptor(), options_builder_add_positional(), options_builder_create(), positional_arg_descriptor_t::parse_fn, options_config_t::positional_args, options_config_t::program_name, options_builder_t::program_name, positional_arg_descriptor_t::required, positional_arg_descriptor_t::section_heading, SET_ERRNO, and options_config_t::struct_size.
| void options_builder_mark_binary_only | ( | options_builder_t * | builder, |
| const char * | option_name | ||
| ) |
Mark an option as binary-level only (hide from mode-specific help)
Binary-level options are still parsed by mode-specific parsers (so they work anywhere in the command line), but they don't appear in mode-specific –help. They should only be documented in the top-level binary help.
| builder | Builder containing the option |
| option_name | Long name of the option to mark |
Example:
Definition at line 607 of file builder.c.
References options_builder_t::descriptors, option_descriptor_t::hide_from_mode_help, log_warn, option_descriptor_t::long_name, and options_builder_t::num_descriptors.
| void options_config_cleanup | ( | const options_config_t * | config, |
| void * | options_struct | ||
| ) |
Clean up memory owned by options struct.
Frees all auto-duplicated strings and sets pointers to NULL. Call this before freeing the options struct.
| config | Options configuration |
| options_struct | Options struct to clean up |
Definition at line 1345 of file builder.c.
References options_config_t::descriptors, options_config_t::num_descriptors, options_config_t::num_owned_strings, option_descriptor_t::offset, OPTION_TYPE_STRING, options_config_t::owned_strings, option_descriptor_t::owns_memory, and option_descriptor_t::type.
| void options_config_destroy | ( | options_config_t * | config | ) |
Free options config.
Frees the config structure. Does NOT free strings in the options struct - use options_config_cleanup() for that.
| config | Config to free (can be NULL) |
Definition at line 329 of file builder.c.
References options_config_t::dependencies, options_config_t::descriptors, options_config_t::owned_strings, options_config_t::positional_args, and SAFE_FREE.
Referenced by parse_acds_options(), parse_client_options(), parse_mirror_options(), parse_server_options(), usage_acds(), usage_client(), usage_mirror(), and usage_server().
| asciichat_error_t options_config_parse | ( | const options_config_t * | config, |
| int | argc, | ||
| char ** | argv, | ||
| void * | options_struct, | ||
| int * | remaining_argc, | ||
| char *** | remaining_argv | ||
| ) |
Parse command-line arguments.
Parses argv using the option descriptors. Strings are automatically strdup'd. Environment variables are checked for missing options.
| config | Options configuration |
| argc | Argument count |
| argv | Argument vector |
| options_struct | Options struct to fill |
| remaining_argc | Optional: receives count of non-option args |
| remaining_argv | Optional: receives array of non-option args |
Definition at line 1101 of file builder.c.
References ASCIICHAT_OK, ERROR_INVALID_PARAM, and SET_ERRNO.
Referenced by parse_acds_options(), parse_client_options(), parse_mirror_options(), and parse_server_options().
| asciichat_error_t options_config_parse_positional | ( | const options_config_t * | config, |
| int | remaining_argc, | ||
| char ** | remaining_argv, | ||
| void * | options_struct | ||
| ) |
Parse positional arguments.
Parses positional arguments from remaining_argv after getopt processing. Calls each positional arg descriptor's parse_fn in order.
This is called automatically by options_config_parse(), but can also be called separately if you want custom control over the parsing flow.
| config | Options configuration |
| remaining_argc | Count of remaining args |
| remaining_argv | Array of remaining args |
| options_struct | Options struct to fill |
Definition at line 647 of file builder.c.
References ASCIICHAT_OK, ERROR_INVALID_PARAM, ERROR_USAGE, positional_arg_descriptor_t::help_text, positional_arg_descriptor_t::name, options_config_t::num_positional_args, positional_arg_descriptor_t::parse_fn, options_config_t::positional_args, positional_arg_descriptor_t::required, and SET_ERRNO.
| void options_config_print_usage | ( | const options_config_t * | config, |
| FILE * | stream | ||
| ) |
Print usage/help text.
Generates formatted help with grouped options.
| config | Options configuration |
| stream | Output stream (stdout or stderr) |
Definition at line 1236 of file builder.c.
References option_descriptor_t::default_value, options_config_t::description, options_config_t::descriptors, option_descriptor_t::env_var_name, option_descriptor_t::group, option_descriptor_t::help_text, option_descriptor_t::hide_from_mode_help, option_descriptor_t::long_name, options_config_t::num_descriptors, OPTION_TYPE_ACTION, OPTION_TYPE_BOOL, OPTION_TYPE_CALLBACK, OPTION_TYPE_DOUBLE, OPTION_TYPE_INT, OPTION_TYPE_STRING, options_config_t::program_name, option_descriptor_t::required, option_descriptor_t::short_name, and option_descriptor_t::type.
Referenced by usage_acds(), usage_client(), usage_mirror(), and usage_server().
| asciichat_error_t options_config_set_defaults | ( | const options_config_t * | config, |
| void * | options_struct | ||
| ) |
Set default values in options struct.
Sets defaults from descriptors, checking environment variables for options with env_var_name set.
| config | Options configuration |
| options_struct | Options struct to initialize |
Definition at line 716 of file builder.c.
References ASCIICHAT_OK, option_descriptor_t::default_value, options_config_t::descriptors, option_descriptor_t::env_var_name, ERROR_INVALID_PARAM, options_config_t::num_descriptors, option_descriptor_t::offset, OPTION_TYPE_ACTION, OPTION_TYPE_BOOL, OPTION_TYPE_CALLBACK, OPTION_TYPE_DOUBLE, OPTION_TYPE_INT, OPTION_TYPE_STRING, OPTIONS_BUFF_SIZE, SAFE_GETENV, SET_ERRNO, and option_descriptor_t::type.
Referenced by parse_acds_options(), parse_client_options(), parse_mirror_options(), and parse_server_options().
| asciichat_error_t options_config_validate | ( | const options_config_t * | config, |
| const void * | options_struct, | ||
| char ** | error_message | ||
| ) |
Validate options struct.
Checks:
| config | Options configuration |
| options_struct | Options struct to validate |
| error_message | Optional: receives detailed error message (must free) |
Definition at line 1125 of file builder.c.
References ASCIICHAT_OK, options_config_t::dependencies, DEPENDENCY_CONFLICTS, DEPENDENCY_IMPLIES, DEPENDENCY_REQUIRES, option_dependency_t::depends_on, options_config_t::descriptors, option_descriptor_t::env_var_name, ERROR_INVALID_PARAM, option_dependency_t::error_message, ERROR_USAGE, is_set, option_descriptor_t::long_name, options_config_t::num_dependencies, options_config_t::num_descriptors, option_descriptor_t::offset, option_dependency_t::option_name, OPTION_TYPE_ACTION, OPTION_TYPE_BOOL, OPTION_TYPE_CALLBACK, OPTION_TYPE_DOUBLE, OPTION_TYPE_INT, OPTION_TYPE_STRING, option_descriptor_t::required, SET_ERRNO, option_descriptor_t::type, option_dependency_t::type, and option_descriptor_t::validate.
| const options_config_t * options_preset_acds | ( | const char * | program_name, |
| const char * | description | ||
| ) |
Get acds mode options preset.
| program_name | Optional program name (defaults to "ascii-chat acds") |
| description | Optional program description (defaults to "ASCII Chat Discovery Service") |
Definition at line 571 of file presets.c.
References action_show_version(), options_builder_t::description, log_file, LOG_INFO, options_builder_add_action(), options_builder_add_bool(), options_builder_add_callback(), options_builder_add_positional(), options_builder_add_string(), options_builder_build(), options_builder_create(), options_builder_destroy(), parse_log_level(), parse_server_bind_address(), and options_builder_t::program_name.
Referenced by parse_acds_options(), and usage_acds().
| const options_config_t * options_preset_binary | ( | const char * | program_name, |
| const char * | description | ||
| ) |
Get binary-level options preset.
Binary options are parsed BEFORE mode selection. Includes: –help, –version, –log-file, –log-level, etc.
| program_name | Optional program name (defaults to "ascii-chat") |
| description | Optional program description |
Definition at line 273 of file presets.c.
References options_builder_t::description, options_builder_add_bool(), options_builder_build(), options_builder_create(), options_builder_destroy(), and options_builder_t::program_name.
| const options_config_t * options_preset_client | ( | const char * | program_name, |
| const char * | description | ||
| ) |
Get client mode options preset.
| program_name | Optional program name (defaults to "ascii-chat client") |
| description | Optional program description (defaults to "Connect to ascii-chat server") |
Definition at line 398 of file presets.c.
References action_help_client(), action_list_microphones(), action_list_speakers(), action_list_webcams(), action_show_capabilities(), options_builder_t::description, OPT_MICROPHONE_INDEX_DEFAULT, OPT_PORT_DEFAULT, OPT_RECONNECT_ATTEMPTS_DEFAULT, OPT_SPEAKERS_INDEX_DEFAULT, options_builder_add_action(), options_builder_add_bool(), options_builder_add_dependency_conflicts(), options_builder_add_dependency_requires(), options_builder_add_int(), options_builder_add_positional(), options_builder_add_string(), options_builder_build(), options_builder_create(), options_builder_destroy(), parse_client_address(), and options_builder_t::program_name.
Referenced by parse_client_options(), and usage_client().
| const options_config_t * options_preset_mirror | ( | const char * | program_name, |
| const char * | description | ||
| ) |
Get mirror mode options preset.
| program_name | Optional program name (defaults to "ascii-chat mirror") |
| description | Optional program description (defaults to "Local webcam viewing (no network)") |
Definition at line 530 of file presets.c.
References action_help_mirror(), action_list_webcams(), action_show_capabilities(), options_builder_t::description, options_builder_add_action(), options_builder_add_dependency_requires(), options_builder_build(), options_builder_create(), options_builder_destroy(), and options_builder_t::program_name.
Referenced by parse_mirror_options(), and usage_mirror().
| const options_config_t * options_preset_server | ( | const char * | program_name, |
| const char * | description | ||
| ) |
Get server mode options preset.
| program_name | Optional program name (defaults to "ascii-chat server") |
| description | Optional program description (defaults to "Start ascii-chat server") |
Definition at line 300 of file presets.c.
References action_help_server(), action_list_microphones(), action_list_speakers(), action_list_webcams(), action_show_version(), options_builder_t::description, OPT_MAX_CLIENTS_DEFAULT, OPT_PORT_DEFAULT, options_builder_add_action(), options_builder_add_bool(), options_builder_add_dependency_conflicts(), options_builder_add_int(), options_builder_add_positional(), options_builder_add_string(), options_builder_build(), options_builder_create(), options_builder_destroy(), parse_server_bind_address(), and options_builder_t::program_name.
Referenced by parse_server_options(), and usage_server().