summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-09-12 15:42:10 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-09-12 15:42:10 (GMT)
commit662997251d4fc43f4155784f9e7df827f193305e (patch)
tree0a9ad5c5607598da0eb6b6d71fa8c47ca44186fb /plugins
parentca9ce71576ddf78cc54fe3b6f0428cdfea72e9df (diff)
downloadmonitoring-plugins-662997251d4fc43f4155784f9e7df827f193305e.tar.gz
Improve interface of np_expect_match() function
Replace the three boolean parameters of lib/utils_tcp.c's np_expect_match() function with a single "flags" parameter.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_tcp.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 9e62638..e8d7ec6 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -82,15 +82,14 @@ static int sd = 0;
82#define MAXBUF 1024 82#define MAXBUF 1024
83static char buffer[MAXBUF]; 83static char buffer[MAXBUF];
84static int expect_mismatch_state = STATE_WARNING; 84static int expect_mismatch_state = STATE_WARNING;
85static int match_flags = NP_MATCH_EXACT;
85 86
86#define FLAG_SSL 0x01 87#define FLAG_SSL 0x01
87#define FLAG_VERBOSE 0x02 88#define FLAG_VERBOSE 0x02
88#define FLAG_EXACT_MATCH 0x04 89#define FLAG_TIME_WARN 0x04
89#define FLAG_TIME_WARN 0x08 90#define FLAG_TIME_CRIT 0x08
90#define FLAG_TIME_CRIT 0x10 91#define FLAG_HIDE_OUTPUT 0x10
91#define FLAG_HIDE_OUTPUT 0x20 92static size_t flags;
92#define FLAG_MATCH_ALL 0x40
93static size_t flags = FLAG_EXACT_MATCH;
94 93
95int 94int
96main (int argc, char **argv) 95main (int argc, char **argv)
@@ -296,12 +295,7 @@ main (int argc, char **argv)
296 (int)len + 1, status); 295 (int)len + 1, status);
297 while(isspace(status[len])) status[len--] = '\0'; 296 while(isspace(status[len])) status[len--] = '\0';
298 297
299 match = np_expect_match(status, 298 match = np_expect_match(status, server_expect, server_expect_count, match_flags);
300 server_expect,
301 server_expect_count,
302 (flags & FLAG_MATCH_ALL ? TRUE : FALSE),
303 (flags & FLAG_EXACT_MATCH ? TRUE : FALSE),
304 (flags & FLAG_VERBOSE ? TRUE : FALSE));
305 } 299 }
306 300
307 if (server_quit != NULL) { 301 if (server_quit != NULL) {
@@ -450,6 +444,7 @@ process_arguments (int argc, char **argv)
450 exit (STATE_OK); 444 exit (STATE_OK);
451 case 'v': /* verbose mode */ 445 case 'v': /* verbose mode */
452 flags |= FLAG_VERBOSE; 446 flags |= FLAG_VERBOSE;
447 match_flags |= NP_MATCH_VERBOSE;
453 break; 448 break;
454 case '4': 449 case '4':
455 address_family = AF_INET; 450 address_family = AF_INET;
@@ -506,7 +501,7 @@ process_arguments (int argc, char **argv)
506 xasprintf(&server_send, "%s", optarg); 501 xasprintf(&server_send, "%s", optarg);
507 break; 502 break;
508 case 'e': /* expect string (may be repeated) */ 503 case 'e': /* expect string (may be repeated) */
509 flags &= ~FLAG_EXACT_MATCH; 504 match_flags &= ~NP_MATCH_EXACT;
510 if (server_expect_count == 0) 505 if (server_expect_count == 0)
511 server_expect = malloc (sizeof (char *) * (++server_expect_count)); 506 server_expect = malloc (sizeof (char *) * (++server_expect_count));
512 else 507 else
@@ -584,7 +579,7 @@ process_arguments (int argc, char **argv)
584#endif 579#endif
585 break; 580 break;
586 case 'A': 581 case 'A':
587 flags |= FLAG_MATCH_ALL; 582 match_flags |= NP_MATCH_ALL;
588 break; 583 break;
589 } 584 }
590 } 585 }