From 0f71b7d07a8badd9aa38ef8d847bd982ab2db72c Mon Sep 17 00:00:00 2001 From: Matthias Eble Date: Fri, 30 Mar 2007 08:53:58 +0000 Subject: check_disk: added regex functionality -r and -R. see np-devel mail (2007-02-10) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1658 f882894a-f735-0410-b71e-b25c423dba1c --- lib/utils_disk.c | 10 ++++++++++ lib/utils_disk.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'lib') diff --git a/lib/utils_disk.c b/lib/utils_disk.c index 877b80d9..cfd6a979 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c @@ -155,3 +155,13 @@ np_seen_name(struct name_list *list, const char *name) return FALSE; } +int +np_regex_match_mount_entry (struct mount_entry* me, regex_t* re) +{ + if (regexec(re, me->me_devname, (size_t) 0, NULL, 0) == 0 || + regexec(re, me->me_mountdir, (size_t) 0, NULL, 0) == 0 ) { + return true; + } else { + return false; + } +} diff --git a/lib/utils_disk.h b/lib/utils_disk.h index 331c16d7..6263339f 100644 --- a/lib/utils_disk.h +++ b/lib/utils_disk.h @@ -2,6 +2,7 @@ #include "mountlist.h" #include "utils_base.h" +#include "regex.h" struct name_list { @@ -32,3 +33,4 @@ struct parameter_list *np_add_parameter(struct parameter_list **list, const char struct parameter_list *np_find_parameter(struct parameter_list *list, const char *name); int search_parameter_list (struct parameter_list *list, const char *name); void np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact); +int np_regex_match_mount_entry (struct mount_entry* me, regex_t* re); -- cgit v1.2.3-74-g34f1