summaryrefslogtreecommitdiffabout
path: root/src/readconfig.c
Unidiff
Diffstat (limited to 'src/readconfig.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/readconfig.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/readconfig.c b/src/readconfig.c
index 1c22cb1..a60f19d 100644
--- a/src/readconfig.c
+++ b/src/readconfig.c
@@ -98,29 +98,35 @@ cb_monitor (enum grecs_callback_command cmd,
98 return 1; 98 return 1;
99 } 99 }
100 mon = xzalloc (sizeof (*mon)); 100 mon = xzalloc (sizeof (*mon));
101 *mon = default_monitor;
101 mon->id = strdup (value->v.string); 102 mon->id = strdup (value->v.string);
102 mon->scale = 1.0; 103 mon->name = NULL;
103 mon->ystep = 100.; 104 mon->dir = NULL;
104 *pdata = mon; 105 *pdata = mon;
105 break; 106 break;
106 107
107 case grecs_callback_section_end: 108 case grecs_callback_section_end:
108 mon = *pdata; 109 mon = *pdata;
109 if (mon->max_rate == 0) 110 if (strcmp (mon->id, "default") == 0)
111 default_monitor = *mon;
112 else
110 { 113 {
111 grecs_error (locus, 0, _("maximum speed not set")); 114 if (mon->max_rate == 0 && mon->max_adjust == 0)
112 free (mon); 115 {
113 return 0; 116 grecs_error (locus, 0, _("maximum speed not set"));
117 free (mon);
118 return 0;
119 }
120 if (!mon->name)
121 mon->name = strdup (mon->id);
122 if (!mon->dir)
123 mon->dir = strdup (mon->id);
124 if (mon_count == 0)
125 obstack_init (&mon_stack);
126
127 obstack_grow (&mon_stack, mon, sizeof *mon);
128 mon_count++;
114 } 129 }
115 if (!mon->name)
116 mon->name = strdup (mon->id);
117 if (!mon->dir)
118 mon->dir = strdup (mon->id);
119 if (mon_count == 0)
120 obstack_init (&mon_stack);
121
122 obstack_grow (&mon_stack, mon, sizeof *mon);
123 mon_count++;
124 free (mon); 130 free (mon);
125 *pdata = NULL; 131 *pdata = NULL;
126 break; 132 break;
@@ -174,6 +180,8 @@ static struct grecs_keyword monitor_kw[] = {
174 grecs_type_string, NULL, offsetof(struct monitor, dir) }, 180 grecs_type_string, NULL, offsetof(struct monitor, dir) },
175 { "max-speed", NULL, N_("Maximum speed"), 181 { "max-speed", NULL, N_("Maximum speed"),
176 grecs_type_ulong, NULL, offsetof(struct monitor, max_rate) }, 182 grecs_type_ulong, NULL, offsetof(struct monitor, max_rate) },
183 { "max-adjust", NULL, N_("Adjust maximum by this value when needed"),
184 grecs_type_ulong, NULL, offsetof(struct monitor, max_adjust) },
177 { "rate-units", NULL, N_("Name of rate units"), 185 { "rate-units", NULL, N_("Name of rate units"),
178 grecs_type_string, NULL, offsetof(struct monitor, rate_unit) }, 186 grecs_type_string, NULL, offsetof(struct monitor, rate_unit) },
179 { "scale", N_("arg: double"), N_("Scaling factor"), 187 { "scale", N_("arg: double"), N_("Scaling factor"),
@@ -182,6 +190,8 @@ static struct grecs_keyword monitor_kw[] = {
182 { "y-step", N_("arg: double"), N_("Step for Y axis"), 190 { "y-step", N_("arg: double"), N_("Step for Y axis"),
183 grecs_type_string, NULL, offsetof(struct monitor, ystep), 191 grecs_type_string, NULL, offsetof(struct monitor, ystep),
184 cb_double}, 192 cb_double},
193 { "y-step-absolute", NULL, N_("y-step is an absolute value"),
194 grecs_type_bool, NULL, offsetof(struct monitor, ystep_absolute) },
185 { "swap", NULL, N_("Swap in and out rates"), 195 { "swap", NULL, N_("Swap in and out rates"),
186 grecs_type_bool, NULL, offsetof(struct monitor, swap) }, 196 grecs_type_bool, NULL, offsetof(struct monitor, swap) },
187 { NULL } 197 { NULL }
@@ -488,8 +498,6 @@ static struct grecs_keyword tagr_kw[] = {
488 N_("Idle timeout for stream connections"), 498 N_("Idle timeout for stream connections"),
489 grecs_type_uint, &stream_idle_timeout }, 499 grecs_type_uint, &stream_idle_timeout },
490 500
491 { "rate-units", NULL, N_("Name of rate units"),
492 grecs_type_string, &rate_unit },
493 { "number-suffixes", N_("suffixes"), 501 { "number-suffixes", N_("suffixes"),
494 N_("Not implemented") /* FIXME */, 502 N_("Not implemented") /* FIXME */,
495 grecs_type_string, NULL, 0, cb_number_suffixes }, 503 grecs_type_string, NULL, 0, cb_number_suffixes },

Return to:

Send suggestions and report system problems to the System administrator.