summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_swap.c13
-rw-r--r--plugins/utils.c16
-rw-r--r--plugins/utils.h5
3 files changed, 16 insertions, 18 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 4d124a35..685c2cc5 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -37,7 +37,6 @@ const char *email = "devel@monitoring-plugins.org";
37#include <string.h> 37#include <string.h>
38#include <math.h> 38#include <math.h>
39#include <libintl.h> 39#include <libintl.h>
40#include <stdbool.h>
41 40
42#ifdef HAVE_DECL_SWAPCTL 41#ifdef HAVE_DECL_SWAPCTL
43# ifdef HAVE_SYS_PARAM_H 42# ifdef HAVE_SYS_PARAM_H
@@ -56,7 +55,7 @@ const char *email = "devel@monitoring-plugins.org";
56#endif 55#endif
57 56
58typedef struct { 57typedef struct {
59 bool is_percentage; 58 int is_percentage;
60 uint64_t value; 59 uint64_t value;
61} threshold_t; 60} threshold_t;
62 61
@@ -69,7 +68,7 @@ void print_help (void);
69threshold_t warn; 68threshold_t warn;
70threshold_t crit; 69threshold_t crit;
71int verbose; 70int verbose;
72bool allswaps; 71int allswaps;
73int no_swap_state = STATE_CRITICAL; 72int no_swap_state = STATE_CRITICAL;
74 73
75int 74int
@@ -467,7 +466,7 @@ process_arguments (int argc, char **argv)
467 466
468 if (optarg[length - 1] == '%') { 467 if (optarg[length - 1] == '%') {
469 /* It's percentage */ 468 /* It's percentage */
470 warn.is_percentage = true; 469 warn.is_percentage = 1;
471 optarg[length - 1] = '\0'; 470 optarg[length - 1] = '\0';
472 if (is_uint64(optarg, &warn.value)) { 471 if (is_uint64(optarg, &warn.value)) {
473 if (warn.value > 100) { 472 if (warn.value > 100) {
@@ -478,7 +477,7 @@ process_arguments (int argc, char **argv)
478 } 477 }
479 } else { 478 } else {
480 /* It's Bytes */ 479 /* It's Bytes */
481 warn.is_percentage = false; 480 warn.is_percentage = 0;
482 if (is_uint64(optarg, &warn.value)) { 481 if (is_uint64(optarg, &warn.value)) {
483 break; 482 break;
484 } else { 483 } else {
@@ -498,7 +497,7 @@ process_arguments (int argc, char **argv)
498 497
499 if (optarg[length - 1] == '%') { 498 if (optarg[length - 1] == '%') {
500 /* It's percentage */ 499 /* It's percentage */
501 crit.is_percentage = true; 500 crit.is_percentage = 1;
502 optarg[length - 1] = '\0'; 501 optarg[length - 1] = '\0';
503 if (is_uint64(optarg, &crit.value)) { 502 if (is_uint64(optarg, &crit.value)) {
504 if (crit.value> 100) { 503 if (crit.value> 100) {
@@ -509,7 +508,7 @@ process_arguments (int argc, char **argv)
509 } 508 }
510 } else { 509 } else {
511 /* It's Bytes */ 510 /* It's Bytes */
512 crit.is_percentage = false; 511 crit.is_percentage = 0;
513 if (is_uint64(optarg, &crit.value)) { 512 if (is_uint64(optarg, &crit.value)) {
514 break; 513 break;
515 } else { 514 } else {
diff --git a/plugins/utils.c b/plugins/utils.c
index 011f715d..f7f8952f 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -246,19 +246,19 @@ is_intnonneg (char *number)
246 * On success the number will be written to the _target_ address, if _target_ is not set 246 * On success the number will be written to the _target_ address, if _target_ is not set
247 * to NULL. 247 * to NULL.
248 */ 248 */
249bool is_int64(char *number, int64_t *target) { 249int is_int64(char *number, int64_t *target) {
250 errno = 0; 250 errno = 0;
251 uint64_t tmp = strtoll(number, NULL, 10); 251 uint64_t tmp = strtoll(number, NULL, 10);
252 if (errno != 0) { 252 if (errno != 0) {
253 return false; 253 return 0;
254 } 254 }
255 if (tmp < INT64_MIN || tmp > INT64_MAX) { 255 if (tmp < INT64_MIN || tmp > INT64_MAX) {
256 return false; 256 return 0;
257 } 257 }
258 if (target != NULL) { 258 if (target != NULL) {
259 *target = tmp; 259 *target = tmp;
260 } 260 }
261 return true; 261 return 1;
262} 262}
263 263
264/* 264/*
@@ -266,19 +266,19 @@ bool is_int64(char *number, int64_t *target) {
266 * On success the number will be written to the _target_ address, if _target_ is not set 266 * On success the number will be written to the _target_ address, if _target_ is not set
267 * to NULL. 267 * to NULL.
268 */ 268 */
269bool is_uint64(char *number, uint64_t *target) { 269int is_uint64(char *number, uint64_t *target) {
270 errno = 0; 270 errno = 0;
271 uint64_t tmp = strtoll(number, NULL, 10); 271 uint64_t tmp = strtoll(number, NULL, 10);
272 if (errno != 0) { 272 if (errno != 0) {
273 return false; 273 return 0;
274 } 274 }
275 if (tmp < 0 || tmp > UINT64_MAX) { 275 if (tmp < 0 || tmp > UINT64_MAX) {
276 return false; 276 return 0;
277 } 277 }
278 if (target != NULL) { 278 if (target != NULL) {
279 *target = tmp; 279 *target = tmp;
280 } 280 }
281 return true; 281 return 1;
282} 282}
283 283
284int 284int
diff --git a/plugins/utils.h b/plugins/utils.h
index 91a9c3f9..5b54da3c 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -17,8 +17,6 @@ suite of plugins. */
17#include "utils_base.h" 17#include "utils_base.h"
18 18
19 19
20#include <stdbool.h>
21
22#ifdef NP_EXTRA_OPTS 20#ifdef NP_EXTRA_OPTS
23/* Include extra-opts functions if compiled in */ 21/* Include extra-opts functions if compiled in */
24#include "extra_opts.h" 22#include "extra_opts.h"
@@ -41,7 +39,8 @@ int is_intpos (char *);
41int is_intneg (char *); 39int is_intneg (char *);
42int is_intnonneg (char *); 40int is_intnonneg (char *);
43int is_intpercent (char *); 41int is_intpercent (char *);
44bool is_uint64(char *number, uint64_t *target); 42int is_uint64(char *number, uint64_t *target);
43int is_int64(char *number, int64_t *target);
45 44
46int is_numeric (char *); 45int is_numeric (char *);
47int is_positive (char *); 46int is_positive (char *);