diff options
author | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-03-30 08:48:50 +0000 |
---|---|---|
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-03-30 08:48:50 +0000 |
commit | a1fea1eafd63ca47cc1227c2ba3e0264e56c6f0d (patch) | |
tree | c45dccf0192bed1977a73e5e74d83287450a0621 /lib | |
parent | b809d23c81021ab39000196af87e1dcac4ac291d (diff) | |
download | monitoring-plugins-a1fea1eafd63ca47cc1227c2ba3e0264e56c6f0d.tar.gz |
check_disk -C is more flexible now. See np-devel post (2007-02-10)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1656 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils_disk.c | 59 | ||||
-rw-r--r-- | lib/utils_disk.h | 1 |
2 files changed, 38 insertions, 22 deletions
diff --git a/lib/utils_disk.c b/lib/utils_disk.c index 74708c0e..fd768b20 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c | |||
@@ -73,39 +73,54 @@ np_add_parameter(struct parameter_list **list, const char *name) | |||
73 | return new_path; | 73 | return new_path; |
74 | } | 74 | } |
75 | 75 | ||
76 | /* returns a pointer to the struct found in the list */ | ||
77 | struct parameter_list * | ||
78 | np_find_parameter(struct parameter_list *list, const char *name) | ||
79 | { | ||
80 | struct parameter_list *temp_list; | ||
81 | for (temp_list = list; temp_list; temp_list = temp_list->name_next) { | ||
82 | if (! strcmp(temp_list->name, name)) | ||
83 | return temp_list; | ||
84 | } | ||
85 | |||
86 | return NULL; | ||
87 | } | ||
88 | |||
76 | void | 89 | void |
77 | np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact) | 90 | np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact) |
78 | { | 91 | { |
79 | struct parameter_list *d; | 92 | struct parameter_list *d; |
80 | for (d = desired; d; d= d->name_next) { | 93 | for (d = desired; d; d= d->name_next) { |
81 | struct mount_entry *me; | 94 | if (! d->best_match) { |
82 | size_t name_len = strlen(d->name); | 95 | struct mount_entry *me; |
83 | size_t best_match_len = 0; | 96 | size_t name_len = strlen(d->name); |
84 | struct mount_entry *best_match = NULL; | 97 | size_t best_match_len = 0; |
98 | struct mount_entry *best_match = NULL; | ||
85 | 99 | ||
86 | for (me = mount_list; me; me = me->me_next) { | 100 | for (me = mount_list; me; me = me->me_next) { |
87 | size_t len = strlen (me->me_mountdir); | 101 | size_t len = strlen (me->me_mountdir); |
88 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | 102 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && |
89 | (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) | 103 | (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) |
90 | || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) | 104 | || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) |
91 | { | ||
92 | best_match = me; | ||
93 | best_match_len = len; | ||
94 | } else { | ||
95 | len = strlen (me->me_devname); | ||
96 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | ||
97 | (len == 1 || strncmp (me->me_devname, d->name, len) == 0))) | ||
98 | || (exact == TRUE && strcmp(me->me_devname, d->name)==0)) | ||
99 | { | 105 | { |
100 | best_match = me; | 106 | best_match = me; |
101 | best_match_len = len; | 107 | best_match_len = len; |
108 | } else { | ||
109 | len = strlen (me->me_devname); | ||
110 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | ||
111 | (len == 1 || strncmp (me->me_devname, d->name, len) == 0))) | ||
112 | || (exact == TRUE && strcmp(me->me_devname, d->name)==0)) | ||
113 | { | ||
114 | best_match = me; | ||
115 | best_match_len = len; | ||
116 | } | ||
102 | } | 117 | } |
103 | } | 118 | } |
104 | } | 119 | if (best_match) { |
105 | if (best_match) { | 120 | d->best_match = best_match; |
106 | d->best_match = best_match; | 121 | } else { |
107 | } else { | 122 | d->best_match = NULL; /* Not sure why this is needed as it should be null on initialisation */ |
108 | d->best_match = NULL; /* Not sure why this is needed as it should be null on initialisation */ | 123 | } |
109 | } | 124 | } |
110 | } | 125 | } |
111 | } | 126 | } |
diff --git a/lib/utils_disk.h b/lib/utils_disk.h index 8bf4f113..55de9385 100644 --- a/lib/utils_disk.h +++ b/lib/utils_disk.h | |||
@@ -28,5 +28,6 @@ void np_add_name (struct name_list **list, const char *name); | |||
28 | int np_find_name (struct name_list *list, const char *name); | 28 | int np_find_name (struct name_list *list, const char *name); |
29 | int np_seen_name (struct name_list *list, const char *name); | 29 | int np_seen_name (struct name_list *list, const char *name); |
30 | struct parameter_list *np_add_parameter(struct parameter_list **list, const char *name); | 30 | struct parameter_list *np_add_parameter(struct parameter_list **list, const char *name); |
31 | struct parameter_list *np_find_parameter(struct parameter_list *list, const char *name); | ||
31 | int search_parameter_list (struct parameter_list *list, const char *name); | 32 | int search_parameter_list (struct parameter_list *list, const char *name); |
32 | void np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact); | 33 | void np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact); |