| version 1.13, 2001/12/05 23:58:48 |
version 1.14, 2001/12/08 18:23:52 |
|
|
| #ifndef _PLATON_CFG_H |
#ifndef _PLATON_CFG_H |
| #define _PLATON_CFG_H |
#define _PLATON_CFG_H |
| |
|
| |
#include "props.h" |
| |
|
| #define CFG_END_OPTION { NULL, '\0', NULL, CFG_END, NULL, 0 } |
#define CFG_END_OPTION { NULL, '\0', NULL, CFG_END, NULL, 0 } |
| #define CFG_END_OF_LIST CFG_END_OPTION |
#define CFG_END_OF_LIST CFG_END_OPTION |
| |
|
|
|
| /* Ignore unknown options. */ |
/* Ignore unknown options. */ |
| CFG_IGNORE_UNKNOWN = 2, |
CFG_IGNORE_UNKNOWN = 2, |
| |
|
| |
/* Process also the first argument on command line. */ |
| CFG_SKIP_FIRST = 0, |
CFG_SKIP_FIRST = 0, |
| CFG_PROCESS_FIRST = 4, |
CFG_PROCESS_FIRST = 4, |
| |
|
| |
/* Ignore all quotations in options arguments. */ |
| |
CFG_USE_QUOTE = 0, |
| |
CFG_IGNORE_QUOTE = 8, |
| |
|
| |
/* Posixly corect or not leftover arguments. */ |
| |
CFG_POSIXLY_LEFTOVERS = 0, |
| |
CFG_ADVANCED_LEFTOVERS = 16, |
| |
CFG_EXTENDED_LEFTOVERS = 16, |
| |
|
| /* TODO: |
/* TODO: |
| CFG_APPEND, |
CFG_APPEND, |
| CFG_OVERWRITE, |
CFG_OVERWRITE, |
| Line 226 struct cfg_context { |
|
| Line 238 struct cfg_context { |
|
| char **line_stop_str; |
char **line_stop_str; |
| |
|
| /* Multi values separator. */ |
/* Multi values separator. */ |
| char **multi_separator; |
char **multi_vals_separator; |
| |
|
| /* Prefixes and option argument separator. */ |
/* Prefixes and option argument separator. */ |
| char **short_option_prefix; /* default: "-" */ |
char **short_option_prefix; /* default: "-" */ |
| Line 244 struct cfg_context { |
|
| Line 256 struct cfg_context { |
|
| FILE *fhandle; |
FILE *fhandle; |
| |
|
| /* Array of strings prefixes which forces to stop config file parsing. */ |
/* Array of strings prefixes which forces to stop config file parsing. */ |
| char **file_stop_str; /* default: "[" */ |
char **file_stop_prefix; /* default: "[" */ |
| |
|
| /* Array of string prefixes which mark comment line. */ |
/* Array of string prefixes which mark comment line. */ |
| char **comment_str; /* defaults: "#", ";" */ |
char **comment_prefix; /* defaults: "#", ";" */ |
| |
|
| |
/* Array of string postfixes to determine multi lines. */ |
| |
char **multi_line_postfix; |
| |
|
| /* Option argument separator. */ |
/* Option argument separator. */ |
| char **file_option_arg_separator; /* default: "=" */ |
char **file_option_arg_separator; /* default: "=" */ |
|
|
| |
|
| void cfg_set_context_flags(const CFG_CONTEXT con, int flags); |
void cfg_set_context_flags(const CFG_CONTEXT con, int flags); |
| |
|
| void cfg_clear_cmdline_stop_str(const CFG_CONTEXT con); |
#define cfg_clear_cmdline_stop_str(con) \ |
| void cfg_add_cmdline_stop_str(const CFG_CONTEXT con, char *str); |
__cfg_clear_strdyn_array(&con->line_stop_str) |
| |
#define cfg_add_cmdline_stop_str(con, str) \ |
| void cfg_clear_cfgfile_stop_str(const CFG_CONTEXT con); |
__cfg_add_strdyn_array(&con->line_stop_str, str) |
| void cfg_add_cfgfile_stop_str(const CFG_CONTEXT con, char *str); |
#define cfg_remove_cmdline_stop_str(con, str) \ |
| |
__cfg_remove_strdyn_array(&con->line_stop_str, str) |
| void cfg_clear_cfgfile_comment_str(const CFG_CONTEXT con); |
|
| void cfg_add_cfgfile_comment_str(const CFG_CONTEXT con, char *str); |
#define cfg_clear_cfgfile_stop_prefix(con) \ |
| |
__cfg_clear_strdyn_array(&con->file_stop_prefix) |
| void cfg_clear_cmdline_short_option_prefix(const CFG_CONTEXT con); |
#define cfg_add_cfgfile_stop_prefix(con, str) \ |
| void cfg_add_cmdline_short_option_prefix(const CFG_CONTEXT con, char *str); |
__cfg_add_strdyn_array(&con->file_stop_prefix, str) |
| |
#define cfg_remove_cfgfile_stop_prefix(con, str) \ |
| void cfg_clear_cmdline_long_option_prefix(const CFG_CONTEXT con); |
__cfg_remove_strdyn_array(&con->file_stop_prefix, str) |
| void cfg_add_cmdline_long_option_prefix(const CFG_CONTEXT con, char *str); |
|
| |
#define cfg_clear_cfgfile_comment_prefix(con) \ |
| void cfg_clear_cmdline_multi_separator(const CFG_CONTEXT con); |
__cfg_clear_strdyn_array(&con->comment_prefix) |
| void cfg_add_cmdline_multi_separator(const CFG_CONTEXT con, char *str); |
#define cfg_add_cfgfile_comment_prefix(con, str) \ |
| |
__cfg_add_strdyn_array(&con->comment_prefix, str) |
| void cfg_clear_cmdline_option_arg_separator(const CFG_CONTEXT con); |
#define cfg_remove_cfgfile_comment_prefix(con, str) \ |
| void cfg_add_cmdline_option_arg_separator(const CFG_CONTEXT con, char *str); |
__cfg_remove_strdyn_array(&con->comment_prefix, str) |
| |
|
| void cfg_clear_cfgfile_option_arg_separator(const CFG_CONTEXT con); |
#define cfg_clear_cmdline_short_option_prefix(con) \ |
| void cfg_add_cfgfile_option_arg_separator(const CFG_CONTEXT con, char *str); |
__cfg_clear_strdyn_array(&con->short_option_prefix) |
| |
#define cfg_add_cmdline_short_option_prefix(con, str) \ |
| |
__cfg_add_strdyn_array(&con->short_option_prefix, str) |
| |
#define cfg_remove_cmdline_short_option_prefix(con, str) \ |
| |
__cfg_remove_strdyn_array(&con->short_option_prefix, str) |
| |
|
| |
#define cfg_clear_cmdline_long_option_prefix(con) \ |
| |
__cfg_clear_strdyn_array(&con->long_option_prefix) |
| |
#define cfg_add_cmdline_long_option_prefix(con, str) \ |
| |
__cfg_add_strdyn_array(&con->long_option_prefix, str) |
| |
#define cfg_remove_cmdline_long_option_prefix(con, str) \ |
| |
__cfg_remove_strdyn_array(&con->long_option_prefix, str) |
| |
|
| |
#define cfg_clear_cmdline_multi_vals_separator(con) \ |
| |
__cfg_clear_strdyn_array(&con->multi_vals_separator) |
| |
#define cfg_add_cmdline_multi_vals_separator(con, str) \ |
| |
__cfg_add_strdyn_array(&con->multi_vals_separator, str) |
| |
#define cfg_remove_cmdline_multi_vals_separator(con, str) \ |
| |
__cfg_remove_strdyn_array(&con->multi_vals_separator, str) |
| |
|
| |
#define cfg_clear_cfgfile_multi_line_postfix(con) \ |
| |
__cfg_clear_strdyn_array(&con->multi_line_postfix) |
| |
#define cfg_add_cfgfile_multi_line_postfix(con, str) \ |
| |
__cfg_add_strdyn_array(&con->multi_line_postfix, str) |
| |
#define cfg_remove_cfgfile_multi_line_postfix(con, str) \ |
| |
__cfg_remove_strdyn_array(&con->multi_line_postfix, str) |
| |
|
| |
#define cfg_clear_cmdline_option_arg_separator(con) \ |
| |
__cfg_clear_strdyn_array(&con->line_option_arg_separator) |
| |
#define cfg_add_cmdline_option_arg_separator(con, str) \ |
| |
__cfg_add_strdyn_array(&con->line_option_arg_separator, str) |
| |
#define cfg_remove_cmdline_option_arg_separator(con, str) \ |
| |
__cfg_remove_strdyn_array(&con->line_option_arg_separator, str) |
| |
|
| |
#define cfg_clear_cfgfile_option_arg_separator(con) \ |
| |
__cfg_clear_strdyn_array(&con->file_option_arg_separator) |
| |
#define cfg_add_cfgfile_option_arg_separator(con, str) \ |
| |
__cfg_add_strdyn_array(&con->file_option_arg_separator, str) |
| |
#define cfg_remove_cfgfile_option_arg_seaprator(con, str) \ |
| |
__cfg_remove_strdyn_array(&con->file_option_arg_separator, str) |
| |
|
| |
/* |
| |
void cfg_clear_cmdline_stop_str(const CFG_CONTEXT con); |
| |
void cfg_add_cmdline_stop_str(const CFG_CONTEXT con, char *str); |
| |
void cfg_clear_cfgfile_stop_prefix(const CFG_CONTEXT con); |
| |
void cfg_add_cfgfile_stop_prefix(const CFG_CONTEXT con, char *str); |
| |
|
| |
void cfg_clear_cfgfile_comment_prefix(const CFG_CONTEXT con); |
| |
void cfg_add_cfgfile_comment_prefix(const CFG_CONTEXT con, char *str); |
| |
|
| |
void cfg_clear_cmdline_short_option_prefix(const CFG_CONTEXT con); |
| |
void cfg_add_cmdline_short_option_prefix(const CFG_CONTEXT con, char *str); |
| |
|
| |
void cfg_clear_cmdline_long_option_prefix(const CFG_CONTEXT con); |
| |
void cfg_add_cmdline_long_option_prefix(const CFG_CONTEXT con, char *str); |
| |
|
| |
void cfg_clear_cmdline_multi_vals_separator(const CFG_CONTEXT con); |
| |
void cfg_add_cmdline_multi_vals_separator(const CFG_CONTEXT con, char *str); |
| |
|
| |
void cfg_clear_cmdline_option_arg_separator(const CFG_CONTEXT con); |
| |
void cfg_add_cmdline_option_arg_separator(const CFG_CONTEXT con, char *str); |
| |
|
| |
void cfg_clear_cfgfile_multi_line_postfix(const CFG_CONTEXT con); |
| |
void cfg_add_cfgfile_multi_line_postfix(const CFG_CONTEXT con, char *str); |
| |
|
| |
void cfg_clear_cfgfile_option_arg_separator(const CFG_CONTEXT con); |
| |
void cfg_add_cfgfile_option_arg_separator(const CFG_CONTEXT con, char *str); |
| |
*/ |
| |
|
| /* Processing context options. */ |
/* Processing context options. */ |
| |
|
| int cfg_parse(const CFG_CONTEXT con); |
int cfg_parse(const CFG_CONTEXT con); |
| int cfg_get_next_opt(const CFG_CONTEXT con); |
int cfg_get_next_opt(const CFG_CONTEXT con); |
| int cfg_get_opt_arg(const CFG_CONTEXT con); |
int cfg_get_opt_arg(const CFG_CONTEXT con); |
| char *cfg_get_cur_opt(const CFG_CONTEXT con); |
char *cfg_get_cur_opt(const CFG_CONTEXT con); |