Diff for /libaitcfg/src/parse.c between versions 1.1.1.1.2.1 and 1.1.1.1.2.4

version 1.1.1.1.2.1, 2008/09/30 15:03:56 version 1.1.1.1.2.4, 2009/05/25 07:43:51
Line 1 Line 1
   /*************************************************************************
   * (C) 2008 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
   *  by Michael Pounov <misho@openbsd-bg.org>
   *
   * $Author$
   * $Id$
   *
   *************************************************************************/
 #include "global.h"  #include "global.h"
 #include "aitcfg.h"  #include "aitcfg.h"
 #include "tools.h"  #include "tools.h"
Line 81  int ReadConfig(FILE *f, sl_config * __restrict cfg) Line 89  int ReadConfig(FILE *f, sl_config * __restrict cfg)
                                 LOGERR;                                  LOGERR;
                                 return -1;                                  return -1;
                         } else {                          } else {
                                   memset(av, 0, sizeof(struct tagPair));
                                 // added new element                                  // added new element
                                 av->sle_next = cfg->slh_first;                                  av->sle_next = cfg->slh_first;
                                 cfg->slh_first = av;                                  cfg->slh_first = av;
Line 93  int ReadConfig(FILE *f, sl_config * __restrict cfg) Line 102  int ReadConfig(FILE *f, sl_config * __restrict cfg)
                                         free(av);                                          free(av);
                                         return -1;                                          return -1;
                                 } else                                  } else
                                        strcpy((char*) av->psSection, (char*) szSection);                                        strlcpy((char*) av->psSection, (char*) szSection, strlen((char*) szSection) + 1);
                         } else                          } else
                                 av->psSection = NULL;                                  av->psSection = NULL;
   
Line 114  int ReadConfig(FILE *f, sl_config * __restrict cfg) Line 123  int ReadConfig(FILE *f, sl_config * __restrict cfg)
                                 free(av);                                  free(av);
                                 return -1;                                  return -1;
                         } else                          } else
                                strcpy((char*) av->psAttribute, (char*) psAttr);                                strlcpy((char*) av->psAttribute, (char*) psAttr, strlen((char*) psAttr) + 1);
                         // added value to element                          // added value to element
                         av->psValue = malloc(strlen((char*) psVal) + 1);                          av->psValue = malloc(strlen((char*) psVal) + 1);
                         if (!av->psValue) {                          if (!av->psValue) {
Line 124  int ReadConfig(FILE *f, sl_config * __restrict cfg) Line 133  int ReadConfig(FILE *f, sl_config * __restrict cfg)
                                 free(av);                                  free(av);
                                 return -1;                                  return -1;
                         } else                          } else
                                strcpy((char*) av->psValue, (char*) psVal);                                strlcpy((char*) av->psValue, (char*) psVal, strlen((char*) psVal) + 1);
                 }                  }
         }          }
   
Line 156  int WriteConfig(FILE *f, sl_config * __restrict cfg) Line 165  int WriteConfig(FILE *f, sl_config * __restrict cfg)
   
         for (av = cfg->slh_first; av; av = av->sle_next) {          for (av = cfg->slh_first; av; av = av->sle_next) {
                 if (av->psSection && strcmp((char*) av->psSection, (char*) szSection)) {                  if (av->psSection && strcmp((char*) av->psSection, (char*) szSection)) {
                        bzero(szSection, MAX_STR + 1);                        strlcpy((char*) szSection, (char*) av->psSection, MAX_STR + 1);
                        strcpy((char*) szSection, (char*) av->psSection); 
                         if (!cfgDbg(f, "\n[%s]\n", av->psSection)) {                          if (!cfgDbg(f, "\n[%s]\n", av->psSection)) {
                                 LOGERR;                                  LOGERR;
                                 return -1;                                  return -1;

Removed from v.1.1.1.1.2.1  
changed lines
  Added in v.1.1.1.1.2.4


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