diff options
| author | Alexander A. Klimov <alexander.klimov@icinga.com> | 2023-08-23 18:26:12 +0200 | 
|---|---|---|
| committer | Alexander A. Klimov <alexander.klimov@icinga.com> | 2023-09-28 13:20:24 +0200 | 
| commit | 1f694195b4a6beef30bbbbffa5835a993be97a9c (patch) | |
| tree | 0a9add089b64d64a4a802e9ae2c371450ac6257b /lib/utils_disk.c | |
| parent | d31a696cadb0bba0914d76aad0eb48c6e7962b8e (diff) | |
| download | monitoring-plugins-1f69419.tar.gz | |
Introduce np_find_regmatch()
Diffstat (limited to 'lib/utils_disk.c')
| -rw-r--r-- | lib/utils_disk.c | 25 | 
1 files changed, 25 insertions, 0 deletions
| diff --git a/lib/utils_disk.c b/lib/utils_disk.c index ce02fdff..34401e21 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include "common.h" | 29 | #include "common.h" | 
| 30 | #include "utils_disk.h" | 30 | #include "utils_disk.h" | 
| 31 | #include "gl/fsusage.h" | 31 | #include "gl/fsusage.h" | 
| 32 | #include <string.h> | ||
| 32 | 33 | ||
| 33 | void | 34 | void | 
| 34 | np_add_name (struct name_list **list, const char *name) | 35 | np_add_name (struct name_list **list, const char *name) | 
| @@ -207,6 +208,30 @@ np_find_name (struct name_list *list, const char *name) | |||
| 207 | return FALSE; | 208 | return FALSE; | 
| 208 | } | 209 | } | 
| 209 | 210 | ||
| 211 | /* Returns TRUE if name is in list */ | ||
| 212 | bool | ||
| 213 | np_find_regmatch (struct regex_list *list, const char *name) | ||
| 214 | { | ||
| 215 | int len; | ||
| 216 | regmatch_t m; | ||
| 217 | |||
| 218 | if (name == NULL) { | ||
| 219 | return false; | ||
| 220 | } | ||
| 221 | |||
| 222 | len = strlen(name); | ||
| 223 | |||
| 224 | for (; list; list = list->next) { | ||
| 225 | /* Emulate a full match as if surrounded with ^( )$ | ||
| 226 | by checking whether the match spans the whole name */ | ||
| 227 | if (!regexec(&list->regex, name, 1, &m, 0) && m.rm_so == 0 && m.rm_eo == len) { | ||
| 228 | return true; | ||
| 229 | } | ||
| 230 | } | ||
| 231 | |||
| 232 | return false; | ||
| 233 | } | ||
| 234 | |||
| 210 | int | 235 | int | 
| 211 | np_seen_name(struct name_list *list, const char *name) | 236 | np_seen_name(struct name_list *list, const char *name) | 
| 212 | { | 237 | { | 
