Diff for /libaitcfg/src/parse.c between versions 1.10.2.4 and 1.10.2.5

version 1.10.2.4, 2012/09/17 14:17:12 version 1.10.2.5, 2012/09/18 13:24:50
Line 47  SUCH DAMAGE. Line 47  SUCH DAMAGE.
 #include "aitcfg.h"  #include "aitcfg.h"
   
   
 static inline int  
 cfg_Write(FILE *f, char *fmt, ...)  
 {  
         int ret = 0;  
         va_list lst;  
   
         va_start(lst, fmt);  
         ret = vfprintf(f, fmt, lst);  
         va_end(lst);  
   
         return ret;  
 }  
   
 static inline void  static inline void
 _invertQueue(cfg_root_t * __restrict cfg)  _invertQueue(cfg_root_t * __restrict cfg)
 {  {
Line 88  cfgReadConfig(FILE *f, cfg_root_t * __restrict cfg) Line 75  cfgReadConfig(FILE *f, cfg_root_t * __restrict cfg)
         int flg = 0;          int flg = 0;
         char *psAttr, *psVal, szSection[STRSIZ] = { 0 };          char *psAttr, *psVal, szSection[STRSIZ] = { 0 };
   
           if (!f || !cfg) {
                   cfg_SetErr(EINVAL, "Invalid parameter(s)");
                   return -1;
           }
   
         while (!feof(f)) {          while (!feof(f)) {
                 memset(line, 0, sizeof line);                  memset(line, 0, sizeof line);
                 fgets(line, sizeof line - 1, f);                  fgets(line, sizeof line - 1, f);
Line 124  cfgReadConfig(FILE *f, cfg_root_t * __restrict cfg) Line 116  cfgReadConfig(FILE *f, cfg_root_t * __restrict cfg)
                 /* *NEW PAIR* alloc new pair element */                  /* *NEW PAIR* alloc new pair element */
                 av = io_malloc(sizeof(struct tagCfg));                  av = io_malloc(sizeof(struct tagCfg));
                 if (!av) {                  if (!av) {
                        LOGERR;                        cfg_SetErr(io_GetErrno(), "%s", io_GetError());
                         return -1;                          return -1;
                 } else {                  } else {
                         memset(av, 0, sizeof(struct tagCfg));                          memset(av, 0, sizeof(struct tagCfg));
Line 207  cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i Line 199  cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i
         time_t tim;          time_t tim;
         char line[BUFSIZ] = { 0 }, szSection[STRSIZ] = { 0 };          char line[BUFSIZ] = { 0 }, szSection[STRSIZ] = { 0 };
   
           if (!f || !cfg) {
                   cfg_SetErr(EINVAL, "Invalid parameter(s)");
                   return -1;
           }
   
         CFG_RC_LOCK(cfg);          CFG_RC_LOCK(cfg);
         _invertQueue(cfg);          _invertQueue(cfg);
         SLIST_FOREACH(av, cfg, cfg_next) {          SLIST_FOREACH(av, cfg, cfg_next) {
Line 244  cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i Line 241  cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i
                 /* write */                  /* write */
                 if (!cfg_Write(f, "%s\n", line)) {                  if (!cfg_Write(f, "%s\n", line)) {
                         LOGERR;                          LOGERR;
                           _invertQueue(cfg);
                         CFG_RC_UNLOCK(cfg);                          CFG_RC_UNLOCK(cfg);
                         return -1;                          return -1;
                 }                  }

Removed from v.1.10.2.4  
changed lines
  Added in v.1.10.2.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>