diff options
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 ce02fdf..34401e2 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 | { |