projects
/
openvswitch
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3c303e5
)
cfg: New function cfg_get_matches().
author
Ben Pfaff
<blp@nicira.com>
Thu, 16 Jul 2009 22:07:05 +0000
(15:07 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Thu, 16 Jul 2009 22:07:05 +0000
(15:07 -0700)
lib/cfg.c
patch
|
blob
|
history
lib/cfg.h
patch
|
blob
|
history
diff --git
a/lib/cfg.c
b/lib/cfg.c
index a53e6e380da3e2783ddd07c51c5fed6dd22bf5bc..433d7a0fac56ba6cb47e402fe573ed909941e8ed 100644
(file)
--- a/
lib/cfg.c
+++ b/
lib/cfg.c
@@
-676,6
+676,25
@@
cfg_del_match(const char *pattern_, ...)
free(pattern);
}
free(pattern);
}
+/* Fills 'svec' with all of the key-value pairs that match shell glob pattern
+ * 'pattern'. The caller must first initialize 'svec'. */
+void
+cfg_get_matches(struct svec *svec, const char *pattern_, ...)
+{
+ char *pattern;
+ char **p;
+
+ FORMAT_KEY(pattern_, pattern);
+
+ for (p = cfg.names; *p; p++) {
+ if (!fnmatch(pattern, *p, 0)) {
+ svec_add(svec, *p);
+ }
+ }
+
+ free(pattern);
+}
+
/* Fills 'svec' with all of the key-value pairs that have sections that
* begin with 'section'. The caller must first initialize 'svec'. */
void
/* Fills 'svec' with all of the key-value pairs that have sections that
* begin with 'section'. The caller must first initialize 'svec'. */
void
diff --git
a/lib/cfg.h
b/lib/cfg.h
index f548de27f75da6d7aa1e869fad6e63910620732d..42345f86b155a4b07badf415541396f728a5d4fc 100644
(file)
--- a/
lib/cfg.h
+++ b/
lib/cfg.h
@@
-63,6
+63,8
@@
void cfg_add_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
void cfg_del_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
void cfg_del_section(const char *key, ...) PRINTF_FORMAT(1, 2);
void cfg_del_match(const char *pattern, ...) PRINTF_FORMAT(1, 2);
void cfg_del_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
void cfg_del_section(const char *key, ...) PRINTF_FORMAT(1, 2);
void cfg_del_match(const char *pattern, ...) PRINTF_FORMAT(1, 2);
+void cfg_get_matches(struct svec *svec, const char *pattern, ...)
+ PRINTF_FORMAT(2, 3);
void cfg_get_section(struct svec *svec, const char *key, ...)
PRINTF_FORMAT(2, 3);
void cfg_get_section(struct svec *svec, const char *key, ...)
PRINTF_FORMAT(2, 3);