X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fcfg.c;h=433d7a0fac56ba6cb47e402fe573ed909941e8ed;hb=fd30311c8701d297f31f6dd92c628d1d9112911e;hp=a53e6e380da3e2783ddd07c51c5fed6dd22bf5bc;hpb=3b01baa3970139c3a195017ab1ea3e42761e3db2;p=openvswitch diff --git a/lib/cfg.c b/lib/cfg.c index a53e6e38..433d7a0f 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -676,6 +676,25 @@ cfg_del_match(const char *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