summaryrefslogtreecommitdiffstats
path: root/plugins/check_swap.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-10-18 06:41:22 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-10-18 06:41:22 +0000
commit93ac4565479ce8b32d5a99aec174323ef73bd12f (patch)
treea8cdbefaacbfab110377d73a79d099698068a77e /plugins/check_swap.c
parent44d249d12aca1cf0562ddeca4104b3462b4640a3 (diff)
downloadmonitoring-plugins-93ac4565479ce8b32d5a99aec174323ef73bd12f.tar.gz
remove old call_getopt
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@142 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r--plugins/check_swap.c65
1 files changed, 26 insertions, 39 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index d225e1dc..ca8442a4 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -150,36 +150,6 @@ main (int argc, char **argv)
150int 150int
151process_arguments (int argc, char **argv) 151process_arguments (int argc, char **argv)
152{ 152{
153 int c;
154
155 if (argc < 2)
156 return ERROR;
157
158 c = 0;
159 while (c += (call_getopt (argc - c, &argv[c]))) {
160 if (argc <= c)
161 break;
162
163 if (warn_percent > 100 && is_intnonneg (argv[c]))
164 warn_percent = atoi (argv[c]);
165 else if (crit_percent > 100 && is_intnonneg (argv[c]))
166 crit_percent = atoi (argv[c]);
167 else if (warn_size < 0 && is_intnonneg (argv[c]))
168 warn_size = atoi (argv[c]);
169 else if (crit_size < 0 && is_intnonneg (argv[c]))
170 crit_size = atoi (argv[c]);
171 }
172
173 return validate_arguments ();
174}
175
176
177
178
179
180int
181call_getopt (int argc, char **argv)
182{
183 int c, i = 0; 153 int c, i = 0;
184 154
185#ifdef HAVE_GETOPT_H 155#ifdef HAVE_GETOPT_H
@@ -194,6 +164,9 @@ call_getopt (int argc, char **argv)
194 }; 164 };
195#endif 165#endif
196 166
167 if (argc < 2)
168 return ERROR;
169
197 while (1) { 170 while (1) {
198#ifdef HAVE_GETOPT_H 171#ifdef HAVE_GETOPT_H
199 c = getopt_long (argc, argv, "+?Vhc:w:", long_options, &option_index); 172 c = getopt_long (argc, argv, "+?Vhc:w:", long_options, &option_index);
@@ -201,18 +174,10 @@ call_getopt (int argc, char **argv)
201 c = getopt (argc, argv, "+?Vhc:w:"); 174 c = getopt (argc, argv, "+?Vhc:w:");
202#endif 175#endif
203 176
204 i++;
205
206 if (c == -1 || c == EOF) 177 if (c == -1 || c == EOF)
207 break; 178 break;
208 179
209 switch (c) { 180 switch (c) {
210 case 'c':
211 case 'w':
212 i++;
213 }
214
215 switch (c) {
216 case 'w': /* warning time threshold */ 181 case 'w': /* warning time threshold */
217 if (is_intnonneg (optarg)) { 182 if (is_intnonneg (optarg)) {
218 warn_size = atoi (optarg); 183 warn_size = atoi (optarg);
@@ -257,7 +222,29 @@ call_getopt (int argc, char **argv)
257 usage ("Invalid argument\n"); 222 usage ("Invalid argument\n");
258 } 223 }
259 } 224 }
260 return i; 225
226 c = optind;
227 if (c == argc)
228 return validate_arguments ();
229 if (warn_percent > 100 && is_intnonneg (argv[c]))
230 warn_percent = atoi (argv[c++]);
231
232 if (c == argc)
233 return validate_arguments ();
234 if (crit_percent > 100 && is_intnonneg (argv[c]))
235 crit_percent = atoi (argv[c++]);
236
237 if (c == argc)
238 return validate_arguments ();
239 if (warn_size < 0 && is_intnonneg (argv[c]))
240 warn_size = atoi (argv[c++]);
241
242 if (c == argc)
243 return validate_arguments ();
244 if (crit_size < 0 && is_intnonneg (argv[c]))
245 crit_size = atoi (argv[c++]);
246
247 return validate_arguments ();
261} 248}
262 249
263 250