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/props.c between version 1.16 and 1.17

version 1.16, 2002/04/21 10:08:40 version 1.17, 2002/05/30 22:29:45
Line 17 
Line 17 
   
 /* $Id$ */  /* $Id$ */
   
   /* Includes {{{ */
 #include "config.h"  #include "config.h"
   
 #include <stdio.h>  #include <stdio.h>
   
 #include "str/strdyn.h"  #include "str/strdyn.h"
 #include "cfg+.h"  #include "cfg+.h"
   /* }}} */
   
   /* Default properties {{{ */
   char *cfg_default_properties[CFG_N_PROPS][4] = {
           { NULL, NULL, NULL, NULL }, /* CFG_LINE_STOP_STRING */
           { "-",  NULL, NULL, NULL }, /* CFG_LINE_SHORT_OPTION_PREFIX */
           { "--", NULL, NULL, NULL }, /* CFG_LINE_LONG_OPTION_PREFIX */
           { "=",  NULL, NULL, NULL }, /* CFG_LINE_OPTION_ARG_SEPARATOR */
           { " ",  ",",  ";",  NULL }, /* CFG_LINE_MULTI_VALS_SEPARATOR */
           { "\"", "'",  NULL, NULL }, /* CFG_QUOTE_PREFIX */
   { "\"", "'",  NULL, NULL }, /* CFG_QUOTE_POSTFIX */
   { NULL, NULL, NULL, NULL }, /* CFG_FILE_STOP_PREFIX */
   { "#",  ";",  NULL, NULL }, /* CFG_FILE_COMMENT_PREFIX */
   { "\\", NULL, NULL, NULL }, /* CFG_FILE_MULTI_LINE_POSTFIX */
   { "=",  NULL, NULL, NULL }, /* CFG_FILE_OPTION_ARG_SEPARATOR */
   { " ",  ",",  ";",  NULL }  /* CFG_FILE_MULTI_VALS_SEPARATOR */
   }; /* }}} */
   
   /*
    * Static functions for strdyn manipulation
    */
   
           static void
   strdyn_array_clear(where)
           char ***where;
   { /* {{{ */
           if (*where != NULL)
                   strdyn_free(*where);
   
           *where = NULL;
   } /* }}} */
   
           static int
   strdyn_array_add(where, str)
           char ***where;
           char *str;
   { /* {{{ */
           if (*where == NULL)
                   *where = strdyn_create();
   
           *where = strdyn_add(*where, str);
   
           return *where == NULL ? 0 : 1;
   } /* }}} */
   
           static int
   strdyn_array_remove(where, str)
           char ***where;
           char *str;
   { /* {{{ */
           if (*where != NULL)
                   *where = strdyn_remove_str_all(*where, str);
   
           return *where == NULL ? 0 : 1;
   } /* }}} */
   
   
 /*  /*
  * Functions for context flags manipulation.   * Functions for context flags manipulation.
Line 32 
Line 89 
 cfg_set_context_flag(con, flag)  cfg_set_context_flag(con, flag)
         const CFG_CONTEXT con;          const CFG_CONTEXT con;
         int               flag;          int               flag;
 {  { /* {{{ */
         con->flags |= flag;          con->flags |= flag;
 }  } /* }}} */
   
         void          void
 cfg_clear_context_flag(con, flag)  cfg_clear_context_flag(con, flag)
         const CFG_CONTEXT con;          const CFG_CONTEXT con;
         int               flag;          int               flag;
 {  { /* {{{ */
         con->flags &= ~flag;          con->flags &= ~flag;
 }  } /* }}} */
   
         int          int
 cfg_get_context_flag(con, flag)  cfg_get_context_flag(con, flag)
         const CFG_CONTEXT con;          const CFG_CONTEXT con;
         int               flag;          int               flag;
 {  { /* {{{ */
         return con->flags & flag;          return con->flags & flag;
 }  } /* }}} */
   
   
         void          void
 cfg_set_context_flags(con, flags)  cfg_set_context_flags(con, flags)
         const CFG_CONTEXT con;          const CFG_CONTEXT con;
         int               flags;          int               flags;
 {  { /* {{{ */
         con->flags = flags;          con->flags       = flags;
   
         con->cur_idx_tmp = con->flags & CFG_PROCESS_FIRST ? 0 : 1;          con->cur_idx_tmp = con->flags & CFG_PROCESS_FIRST ? 0 : 1;
 }  } /* }}} */
   
         int          int
 cfg_get_context_flags(con)  cfg_get_context_flags(con)
         const CFG_CONTEXT con;          const CFG_CONTEXT con;
 {  { /* {{{ */
         return con->flags;          return con->flags;
 }  } /* }}} */
   
 /*  /*
  * Functions for multi values separator manipulation.   * Functions for multi values separator manipulation.
  */   */
   
   #define cfg_normal_property_type(type) (type >= 0 && type < CFG_N_PROPS)
   #define cfg_virtual_property_type(type) (type > CFG_N_PROPS)
   
           void
   cfg_clear_property(con, type)
           const CFG_CONTEXT con;
           enum cfg_property_type type;
   { /* {{{ */
           if (cfg_normal_property_type(type)) {
                   strdyn_array_clear(&(con->prop[type]));
           }
           else if (cfg_virtual_property_type(type)) {
                   /* TODO */
           }
   } /* }}} */
   
           int
   cfg_add_property(con, type, str)
           const CFG_CONTEXT con;
           enum cfg_property_type type;
           char *str;
   { /* {{{ */
           if (cfg_normal_property_type(type)) {
                   return strdyn_array_add(&(con->prop[type]), str);
           }
           else if (cfg_virtual_property_type(type)) {
                   /* TODO */
           }
   
           return 0; /* failure */
   } /* }}} */
   
           int
   cfg_remove_property(con, type, str)
           const CFG_CONTEXT con;
           enum cfg_property_type type;
           char *str;
   { /* {{{ */
           if (cfg_normal_property_type(type)) {
                   return strdyn_array_remove(&(con->prop[type]), str);
           }
           else if (cfg_virtual_property_type(type)) {
                   /* TODO */
           }
   
           return 0; /* failure */
   } /* }}} */
   
   #if 0
         void          void
 cfg_clear_multi_vals_separator(con)  cfg_clear_multi_vals_separator(con)
         const CFG_CONTEXT con;          const CFG_CONTEXT con;
Line 162  cfg_remove_quote_strings(con, prefix, po
Line 267  cfg_remove_quote_strings(con, prefix, po
                 && __cfg_remove_strdyn_array(&con->quote_postfix, postfix);                  && __cfg_remove_strdyn_array(&con->quote_postfix, postfix);
 }  }
   
 /*  #endif
  * Universal functions for various properties manipulation.  
  */  
   
         void  
 __cfg_clear_strdyn_array(where)  
         char ***where;  
 {  
         if (*where != NULL)  
                 strdyn_free(*where);  
   
         *where = NULL;  
 }  
   
         int  
 __cfg_add_strdyn_array(where, str)  
         char ***where;  
         char *str;  
 {  
         if (*where == NULL)  
                 *where = strdyn_create();  
   
         *where = strdyn_add(*where, str);  
   
         return *where == NULL ? 0 : 1;  /* Modeline for ViM {{{
 }   * vim:set ts=4:
    * vim600:fdm=marker fdl=0 fdc=0:
         int   * }}} */
 __cfg_remove_strdyn_array(where, str)  
         char ***where;  
         char *str;  
 {  
         if (*where != NULL)  
                 *where = strdyn_remove_str_all(*where, str);  
   
         return *where == NULL ? 0 : 1;  
 }  
   

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

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