From d31a696cadb0bba0914d76aad0eb48c6e7962b8e Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 23 Aug 2023 18:13:01 +0200 Subject: Introduce np_add_regex() --- lib/utils_disk.c | 11 +++++++++++ lib/utils_disk.h | 1 + 2 files changed, 12 insertions(+) diff --git a/lib/utils_disk.c b/lib/utils_disk.c index 582d3ea1..ce02fdff 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c @@ -40,6 +40,17 @@ np_add_name (struct name_list **list, const char *name) *list = new_entry; } +/* Initialises a new regex at the begin of list via regcomp(3) */ +int +np_add_regex (struct regex_list **list, const char *regex, int cflags) +{ + struct regex_list *new_entry = (struct regex_list *) malloc (sizeof *new_entry); + new_entry->next = *list; + *list = new_entry; + + return regcomp(&new_entry->regex, regex, cflags); +} + /* Initialises a new parameter at the end of list */ struct parameter_list * np_add_parameter(struct parameter_list **list, const char *name) diff --git a/lib/utils_disk.h b/lib/utils_disk.h index 442fd94f..bda088f6 100644 --- a/lib/utils_disk.h +++ b/lib/utils_disk.h @@ -41,6 +41,7 @@ struct parameter_list void np_add_name (struct name_list **list, const char *name); int np_find_name (struct name_list *list, const char *name); int np_seen_name (struct name_list *list, const char *name); +int np_add_regex (struct regex_list **list, const char *regex, int cflags); struct parameter_list *np_add_parameter(struct parameter_list **list, const char *name); struct parameter_list *np_find_parameter(struct parameter_list *list, const char *name); struct parameter_list *np_del_parameter(struct parameter_list *item, struct parameter_list *prev); -- cgit v1.2.3-74-g34f1