diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-12 18:41:57 +0100 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-12 18:41:57 +0100 |
commit | 53e72bfa25a17b253c171f6ec4d936bb2cb87cca (patch) | |
tree | 57749f9e26a17f132d99de1a86b85ca34f552ef8 /plugins/negate.c | |
parent | 399121ed0d69a83cce483ce6b762ad48937a3c70 (diff) | |
download | monitoring-plugins-53e72bfa25a17b253c171f6ec4d936bb2cb87cca.tar.gz |
negate: clang-format
Diffstat (limited to 'plugins/negate.c')
-rw-r--r-- | plugins/negate.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/plugins/negate.c b/plugins/negate.c index 750c0bfb..6c53a1b9 100644 --- a/plugins/negate.c +++ b/plugins/negate.c | |||
@@ -64,8 +64,9 @@ int main(int argc, char **argv) { | |||
64 | char **command_line = (char **)process_arguments(argc, argv); | 64 | char **command_line = (char **)process_arguments(argc, argv); |
65 | 65 | ||
66 | /* Set signal handling and alarm */ | 66 | /* Set signal handling and alarm */ |
67 | if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) | 67 | if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) { |
68 | die(STATE_UNKNOWN, _("Cannot catch SIGALRM")); | 68 | die(STATE_UNKNOWN, _("Cannot catch SIGALRM")); |
69 | } | ||
69 | 70 | ||
70 | (void)alarm((unsigned)timeout_interval); | 71 | (void)alarm((unsigned)timeout_interval); |
71 | 72 | ||
@@ -86,8 +87,9 @@ int main(int argc, char **argv) { | |||
86 | } | 87 | } |
87 | 88 | ||
88 | /* Return UNKNOWN or worse if no output is returned */ | 89 | /* Return UNKNOWN or worse if no output is returned */ |
89 | if (chld_out.lines == 0) | 90 | if (chld_out.lines == 0) { |
90 | die(max_state_alt(result, STATE_UNKNOWN), _("No data returned from command\n")); | 91 | die(max_state_alt(result, STATE_UNKNOWN), _("No data returned from command\n")); |
92 | } | ||
91 | 93 | ||
92 | char *sub; | 94 | char *sub; |
93 | for (size_t i = 0; i < chld_out.lines; i++) { | 95 | for (size_t i = 0; i < chld_out.lines; i++) { |
@@ -124,8 +126,9 @@ static const char **process_arguments(int argc, char **argv) { | |||
124 | int option = 0; | 126 | int option = 0; |
125 | int option_char = getopt_long(argc, argv, "+hVt:T:o:w:c:u:s", longopts, &option); | 127 | int option_char = getopt_long(argc, argv, "+hVt:T:o:w:c:u:s", longopts, &option); |
126 | 128 | ||
127 | if (option_char == -1 || option_char == EOF) | 129 | if (option_char == -1 || option_char == EOF) { |
128 | break; | 130 | break; |
131 | } | ||
129 | 132 | ||
130 | switch (option_char) { | 133 | switch (option_char) { |
131 | case '?': /* help */ | 134 | case '?': /* help */ |
@@ -139,34 +142,40 @@ static const char **process_arguments(int argc, char **argv) { | |||
139 | print_revision(progname, NP_VERSION); | 142 | print_revision(progname, NP_VERSION); |
140 | exit(STATE_UNKNOWN); | 143 | exit(STATE_UNKNOWN); |
141 | case 't': /* timeout period */ | 144 | case 't': /* timeout period */ |
142 | if (!is_integer(optarg)) | 145 | if (!is_integer(optarg)) { |
143 | usage2(_("Timeout interval must be a positive integer"), optarg); | 146 | usage2(_("Timeout interval must be a positive integer"), optarg); |
144 | else | 147 | } else { |
145 | timeout_interval = atoi(optarg); | 148 | timeout_interval = atoi(optarg); |
149 | } | ||
146 | break; | 150 | break; |
147 | case 'T': /* Result to return on timeouts */ | 151 | case 'T': /* Result to return on timeouts */ |
148 | if ((timeout_state = mp_translate_state(optarg)) == ERROR) | 152 | if ((timeout_state = mp_translate_state(optarg)) == ERROR) { |
149 | usage4(_("Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 153 | usage4(_("Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
154 | } | ||
150 | break; | 155 | break; |
151 | case 'o': /* replacement for OK */ | 156 | case 'o': /* replacement for OK */ |
152 | if ((state[STATE_OK] = mp_translate_state(optarg)) == ERROR) | 157 | if ((state[STATE_OK] = mp_translate_state(optarg)) == ERROR) { |
153 | usage4(_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 158 | usage4(_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
159 | } | ||
154 | permute = false; | 160 | permute = false; |
155 | break; | 161 | break; |
156 | 162 | ||
157 | case 'w': /* replacement for WARNING */ | 163 | case 'w': /* replacement for WARNING */ |
158 | if ((state[STATE_WARNING] = mp_translate_state(optarg)) == ERROR) | 164 | if ((state[STATE_WARNING] = mp_translate_state(optarg)) == ERROR) { |
159 | usage4(_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 165 | usage4(_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
166 | } | ||
160 | permute = false; | 167 | permute = false; |
161 | break; | 168 | break; |
162 | case 'c': /* replacement for CRITICAL */ | 169 | case 'c': /* replacement for CRITICAL */ |
163 | if ((state[STATE_CRITICAL] = mp_translate_state(optarg)) == ERROR) | 170 | if ((state[STATE_CRITICAL] = mp_translate_state(optarg)) == ERROR) { |
164 | usage4(_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 171 | usage4(_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
172 | } | ||
165 | permute = false; | 173 | permute = false; |
166 | break; | 174 | break; |
167 | case 'u': /* replacement for UNKNOWN */ | 175 | case 'u': /* replacement for UNKNOWN */ |
168 | if ((state[STATE_UNKNOWN] = mp_translate_state(optarg)) == ERROR) | 176 | if ((state[STATE_UNKNOWN] = mp_translate_state(optarg)) == ERROR) { |
169 | usage4(_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 177 | usage4(_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
178 | } | ||
170 | permute = false; | 179 | permute = false; |
171 | break; | 180 | break; |
172 | case 's': /* Substitute status text */ | 181 | case 's': /* Substitute status text */ |
@@ -186,11 +195,13 @@ static const char **process_arguments(int argc, char **argv) { | |||
186 | } | 195 | } |
187 | 196 | ||
188 | void validate_arguments(char **command_line) { | 197 | void validate_arguments(char **command_line) { |
189 | if (command_line[0] == NULL) | 198 | if (command_line[0] == NULL) { |
190 | usage4(_("Could not parse arguments")); | 199 | usage4(_("Could not parse arguments")); |
200 | } | ||
191 | 201 | ||
192 | if (strncmp(command_line[0], "/", 1) != 0 && strncmp(command_line[0], "./", 2) != 0) | 202 | if (strncmp(command_line[0], "/", 1) != 0 && strncmp(command_line[0], "./", 2) != 0) { |
193 | usage4(_("Require path to command")); | 203 | usage4(_("Require path to command")); |
204 | } | ||
194 | } | 205 | } |
195 | 206 | ||
196 | void print_help(void) { | 207 | void print_help(void) { |