libcfg+: cfg+.h Source File

libcfg+ 0.7.0

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

cfg+.h
Go to the documentation of this file.
1 /*
2 * libcfg+ - precise command line & config file parsing library
3 *
4 * cfg+.h - main implementation header file
5 * ____________________________________________________________
6 *
7 * Developed by Ondrej Jombik <nepto@platon.sk>
8 * and Lubomir Host <rajo@platon.sk>
9 * Copyright (c) 2001-2015 Platon Group, http://platon.sk/
10 * All rights reserved.
11 *
12 * See README file for more information about this software.
13 * See COPYING file for license information.
14 *
15 * Download the latest version from
16 * http://opensource.platon.sk/projects/libcfg+/
17 */
18
19 /* $Platon: libcfg+/src/cfg+.h,v 1.61 2015/09/12 04:04:49 nepto Exp $ */
20
30 #ifndef _PLATON_CFG_H
31 #define _PLATON_CFG_H
32
33 #include <stdio.h>
34
36 #define CFG_END_OPTION { NULL, '\0', NULL, CFG_END, NULL, 0 }
37 #define CFG_END_OF_LIST CFG_END_OPTION
46 enum cfg_error { /* {{{ */
47
50 CFG_ERR_OK = 0,
51 CFG_ERROR_OK = 0,
52 CFG_OK = 0,
56 CFG_ERR_NOARG = -1,
57 CFG_ERROR_NOARG = -1,
58
60 CFG_ERR_NOTALLOWEDARG = -2,
61 CFG_ERROR_NOTALLOWEDARG = -2,
62
64 CFG_ERR_BADOPT = -3,
65 CFG_ERROR_BADOPT = -3,
66
68 CFG_ERR_BADQUOTE = -4,
69 CFG_ERROR_BADQUOTE = -4,
70
72 CFG_ERR_BADNUMBER = -5,
73 CFG_ERROR_BADNUMBER = -5,
74
76 CFG_ERR_OVERFLOW = -6,
77 CFG_ERROR_OVERFLOW = -6,
78
80 CFG_ERR_MULTI = -7,
81 CFG_ERROR_MULTI = -7,
82
84 CFG_ERR_NOMEM = -8,
85 CFG_ERROR_NOMEM = -8,
86
88 CFG_ERR_STOP_STR = -9,
89 CFG_ERR_STOP_STR_FOUND = -9,
90 CFG_ERROR_STOP_STR = -9,
91 CFG_ERROR_STOP_STR_FOUND = -9,
92
94 CFG_ERR_NOEQUAL = -10,
95 CFG_ERROR_NOEQUAL = -10,
96
98 CFG_ERR_UNKNOWN = -11,
99 CFG_ERROR_UNKNOWN = -11,
100
102 CFG_ERR_FILE_NOT_FOUND = -12,
103 CFG_ERROR_FILE_NOT_FOUND = -12,
104
106 CFG_ERR_SEEK_ERROR = -13,
107 CFG_ERROR_SEEK_ERROR = -13,
108
110 CFG_ERR_INTERNAL = -20,
111 CFG_ERROR_INTERNAL = -20
112
113 }; /* }}} */ /*@}*/
114
124 enum cfg_flag { /* {{{ */
125
127 CFG_IGNORE_MULTI = 1,
128
130 CFG_IGNORE_UNKNOWN = 2,
131
133 CFG_PROCESS_FIRST = 0,
134
136 CFG_SKIP_FIRST = 4,
137
139 CFG_POSIXLY_LEFTOVERS = 0,
140
142 CFG_ADVANCED_LEFTOVERS = 8,
143
146 CFG_NORMAL_LEFTOVERS = 0,
147
150 CFG_STRICT_LEFTOVERS = 16,
151
153 CFG_FILE_BYTE_POS_USAGE = 0,
154
156 CFG_FILE_LINE_POS_USAGE = 32
157
158 /* Ignore all quotations in options arguments. */
159 /*
160 CFG_USE_QUOTE = 0,
161 CFG_IGNORE_QUOTE = 16
162 */
163 /* Advanced quotations are things like option = va"'l'"ue
164 which resolves to va'l'ue.
165
166 We really want this strange stuff? Any volunter?
167
168 CFG_ADVANCED_QUOTE = 32 + 16
169 */
170
171 }; /* }}} */ /*@}*/
172
182 enum cfg_option_type { /* {{{ */
183
185 CFG_BOOL = 1,
186 CFG_BOOLEAN = 1,
187
189 CFG_INT = 2,
190 CFG_INTEGER = 2,
191
193 CFG_UINT = 3,
194 CFG_UNSIGNED = 3,
195 CFG_UNSIGNED_INT = 3,
196
198 CFG_LONG = 4,
199
201 CFG_ULONG = 5,
202 CFG_UNSIGNED_LONG = 5,
203
205 CFG_FLOAT = 6,
206
208 CFG_DOUBLE = 7,
209
211 CFG_STR = 8,
212 CFG_STRING = 8,
213
215 CFG_END = 0,
216
218 CFG_DATA_TYPE_MASK = 31,
219
225 CFG_SINGLE = 0,
226 CFG_MULTI = 32,
227 CFG_MULTI_ARRAY = 32,
228 CFG_MULTI_SEPARATED = 32 + 64,
229
234 CFG_LAST_ARGS = 128,
235 CFG_LAST_ARGUMENTS = 128,
236 CFG_LEFTOVER_ARGS = 128,
237 CFG_LEFTOVER_ARGUMENTS = 128
238
239 }; /* }}} */ /*@}*/
240
245 enum cfg_property_type { /* {{{ */
246
251
254 CFG_LINE_STOP_STRING = 0,
255
258 CFG_LINE_SHORT_OPTION_PREFIX = 1,
259
262 CFG_LINE_LONG_OPTION_PREFIX = 2,
263
266 CFG_LINE_OPTION_ARG_SEPARATOR = 3,
267
270 CFG_LINE_NORMAL_MULTI_VALS_SEPARATOR = 4,
271
274 CFG_LINE_LEFTOVER_MULTI_VALS_SEPARATOR = 5,
275
278 CFG_LINE_QUOTE_PREFIX = 6,
279 CFG_LINE_QUOTE_POSTFIX = 7,
280
283 CFG_FILE_STOP_PREFIX = 8,
284
287 CFG_FILE_COMMENT_PREFIX = 9,
288
291 CFG_FILE_MULTI_LINE_POSTFIX = 10,
292
295 CFG_FILE_OPTION_ARG_SEPARATOR = 11,
296
299 CFG_FILE_NORMAL_MULTI_VALS_SEPARATOR = 12,
300
303 CFG_FILE_LEFTOVER_MULTI_VALS_SEPARATOR = 13,
304
307 CFG_FILE_QUOTE_PREFIX = 14,
308 CFG_FILE_QUOTE_POSTFIX = 15,
309
317 CFG_N_PROPS = 16,
324
326 CFG_QUOTE = 50,
327 CFG_LINE_QUOTE = 51,
328 CFG_FILE_QUOTE = 52,
329 CFG_QUOTE_PREFIX = 53,
330 CFG_QUOTE_POSTFIX = 54,
331
333 CFG_MULTI_VALS_SEPARATOR = 55,
334 CFG_FILE_MULTI_VALS_SEPARATOR = 56,
335 CFG_LINE_MULTI_VALS_SEPARATOR = 57,
336 CFG_NORMAL_MULTI_VALS_SEPARATOR = 58,
337 CFG_LEFTOVER_MULTI_VALS_SEPARATOR = 59,
338
340 CFG_OPTION_ARG_SEPARATOR = 60
342 }; /* }}} */
343
348 #define CFG_EOT CFG_N_PROPS
349 #define CFG_END_TYPE CFG_N_PROPS
350
362 enum cfg_context_type { /* {{{ */
363
365 CFG_NO_CONTEXT = 0,
366
368 CFG_CMDLINE = 1,
369 CFG_LINE = 1,
370
372 CFG_CFGFILE = 2,
373 CFG_FILE = 2
374 }; /* }}} */
375
381 enum cfg_line_option_type { /* {{{ */
382
384 CFG_NONE_OPTION = 0,
385
387 CFG_SHORT_OPTION = 1,
388
390 CFG_LONG_OPTION = 2,
391
393 CFG_SHORT_OPTIONS = 4,
394
396 CFG_LONG_SEPINIT = 8,
397
399 CFG_LONG_NOSEPINIT = 0
400 }; /* }}} */ /*@}*/
401
405 struct cfg_option { /* {{{ */
407 const char *cmdline_long_name;
409 const char cmdline_short_name;
411 const char *cfgfile_name;
412
415 const enum cfg_option_type type;
416
418 void *value;
419
421 int val;
422 }; /* }}} */
423
427 struct cfg_context { /* {{{ */
428
433
435 enum cfg_context_type type;
436
438 int flags;
439
441 const struct cfg_option *options;
442
444 long begin_pos;
445
448 long size;
449
451 int *used_opt_idx;
452
454 enum cfg_error error_code;
455
457 char **prop[CFG_N_PROPS];
458
460 long cur_idx;
461 long cur_idx_tmp;
462 int cur_opt_type;
463
465 char *cur_opt;
466
468 char *cur_arg;
469
476
478 int parsing_started:1;
479
481 char **argv;
482
489
491 char *filename;
492
494 FILE *fhandle;
495
497 }; /* }}} */
498
502 typedef struct cfg_context * CFG_CONTEXT;
503
504 /*
505 * Functions
506 */
507
508 #ifdef __cplusplus
509 extern "C" {
510 #endif
511
515 /* {{{ */
516
524 CFG_CONTEXT cfg_get_context(struct cfg_option *options);
525
536 CFG_CONTEXT cfg_get_cmdline_context(
537 long begin_pos,
538 long size,
539 char **argv,
540 struct cfg_option *options);
541
542 #define cfg_get_cmdline_context_pos(begin_pos, end_pos, argv, options) \
543 cfg_get_cmdline_context( \
544 begin_pos, \
545 end_pos - begin_pos + 1, \
546 argv, \
547 options)
548
557 CFG_CONTEXT cfg_get_cmdline_context_argc(
558 int argc,
559 char **argv,
560 struct cfg_option *options);
561
572 CFG_CONTEXT cfg_get_cfgfile_context(
573 long begin_pos,
574 long size,
575 char *filename,
576 struct cfg_option *options);
577
578 #define cfg_get_cfgfile_context_pos(begin_pos, end_pos, argv, options) \
579 cfg_get_cfgfile_context( \
580 begin_pos, \
581 end_pos - begin_pos + 1, \
582 argv, \
583 options)
584
595 void cfg_set_cmdline_context(
596 const CFG_CONTEXT con,
597 long begin_pos,
598 long size,
599 char **argv);
600
601 #define cfg_set_cmdline_context_pos(con, begin_pos, end_pos, argv) \
602 cfg_get_cmdline_context( \
603 con \
604 begin_pos, \
605 end_pos - begin_pos + 1, \
606 argv)
607
616 void cfg_set_cmdline_context_argc(
617 const CFG_CONTEXT con,
618 int argc,
619 char **argv);
620
631 void cfg_set_cfgfile_context(
632 const CFG_CONTEXT con,
633 long begin_pos,
634 long size,
635 char *filename);
636
637 #define cfg_set_cfgfile_context_pos(con, begin_pos, end_pos, argv) \
638 cfg_get_cfgfile_context( \
639 con \
640 begin_pos, \
641 end_pos - begin_pos + 1, \
642 argv)
643
650 void cfg_reset_context(const CFG_CONTEXT con);
651
658 void cfg_free_context(const CFG_CONTEXT con);
659
660 /* }}} */ /*@}*/
661
665 /* {{{ */
666
674 void cfg_set_context_flag(const CFG_CONTEXT con, int flag);
675
683 void cfg_clear_context_flag(const CFG_CONTEXT con, int flag);
684
692 int cfg_get_context_flag(const CFG_CONTEXT con, int flag);
693
694 #define cfg_is_context_flag(con, flag) cfg_get_context_flag(con, flag)
695
703 void cfg_set_context_flags(const CFG_CONTEXT con, int flags);
704
711 int cfg_get_context_flags(const CFG_CONTEXT con);
712
713 /* }}} */ /*@}*/
714
718 /* {{{ */
719
728 int cfg_clear_property(
729 const CFG_CONTEXT con, enum cfg_property_type type);
730
739 int cfg_clear_properties(
740 const CFG_CONTEXT con, enum cfg_property_type type, ...);
741
742
752 int cfg_add_property(
753 const CFG_CONTEXT con, enum cfg_property_type type, char *str);
754
768 int cfg_add_properties(
769 const CFG_CONTEXT con, enum cfg_property_type type, char *str, ...);
770
784 int cfg_add_properties_str(
785 const CFG_CONTEXT con, char *str, enum cfg_property_type type, ...);
786
800 int cfg_add_properties_type(
801 const CFG_CONTEXT con, enum cfg_property_type type, char *str, ...);
802
812 int cfg_remove_property(
813 const CFG_CONTEXT con, enum cfg_property_type type, char *str);
814
828 int cfg_remove_properties(
829 const CFG_CONTEXT con, enum cfg_property_type type, char *str, ...);
830
844 int cfg_remove_properties_str(
845 const CFG_CONTEXT con, char *str, enum cfg_property_type type, ...);
846
860 int cfg_remove_properties_type(
861 const CFG_CONTEXT con, enum cfg_property_type type, char *str, ...);
862
863 /* }}} */ /*@}*/
864
868 /* {{{ */
869
878 int cfg_parse(const CFG_CONTEXT con);
879
889 int cfg_get_next_opt(const CFG_CONTEXT con);
890
897 char *cfg_get_cur_opt(const CFG_CONTEXT con);
898
905 char *cfg_get_cur_arg(const CFG_CONTEXT con);
906
913 int cfg_get_cur_idx(const CFG_CONTEXT con);
914
915 /* }}} */ /*@}*/
916
920 /* {{{ */
921
928 void cfg_print_error(const CFG_CONTEXT con);
929
937 void cfg_fprint_error(const CFG_CONTEXT con, FILE *fh);
938
946 char *cfg_get_error_str(const CFG_CONTEXT con);
947
954 char *cfg_get_static_error_str(const int errorcode);
955
956 /* }}} */ /*@}*/
957
958 #ifdef __cplusplus
959 }
960 #endif
961
962 #endif /* _PLATON_CFG_H */
963
964 /* Modeline for ViM {{{
965 * vim:set ts=4:
966 * vim600:fdm=marker fdl=0 fdc=0:
967 * }}} */
968
cfg_context::parsing_started
int parsing_started
Flag to detect if parsing already started.
Definition: cfg+.h:478
CFG_FILE_QUOTE_PREFIX
Config file quote prefix & postfix.
Definition: cfg+.h:307
cfg_context_type
cfg_context_type
Context type.
Definition: cfg+.h:362
CFG_FILE_LINE_POS_USAGE
Line type position usage in file.
Definition: cfg+.h:156
CFG_FLOAT
Float.
Definition: cfg+.h:205
cfg_set_cfgfile_context
void cfg_set_cfgfile_context(const CFG_CONTEXT con, long begin_pos, long size, char *filename)
Set context to configuration file.
cfg_option::type
enum cfg_option_type type
Option type.
Definition: cfg+.h:415
CFG_DATA_TYPE_MASK
Data type mask (used internally)
Definition: cfg+.h:218
cfg_context::size
long size
Number of elements (array arguments, bytes or lines) to parse (value of -1 means infinite) ...
Definition: cfg+.h:448
CFG_FILE_QUOTE_POSTFIX
Array of strings which forces to stop command line parsing.
Definition: cfg+.h:308
CFG_ERR_FILE_NOT_FOUND
File not found error.
Definition: cfg+.h:102
CFG_CFGFILE
Config file context type.
Definition: cfg+.h:372
CFG_STRICT_LEFTOVERS
Strict leftover arguments initialization in file.
Definition: cfg+.h:150
CFG_FILE_NORMAL_MULTI_VALS_SEPARATOR
Config file multi values separator.
Definition: cfg+.h:299
CFG_FILE_STOP_PREFIX
Array of strings prefixes which forces to stop config file parsing.
Definition: cfg+.h:283
CFG_UINT
Unsigned int.
Definition: cfg+.h:193
CFG_INT
Integer.
Definition: cfg+.h:189
cfg_context::options
const struct cfg_option * options
Options table.
Definition: cfg+.h:441
CFG_ERR_BADQUOTE
Error in quotations.
Definition: cfg+.h:68
CFG_LINE_QUOTE_PREFIX
Command line quote prefix & postfix.
Definition: cfg+.h:278
cfg_get_context_flags
int cfg_get_context_flags(const CFG_CONTEXT con)
Get all context flags.
CFG_ERR_UNKNOWN
An unknown option.
Definition: cfg+.h:98
CFG_NORMAL_LEFTOVERS
Normal leftover arguments initialization in file.
Definition: cfg+.h:146
cfg_add_properties_type
int cfg_add_properties_type(const CFG_CONTEXT con, enum cfg_property_type type, char *str,...)
Add multiple strings to one property.
cfg_set_cmdline_context_argc
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()
cfg_parse
int cfg_parse(const CFG_CONTEXT con)
Parse context.
cfg_context::fhandle
FILE * fhandle
Pointer to FILE* structure of parsed file.
Definition: cfg+.h:494
CFG_ERR_SEEK_ERROR
Seek error (fseek() failure).
Definition: cfg+.h:106
cfg_option::cfgfile_name
const char * cfgfile_name
Config file name (may be NULL)
Definition: cfg+.h:411
cfg_get_cmdline_context_argc
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()
cfg_context::cur_idx
long cur_idx
Currents.
Definition: cfg+.h:460
CFG_QUOTE_PREFIX
File quote prefix & postfix.
Definition: cfg+.h:329
cfg_context::used_opt_idx
int * used_opt_idx
Array of used options indexes.
Definition: cfg+.h:451
CFG_ERR_NOARG
An argument is missing for an option.
Definition: cfg+.h:56
CFG_ERR_MULTI
Multiple arguments used for single option.
Definition: cfg+.h:80
cfg_remove_property
int cfg_remove_property(const CFG_CONTEXT con, enum cfg_property_type type, char *str)
Remove string from property.
cfg_remove_properties_str
int cfg_remove_properties_str(const CFG_CONTEXT con, char *str, enum cfg_property_type type,...)
Remove string from multiple properties.
cfg_context::argv
char ** argv
NULL terminated array of argument.
Definition: cfg+.h:481
cfg_add_properties_str
int cfg_add_properties_str(const CFG_CONTEXT con, char *str, enum cfg_property_type type,...)
Add string to multiple properties.
CFG_LINE_LEFTOVER_MULTI_VALS_SEPARATOR
Command line multi values leftover arguments separator.
Definition: cfg+.h:274
cfg_option
Structure for defining one config option.
Definition: cfg+.h:405
cfg_context::prop
char ** prop[CFG_N_PROPS]
Special properties.
Definition: cfg+.h:457
CFG_SINGLE
Single, multi or multi separated.
Definition: cfg+.h:225
CFG_STR
String.
Definition: cfg+.h:211
cfg_clear_properties
int cfg_clear_properties(const CFG_CONTEXT con, enum cfg_property_type type,...)
Clear all strings of property.
cfg_option::cmdline_long_name
const char * cmdline_long_name
Command line long name (may be NULL)
Definition: cfg+.h:407
cfg_line_option_type
cfg_line_option_type
Command line option type.
Definition: cfg+.h:381
CFG_ERR_OK
OK, all is right.
Definition: cfg+.h:50
cfg_option::val
int val
Return value (set to 0 for not return)
Definition: cfg+.h:421
CFG_FILE_QUOTE
File quote prefix & postfix.
Definition: cfg+.h:328
CFG_N_PROPS
Special properties count.
Definition: cfg+.h:317
CFG_LINE_STOP_STRING
Array of strings which forces to stop command line parsing.
Definition: cfg+.h:254
CFG_FILE_COMMENT_PREFIX
Array of string prefixes which mark comment line.
Definition: cfg+.h:287
CFG_FILE_MULTI_VALS_SEPARATOR
File quote prefix & postfix.
Definition: cfg+.h:334
CFG_POSIXLY_LEFTOVERS
Posixly correct leftover arguments.
Definition: cfg+.h:139
CFG_IGNORE_MULTI
Ignore multiple arguments for single option.
Definition: cfg+.h:127
CFG_CMDLINE
Command line context type.
Definition: cfg+.h:368
CFG_QUOTE
File quote prefix & postfix.
Definition: cfg+.h:326
cfg_get_error_str
char * cfg_get_error_str(const CFG_CONTEXT con)
Get error string; error string is dynamically allocated, it needs to be freed after use...
CFG_LINE_QUOTE_POSTFIX
Array of strings which forces to stop command line parsing.
Definition: cfg+.h:279
CFG_LINE_LONG_OPTION_PREFIX
Command line long option prefix.
Definition: cfg+.h:262
cfg_context::type
enum cfg_context_type type
Context type (command line or config file)
Definition: cfg+.h:435
CFG_DOUBLE
Double.
Definition: cfg+.h:208
cfg_get_cfgfile_context
CFG_CONTEXT cfg_get_cfgfile_context(long begin_pos, long size, char *filename, struct cfg_option *options)
Initialize configuration file context.
CFG_LINE_OPTION_ARG_SEPARATOR
Command line option argument separator.
Definition: cfg+.h:266
cfg_get_next_opt
int cfg_get_next_opt(const CFG_CONTEXT con)
Parse next option(s) and return its value (if non-zero) or error code.
CFG_LEFTOVER_MULTI_VALS_SEPARATOR
File quote prefix & postfix.
Definition: cfg+.h:337
CFG_FILE_BYTE_POS_USAGE
Byte type position usage in file.
Definition: cfg+.h:153
cfg_get_context
CFG_CONTEXT cfg_get_context(struct cfg_option *options)
Initialize core context.
cfg_context::cur_idx_tmp
long cur_idx_tmp
Context type (command line or config file)
Definition: cfg+.h:461
CFG_SHORT_OPTIONS
Short command line options.
Definition: cfg+.h:393
CFG_FILE_LEFTOVER_MULTI_VALS_SEPARATOR
Command line multi values leftover arguments separator.
Definition: cfg+.h:303
cfg_add_properties
int cfg_add_properties(const CFG_CONTEXT con, enum cfg_property_type type, char *str,...)
Add multiple strings to particular properties.
cfg_get_cur_idx
int cfg_get_cur_idx(const CFG_CONTEXT con)
Return currently processed option index (argv index in command line context, file byte position or li...
CFG_LONG
Long.
Definition: cfg+.h:198
CFG_SHORT_OPTION
Short command line option.
Definition: cfg+.h:387
CFG_ERR_NOMEM
Not enough memory.
Definition: cfg+.h:84
CFG_ERR_NOTALLOWEDARG
An argument is not allowed for an option.
Definition: cfg+.h:60
CFG_ERROR_OK
OK, all is right.
Definition: cfg+.h:51
CFG_OPTION_ARG_SEPARATOR
Option argument separator.
Definition: cfg+.h:340
cfg_option::value
void * value
Pointer where to store value of option.
Definition: cfg+.h:418
CFG_CONTEXT
struct cfg_context * CFG_CONTEXT
Context data type.
Definition: cfg+.h:502
CFG_LINE_QUOTE
File quote prefix & postfix.
Definition: cfg+.h:327
cfg_get_cur_opt
char * cfg_get_cur_opt(const CFG_CONTEXT con)
Return currently processed option name.
CFG_ULONG
Unsigned long.
Definition: cfg+.h:201
CFG_LONG_NOSEPINIT
Long command line option argument initialized without separator (default)
Definition: cfg+.h:399
cfg_reset_context
void cfg_reset_context(const CFG_CONTEXT con)
Reinitialize popt context.
CFG_LINE_MULTI_VALS_SEPARATOR
File quote prefix & postfix.
Definition: cfg+.h:335
CFG_ERR_INTERNAL
Internal error.
Definition: cfg+.h:110
cfg_remove_properties
int cfg_remove_properties(const CFG_CONTEXT con, enum cfg_property_type type, char *str,...)
Remove multiple strings from particular properties.
cfg_context::begin_pos
long begin_pos
Starting parsing position.
Definition: cfg+.h:444
cfg_remove_properties_type
int cfg_remove_properties_type(const CFG_CONTEXT con, enum cfg_property_type type, char *str,...)
Remove multiple strings from one property.
CFG_NORMAL_MULTI_VALS_SEPARATOR
File quote prefix & postfix.
Definition: cfg+.h:336
CFG_NONE_OPTION
Not long and not short option.
Definition: cfg+.h:384
cfg_property_type
cfg_property_type
Terminators of variable number arguments in functions cfg_add_properties(), cfg_set_properties(), cfg_get_properties() and similar.
Definition: cfg+.h:245
cfg_clear_context_flag
void cfg_clear_context_flag(const CFG_CONTEXT con, int flag)
Clear context flag.
CFG_QUOTE_POSTFIX
File quote prefix & postfix.
Definition: cfg+.h:330
CFG_BOOL
Boolean.
Definition: cfg+.h:185
cfg_context::cur_arg
char * cur_arg
Current option argument.
Definition: cfg+.h:468
CFG_IGNORE_UNKNOWN
Ignore unknown options.
Definition: cfg+.h:130
CFG_ERR_STOP_STR
Stop string was found.
Definition: cfg+.h:88
cfg_clear_property
int cfg_clear_property(const CFG_CONTEXT con, enum cfg_property_type type)
Clear all strings of property.
CFG_ERR_BADOPT
An option's argument could not be parsed.
Definition: cfg+.h:64
CFG_FILE_OPTION_ARG_SEPARATOR
Config file option argument separator.
Definition: cfg+.h:295
cfg_set_context_flag
void cfg_set_context_flag(const CFG_CONTEXT con, int flag)
Set context flag.
CFG_SKIP_FIRST
Skip processing of the first argument on command line.
Definition: cfg+.h:136
cfg_flag
cfg_flag
By default are CFG_PROCESS_FIRST, CFG_POSIXLY_LEFTOVERS and CFG_NORMAL_LEFTOVERS initialized.
Definition: cfg+.h:124
cfg_option_type
cfg_option_type
Possible types of options.
Definition: cfg+.h:182
CFG_ERR_OVERFLOW
A given number was too big or too small.
Definition: cfg+.h:76
cfg_context::cur_opt
char * cur_opt
Current option string.
Definition: cfg+.h:465
cfg_print_error
void cfg_print_error(const CFG_CONTEXT con)
Print error string to stderr.
cfg_get_cmdline_context
CFG_CONTEXT cfg_get_cmdline_context(long begin_pos, long size, char **argv, struct cfg_option *options)
Initialize command line context.
cfg_get_context_flag
int cfg_get_context_flag(const CFG_CONTEXT con, int flag)
Get context flag.
CFG_ADVANCED_LEFTOVERS
Advanced leftover arguments.
Definition: cfg+.h:142
cfg_context::error_code
enum cfg_error error_code
Error code of last occured error.
Definition: cfg+.h:454
cfg_context::filename
char * filename
Filename (name of file)
Definition: cfg+.h:491
CFG_ERR_BADNUMBER
An option could not be converted to appropriate numeric type.
Definition: cfg+.h:72
CFG_LAST_ARGS
Leftover arguments specification.
Definition: cfg+.h:234
CFG_ERR_NOEQUAL
No equal sign on the line.
Definition: cfg+.h:94
cfg_context
Main structure for defining context.
Definition: cfg+.h:427
CFG_LONG_OPTION
Long command line option.
Definition: cfg+.h:390
CFG_FILE_MULTI_LINE_POSTFIX
Array of string postfixes to determine multi lines.
Definition: cfg+.h:291
CFG_MULTI_VALS_SEPARATOR
Multi values separator.
Definition: cfg+.h:333
CFG_LINE_NORMAL_MULTI_VALS_SEPARATOR
Command line multi values separator.
Definition: cfg+.h:270
cfg_set_cmdline_context
void cfg_set_cmdline_context(const CFG_CONTEXT con, long begin_pos, long size, char **argv)
Set context to command line.
cfg_set_context_flags
void cfg_set_context_flags(const CFG_CONTEXT con, int flags)
Overwrite context flags.
cfg_context::flags
int flags
Flags.
Definition: cfg+.h:438
cfg_option::cmdline_short_name
const char cmdline_short_name
Command line short name (may be '\0')
Definition: cfg+.h:409
CFG_PROCESS_FIRST
Process also the first argument on command line.
Definition: cfg+.h:133
cfg_get_static_error_str
char * cfg_get_static_error_str(const int errorcode)
Get static error string.
CFG_OK
OK, all is right.
Definition: cfg+.h:52
cfg_context::cur_opt_type
int cur_opt_type
Context type (command line or config file)
Definition: cfg+.h:462
cfg_get_cur_arg
char * cfg_get_cur_arg(const CFG_CONTEXT con)
Return currently processed option argument.
cfg_add_property
int cfg_add_property(const CFG_CONTEXT con, enum cfg_property_type type, char *str)
Add string to property.
cfg_error
cfg_error
Possible return values returned by parsing functions.
Definition: cfg+.h:46
cfg_fprint_error
void cfg_fprint_error(const CFG_CONTEXT con, FILE *fh)
Print error string to stream.
CFG_END
End (to mark last item in list)
Definition: cfg+.h:215
cfg_free_context
void cfg_free_context(const CFG_CONTEXT con)
Destroy context.
CFG_LINE_SHORT_OPTION_PREFIX
Command line short option prefix.
Definition: cfg+.h:258
CFG_LONG_SEPINIT
Long command line option argument initialized with separator.
Definition: cfg+.h:396
CFG_NO_CONTEXT
No context.
Definition: cfg+.h:365