[monitoring-plugins] Introduce np_add_regex()

Alexander A. Klimov git at monitoring-plugins.org
Thu Oct 5 11:00:13 CEST 2023


 Module: monitoring-plugins
 Branch: master
 Commit: d31a696cadb0bba0914d76aad0eb48c6e7962b8e
 Author: Alexander A. Klimov <alexander.klimov at icinga.com>
   Date: Wed Aug 23 18:13:01 2023 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=d31a696

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 582d3ea..ce02fdf 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 442fd94..bda088f 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);



More information about the Commits mailing list