summaryrefslogtreecommitdiffstats
path: root/lib/utils_tcp.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-09-15 13:18:17 +0200
committerGitHub <noreply@github.com>2025-09-15 13:18:17 +0200
commit8ef825d85fb4d09c32ca44c545d6eb8d995ddea4 (patch)
tree5ab7b18797dfd5849dec7827c87ca3bb5fcb0993 /lib/utils_tcp.c
parenta3cf9041af810770daf5d9b83f1906fa9bb0dd11 (diff)
parent204cf956f0b3db90d079321ee957b3860da7e33f (diff)
downloadmonitoring-plugins-8ef825d85fb4d09c32ca44c545d6eb8d995ddea4.tar.gz
Merge pull request #2149 from RincewindsHat/clang-format
Clang format
Diffstat (limited to 'lib/utils_tcp.c')
-rw-r--r--lib/utils_tcp.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/utils_tcp.c b/lib/utils_tcp.c
index daae1d54..1482458b 100644
--- a/lib/utils_tcp.c
+++ b/lib/utils_tcp.c
@@ -29,18 +29,21 @@
29#include "common.h" 29#include "common.h"
30#include "utils_tcp.h" 30#include "utils_tcp.h"
31 31
32#define VERBOSE(message) \ 32#define VERBOSE(message) \
33 do { \ 33 do { \
34 if (flags & NP_MATCH_VERBOSE) \ 34 if (flags & NP_MATCH_VERBOSE) \
35 puts(message); \ 35 puts(message); \
36 } while (0) 36 } while (0)
37 37
38enum np_match_result np_expect_match(char *status, char **server_expect, int expect_count, int flags) { 38enum np_match_result np_expect_match(char *status, char **server_expect, int expect_count,
39 int flags) {
39 int i, match = 0, partial = 0; 40 int i, match = 0, partial = 0;
40 41
41 for (i = 0; i < expect_count; i++) { 42 for (i = 0; i < expect_count; i++) {
42 if (flags & NP_MATCH_VERBOSE) 43 if (flags & NP_MATCH_VERBOSE) {
43 printf("looking for [%s] %s [%s]\n", server_expect[i], (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status); 44 printf("looking for [%s] %s [%s]\n", server_expect[i],
45 (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status);
46 }
44 47
45 if (flags & NP_MATCH_EXACT) { 48 if (flags & NP_MATCH_EXACT) {
46 if (strncmp(status, server_expect[i], strlen(server_expect[i])) == 0) { 49 if (strncmp(status, server_expect[i], strlen(server_expect[i])) == 0) {
@@ -60,10 +63,12 @@ enum np_match_result np_expect_match(char *status, char **server_expect, int exp
60 VERBOSE("couldn't find it"); 63 VERBOSE("couldn't find it");
61 } 64 }
62 65
63 if ((flags & NP_MATCH_ALL && match == expect_count) || (!(flags & NP_MATCH_ALL) && match >= 1)) 66 if ((flags & NP_MATCH_ALL && match == expect_count) ||
67 (!(flags & NP_MATCH_ALL) && match >= 1)) {
64 return NP_MATCH_SUCCESS; 68 return NP_MATCH_SUCCESS;
65 else if (partial > 0 || !(flags & NP_MATCH_EXACT)) 69 } else if (partial > 0 || !(flags & NP_MATCH_EXACT)) {
66 return NP_MATCH_RETRY; 70 return NP_MATCH_RETRY;
67 else 71 } else {
68 return NP_MATCH_FAILURE; 72 return NP_MATCH_FAILURE;
73 }
69} 74}