Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for libcfg+/src/cfg+.h between version 1.36 and 1.37

version 1.36, 2002/05/20 16:06:09 version 1.37, 2002/05/30 22:29:45
Line 29 
Line 29 
 #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 }
Line 239  enum cfg_option_type {
Line 238  enum cfg_option_type {
 /*@}*/  /*@}*/
   
 /**  /**
    * @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 parsing.
            * 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
  */   */
 /*@{*/  /*@{*/
Line 329  struct cfg_context {
Line 398  struct cfg_context {
         /** 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;  
   
         /*@}*/          /*@}*/
   
Line 348  struct cfg_context {
Line 419  struct cfg_context {
   
         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;  
   
         /*@}*/          /*@}*/
   
         /**          /**
Line 377  struct cfg_context {
Line 434  struct cfg_context {
         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 parsing.  
          * 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;  
   
         /*@}*/          /*@}*/
 };  };
   
Line 558  extern "C" {
Line 594  extern "C" {
         /*@}*/          /*@}*/
   
         /**          /**
          * @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
         void cfg_clear_option_arg_separator(const CFG_CONTEXT con);           * @param type  property type
         int cfg_add_option_arg_separator(const CFG_CONTEXT con, char *str);           * @return              void
         int cfg_remove_option_arg_separator(const CFG_CONTEXT con, char *str);           * @see                 cfg_property_type
            */
         void cfg_clear_quote_strings(const CFG_CONTEXT con);          void cfg_clear_property(
         int cfg_add_quote_strings(const CFG_CONTEXT con,                          const CFG_CONTEXT con, enum cfg_property_type type);
                         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))  
 #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_separator(con, str) \  
                 __cfg_remove_strdyn_array(&((con)->file_option_arg_separator), str)  
   
                 /*@}*/          /**
            * Add string to property
            *
            * @param con   initialized context
            * @param type  property type
            * @param str   string for addition
            * @return              1 on success, 0 on not enough memory error
            * @see                 cfg_property_type
            */
           int cfg_add_property(
                           const CFG_CONTEXT con, enum cfg_property_type type, char *str);
   
           /**
            * Remove string from property
            *
            * @param con   initialized context
            * @param type  property type
            * @param str   string for removing
            * @return              1 on success, 0 on not enough memory error
            * @see                 cfg_property_type
            */
           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  
                  *          /**
                  * @param con   initialized context           * Parse context
                  * @return              code of error (CFG_ERR_*) or CFG_OK           *
                  * @see                 cfg_error           * @param con   initialized context
                  */           * @return              code of error (CFG_ERR_*) or CFG_OK
                 int cfg_parse(const CFG_CONTEXT con);           * @see                 cfg_error
            */
           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.

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top