#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | cfg_context |
Main structure for defining context. More... | |
struct | cfg_option |
Structure for defining one config option. More... | |
Functions for setting and clearing context flags | |
#define | cfg_is_context_flag(con, flag) cfg_get_context_flag(con, flag) |
void | cfg_set_context_flag (const CFG_CONTEXT con, int flag) |
void | cfg_clear_context_flag (const CFG_CONTEXT con, int flag) |
int | cfg_get_context_flag (const CFG_CONTEXT con, int flag) |
void | cfg_set_context_flags (const CFG_CONTEXT con, int flags) |
int | cfg_get_context_flags (const CFG_CONTEXT con) |
Error codes | |
enum | cfg_error { CFG_ERR_OK = 0, CFG_ERROR_OK = 0, CFG_OK = 0, CFG_ERR_NOARG = -1, CFG_ERROR_NOARG = -1, CFG_ERR_NOTALLOWEDARG = -2, CFG_ERROR_NOTALLOWEDARG = -2, CFG_ERR_BADOPT = -3, CFG_ERROR_BADOPT = -3, CFG_ERR_BADQUOTE = -4, CFG_ERROR_BADQUOTE = -4, CFG_ERR_BADNUMBER = -5, CFG_ERROR_BADNUMBER = -5, CFG_ERR_OVERFLOW = -6, CFG_ERROR_OVERFLOW = -6, CFG_ERR_MULTI = -7, CFG_ERROR_MULTI = -7, CFG_ERR_NOMEM = -8, CFG_ERROR_NOMEM = -8, CFG_ERR_STOP_STR = -9, CFG_ERR_STOP_STR_FOUND = -9, CFG_ERROR_STOP_STR = -9, CFG_ERROR_STOP_STR_FOUND = -9, CFG_ERR_NOEQUAL = -10, CFG_ERROR_NOEQUAL = -10, CFG_ERR_UNKNOWN = -11, CFG_ERROR_UNKNOWN = -11, CFG_ERR_FILE_NOT_FOUND = -12, CFG_ERROR_FILE_NOT_FOUND = -12, CFG_ERR_SEEK_ERROR = -13, CFG_ERROR_SEEK_ERROR = -13, CFG_ERR_INTERNAL = -20, CFG_ERROR_INTERNAL = -20 } |
Context flags | |
enum | cfg_flag { CFG_IGNORE_MULTI = 1, CFG_IGNORE_UNKNOWN = 2, CFG_SKIP_FIRST = 0, CFG_PROCESS_FIRST = 4, CFG_POSIXLY_LEFTOVERS = 0, CFG_ADVANCED_LEFTOVERS = 8, CFG_NORMAL_LEFTOVERS = 0, CFG_STRICT_LEFTOVERS = 16, CFG_FILE_BYTE_POS_USAGE = 0, CFG_FILE_LINE_POS_USAGE = 32 } |
Option types | |
enum | cfg_option_type { CFG_BOOL = 1, CFG_BOOLEAN = 1, CFG_INT = 2, CFG_INTEGER = 2, CFG_UINT = 3, CFG_UNSIGNED = 3, CFG_UNSIGNED_INT = 3, CFG_LONG = 4, CFG_ULONG = 5, CFG_UNSIGNED_LONG = 5, CFG_FLOAT = 6, CFG_DOUBLE = 7, CFG_STR = 8, CFG_STRING = 8, CFG_END = 0, CFG_DATA_TYPE_MASK = 31, CFG_SINGLE = 0, CFG_MULTI = 32, CFG_MULTI_ARRAY = 32, CFG_MULTI_SEPARATED = 32 + 64, CFG_LAST_ARGS = 128, CFG_LAST_ARGUMENTS = 128, CFG_LEFTOVER_ARGS = 128, CFG_LEFTOVER_ARGUMENTS = 128 } |
Special properties types | |
enum | cfg_property_type { CFG_LINE_STOP_STRING = 0, CFG_LINE_SHORT_OPTION_PREFIX = 1, CFG_LINE_LONG_OPTION_PREFIX = 2, CFG_LINE_OPTION_ARG_SEPARATOR = 3, CFG_LINE_MULTI_VALS_SEPARATOR = 4, CFG_QUOTE_PREFIX = 5, CFG_QUOTE_POSTFIX = 6, CFG_FILE_STOP_PREFIX = 7, CFG_FILE_COMMENT_PREFIX = 8, CFG_FILE_MULTI_LINE_POSTFIX = 9, CFG_FILE_OPTION_ARG_SEPARATOR = 10, CFG_FILE_MULTI_VALS_SEPARATOR = 11, CFG_N_PROPS = 12, CFG_VIRTUAL_SPECIAL_PROPERTY = 13 } |
Internal enumerations | |
enum | cfg_context_type { CFG_NO_CONTEXT = 0, CFG_CMDLINE = 1, CFG_LINE = 1, CFG_CFGFILE = 2, CFG_FILE = 2 } |
enum | cfg_line_option_type { CFG_NONE_OPTION = 0, CFG_SHORT_OPTION = 1, CFG_LONG_OPTION = 2, CFG_SHORT_OPTIONS = 4, CFG_LONG_SEPINIT = 8, CFG_LONG_NOSEPINIT = 0 } |
Functions for creating and manipulating context | |
CFG_CONTEXT | cfg_get_context (struct cfg_option *options) |
CFG_CONTEXT | cfg_get_cmdline_context (int argc, char **argv, struct cfg_option *options) |
CFG_CONTEXT | cfg_get_cfgfile_context (long begin_pos, long end_pos, char *filename, struct cfg_option *options) |
void | cfg_set_cmdline_context (const CFG_CONTEXT con, int argc, char **argv) |
void | cfg_set_cfgfile_context (const CFG_CONTEXT con, long begin_pos, long end_pos, char *filename) |
void | cfg_reset_context (const CFG_CONTEXT con) |
void | cfg_free_context (const CFG_CONTEXT con) |
Functions and macros for properties manipulation | |
void | cfg_clear_property (const CFG_CONTEXT con, enum cfg_property_type type) |
int | cfg_add_property (const CFG_CONTEXT con, enum cfg_property_type type, char *str) |
int | cfg_remove_property (const CFG_CONTEXT con, enum cfg_property_type type, char *str) |
Functions for processing context options | |
int | cfg_parse (const CFG_CONTEXT con) |
int | cfg_get_next_opt (const CFG_CONTEXT con) |
char * | cfg_get_cur_opt (const CFG_CONTEXT con) |
char * | cfg_get_cur_arg (const CFG_CONTEXT con) |
int | cfg_get_cur_idx (const CFG_CONTEXT con) |
Error handling functions | |
void | cfg_print_error (const CFG_CONTEXT con) |
void | cfg_fprint_error (const CFG_CONTEXT con, FILE *fh) |
char * | cfg_get_error_str (const CFG_CONTEXT con) |
char * | cfg_get_static_error_str (const int errorcode) |
Defines | |
#define | CFG_END_OPTION { NULL, '\0', NULL, CFG_END, NULL, 0 } |
#define | CFG_END_OF_LIST CFG_END_OPTION |
Typedefs | |
typedef cfg_context * | CFG_CONTEXT |
Context data type. |
|
|
End of options list marker |
|
Context type Possible types of context (used internally) |
|
|
By default are CFG_SKIP_FIRST, CFG_POSIXLY_LEFTOVERS and CFG_NORMAL_LEFTOVERS initialized.
|
|
Command line option type. Possible types of command line option (used internally)
|
|
Possible types of options
|
|
|
|
Add string to property
|
|
Clear context flag
|
|
Clear all strings of property
|
|
Print error string to stream
|
|
Destroy context
|
|
Initialize config line context
|
|
Initialize command line context
|
|
Initialize core context
|
|
Get context flag
|
|
Get all context flags
|
|
Return currently processed option argument
|
|
Return currently processed option index (argv index in command line context, file byte position or line position in config file context)
|
|
Return currently processed option name
|
|
Get error string; error string is dynamically allocated, it needs to be freed after use.
|
|
Parse next option(s) and return its value (if non-zero) or error code.
|
|
Get static error string
|
|
Parse context
|
|
Print error string to stderr
|
|
Remove string from property
|
|
Reinitialize popt context
|
|
Set context to command line
|
|
Set context to command line
|
|
Set context flag
|
|
Overwrite context flags
|