main implementation header file
More...
#include <stdio.h>
Go to the source code of this file.
|
|
| 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
} |
| | Possible return values returned by parsing functions. More...
|
| |
|
| enum | cfg_flag {
CFG_IGNORE_MULTI = 1,
CFG_IGNORE_UNKNOWN = 2,
CFG_PROCESS_FIRST = 0,
CFG_SKIP_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
} |
| | By default are CFG_PROCESS_FIRST, CFG_POSIXLY_LEFTOVERS and CFG_NORMAL_LEFTOVERS initialized. More...
|
| |
|
| 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
} |
| | Possible types of options. More...
|
| |
|
| enum | cfg_context_type {
CFG_NO_CONTEXT = 0,
CFG_CMDLINE = 1,
CFG_LINE = 1,
CFG_CFGFILE = 2,
CFG_FILE = 2
} |
| | Context type. More...
|
| |
| 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
} |
| | Command line option type. More...
|
| |
|
|
| int | cfg_clear_property (const CFG_CONTEXT con, enum cfg_property_type type) |
| | Clear all strings of property. More...
|
| |
| int | cfg_clear_properties (const CFG_CONTEXT con, enum cfg_property_type type,...) |
| | Clear all strings of property. More...
|
| |
| int | cfg_add_property (const CFG_CONTEXT con, enum cfg_property_type type, char *str) |
| | Add string to property. More...
|
| |
| int | cfg_add_properties (const CFG_CONTEXT con, enum cfg_property_type type, char *str,...) |
| | Add multiple strings to particular properties. More...
|
| |
| int | cfg_add_properties_str (const CFG_CONTEXT con, char *str, enum cfg_property_type type,...) |
| | Add string to multiple properties. More...
|
| |
| int | cfg_add_properties_type (const CFG_CONTEXT con, enum cfg_property_type type, char *str,...) |
| | Add multiple strings to one property. More...
|
| |
| int | cfg_remove_property (const CFG_CONTEXT con, enum cfg_property_type type, char *str) |
| | Remove string from property. More...
|
| |
| int | cfg_remove_properties (const CFG_CONTEXT con, enum cfg_property_type type, char *str,...) |
| | Remove multiple strings from particular properties. More...
|
| |
| int | cfg_remove_properties_str (const CFG_CONTEXT con, char *str, enum cfg_property_type type,...) |
| | Remove string from multiple properties. More...
|
| |
| int | cfg_remove_properties_type (const CFG_CONTEXT con, enum cfg_property_type type, char *str,...) |
| | Remove multiple strings from one property. More...
|
| |
|
| int | cfg_parse (const CFG_CONTEXT con) |
| | Parse context. More...
|
| |
| int | cfg_get_next_opt (const CFG_CONTEXT con) |
| | Parse next option(s) and return its value (if non-zero) or error code. More...
|
| |
| char * | cfg_get_cur_opt (const CFG_CONTEXT con) |
| | Return currently processed option name. More...
|
| |
| char * | cfg_get_cur_arg (const CFG_CONTEXT con) |
| | Return currently processed option argument. More...
|
| |
| int | cfg_get_cur_idx (const CFG_CONTEXT con) |
| | Return currently processed option index (argv index in command line context, file byte position or line position in config file context) More...
|
| |
|
| void | cfg_print_error (const CFG_CONTEXT con) |
| | Print error string to stderr. More...
|
| |
| void | cfg_fprint_error (const CFG_CONTEXT con, FILE *fh) |
| | Print error string to stream. More...
|
| |
| char * | cfg_get_error_str (const CFG_CONTEXT con) |
| | Get error string; error string is dynamically allocated, it needs to be freed after use. More...
|
| |
| char * | cfg_get_static_error_str (const int errorcode) |
| | Get static error string. More...
|
| |
|
|
#define | CFG_EOT CFG_N_PROPS |
| | Terminators of variable number arguments in functions cfg_add_properties(), cfg_set_properties(), cfg_get_properties() and similar.
|
| |
|
#define | CFG_END_TYPE CFG_N_PROPS |
| | Terminators of variable number arguments in functions cfg_add_properties(), cfg_set_properties(), cfg_get_properties() and similar.
|
| |
| 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_NORMAL_MULTI_VALS_SEPARATOR = 4,
CFG_LINE_LEFTOVER_MULTI_VALS_SEPARATOR = 5,
CFG_LINE_QUOTE_PREFIX = 6,
CFG_LINE_QUOTE_POSTFIX = 7,
CFG_FILE_STOP_PREFIX = 8,
CFG_FILE_COMMENT_PREFIX = 9,
CFG_FILE_MULTI_LINE_POSTFIX = 10,
CFG_FILE_OPTION_ARG_SEPARATOR = 11,
CFG_FILE_NORMAL_MULTI_VALS_SEPARATOR = 12,
CFG_FILE_LEFTOVER_MULTI_VALS_SEPARATOR = 13,
CFG_FILE_QUOTE_PREFIX = 14,
CFG_FILE_QUOTE_POSTFIX = 15,
CFG_N_PROPS = 16,
CFG_QUOTE = 50,
CFG_LINE_QUOTE = 51,
CFG_FILE_QUOTE = 52,
CFG_QUOTE_PREFIX = 53,
CFG_QUOTE_POSTFIX = 54,
CFG_MULTI_VALS_SEPARATOR = 55,
CFG_FILE_MULTI_VALS_SEPARATOR = 56,
CFG_LINE_MULTI_VALS_SEPARATOR = 57,
CFG_NORMAL_MULTI_VALS_SEPARATOR = 58,
CFG_LEFTOVER_MULTI_VALS_SEPARATOR = 59,
CFG_OPTION_ARG_SEPARATOR = 60
} |
| | Terminators of variable number arguments in functions cfg_add_properties(), cfg_set_properties(), cfg_get_properties() and similar. More...
|
| |
|
| #define | cfg_get_cmdline_context_pos(begin_pos, end_pos, argv, options) |
| | Initialize core context. More...
|
| |
| #define | cfg_get_cfgfile_context_pos(begin_pos, end_pos, argv, options) |
| | Initialize core context. More...
|
| |
| #define | cfg_set_cmdline_context_pos(con, begin_pos, end_pos, argv) |
| | Initialize core context. More...
|
| |
| #define | cfg_set_cfgfile_context_pos(con, begin_pos, end_pos, argv) |
| | Initialize core context. More...
|
| |
| CFG_CONTEXT | cfg_get_context (struct cfg_option *options) |
| | Initialize core context. More...
|
| |
| CFG_CONTEXT | cfg_get_cmdline_context (long begin_pos, long size, char **argv, struct cfg_option *options) |
| | Initialize command line context. More...
|
| |
| CFG_CONTEXT | cfg_get_cmdline_context_argc (int argc, char **argv, struct cfg_option *options) |
| | Initialize command line context by argc and argv passed to main() More...
|
| |
| CFG_CONTEXT | cfg_get_cfgfile_context (long begin_pos, long size, char *filename, struct cfg_option *options) |
| | Initialize configuration file context. More...
|
| |
| void | cfg_set_cmdline_context (const CFG_CONTEXT con, long begin_pos, long size, char **argv) |
| | Set context to command line. More...
|
| |
| void | cfg_set_cmdline_context_argc (const CFG_CONTEXT con, int argc, char **argv) |
| | Set context to command line by argc and argv passed to main() More...
|
| |
| void | cfg_set_cfgfile_context (const CFG_CONTEXT con, long begin_pos, long size, char *filename) |
| | Set context to configuration file. More...
|
| |
| void | cfg_reset_context (const CFG_CONTEXT con) |
| | Reinitialize popt context. More...
|
| |
| void | cfg_free_context (const CFG_CONTEXT con) |
| | Destroy context. More...
|
| |
main implementation header file
- Author
- Ondrej Jombik nepto.nosp@m.@pla.nosp@m.ton.s.nosp@m.k
-
Lubomir Host rajo@.nosp@m.plat.nosp@m.on.sk
- Version
- $Platon: libcfg+/src/cfg+.h,v 1.61 2015/09/12 04:04:49 nepto Exp $
- Date
- 2001-2015
| #define cfg_get_cfgfile_context_pos |
( |
|
begin_pos, |
|
|
|
end_pos, |
|
|
|
argv, |
|
|
|
options |
|
) |
| |
Value:
const struct cfg_option * options Options table. Definition: cfg+.h:441
char ** argv NULL terminated array of argument. Definition: cfg+.h:481
CFG_CONTEXT cfg_get_cfgfile_context(long begin_pos, long size, char *filename, struct cfg_option *options) Initialize configuration file context.
long begin_pos Starting parsing position. Definition: cfg+.h:444
Initialize core context.
- Parameters
-
| options | pointer to options table |
- Returns
- initialized core context; further specification to command line or config file is required
| #define cfg_get_cmdline_context_pos |
( |
|
begin_pos, |
|
|
|
end_pos, |
|
|
|
argv, |
|
|
|
options |
|
) |
| |
Value:
const struct cfg_option * options Options table. Definition: cfg+.h:441
char ** argv NULL terminated array of argument. Definition: cfg+.h:481
long begin_pos Starting parsing position. Definition: cfg+.h:444
CFG_CONTEXT cfg_get_cmdline_context(long begin_pos, long size, char **argv, struct cfg_option *options) Initialize command line context.
Initialize core context.
- Parameters
-
| options | pointer to options table |
- Returns
- initialized core context; further specification to command line or config file is required
Set context flag.
- Parameters
-
| con | initialized context |
| flag | context flag |
- Returns
- void
| #define cfg_set_cfgfile_context_pos |
( |
|
con, |
|
|
|
begin_pos, |
|
|
|
end_pos, |
|
|
|
argv |
|
) |
| |
Value:
con \
end_pos - begin_pos + 1, \
char ** argv NULL terminated array of argument. Definition: cfg+.h:481
CFG_CONTEXT cfg_get_cfgfile_context(long begin_pos, long size, char *filename, struct cfg_option *options) Initialize configuration file context.
long begin_pos Starting parsing position. Definition: cfg+.h:444
Initialize core context.
- Parameters
-
| options | pointer to options table |
- Returns
- initialized core context; further specification to command line or config file is required
| #define cfg_set_cmdline_context_pos |
( |
|
con, |
|
|
|
begin_pos, |
|
|
|
end_pos, |
|
|
|
argv |
|
) |
| |
Value:
con \
end_pos - begin_pos + 1, \
char ** argv NULL terminated array of argument. Definition: cfg+.h:481
long begin_pos Starting parsing position. Definition: cfg+.h:444
CFG_CONTEXT cfg_get_cmdline_context(long begin_pos, long size, char **argv, struct cfg_option *options) Initialize command line context.
Initialize core context.
- Parameters
-
| options | pointer to options table |
- Returns
- initialized core context; further specification to command line or config file is required
Context type.
Possible types of context (used internally)
| Enumerator |
|---|
| CFG_NO_CONTEXT |
No context.
|
| CFG_CMDLINE |
Command line context type.
|
| CFG_CFGFILE |
Config file context type.
|
Possible return values returned by parsing functions.
| Enumerator |
|---|
| CFG_ERR_OK |
OK, all is right.
|
| CFG_ERROR_OK |
OK, all is right.
|
| CFG_OK |
OK, all is right.
|
| CFG_ERR_NOARG |
An argument is missing for an option.
|
| CFG_ERR_NOTALLOWEDARG |
An argument is not allowed for an option.
|
| CFG_ERR_BADOPT |
An option's argument could not be parsed.
|
| CFG_ERR_BADQUOTE |
Error in quotations.
|
| CFG_ERR_BADNUMBER |
An option could not be converted to appropriate numeric type.
|
| CFG_ERR_OVERFLOW |
A given number was too big or too small.
|
| CFG_ERR_MULTI |
Multiple arguments used for single option.
|
| CFG_ERR_NOMEM |
Not enough memory.
|
| CFG_ERR_STOP_STR |
Stop string was found.
|
| CFG_ERR_NOEQUAL |
No equal sign on the line.
|
| CFG_ERR_UNKNOWN |
An unknown option.
|
| CFG_ERR_FILE_NOT_FOUND |
File not found error.
|
| CFG_ERR_SEEK_ERROR |
Seek error (fseek() failure).
|
| CFG_ERR_INTERNAL |
Internal error.
|
By default are CFG_PROCESS_FIRST, CFG_POSIXLY_LEFTOVERS and CFG_NORMAL_LEFTOVERS initialized.
- Todo:
- CFG_APPEND, CFG_OVERWRITE, CFG_APPEND_MULTI_ONLY
| Enumerator |
|---|
| CFG_IGNORE_MULTI |
Ignore multiple arguments for single option.
|
| CFG_IGNORE_UNKNOWN |
Ignore unknown options.
|
| CFG_PROCESS_FIRST |
Process also the first argument on command line.
|
| CFG_SKIP_FIRST |
Skip processing of the first argument on command line.
|
| CFG_POSIXLY_LEFTOVERS |
Posixly correct leftover arguments.
|
| CFG_ADVANCED_LEFTOVERS |
Advanced leftover arguments.
|
| CFG_NORMAL_LEFTOVERS |
Normal leftover arguments initialization in file.
This flag is not used and it is kept from historical reasons.
|
| CFG_STRICT_LEFTOVERS |
Strict leftover arguments initialization in file.
This flag is not used and it is kept from historical reasons.
|
| CFG_FILE_BYTE_POS_USAGE |
Byte type position usage in file.
|
| CFG_FILE_LINE_POS_USAGE |
Line type position usage in file.
|
Command line option type.
Possible types of command line option (used internally)
| Enumerator |
|---|
| CFG_NONE_OPTION |
Not long and not short option.
|
| CFG_SHORT_OPTION |
Short command line option.
|
| CFG_LONG_OPTION |
Long command line option.
|
| CFG_SHORT_OPTIONS |
Short command line options.
|
| CFG_LONG_SEPINIT |
Long command line option argument initialized with separator.
|
| CFG_LONG_NOSEPINIT |
Long command line option argument initialized without separator (default)
|
Possible types of options.
- Todo:
- Thinking about case insensitivy of option ("--input" is the same as "--INPUT")
| Enumerator |
|---|
| CFG_BOOL |
Boolean.
|
| CFG_INT |
Integer.
|
| CFG_UINT |
Unsigned int.
|
| CFG_LONG |
Long.
|
| CFG_ULONG |
Unsigned long.
|
| CFG_FLOAT |
Float.
|
| CFG_DOUBLE |
Double.
|
| CFG_STR |
String.
|
| CFG_END |
End (to mark last item in list)
|
| CFG_DATA_TYPE_MASK |
Data type mask (used internally)
|
| CFG_SINGLE |
Single, multi or multi separated.
Single by default. Tells if option can be repeated. In multi case value is array of poiters to type ended with NULL.
|
| CFG_LAST_ARGS |
Leftover arguments specification.
Mark option which will contain leftover arguments.
|
Terminators of variable number arguments in functions cfg_add_properties(), cfg_set_properties(), cfg_get_properties() and similar.
| Enumerator |
|---|
| CFG_LINE_STOP_STRING |
Array of strings which forces to stop command line parsing.
By default it is empty.
|
| CFG_LINE_SHORT_OPTION_PREFIX |
Command line short option prefix.
By default is "-" initialized.
|
| CFG_LINE_LONG_OPTION_PREFIX |
Command line long option prefix.
By default is "--" initialized.
|
| CFG_LINE_OPTION_ARG_SEPARATOR |
Command line option argument separator.
By default is "=" initialized.
|
| CFG_LINE_NORMAL_MULTI_VALS_SEPARATOR |
Command line multi values separator.
By default are "," and ";" initialized.
|
| CFG_LINE_LEFTOVER_MULTI_VALS_SEPARATOR |
Command line multi values leftover arguments separator.
By default it is empty.
|
| CFG_LINE_QUOTE_PREFIX |
Command line quote prefix & postfix.
By default are apostrophes (') and quotations (") initlized for both.
|
| CFG_LINE_QUOTE_POSTFIX |
Array of strings which forces to stop command line parsing.
By default it is empty.
|
| CFG_FILE_STOP_PREFIX |
Array of strings prefixes which forces to stop config file parsing.
By default it is empty.
|
| CFG_FILE_COMMENT_PREFIX |
Array of string prefixes which mark comment line.
By default are "#" and ";" initialized.
|
| CFG_FILE_MULTI_LINE_POSTFIX |
Array of string postfixes to determine multi lines.
By default is "\\" initialized.
|
| CFG_FILE_OPTION_ARG_SEPARATOR |
Config file option argument separator.
By default is "=" initialized.
|
| CFG_FILE_NORMAL_MULTI_VALS_SEPARATOR |
Config file multi values separator.
By default are ",", ";" and " " initialized.
|
| CFG_FILE_LEFTOVER_MULTI_VALS_SEPARATOR |
Command line multi values leftover arguments separator.
By default is " " initialized.
|
| CFG_FILE_QUOTE_PREFIX |
Config file quote prefix & postfix.
By default are apostrophes (') and quotations (") initlized for both.
|
| CFG_FILE_QUOTE_POSTFIX |
Array of strings which forces to stop command line parsing.
By default it is empty.
|
| CFG_N_PROPS |
Special properties count.
|
| CFG_QUOTE |
File quote prefix & postfix.
|
| CFG_LINE_QUOTE |
File quote prefix & postfix.
|
| CFG_FILE_QUOTE |
File quote prefix & postfix.
|
| CFG_QUOTE_PREFIX |
File quote prefix & postfix.
|
| CFG_QUOTE_POSTFIX |
File quote prefix & postfix.
|
| CFG_MULTI_VALS_SEPARATOR |
Multi values separator.
|
| CFG_FILE_MULTI_VALS_SEPARATOR |
File quote prefix & postfix.
|
| CFG_LINE_MULTI_VALS_SEPARATOR |
File quote prefix & postfix.
|
| CFG_NORMAL_MULTI_VALS_SEPARATOR |
File quote prefix & postfix.
|
| CFG_LEFTOVER_MULTI_VALS_SEPARATOR |
File quote prefix & postfix.
|
| CFG_OPTION_ARG_SEPARATOR |
Option argument separator.
|
Add multiple strings to particular properties.
- Parameters
-
| con | initialized context |
| type | property type(s) |
| str | string(s) for addition |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
Argument list must be terminated with typeN = CFG_EOT or strN = NULL. Use constructions like this:
cfg_add_properties(con, type1, str1, type2, str2, type3=CFG_EOT)
Add string to multiple properties.
- Parameters
-
| con | initialized context |
| str | string for addition |
| type | property type(s) |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
Argument list must be terminated with typeN = CFG_EOT. Use constructions like this:
cfg_add_properties(con, str, type1, type2, type3=CFG_EOT)
Add multiple strings to one property.
- Parameters
-
| con | initialized context |
| type | property type |
| str | string(s) for addition |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
Argument list must be terminated with strN = NULL. Use constructions like this:
cfg_add_properties(con, type, str1, str2, str3=NULL)
Add string to property.
- Parameters
-
| con | initialized context |
| type | property type |
| str | string for addition |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
| void cfg_clear_context_flag |
( |
const CFG_CONTEXT |
con, |
|
|
int |
flag |
|
) |
| |
Clear context flag.
- Parameters
-
| con | initialized context |
| flag | context flag |
- Returns
- void
Clear all strings of property.
- Parameters
-
| con | initialized context |
| type | property type |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
Clear all strings of property.
- Parameters
-
| con | initialized context |
| type | property type |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
| void cfg_fprint_error |
( |
const CFG_CONTEXT |
con, |
|
|
FILE * |
fh |
|
) |
| |
Print error string to stream.
- Parameters
-
| con | initialized context |
| fh | stream opened for writting |
- Returns
- void
Destroy context.
- Parameters
-
- Returns
- void
| CFG_CONTEXT cfg_get_cfgfile_context |
( |
long |
begin_pos, |
|
|
long |
size, |
|
|
char * |
filename, |
|
|
struct cfg_option * |
options |
|
) |
| |
Initialize configuration file context.
- Parameters
-
| begin_pos | starting position in file to parse |
| size | maximal number of bytes/lines in file to parse (set value of -1 for infinite) |
| filename | parsed filename |
| options | pointer to options table |
- Returns
- initialized command line context
| CFG_CONTEXT cfg_get_cmdline_context |
( |
long |
begin_pos, |
|
|
long |
size, |
|
|
char ** |
argv, |
|
|
struct cfg_option * |
options |
|
) |
| |
Initialize command line context.
- Parameters
-
| begin_pos | index of beginning argument of arguments array |
| size | maximal number of array elements to parse (set value of -1 for infinite) |
| argv | arguments array |
| options | pointer to options table |
- Returns
- initialized command line context
Initialize command line context by argc and argv passed to main()
- Parameters
-
| argc | argumet count (argc) passed to function main() |
| argv | arguments array (argv) passed to function main() |
| options | pointer to options table |
- Returns
- initialized command line context
Initialize core context.
- Parameters
-
| options | pointer to options table |
- Returns
- initialized core context; further specification to command line or config file is required
| int cfg_get_context_flag |
( |
const CFG_CONTEXT |
con, |
|
|
int |
flag |
|
) |
| |
Get context flag.
- Parameters
-
| con | initialized context |
| flag | context flag |
- Returns
- 0 on false, non-zero on true
Get all context flags.
- Parameters
-
- Returns
- all context flags
Return currently processed option argument.
- Parameters
-
- Returns
- pointer to current option argument
Return currently processed option index (argv index in command line context, file byte position or line position in config file context)
- Parameters
-
- Returns
- index of current option
Return currently processed option name.
- Parameters
-
- Returns
- pointer to current option name
Get error string; error string is dynamically allocated, it needs to be freed after use.
- Parameters
-
- Returns
- dynamically allocated error string
Parse next option(s) and return its value (if non-zero) or error code.
- Parameters
-
- Returns
- next option val, code of error (CFG_ERROR_*) or CFG_OK on end
- See also
- cfg_error
-
cfg_context
| char* cfg_get_static_error_str |
( |
const int |
errorcode | ) |
|
Get static error string.
- Parameters
-
| errorcode | code of libcfg error |
- Returns
- static error string
Parse context.
- Parameters
-
- Returns
- code of error (CFG_ERROR_*) or CFG_OK if parsing was sucessfull
- See also
- cfg_error
Print error string to stderr.
- Parameters
-
- Returns
- void
Remove multiple strings from particular properties.
- Parameters
-
| con | initialized context |
| type | property type(s) |
| str | string(s) for removal |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
Argument list must be terminated with typeN = CFG_EOT or strN = NULL. Use constructions like this:
cfg_remove_properties(con, type1, str1, type2, str2, type3=CFG_EOT)
Remove string from multiple properties.
- Parameters
-
| con | initialized context |
| str | string for removal |
| type | property type(s) |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
Argument list must be terminated with typeN = CFG_EOT. Use constructions like this:
cfg_remove_properties(con, str, type1, type2, type3=CFG_EOT)
Remove multiple strings from one property.
- Parameters
-
| con | initialized context |
| type | property type |
| str | string(s) for removal |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
Argument list must be terminated with strN = NULL. Use constructions like this:
cfg_add_properties(con, type, str1, str2, str3=NULL)
Remove string from property.
- Parameters
-
| con | initialized context |
| type | property type |
| str | string for removal |
- Returns
- 1 on success, 0 on not enough memory error
- See also
- cfg_property_type
Reinitialize popt context.
- Parameters
-
- Returns
- void
| void cfg_set_cfgfile_context |
( |
const CFG_CONTEXT |
con, |
|
|
long |
begin_pos, |
|
|
long |
size, |
|
|
char * |
filename |
|
) |
| |
Set context to configuration file.
- Parameters
-
| con | initialized context |
| begin_pos | starting position in file to parse |
| size | maximal number of bytes/lines in file to parse (set value of -1 for infinite) |
| filename | parsed filename |
- Returns
- void
| void cfg_set_cmdline_context |
( |
const CFG_CONTEXT |
con, |
|
|
long |
begin_pos, |
|
|
long |
size, |
|
|
char ** |
argv |
|
) |
| |
Set context to command line.
- Parameters
-
| con | initialized context |
| begin_pos | index of beginning argument of arguments array |
| size | maximal number of array elements to parse (set value of -1 for infinite) |
| argv | arguments array |
- Returns
- void
| void cfg_set_cmdline_context_argc |
( |
const CFG_CONTEXT |
con, |
|
|
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Set context to command line by argc and argv passed to main()
- Parameters
-
| con | initialized context |
| argc | argumet count (argc) passed to function main() |
| argv | arguments array (argv) passed to function main() |
- Returns
- initialized command line context
| void cfg_set_context_flag |
( |
const CFG_CONTEXT |
con, |
|
|
int |
flag |
|
) |
| |
Set context flag.
- Parameters
-
| con | initialized context |
| flag | context flag |
- Returns
- void
| void cfg_set_context_flags |
( |
const CFG_CONTEXT |
con, |
|
|
int |
flags |
|
) |
| |
Overwrite context flags.
- Parameters
-
| con | initialized context |
| flags | context flags |
- Returns
- void
libcfg+ developer documentation generated by
Doxygen
|
|