projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #2819 from rpv-tomsk/snmp-fix-2291-1
[collectd.git]
/
src
/
utils_vl_lookup.c
diff --git
a/src/utils_vl_lookup.c
b/src/utils_vl_lookup.c
index
76c0674
..
03e61f8
100644
(file)
--- a/
src/utils_vl_lookup.c
+++ b/
src/utils_vl_lookup.c
@@
-33,6
+33,10
@@
#include "utils_avltree.h"
#include "utils_vl_lookup.h"
#include "utils_avltree.h"
#include "utils_vl_lookup.h"
+#if HAVE_KSTAT_H
+#include <kstat.h>
+#endif
+
#if HAVE_LIBKSTAT
kstat_ctl_t *kc;
#endif /* HAVE_LIBKSTAT */
#if HAVE_LIBKSTAT
kstat_ctl_t *kc;
#endif /* HAVE_LIBKSTAT */
@@
-53,7
+57,7
@@
kstat_ctl_t *kc;
struct part_match_s {
char str[DATA_MAX_NAME_LEN];
regex_t regex;
struct part_match_s {
char str[DATA_MAX_NAME_LEN];
regex_t regex;
-
_B
ool is_regex;
+
b
ool is_regex;
};
typedef struct part_match_s part_match_t;
};
typedef struct part_match_s part_match_t;
@@
-110,25
+114,25
@@
typedef struct by_type_entry_s by_type_entry_t;
/*
* Private functions
*/
/*
* Private functions
*/
-static
_B
ool lu_part_matches(part_match_t const *match, /* {{{ */
-
char const *str) {
+static
b
ool lu_part_matches(part_match_t const *match, /* {{{ */
+ char const *str) {
if (match->is_regex) {
/* Short cut popular catch-all regex. */
if (strcmp(".*", match->str) == 0)
if (match->is_regex) {
/* Short cut popular catch-all regex. */
if (strcmp(".*", match->str) == 0)
- return
1
;
+ return
true
;
int status = regexec(&match->regex, str,
/* nmatch = */ 0, /* pmatch = */ NULL,
/* flags = */ 0);
if (status == 0)
int status = regexec(&match->regex, str,
/* nmatch = */ 0, /* pmatch = */ NULL,
/* flags = */ 0);
if (status == 0)
- return
1
;
+ return
true
;
else
else
- return
0
;
+ return
false
;
} else if (strcmp(match->str, str) == 0)
} else if (strcmp(match->str, str) == 0)
- return
1
;
+ return
true
;
else
else
- return
0
;
-} /* }}}
_B
ool lu_part_matches */
+ return
false
;
+} /* }}}
b
ool lu_part_matches */
static int lu_copy_ident_to_match_part(part_match_t *match_part, /* {{{ */
char const *ident_part) {
static int lu_copy_ident_to_match_part(part_match_t *match_part, /* {{{ */
char const *ident_part) {
@@
-137,7
+141,7
@@
static int lu_copy_ident_to_match_part(part_match_t *match_part, /* {{{ */
if ((len < 3) || (ident_part[0] != '/') || (ident_part[len - 1] != '/')) {
sstrncpy(match_part->str, ident_part, sizeof(match_part->str));
if ((len < 3) || (ident_part[0] != '/') || (ident_part[len - 1] != '/')) {
sstrncpy(match_part->str, ident_part, sizeof(match_part->str));
- match_part->is_regex =
0
;
+ match_part->is_regex =
false
;
return 0;
}
return 0;
}
@@
-156,7
+160,7
@@
static int lu_copy_ident_to_match_part(part_match_t *match_part, /* {{{ */
match_part->str, errbuf);
return EINVAL;
}
match_part->str, errbuf);
return EINVAL;
}
- match_part->is_regex =
1
;
+ match_part->is_regex =
true
;
return 0;
} /* }}} int lu_copy_ident_to_match_part */
return 0;
} /* }}} int lu_copy_ident_to_match_part */
@@
-331,7
+335,7
@@
static int lu_handle_user_class_list(lookup_t *obj, /* {{{ */
static by_type_entry_t *lu_search_by_type(lookup_t *obj, /* {{{ */
char const *type,
static by_type_entry_t *lu_search_by_type(lookup_t *obj, /* {{{ */
char const *type,
-
_B
ool allocate_if_missing) {
+
b
ool allocate_if_missing) {
by_type_entry_t *by_type;
char *type_copy;
int status;
by_type_entry_t *by_type;
char *type_copy;
int status;
@@
-463,7
+467,7
@@
static void lu_destroy_user_class_list(lookup_t *obj, /* {{{ */
do { \
if (user_class_list->entry.match.field.is_regex) { \
regfree(&user_class_list->entry.match.field.regex); \
do { \
if (user_class_list->entry.match.field.is_regex) { \
regfree(&user_class_list->entry.match.field.regex); \
- user_class_list->entry.match.field.is_regex =
0;
\
+ user_class_list->entry.match.field.is_regex =
false;
\
} \
} while (0)
} \
} while (0)
@@
-572,7
+576,7
@@
int lookup_add(lookup_t *obj, /* {{{ */
by_type_entry_t *by_type = NULL;
user_class_list_t *user_class_obj;
by_type_entry_t *by_type = NULL;
user_class_list_t *user_class_obj;
- by_type = lu_search_by_type(obj, ident->type, /* allocate = */
1
);
+ by_type = lu_search_by_type(obj, ident->type, /* allocate = */
true
);
if (by_type == NULL)
return -1;
if (by_type == NULL)
return -1;
@@
-601,7
+605,7
@@
int lookup_search(lookup_t *obj, /* {{{ */
if ((obj == NULL) || (ds == NULL) || (vl == NULL))
return -EINVAL;
if ((obj == NULL) || (ds == NULL) || (vl == NULL))
return -EINVAL;
- by_type = lu_search_by_type(obj, vl->type, /* allocate = */
0
);
+ by_type = lu_search_by_type(obj, vl->type, /* allocate = */
false
);
if (by_type == NULL)
return 0;
if (by_type == NULL)
return 0;