Diff for /libaitcfg/src/aitcfg.c between versions 1.14.2.1 and 1.16.6.3

version 1.14.2.1, 2021/11/25 23:44:52 version 1.16.6.3, 2025/08/19 11:22:09
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004 - 2021Copyright 2004 - 2025
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 157  cfgEndConfig(cfg_root_t **pcfg) Line 157  cfgEndConfig(cfg_root_t **pcfg)
 }  }
   
 /*  /*
    * cfgInitConfigExt() - Init existed config root
    *
    * @cfg = Config root
    * return: NULL error or !=NULL inited config root
    */
   cfg_root_t *
   cfgInitConfigExt(cfg_root_t * __restrict cfg)
   {
           pthread_mutex_t mtx = { 0 };
   
           if (!TAILQ_EMPTY(cfg) || !RB_EMPTY(cfg) ||
                           memcmp(&cfg->rc_mtx, &mtx, sizeof mtx))
                   cfgUnloadConfig(cfg);
   
           memset(cfg, 0, sizeof(cfg_root_t));
   
           pthread_mutex_init(&cfg->rc_mtx, NULL);
   
           TAILQ_INIT(cfg);
           RB_INIT(cfg);
           return cfg;
   }
   
   /*
  * cfgLoadConfig() - Load config from file   * cfgLoadConfig() - Load config from file
  *   *
  * @cfgName = Config filename   * @cfgName = Config filename
Line 168  cfgLoadConfig(const char *cfgName, cfg_root_t * __rest Line 192  cfgLoadConfig(const char *cfgName, cfg_root_t * __rest
 {  {
         FILE *f;          FILE *f;
         int ret;          int ret;
           pthread_mutex_t mtx = { 0 };
   
         if (!cfgName || !cfg) {          if (!cfgName || !cfg) {
                 cfg_SetErr(EINVAL, "Invalid parameter(s)");                  cfg_SetErr(EINVAL, "Invalid parameter(s)");
                 return -1;                  return -1;
         } else {          } else {
                   if (!TAILQ_EMPTY(cfg) || !RB_EMPTY(cfg) || memcmp(&cfg->rc_mtx, &mtx, sizeof mtx))
                           cfgUnloadConfig(cfg);
                   /*
                   if (memcmp(&cfg->rc_mtx, &mtx, sizeof mtx))
                           pthread_mutex_destroy(&cfg->rc_mtx);
                           */
   
                 memset(cfg, 0, sizeof(cfg_root_t));                  memset(cfg, 0, sizeof(cfg_root_t));
   
                 pthread_mutex_init(&cfg->rc_mtx, NULL);                  pthread_mutex_init(&cfg->rc_mtx, NULL);
Line 234  cfgUnloadConfig(cfg_root_t * __restrict cfg) Line 266  cfgUnloadConfig(cfg_root_t * __restrict cfg)
   
         cfgClearConfig(cfg);          cfgClearConfig(cfg);
         pthread_mutex_destroy(&cfg->rc_mtx);          pthread_mutex_destroy(&cfg->rc_mtx);
           memset(&cfg->rc_mtx, 0, sizeof cfg->rc_mtx);
 }  }
   
 /*  /*
Line 259  cfgCreateConfig(const char *csConfigName, cfg_root_t * Line 292  cfgCreateConfig(const char *csConfigName, cfg_root_t *
                 return -1;                  return -1;
         }          }
                   
        ret = cfgWriteConfig(f, cfg, whitespace);        ret = cfgWriteConfigRaw(f, cfg, whitespace);
   
         fclose(f);          fclose(f);
         return ret;          return ret;

Removed from v.1.14.2.1  
changed lines
  Added in v.1.16.6.3


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