Diff for /embedaddon/bmon/src/conf.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2014/07/30 07:55:27 version 1.1.1.3, 2019/10/21 14:58:35
Line 30 Line 30
 #include <bmon/element.h>  #include <bmon/element.h>
 #include <bmon/element_cfg.h>  #include <bmon/element_cfg.h>
 #include <bmon/history.h>  #include <bmon/history.h>
   #include <bmon/layout.h>
 #include <bmon/utils.h>  #include <bmon/utils.h>
   
 cfg_t *cfg;  cfg_t *cfg;
Line 69  static cfg_opt_t unit_opts[] = { Line 70  static cfg_opt_t unit_opts[] = {
         CFG_END()          CFG_END()
 };  };
   
   static cfg_opt_t color_opts[] = {
       CFG_STR_LIST("color_pair", "", CFGF_NONE),
       CFG_END()
   };
   
   static cfg_opt_t layout_opts[] = {
       CFG_SEC("color", color_opts, CFGF_MULTI | CFGF_TITLE),
       CFG_END()
   };
   
 static cfg_opt_t global_opts[] = {  static cfg_opt_t global_opts[] = {
         CFG_FLOAT("read_interval", 1.0f, CFGF_NONE),          CFG_FLOAT("read_interval", 1.0f, CFGF_NONE),
         CFG_FLOAT("rate_interval", 1.0f, CFGF_NONE),          CFG_FLOAT("rate_interval", 1.0f, CFGF_NONE),
Line 87  static cfg_opt_t global_opts[] = { Line 98  static cfg_opt_t global_opts[] = {
         CFG_SEC("attr", attr_opts, CFGF_MULTI | CFGF_TITLE),          CFG_SEC("attr", attr_opts, CFGF_MULTI | CFGF_TITLE),
         CFG_SEC("history", history_opts, CFGF_MULTI | CFGF_TITLE),          CFG_SEC("history", history_opts, CFGF_MULTI | CFGF_TITLE),
         CFG_SEC("element", element_opts, CFGF_MULTI | CFGF_TITLE),          CFG_SEC("element", element_opts, CFGF_MULTI | CFGF_TITLE),
       CFG_SEC("layout", layout_opts, CFGF_MULTI | CFGF_TITLE),
         CFG_END()          CFG_END()
 };  };
   
Line 103  static char *  configfile  = NULL; Line 115  static char *  configfile  = NULL;
 #if defined HAVE_USE_DEFAULT_COLORS  #if defined HAVE_USE_DEFAULT_COLORS
 struct layout cfg_layout[] =  struct layout cfg_layout[] =
 {  {
        {-1, -1, 0},                           /* dummy, not used */    {-1, -1, 0},            /* dummy, not used */
        {-1, -1, 0},                           /* default */    {-1, -1, 0},            /* default */
        {-1, -1, A_REVERSE},                   /* statusbar */    {-1, -1, A_REVERSE},    /* statusbar */
        {-1, -1, 0},                           /* header */    {-1, -1, 0},            /* header */
        {-1, -1, 0},                           /* list */    {-1, -1, 0},            /* list */
        {-1, -1, A_REVERSE},                   /* selected */    {-1, -1, A_REVERSE},    /* selected */
     {-1, -1, 0},            /* RX graph */
     {-1, -1, 0},            /* TX graph */
 };  };
 #else  #else
 struct layout cfg_layout[] =  struct layout cfg_layout[] =
 {  {
        {0, 0, 0},                              /* dummy, not used */        {0, 0, 0},                               /* dummy, not used */
        {COLOR_BLACK, COLOR_WHITE, 0},          /* default */        {COLOR_WHITE, COLOR_BLACK, 0},           /* default */
        {COLOR_BLACK, COLOR_WHITE, A_REVERSE},  /* statusbar */        {COLOR_BLUE,   COLOR_GREEN, A_REVERSE},  /* statusbar */
        {COLOR_BLACK, COLOR_WHITE, 0},          /* header */        {COLOR_GREEN,  COLOR_BLACK, 0},          /* header */
        {COLOR_BLACK, COLOR_WHITE, 0},          /* list */        {COLOR_WHITE,  COLOR_BLACK, 0},          /* list */
        {COLOR_BLACK, COLOR_WHITE, A_REVERSE},  /* selected */        {COLOR_YELLOW, COLOR_BLACK, A_REVERSE},  /* selected */
     {COLOR_GREEN,  COLOR_BLACK, 0},          /* RX graph */
     {COLOR_RED,    COLOR_BLACK, 0},          /* TX graph */
 };  };
 #endif  #endif
 #endif  #endif
Line 371  static void configfile_read_units(void) Line 387  static void configfile_read_units(void)
   
 static void configfile_read_attrs(void)  static void configfile_read_attrs(void)
 {  {
        int i, nattrs, t;        int i, nattrs, t = 0;
   
         nattrs = cfg_size(cfg, "attr");          nattrs = cfg_size(cfg, "attr");
   
Line 423  static void configfile_read_attrs(void) Line 439  static void configfile_read_attrs(void)
         }          }
 }  }
   
   static void configfile_read_layout_cfg(void)
   {
       int i, nlayouts;
       cfg_t *lout;
       nlayouts = cfg_size(cfg, "layout");
       for (i = 0; i < nlayouts; i++)
       {
           int c, ncolors;
           const char *name;
           if (!(lout = cfg_getnsec(cfg, "layout", i)))
               BUG();
   
           if (!(name = cfg_title(lout)))
               BUG();
   
           ncolors = cfg_size(lout, "color");
           if (ncolors > LAYOUT_MAX) {
               fprintf(stderr, "Warning excceeded maximum number of layouts\n");
               ncolors = LAYOUT_MAX;
           }
   
           for (c = 0; c < ncolors; c++) {
               cfg_t *color_pair;
   
               if (!(color_pair = cfg_getnsec(lout, "color", c)))
                   BUG();
   
               if (!(name = cfg_title(color_pair)))
                   BUG();
   
               add_layout(name, color_pair);
           }
       }
   }
   
 static void conf_read(const char *path, int must)  static void conf_read(const char *path, int must)
 {  {
         int err;          int err;
Line 450  static void conf_read(const char *path, int must) Line 501  static void conf_read(const char *path, int must)
         configfile_read_history();          configfile_read_history();
         configfile_read_attrs();          configfile_read_attrs();
         configfile_read_element_cfg();          configfile_read_element_cfg();
       configfile_read_layout_cfg();
 }  }
   
 static const char default_config[] = \  static const char default_config[] = \
Line 508  static const char default_config[] = \ Line 560  static const char default_config[] = \
 "history day {" \  "history day {" \
 "       interval        = 86400.0" \  "       interval        = 86400.0" \
 "       size            = 60" \  "       size            = 60" \
   "}"
   "layout colors {" \
   "   color default {" \
   "       color_pair = { \"white\", \"black\" }" \
   "   }" \
   "   color statusbar{" \
   "       color_pair = { \"blue\", \"white\", \"reverse\" }" \
   "   }" \
   "   color header {" \
   "       color_pair = { \"yellow\", \"black\" }" \
   "   }" \
   "   color list {" \
   "       color_pair = { \"white\", \"black\" }" \
   "   }" \
   "   color selected {" \
   "       color_pair = { \"yellow\", \"black\", \"reverse\" }" \
   "   }" \
   "   color rx_graph {" \
   "       color_pair = { \"green\", \"black\" }" \
   "   }" \
   "   color tx_graph {" \
   "       color_pair = { \"red\", \"black\" }" \
   "   }" \
 "}";  "}";
   
 static void conf_read_default(void)  static void conf_read_default(void)
Line 524  static void conf_read_default(void) Line 599  static void conf_read_default(void)
         configfile_read_history();          configfile_read_history();
         configfile_read_attrs();          configfile_read_attrs();
         configfile_read_element_cfg();          configfile_read_element_cfg();
       configfile_read_layout_cfg();
 }  }
   
 void configfile_read(void)  void configfile_read(void)

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


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