diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2014-01-29 03:20:23 -0500 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2014-01-29 03:20:23 -0500 |
commit | 8fc9e5ac4b3a699f8d6b78471829692f0c92d5fa (patch) | |
tree | 4d630aa158d65602307723e9c7c6d41eca82b94d /plugins | |
parent | 55f97c2021bf920b62148ea31fdf56d95572d944 (diff) | |
download | monitoring-plugins-8fc9e5ac4b3a699f8d6b78471829692f0c92d5fa.tar.gz |
Move negate' translate_state() to utils_base.h mp_translate_state()
Also use strcasecmp imported from gnulib for simplicity
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/negate.c | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/plugins/negate.c b/plugins/negate.c index 84ad7eb3..4bd09deb 100644 --- a/plugins/negate.c +++ b/plugins/negate.c @@ -45,7 +45,6 @@ const char *email = "devel@monitoring-plugins.org"; static const char **process_arguments (int, char **); int validate_arguments (char **); -int translate_state (char *); void print_help (void); void print_usage (void); int subst_text = FALSE; @@ -166,27 +165,27 @@ process_arguments (int argc, char **argv) timeout_interval = atoi (optarg); break; case 'T': /* Result to return on timeouts */ - if ((timeout_state = translate_state(optarg)) == ERROR) + if ((timeout_state = mp_translate_state(optarg)) == ERROR) usage4 (_("Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); break; case 'o': /* replacement for OK */ - if ((state[STATE_OK] = translate_state(optarg)) == ERROR) + if ((state[STATE_OK] = mp_translate_state(optarg)) == ERROR) usage4 (_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); permute = FALSE; break; case 'w': /* replacement for WARNING */ - if ((state[STATE_WARNING] = translate_state(optarg)) == ERROR) + if ((state[STATE_WARNING] = mp_translate_state(optarg)) == ERROR) usage4 (_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); permute = FALSE; break; case 'c': /* replacement for CRITICAL */ - if ((state[STATE_CRITICAL] = translate_state(optarg)) == ERROR) + if ((state[STATE_CRITICAL] = mp_translate_state(optarg)) == ERROR) usage4 (_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); permute = FALSE; break; case 'u': /* replacement for UNKNOWN */ - if ((state[STATE_UNKNOWN] = translate_state(optarg)) == ERROR) + if ((state[STATE_UNKNOWN] = mp_translate_state(optarg)) == ERROR) usage4 (_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); permute = FALSE; break; @@ -218,24 +217,6 @@ validate_arguments (char **command_line) } -int -translate_state (char *state_text) -{ - char *temp_ptr; - for (temp_ptr = state_text; *temp_ptr; temp_ptr++) { - *temp_ptr = toupper(*temp_ptr); - } - if (!strcmp(state_text,"OK") || !strcmp(state_text,"0")) - return STATE_OK; - if (!strcmp(state_text,"WARNING") || !strcmp(state_text,"1")) - return STATE_WARNING; - if (!strcmp(state_text,"CRITICAL") || !strcmp(state_text,"2")) - return STATE_CRITICAL; - if (!strcmp(state_text,"UNKNOWN") || !strcmp(state_text,"3")) - return STATE_UNKNOWN; - return ERROR; -} - void print_help (void) { |