diff options
Diffstat (limited to 'plugins/negate.c')
-rw-r--r-- | plugins/negate.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/negate.c b/plugins/negate.c index 50f62d3..c5fe7e1 100644 --- a/plugins/negate.c +++ b/plugins/negate.c | |||
@@ -47,7 +47,7 @@ static const char **process_arguments (int, char **); | |||
47 | void validate_arguments (char **); | 47 | void validate_arguments (char **); |
48 | void print_help (void); | 48 | void print_help (void); |
49 | void print_usage (void); | 49 | void print_usage (void); |
50 | int subst_text = FALSE; | 50 | bool subst_text = false; |
51 | 51 | ||
52 | static int state[4] = { | 52 | static int state[4] = { |
53 | STATE_OK, | 53 | STATE_OK, |
@@ -63,7 +63,6 @@ main (int argc, char **argv) | |||
63 | char *sub; | 63 | char *sub; |
64 | char **command_line; | 64 | char **command_line; |
65 | output chld_out, chld_err; | 65 | output chld_out, chld_err; |
66 | int i; | ||
67 | 66 | ||
68 | setlocale (LC_ALL, ""); | 67 | setlocale (LC_ALL, ""); |
69 | bindtextdomain (PACKAGE, LOCALEDIR); | 68 | bindtextdomain (PACKAGE, LOCALEDIR); |
@@ -86,7 +85,7 @@ main (int argc, char **argv) | |||
86 | result = cmd_run_array (command_line, &chld_out, &chld_err, 0); | 85 | result = cmd_run_array (command_line, &chld_out, &chld_err, 0); |
87 | } | 86 | } |
88 | if (chld_err.lines > 0) { | 87 | if (chld_err.lines > 0) { |
89 | for (i = 0; i < chld_err.lines; i++) { | 88 | for (size_t i = 0; i < chld_err.lines; i++) { |
90 | fprintf (stderr, "%s\n", chld_err.line[i]); | 89 | fprintf (stderr, "%s\n", chld_err.line[i]); |
91 | } | 90 | } |
92 | } | 91 | } |
@@ -95,7 +94,7 @@ main (int argc, char **argv) | |||
95 | if (chld_out.lines == 0) | 94 | if (chld_out.lines == 0) |
96 | die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n")); | 95 | die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n")); |
97 | 96 | ||
98 | for (i = 0; i < chld_out.lines; i++) { | 97 | for (size_t i = 0; i < chld_out.lines; i++) { |
99 | if (subst_text && result >= 0 && result <= 4 && result != state[result]) { | 98 | if (subst_text && result >= 0 && result <= 4 && result != state[result]) { |
100 | /* Loop over each match found */ | 99 | /* Loop over each match found */ |
101 | while ((sub = strstr (chld_out.line[i], state_text (result)))) { | 100 | while ((sub = strstr (chld_out.line[i], state_text (result)))) { |
@@ -122,7 +121,7 @@ static const char ** | |||
122 | process_arguments (int argc, char **argv) | 121 | process_arguments (int argc, char **argv) |
123 | { | 122 | { |
124 | int c; | 123 | int c; |
125 | int permute = TRUE; | 124 | bool permute = true; |
126 | 125 | ||
127 | int option = 0; | 126 | int option = 0; |
128 | static struct option longopts[] = { | 127 | static struct option longopts[] = { |
@@ -168,26 +167,26 @@ process_arguments (int argc, char **argv) | |||
168 | case 'o': /* replacement for OK */ | 167 | case 'o': /* replacement for OK */ |
169 | if ((state[STATE_OK] = mp_translate_state(optarg)) == ERROR) | 168 | if ((state[STATE_OK] = mp_translate_state(optarg)) == ERROR) |
170 | usage4 (_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 169 | usage4 (_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
171 | permute = FALSE; | 170 | permute = false; |
172 | break; | 171 | break; |
173 | 172 | ||
174 | case 'w': /* replacement for WARNING */ | 173 | case 'w': /* replacement for WARNING */ |
175 | if ((state[STATE_WARNING] = mp_translate_state(optarg)) == ERROR) | 174 | if ((state[STATE_WARNING] = mp_translate_state(optarg)) == ERROR) |
176 | usage4 (_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 175 | usage4 (_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
177 | permute = FALSE; | 176 | permute = false; |
178 | break; | 177 | break; |
179 | case 'c': /* replacement for CRITICAL */ | 178 | case 'c': /* replacement for CRITICAL */ |
180 | if ((state[STATE_CRITICAL] = mp_translate_state(optarg)) == ERROR) | 179 | if ((state[STATE_CRITICAL] = mp_translate_state(optarg)) == ERROR) |
181 | usage4 (_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 180 | usage4 (_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
182 | permute = FALSE; | 181 | permute = false; |
183 | break; | 182 | break; |
184 | case 'u': /* replacement for UNKNOWN */ | 183 | case 'u': /* replacement for UNKNOWN */ |
185 | if ((state[STATE_UNKNOWN] = mp_translate_state(optarg)) == ERROR) | 184 | if ((state[STATE_UNKNOWN] = mp_translate_state(optarg)) == ERROR) |
186 | usage4 (_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 185 | usage4 (_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
187 | permute = FALSE; | 186 | permute = false; |
188 | break; | 187 | break; |
189 | case 's': /* Substitute status text */ | 188 | case 's': /* Substitute status text */ |
190 | subst_text = TRUE; | 189 | subst_text = true; |
191 | break; | 190 | break; |
192 | } | 191 | } |
193 | } | 192 | } |
@@ -221,8 +220,10 @@ print_help (void) | |||
221 | 220 | ||
222 | printf (COPYRIGHT, copyright, email); | 221 | printf (COPYRIGHT, copyright, email); |
223 | 222 | ||
224 | printf ("%s\n", _("Negates the status of a plugin (returns OK for CRITICAL and vice-versa).")); | 223 | printf ("%s\n", _("Negates only the return code of a plugin (returns OK for CRITICAL and vice-versa) by default.")); |
225 | printf ("%s\n", _("Additional switches can be used to control which state becomes what.")); | 224 | printf ("%s\n", _("Additional switches can be used to control:\n")); |
225 | printf ("\t - which state becomes what\n"); | ||
226 | printf ("\t - changing the plugin output text to match the return code"); | ||
226 | 227 | ||
227 | printf ("\n\n"); | 228 | printf ("\n\n"); |
228 | 229 | ||