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.27 and 1.28

version 1.27, 2002/04/05 03:31:21 version 1.28, 2002/04/07 12:47:08
Line 34 
Line 34 
 #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
    */
   /*@{*/
   /**
  * Possible return values returned by parsing functions.   * Possible return values returned by parsing functions.
  */   */
 enum cfg_error {  enum cfg_error {
Line 104  enum cfg_error {
Line 108  enum cfg_error {
         CFG_ERROR_INTERNAL = -20          CFG_ERROR_INTERNAL = -20
   
 };  };
   /*@}*/
   
 /**  /**
  * Context flags   * @name Context flags
  *   */
   /*@{*/
   /**
  * By default are @ref CFG_SKIP_FIRST, @ref CFG_POSIXLY_LEFTOVERS and   * By default are @ref CFG_SKIP_FIRST, @ref CFG_POSIXLY_LEFTOVERS and
  * @ref CFG_NORMAL_LEFTOVERS initialized.   * @ref CFG_NORMAL_LEFTOVERS initialized.
  * @todo CFG_APPEND, CFG_OVERWRITE, CFG_APPEND_MULTI_ONLY   * @todo CFG_APPEND, CFG_OVERWRITE, CFG_APPEND_MULTI_ONLY
Line 136  enum cfg_flag {
Line 143  enum cfg_flag {
         CFG_NORMAL_LEFTOVERS = 0,          CFG_NORMAL_LEFTOVERS = 0,
   
         /** Strict leftover arguments initialization in file. */          /** Strict leftover arguments initialization in file. */
         CFG_STRICT_LEFTOVERS = 16,          CFG_STRICT_LEFTOVERS = 16
   
         /* Ignore all quotations in options arguments. */                  /* Ignore all quotations in options arguments. */
         /*                  /*
            CFG_USE_QUOTE = 0,                     CFG_USE_QUOTE = 0,
            CFG_IGNORE_QUOTE = 16                     CFG_IGNORE_QUOTE = 16
            */                     */
         /* Advanced quotations are things like  option = va"'l'"ue                  /* Advanced quotations are things like  option = va"'l'"ue
            which resolves to                                    va'l'ue.                     which resolves to                                    va'l'ue.
   
            We really want this strange stuff? Any volunter?                     We really want this strange stuff? Any volunter?
   
            CFG_ADVANCED_QUOTE = 32 + 16                     CFG_ADVANCED_QUOTE = 32 + 16
            */                     */
   
 };  };
   /*@}*/
   
 /**  /**
  * Option types   * @name Option types
  *   */
   /*@{*/
   /**
  * Possible types of options   * Possible types of options
  * @todo Thinking about case insensitivy of option   * @todo Thinking about case insensitivy of option
  * ("--input" is the same as "--INPUT")   * ("--input" is the same as "--INPUT")
Line 218  enum cfg_option_type {
Line 228  enum cfg_option_type {
         CFG_LEFTOVER_ARGUMENTS = 128          CFG_LEFTOVER_ARGUMENTS = 128
   
 };  };
   /*@}*/
   
 /**  /**
    * @name Internal enumerations
    */
   /*@{*/
   /**
  * Context type   * Context type
  *   *
  * Possible types of context (used internally)   * Possible types of context (used internally)
Line 263  enum cfg_line_option_type {
Line 278  enum cfg_line_option_type {
         /** Long command line option argument initialized without separator (default) */          /** Long command line option argument initialized without separator (default) */
         CFG_LONG_NOSEPINIT = 0          CFG_LONG_NOSEPINIT = 0
 };  };
   /*@}*/
   
 /**  /**
  * @brief Structure for defining one config option   * @brief Structure for defining one config option
Line 279  struct cfg_option {
Line 295  struct cfg_option {
           @see cfg_option_type */            @see cfg_option_type */
         const enum cfg_option_type type;          const enum cfg_option_type type;
   
         /** Value */          /** Pointer where to store value of option */
         void *value;          void *value;
   
         /** Return value (set to 0 for not return) */          /** Return value (set to 0 for not return) */
Line 327  struct cfg_context {
Line 343  struct cfg_context {
         char *cur_opt;          char *cur_opt;
         char *cur_arg;          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;
   
         /** default: "-" */          /** default: "-" */
Line 354  struct cfg_context {
Line 370  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.
          default: "[" */           * default: "["
            */
         char **file_stop_prefix;          char **file_stop_prefix;
   
         /** Array of string prefixes which mark comment line.          /** Array of string prefixes which mark comment line.
         defaults: "#", ";" */           * defaults: "#", ";"
            */
         char **comment_prefix;          char **comment_prefix;
   
         /** Array of string postfixes to determine multi lines. */          /** Array of string postfixes to determine multi lines. */
         char **multi_line_postfix;          char **multi_line_postfix;
   
         /** Option argument separator.          /** Option argument separator.
          default: "=" */            default: "=" */
         char **file_option_arg_separator;          char **file_option_arg_separator;
   
         /** Multi values separator. */          /** Multi values separator. */
Line 387  typedef struct cfg_context * CFG_CONTEXT
Line 405  typedef struct cfg_context * CFG_CONTEXT
 extern "C" {  extern "C" {
 #endif  #endif
   
         /* Getting & modifying context functions. */          /**
            * @name Functions for creating and manipulating context
            */
           /*@{*/
   
           /**
            * Initialize core context
            *
            * @param options       pointer to options table
            * @return                      initialized core context; further specification
            *                                      to command line or config file is required
            */
         CFG_CONTEXT cfg_get_context(struct cfg_option *options);          CFG_CONTEXT cfg_get_context(struct cfg_option *options);
   
           /**
            * Initialize command line context
            *
            * @param argc          number of arguments
            * @param argv          arguments array
            * @param options       pointer to options table
            * @return                      initialized command line context
            */
         CFG_CONTEXT cfg_get_cmdline_context(          CFG_CONTEXT cfg_get_cmdline_context(
                         int argc,                          int argc,
                         char **argv,                          char **argv,
                         struct cfg_option *options);                          struct cfg_option *options);
   
           /**
            * Initialize config line context
            *
            * @param begin_pos     starting position in file to parse
            * @param end_pos       ending position of file to parse
            * @param filename      parsed filename
            * @param options       pointer to options table
            * @return                      initialized command line context
            */
         CFG_CONTEXT cfg_get_cfgfile_context(          CFG_CONTEXT cfg_get_cfgfile_context(
                         long begin_pos,                          long begin_pos,
                         long end_pos,                          long end_pos,
                         char *filename,                          char *filename,
                         struct cfg_option *options);                          struct cfg_option *options);
   
           /**
            * Set context to command line
            *
            * @param con           initialized context
            * @param argc          number of arguments
            * @param argv          arguments array
            * @return                      void
            */
         void cfg_set_cmdline_context(          void cfg_set_cmdline_context(
                         const CFG_CONTEXT con,                          const CFG_CONTEXT con,
                         int argc,                          int argc,
                         char **argv);                          char **argv);
   
           /**
            * Set context to command line
            *
            * @param con           initialized context
            * @param begin_pos     starting position in file to parse
            * @param end_pos       ending position of file to parse
            * @param filename      parsed filename
            * @return                      void
            */
         void cfg_set_cfgfile_context(          void cfg_set_cfgfile_context(
                         const CFG_CONTEXT con,                          const CFG_CONTEXT con,
                         long begin_pos,                          long begin_pos,
                         long end_pos,                          long end_pos,
                         char *filename);                          char *filename);
   
         /* Context flags & special properties manipulation. */          /**
            * Reinitialize popt context
            *
            * @param con           initialized context
            * @return                      void
            */
           void cfg_reset_context(const CFG_CONTEXT con);
   
           /**
            * Destroy context
            *
            * @param con           initialized context
            * @return                      void
            */
           void cfg_free_context(const CFG_CONTEXT con);
   
           /*@}*/
   
           /**
            * @name Functions for setting and clearing context flags
            */
           /*@{*/
   
           /**
            * Set context flag
            *
            * @param con   initialized context
            * @param flag  context flag
            * @return              void
            */
         void cfg_set_context_flag(const CFG_CONTEXT con, int flag);          void cfg_set_context_flag(const CFG_CONTEXT con, int flag);
   
           /**
            * Clear context flag
            *
            * @param con   initialized context
            * @param flag  context flag
            * @return              void
            */
         void cfg_clear_context_flag(const CFG_CONTEXT con, int flag);          void cfg_clear_context_flag(const CFG_CONTEXT con, int flag);
   
           /**
            * Get context flag
            *
            * @param con   initialized context
            * @param flag  context flag
            * @return              0 on false, non-zero on true
            */
         int cfg_get_context_flag(const CFG_CONTEXT con, int flag);          int cfg_get_context_flag(const CFG_CONTEXT con, int flag);
   
           /**
            * Overwrite context flags
            *
            * @param con   initialized context
            * @param flags context flags
            * @return              void
            */
         void cfg_set_context_flags(const CFG_CONTEXT con, int flags);          void cfg_set_context_flags(const CFG_CONTEXT con, int flags);
         int cfg_get_context_flags(const CFG_CONTEXT con, int flags);  
           /**
            * Get all context flags
            *
            * @param con   initialized context
            * @return              all context flags
            */
           int cfg_get_context_flags(const CFG_CONTEXT con);
   
   #define cfg_is_context_flag(con, flag) cfg_get_context_flag(con, flag)
   
           /*@}*/
   
           /**
            * @name Functions and macros for special properties manipulation
            */
           /*@{*/
   
         void cfg_clear_multi_vals_separator(const CFG_CONTEXT con);          void cfg_clear_multi_vals_separator(const CFG_CONTEXT con);
         int cfg_add_multi_vals_separator(const CFG_CONTEXT con, char *str);          int cfg_add_multi_vals_separator(const CFG_CONTEXT con, char *str);
Line 435  extern "C" {
Line 565  extern "C" {
         int cfg_remove_quote_strings(const CFG_CONTEXT con,          int cfg_remove_quote_strings(const CFG_CONTEXT con,
                         char *prefix, char *postfix);                          char *prefix, char *postfix);
   
 #define cfg_is_context_flag(con, flag) cfg_get_context_flag(con, flag)  
   
 #define cfg_clear_cmdline_stop_string(con) \  #define cfg_clear_cmdline_stop_string(con) \
         __cfg_clear_strdyn_array(&((con)->line_stop_str))          __cfg_clear_strdyn_array(&((con)->line_stop_str))
 #define cfg_add_cmdline_stop_string(con, str) \  #define cfg_add_cmdline_stop_string(con, str) \
Line 507  extern "C" {
Line 635  extern "C" {
 #define cfg_remove_cfgfile_option_arg_separator(con, str) \  #define cfg_remove_cfgfile_option_arg_separator(con, str) \
                 __cfg_remove_strdyn_array(&((con)->file_option_arg_separator), str)                  __cfg_remove_strdyn_array(&((con)->file_option_arg_separator), str)
   
                 /* Processing context options. */                  /*@}*/
   
                   /**
                    * @name Functions for processing context options
                    */
                   /*@{*/
   
                   /**
                    * Parse context
                    *
                    * @param con   initialized context
                    * @return              code of error (CFG_ERR_*) or CFG_OK
                    * @see                 cfg_error
                    */
                 int cfg_parse(const CFG_CONTEXT con);                  int cfg_parse(const CFG_CONTEXT con);
   
           /**
            * Return value of next option found
            *
            * @param con   initialized context
            * @return              next option val, code of error (CFG_ERR_*)
            *                              or CFG_OK on end
            * @see                 cfg_error
            * @see                 cfg_context
            */
         int cfg_get_next_opt(const CFG_CONTEXT con);          int cfg_get_next_opt(const CFG_CONTEXT con);
   
           /**
            * Return currently processed option name
            *
            * @param con   initialized context
            * @return              pointer to current option name
            */
         char *cfg_get_cur_opt(const CFG_CONTEXT con);          char *cfg_get_cur_opt(const CFG_CONTEXT con);
         char *cfg_get_cur_arg(const CFG_CONTEXT con);  
         int cfg_get_cur_idx(const CFG_CONTEXT con);  
   
         /* Reseting context. */          /**
            * Return currently processed option argument
            *
            * @param con   initialized context
            * @return              pointer to current option argument
            */
           char *cfg_get_cur_arg(const CFG_CONTEXT con);
   
         void cfg_reset_context(const CFG_CONTEXT con);          /**
            * Return currently processed option index
            *
            * @param con   initialized context
            * @return              index of current option
            */
           int cfg_get_cur_idx(const CFG_CONTEXT con);
   
         /* Freeing context. */          /*@}*/
   
         void cfg_free_context(const CFG_CONTEXT con);  
   
         /* Error string getting. */          /**
            * @name Others functions
            */
           /*@{*/
   
           /**
            * Get error string
            *
            * @param errorcode     code of libcfg error
            * @return                      static error string
            */
         const char *cfg_get_error_str(const int errorcode);          const char *cfg_get_error_str(const int errorcode);
           /*@}*/
   
 #ifdef __cplusplus  #ifdef __cplusplus
 }  }

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

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