summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-01-30 16:10:50 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2006-01-30 16:10:50 (GMT)
commit795100ae5124915bb647a304d5dfe2ada2f44ab0 (patch)
treeb3fd0dc1a88ebb533f074c476ee020e32877632e /plugins/utils.c
parentc8a9bf228fdd34b021796f577a404cb8b0cba1f9 (diff)
downloadmonitoring-plugins-795100ae5124915bb647a304d5dfe2ada2f44ab0.tar.gz
Added libtap tests for utils.c library functions. Removed redundant
test files git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1303 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 8b31c5a..dbb2520 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -265,7 +265,62 @@ is_option (char *str)
265 return FALSE; 265 return FALSE;
266} 266}
267 267
268void set_threshold_start (threshold *this, double value) {
269 this->start = value;
270 this->start_infinity = FALSE;
271}
272
273void set_threshold_end (threshold *this, double value) {
274 this->end = value;
275 this->end_infinity = FALSE;
276}
277
278threshold
279*parse_threshold (char *str) {
280 threshold *temp_threshold;
281 double start;
282 double end;
283 char *end_str;
268 284
285 temp_threshold = (threshold *) malloc(sizeof(threshold));
286
287 /* Set defaults */
288 temp_threshold->start = 0;
289 temp_threshold->start_infinity = FALSE;
290 temp_threshold->end = 0;
291 temp_threshold->end_infinity = TRUE;
292 temp_threshold->alert_on = OUTSIDE;
293
294 if (str[0] == '@') {
295 temp_threshold->alert_on = INSIDE;
296 str++;
297 }
298
299 end_str = index(str, ':');
300 if (end_str != NULL) {
301 if (str[0] == '~') {
302 temp_threshold->start_infinity = TRUE;
303 } else {
304 start = strtod(str, NULL); /* Will stop at the ':' */
305 set_threshold_start(temp_threshold, start);
306 }
307 end_str++; /* Move past the ':' */
308 } else {
309 end_str = str;
310 }
311 end = strtod(end_str, NULL);
312 if (strcmp(end_str, "") != 0) {
313 set_threshold_end(temp_threshold, end);
314 }
315
316 if (temp_threshold->start_infinity == TRUE ||
317 temp_threshold->end_infinity == TRUE ||
318 temp_threshold->start <= temp_threshold->end) {
319 return temp_threshold;
320 }
321 free(temp_threshold);
322 return NULL;
323}
269 324
270#ifdef NEED_GETTIMEOFDAY 325#ifdef NEED_GETTIMEOFDAY
271int 326int