Create expired cert for testing purposes. Updated tests to check
[monitoring-plugins.git] / lib / utils_tcp.c
blob8589ce6711c8239bf0345045823e437245b31e85
1 /*****************************************************************************
2 *
3 * Library for check_tcp
4 *
5 * License: GPL
6 * Copyright (c) 1999-2007 Nagios Plugins Development Team
7 *
8 * Description:
9 *
10 * This file contains utilities for check_tcp. These are tested by libtap
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 *****************************************************************************/
29 #include "common.h"
30 #include "utils_tcp.h"
32 int
33 np_expect_match(char* status, char** server_expect, int expect_count, int all, int exact_match, int verbose)
35 int match = 0;
36 int i;
37 for (i = 0; i < expect_count; i++) {
38 if (verbose)
39 printf ("looking for [%s] %s [%s]\n", server_expect[i],
40 (exact_match) ? "in beginning of" : "anywhere in",
41 status);
43 if ((exact_match && !strncmp(status, server_expect[i], strlen(server_expect[i]))) ||
44 (! exact_match && strstr(status, server_expect[i])))
46 if(verbose) puts("found it");
47 match += 1;
48 } else
49 if(verbose) puts("couldn't find it");
51 if ((all == TRUE && match == expect_count) ||
52 (! all && match >= 1)) {
53 return TRUE;
54 } else
55 return FALSE;