| verzia 1.6, 2001/10/16 18:22:17 |
verzia 1.7, 2001/10/23 00:05:18 |
| Riadok 16 enum cfg_error { |
|
| Riadok 16 enum cfg_error { |
|
| CFG_ERR_NOARG = -1, |
CFG_ERR_NOARG = -1, |
| CFG_ERROR_NOARG = -1, |
CFG_ERROR_NOARG = -1, |
| |
|
| |
/* An argument is not allowed for an option. */ |
| |
CFG_ERR_NOTALLOWEDARG = -2, |
| |
CFG_ERROR_NOTALLOWEDARG = -2, |
| |
|
| /* An option's argument could not be parsed. */ |
/* An option's argument could not be parsed. */ |
| CFG_ERR_BADOPT = -2, |
CFG_ERR_BADOPT = -3, |
| CFG_ERROR_BADOPT = -2, |
CFG_ERROR_BADOPT = -3, |
| |
|
| /* Error in quotations. */ |
/* Error in quotations. */ |
| CFG_ERR_BADQUOTE = -3, |
CFG_ERR_BADQUOTE = -4, |
| CFG_ERROR_BADQUOTE = -3, |
CFG_ERROR_BADQUOTE = -4, |
| |
|
| /* An option could not be converted to appropiate numeric type. */ |
/* An option could not be converted to appropiate numeric type. */ |
| CFG_ERR_BADNUMBER = -4, |
CFG_ERR_BADNUMBER = -5, |
| CFG_ERROR_BADNUMBER = -4, |
CFG_ERROR_BADNUMBER = -5, |
| |
|
| /* A given number was too big or too small. */ |
/* A given number was too big or too small. */ |
| CFG_ERR_OVERFLOW = -5, |
CFG_ERR_OVERFLOW = -6, |
| CFG_ERROR_OVERFLOW = -5, |
CFG_ERROR_OVERFLOW = -6, |
| |
|
| /* Multiple arguments user for single option. */ |
/* Multiple arguments user for single option. */ |
| CFG_ERR_MULTI = -6, |
CFG_ERR_MULTI = -7, |
| CFG_ERROR_MULTI = -6, |
CFG_ERROR_MULTI = -7, |
| |
|
| /* An unknown option. */ |
/* Not enough memory. */ |
| CFG_ERR_UNKNOWN = -7, |
CFG_ERR_NOMEM = -8, |
| CFG_ERROR_UNKNOWN = -7, |
CFG_ERROR_NOMEM = -8, |
| |
|
| /* Stop string was found. */ |
/* Stop string was found. */ |
| CFG_ERR_STOP_STR = -8, |
CFG_ERR_STOP_STR = -9, |
| CFG_ERR_STOP_STR_FOUND = -8, |
CFG_ERR_STOP_STR_FOUND = -9, |
| CFG_ERROR_STOP_STR = -8, |
CFG_ERROR_STOP_STR = -9, |
| CFG_ERROR_STOP_STR_FOUND = -8, |
CFG_ERROR_STOP_STR_FOUND = -9, |
| |
|
| /* No equal sign on the line. */ |
/* No equal sign on the line. */ |
| CFG_ERR_NOEQUAL = -9, |
CFG_ERR_NOEQUAL = -10, |
| CFG_ERROR_NOEQUAL = -9, |
CFG_ERROR_NOEQUAL = -10, |
| |
|
| |
/* An unknown option. */ |
| |
CFG_ERR_UNKNOWN = -15, |
| |
CFG_ERROR_UNKNOWN = -15, |
| |
|
| /* Internal error. */ |
/* Internal error. */ |
| CFG_ERR_INTERNAL = -20, |
CFG_ERR_INTERNAL = -20, |
| Riadok 64 enum cfg_flag { |
|
| Riadok 72 enum cfg_flag { |
|
| /* Ignore unknown options. */ |
/* Ignore unknown options. */ |
| CFG_IGNORE_UNKNOWN = 2, |
CFG_IGNORE_UNKNOWN = 2, |
| |
|
| |
CFG_SKIP_FIRST = 0, |
| |
CFG_PROCESS_FIRST = 4, |
| |
|
| |
/* |
| CFG_APPEND, |
CFG_APPEND, |
| CFG_OVERWRITE, |
CFG_OVERWRITE, |
| CFG_APPEND_MULTI_ONLY |
CFG_APPEND_MULTI_ONLY |
| |
*/ |
| }; |
}; |
| |
|
| enum cfg_option_type { |
enum cfg_option_type { |
| Riadok 119 enum cfg_option_type { |
|
| Riadok 132 enum cfg_option_type { |
|
| CFG_LEFTOVER_ARGS = 128, |
CFG_LEFTOVER_ARGS = 128, |
| CFG_LEFTOVER_ARGUMENTS = 128 |
CFG_LEFTOVER_ARGUMENTS = 128 |
| |
|
| |
/* TODO: Thinking about case insensitivy of option. (--input, --INPUT) */ |
| |
|
| }; |
}; |
| |
|
| enum cfg_context_type { |
enum cfg_context_type { |
| Riadok 132 enum cfg_context_type { |
|
| Riadok 147 enum cfg_context_type { |
|
| CFG_FILE = 2 |
CFG_FILE = 2 |
| }; |
}; |
| |
|
| |
enum cfg_line_option_type { |
| |
|
| |
/* Not long and not short option. */ |
| |
CFG_NONE_OPTION = 0, |
| |
|
| |
/* Short command line option. */ |
| |
CFG_SHORT_OPTION = 1, |
| |
|
| |
/* Short command line options. */ |
| |
CFG_SHORT_OPTIONS = 2, |
| |
|
| |
/* Long command line option. */ |
| |
CFG_LONG_OPTION = 3, |
| |
|
| |
/* Long command line option argument initialized with separator. */ |
| |
CFG_LONG_SEPINIT = 4, |
| |
CFG_LONG_NOSEPINIT = 0 |
| |
}; |
| |
|
| struct cfg_option { |
struct cfg_option { |
| const char *cmdline_long_name; |
const char *cmdline_long_name; |
| const char cmdline_short_name; |
const char cmdline_short_name; |
| Riadok 166 struct cfg_context { |
|
| Riadok 200 struct cfg_context { |
|
| int argc; |
int argc; |
| char **argv; |
char **argv; |
| |
|
| |
int cur_idx; |
| |
|
| |
int cur_opt_type; |
| |
char *cur_opt; |
| |
char *cur_arg; |
| |
|
| /* Array of strings which forces to stop command line parsing. */ |
/* Array of strings which forces to stop command line parsing. */ |
| char **line_stop_str; |
char **line_stop_str; |
| |
|
| /* Multi values separator. */ |
/* Multi values separator. */ |
| char **multi_separator; |
char **multi_separator; |
| |
|
| |
/* Prefixes and option argument separator. */ |
| /* THIS WILL BE IMPLEMENTED AT THE END! */ |
|
| /* The question is, if it is needed to have this implemented. */ |
|
| char **short_option_prefix; /* default: "-" */ |
char **short_option_prefix; /* default: "-" */ |
| char **long_option_prefix; /* default: "--" */ |
char **long_option_prefix; /* default: "--" */ |
| char **line_option_arg_separator; /* default: "=" */ |
char **line_option_arg_separator; /* default: "=" */ |
| Riadok 193 struct cfg_context { |
|
| Riadok 231 struct cfg_context { |
|
| /* Array of string prefixes which mark comment line. */ |
/* Array of string prefixes which mark comment line. */ |
| char **comment_str; |
char **comment_str; |
| |
|
| |
/* Option argument separator. */ |
| char **file_option_arg_separator; /* default: "=" */ |
char **file_option_arg_separator; /* default: "=" */ |
| }; |
}; |
| |
|