static guint get_event_bits(const char *name);
static AuGroup *get_group(const char *name);
static char *get_next_word(char **line);
+static gboolean wildmatch(char *patterns, const char *uri);
static AuGroup *new_group(const char *name);
static void free_group(AuGroup *group);
static AutoCmd *new_autocmd(const char *excmd, const char *pattern);
}
/* skip if pattern does not match - we check the pattern against
* another pattern */
- if (!util_wildmatch(pattern, cmd->pattern)) {
+ if (!wildmatch(pattern, cmd->pattern)) {
continue;
}
/* remove the bits from the item */
}
/* check pattern only if uri was given */
/* skip if pattern does not match */
- if (uri && !util_wildmatch(cmd->pattern, uri)) {
+ if (uri && !wildmatch(cmd->pattern, uri)) {
continue;
}
/* run the command */
return word;
}
+/**
+ * Check if given uri matches one of the patterns given as comma separated
+ * string.
+ */
+static gboolean wildmatch(char *patterns, const char *uri)
+{
+ char *cur, *start;
+ gboolean matched;
+
+ for (cur = start = patterns; *cur; cur++) {
+ /* iterate through the patterns until the next ',' */
+ if (*cur == ',') {
+ *cur = '\0';
+ matched = util_wildmatch(start, uri);
+ *cur = ',';
+
+ /* return if the first match is found */
+ if (matched) {
+ return true;
+ }
+
+ /* set the start right after the ',' */
+ start = cur + 1;
+ }
+ }
+
+ /* still no match found - check the last pattern */
+ return util_wildmatch(start, uri);
+}
+
static AuGroup *new_group(const char *name)
{
AuGroup *new = g_slice_new(AuGroup);