cfg+.h   cfg+.h 
skipping to change at line 18 skipping to change at line 18
* Copyright (c) 2001-2002 Platon SDG, http://www.platon.sk/ * Copyright (c) 2001-2002 Platon SDG, http://www.platon.sk/
* All rights reserved. * All rights reserved.
* *
* See README file for more information about this software. * See README file for more information about this software.
* See COPYING file for license information. * See COPYING file for license information.
* *
* Download the latest version from * Download the latest version from
* http://www.platon.sk/projects/libcfg+/ * http://www.platon.sk/projects/libcfg+/
*/ */
/* $Id: cfg+.h,v 1.36 2002/05/20 16:06:09 jombik9 Exp $ */ /* $Id: cfg+.h,v 1.37 2002/05/30 22:29:45 jombik9 Exp $ */
/** /**
* @file cfg+.h * @file cfg+.h
* @brief main implementation header file * @brief main implementation header file
* @author Ondrej Jombik <nepto@pobox.sk> * @author Ondrej Jombik <nepto@pobox.sk>
* @version \$Id: cfg+.h,v 1.36 2002/05/20 16:06:09 jombik9 Exp $ * @version \$Id: cfg+.h,v 1.37 2002/05/30 22:29:45 jombik9 Exp $
* @date 2001-2002 * @date 2001-2002
*/ */
#ifndef _PLATON_CFG_H #ifndef _PLATON_CFG_H
#define _PLATON_CFG_H #define _PLATON_CFG_H
#include <stdio.h> #include <stdio.h>
#include "props.h"
/** End of options list marker */ /** End of options list marker */
#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 /**< @ref CFG_END_OPTION */ #define CFG_END_OF_LIST CFG_END_OPTION /**< @ref CFG_END_OPTION */
/** /**
* @name Error codes * @name Error codes
*/ */
/*@{*/ /*@{*/
/** /**
skipping to change at line 242 skipping to change at line 241
*/ */
CFG_LAST_ARGS = 128, CFG_LAST_ARGS = 128,
CFG_LAST_ARGUMENTS = 128, CFG_LAST_ARGUMENTS = 128,
CFG_LEFTOVER_ARGS = 128, CFG_LEFTOVER_ARGS = 128,
CFG_LEFTOVER_ARGUMENTS = 128 CFG_LEFTOVER_ARGUMENTS = 128
}; };
/*@}*/ /*@}*/
/** /**
* @name Special properties types
*/
/*@{*/
enum cfg_property_type {
/**
* @name Special properties codes
*/
/*@{*/
/** Array of strings which forces to stop command line parsing. */
CFG_LINE_STOP_STRING = 0,
/** default: "-" */
CFG_LINE_SHORT_OPTION_PREFIX = 1,
/** default: "--" */
CFG_LINE_LONG_OPTION_PREFIX = 2,
/** default: "=" */
CFG_LINE_OPTION_ARG_SEPARATOR = 3,
/** Multi values separator. */
CFG_LINE_MULTI_VALS_SEPARATOR = 4,
/** Quote prefix & postfix */
CFG_QUOTE_PREFIX = 5,
CFG_QUOTE_POSTFIX = 6,
/** Array of strings prefixes which forces to stop config file parsi
ng.
* default: "["
*/
CFG_FILE_STOP_PREFIX = 7,
/** Array of string prefixes which mark comment line.
* defaults: "#", ";"
*/
CFG_FILE_COMMENT_PREFIX = 8,
/** Array of string postfixes to determine multi lines. */
CFG_FILE_MULTI_LINE_POSTFIX = 9,
/** Option argument separator.
default: "=" */
CFG_FILE_OPTION_ARG_SEPARATOR = 10,
/** Multi values separator. */
CFG_FILE_MULTI_VALS_SEPARATOR = 11,
/*@}*/
/**
* @name Numbers of normal properties
*/
/*@{*/
/** Special properties count */
CFG_N_PROPS = 12,
/*@}*/
/**
* @name Virtual properties codes
*/
/*@{*/
/* TODO: virtual properties */
CFG_VIRTUAL_SPECIAL_PROPERTY = 13
/*@}*/
};
/*@}*/
/**
* @name Internal enumerations * @name Internal enumerations
*/ */
/*@{*/ /*@{*/
/** /**
* Context type * Context type
* *
* Possible types of context (used internally) * Possible types of context (used internally)
*/ */
enum cfg_context_type { enum cfg_context_type {
skipping to change at line 332 skipping to change at line 401
/** Context type (command line or config file) */ /** Context type (command line or config file) */
enum cfg_context_type type; enum cfg_context_type type;
/** Flags */ /** Flags */
int flags; int flags;
/** Options table */ /** Options table */
const struct cfg_option *options; const struct cfg_option *options;
/** Array of used options indexes */
int *used_opt_idx;
/** Error code of last occured error. */ /** Error code of last occured error. */
enum cfg_error error_code; enum cfg_error error_code;
/** Quote prefix & postfix */ /** Special properties */
char **quote_prefix; char **prop[CFG_N_PROPS];
char **quote_postfix;
/*@}*/ /*@}*/
/** /**
* @name Command line specific properties * @name Command line specific properties
*/ */
/*@{*/ /*@{*/
int argc; int argc;
char **argv; char **argv;
int cur_idx; int cur_idx;
int cur_idx_tmp; int cur_idx_tmp;
int *used_opt_idx;
int cur_opt_type; int cur_opt_type;
char *cur_opt; char *cur_opt;
char *cur_arg; char *cur_arg;
/** Array of strings which forces to stop command line parsing. */
char **line_stop_str;
/** default: "-" */
char **short_option_prefix;
/** default: "--" */
char **long_option_prefix;
/** default: "=" */
char **line_option_arg_separator;
/** Multi values separator. */
char **line_multi_vals_separator;
/*@}*/ /*@}*/
/** /**
* @name Config file specific properties. * @name Config file specific properties.
*/ */
/*@{*/ /*@{*/
long begin_pos; long begin_pos;
long end_pos; long end_pos;
char *filename; char *filename;
skipping to change at line 380 skipping to change at line 437
/*@}*/ /*@}*/
/** /**
* @name Config file specific properties. * @name Config file specific properties.
*/ */
/*@{*/ /*@{*/
long begin_pos; long begin_pos;
long end_pos; long end_pos;
char *filename; char *filename;
FILE *fhandle; FILE *fhandle;
/** Array of strings prefixes which forces to stop config file parsi
ng.
* default: "["
*/
char **file_stop_prefix;
/** Array of string prefixes which mark comment line.
* defaults: "#", ";"
*/
char **comment_prefix;
/** Array of string postfixes to determine multi lines. */
char **multi_line_postfix;
/** Option argument separator.
default: "=" */
char **file_option_arg_separator;
/** Multi values separator. */
char **file_multi_vals_separator;
/*@}*/ /*@}*/
}; };
/** /**
* @brief Context data type * @brief Context data type
*/ */
typedef struct cfg_context * CFG_CONTEXT; typedef struct cfg_context * CFG_CONTEXT;
/* /*
* Functions * Functions
skipping to change at line 561 skipping to change at line 597
* Get all context flags * Get all context flags
* *
* @param con initialized context * @param con initialized context
* @return all context flags * @return all context flags
*/ */
int cfg_get_context_flags(const CFG_CONTEXT con); int cfg_get_context_flags(const CFG_CONTEXT con);
/*@}*/ /*@}*/
/** /**
* @name Functions and macros for special properties manipulation * @name Functions and macros for properties manipulation
*/ */
/*@{*/ /*@{*/
void cfg_clear_multi_vals_separator(const CFG_CONTEXT con); /**
int cfg_add_multi_vals_separator(const CFG_CONTEXT con, char *str); * Clear all strings of property
int cfg_remove_multi_vals_separator(const CFG_CONTEXT con, char *str *
); * @param con initialized context
* @param type property type
void cfg_clear_option_arg_separator(const CFG_CONTEXT con); * @return void
int cfg_add_option_arg_separator(const CFG_CONTEXT con, char *str); * @see cfg_property_type
int cfg_remove_option_arg_separator(const CFG_CONTEXT con, char *str */
); void cfg_clear_property(
const CFG_CONTEXT con, enum cfg_property_type type);
void cfg_clear_quote_strings(const CFG_CONTEXT con);
int cfg_add_quote_strings(const CFG_CONTEXT con,
char *prefix, char *postfix);
int cfg_remove_quote_strings(const CFG_CONTEXT con,
char *prefix, char *postfix);
#define cfg_clear_cmdline_stop_string(con) \
__cfg_clear_strdyn_array(&((con)->line_stop_str))
#define cfg_add_cmdline_stop_string(con, str) \
__cfg_add_strdyn_array(&((con)->line_stop_str), str)
#define cfg_remove_cmdline_stop_string(con, str) \
__cfg_remove_strdyn_array(&((con)->line_stop_str), str)
#define cfg_clear_cfgfile_stop_prefix(con) \
__cfg_clear_strdyn_array(&((con)->file_stop_prefix))
#define cfg_add_cfgfile_stop_prefix(con, str) \
__cfg_add_strdyn_array(&((con)->file_stop_prefix), str)
#define cfg_remove_cfgfile_stop_prefix(con, str) \
__cfg_remove_strdyn_array(&((con)->file_stop_prefix), str)
#define cfg_clear_cfgfile_comment_prefix(con) \
__cfg_clear_strdyn_array(&((con)->comment_prefix))
#define cfg_add_cfgfile_comment_prefix(con, str) \
__cfg_add_strdyn_array(&((con)->comment_prefix), str)
#define cfg_remove_cfgfile_comment_prefix(con, str) \
__cfg_remove_strdyn_array(&((con)->comment_prefix), str)
#define cfg_clear_cmdline_short_option_prefix(con) \
__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_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_multi_vals_separator(con) \
__cfg_clear_strdyn_array(&((con)->line_multi_vals_separator)
)
#define cfg_add_cmdline_multi_vals_separator(con, str) \
__cfg_add_strdyn_array(&((con)->line_multi_vals_separator),
str)
#define cfg_remove_cmdline_multi_vals_separator(con, str) \
__cfg_remove_strdyn_array(&((con)->line_multi_vals_separator
), str)
#define cfg_clear_cfgfile_multi_vals_separator(con) \
__cfg_clear_strdyn_array(&((con)->file_multi_vals_separator)
)
#define cfg_add_cfgfile_multi_vals_separator(con, str) \
__cfg_add_strdyn_array(&((con)->file_multi_vals_separator),
str)
#define cfg_remove_cfgfile_multi_vals_separator(con, str) \
__cfg_remove_strdyn_array(&((con)->file_multi_vals_separator
), str)
#define cfg_clear_cmdline_option_arg_separator(con) \ /**
__cfg_clear_strdyn_array(&((con)->line_option_arg_separator) * Add string to property
) *
#define cfg_add_cmdline_option_arg_separator(con, str) \ * @param con initialized context
__cfg_add_strdyn_array(&((con)->line_option_arg_separator), * @param type property type
str) * @param str string for addition
#define cfg_remove_cmdline_option_arg_separator(con, str) \ * @return 1 on success, 0 on not enough memory error
__cfg_remove_strdyn_array(&((con)->line_option_arg_separator * @see cfg_property_type
), str) */
int cfg_add_property(
const CFG_CONTEXT con, enum cfg_property_type type,
char *str);
#define cfg_clear_cfgfile_option_arg_separator(con) \ /**
__cfg_clear_strdyn_array(&((con)->file_option_arg_separator) * Remove string from property
) *
#define cfg_add_cfgfile_option_arg_separator(con, str) \ * @param con initialized context
__cfg_add_strdyn_array(&((con)->file_option_arg_separator), * @param type property type
str) * @param str string for removing
#define cfg_remove_cfgfile_option_arg_separator(con, str) \ * @return 1 on success, 0 on not enough memory error
__cfg_remove_strdyn_array(&((con)->file_option_arg_separator * @see cfg_property_type
), str) */
int cfg_remove_property(
const CFG_CONTEXT con, enum cfg_property_type type,
char *str);
/*@}*/ /*@}*/
/** /**
* @name Functions for processing context options * @name Functions for processing context options
*/ */
/*@{*/ /*@{*/
/** /**
* Parse context * Parse context
* *
* @param con initialized context * @param con initialized context
* @return code of error (CFG_ERR_*) or CFG_OK * @return code of error (CFG_ERR_*) or CFG_OK
* @see cfg_error * @see cfg_error
*/ */
int cfg_parse(const CFG_CONTEXT con); int cfg_parse(const CFG_CONTEXT con);
/** /**
* Parse next option(s) and return its value (if non-zero) or error code. * Parse next option(s) and return its value (if non-zero) or error code.
* *
* @param con initialized context * @param con initialized context
* @return next option val, code of error (CFG_ERR_*) * @return next option val, code of error (CFG_ERR_*)
* or CFG_OK on end * or CFG_OK on end
* @see cfg_error * @see cfg_error
* @see cfg_context * @see cfg_context
*/ */
 End of changes. 18 change blocks. 
153 lines changed or deleted 127 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/