summaryrefslogtreecommitdiffstats
path: root/runtime/srutils.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-09-13 02:39:42 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2013-09-13 02:39:42 +0200
commit7903677bfba6fd897010d9c5dbb56531bfe0d825 (patch)
tree110e409834bab0fb1edd8f869e911c8d8d510493 /runtime/srutils.c
parentad777330629c31447018e47b4033a7ebaa9fe655 (diff)
parent15921d4e4e9d03e0cfd4ca5a9745c89b5dcd37c3 (diff)
downloadrsyslog-7903677bfba6fd897010d9c5dbb56531bfe0d825.tar.gz
rsyslog-7903677bfba6fd897010d9c5dbb56531bfe0d825.tar.bz2
rsyslog-7903677bfba6fd897010d9c5dbb56531bfe0d825.zip
Merge branch 'v7-stable' into v7-stable-tlsfix
Conflicts: ChangeLog runtime/rsyslog.h
Diffstat (limited to 'runtime/srutils.c')
-rw-r--r--runtime/srutils.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/runtime/srutils.c b/runtime/srutils.c
index 4ce6196a..6a509b4a 100644
--- a/runtime/srutils.c
+++ b/runtime/srutils.c
@@ -527,8 +527,7 @@ char *rs_strerror_r(int errnum, char *buf, size_t buflen) {
}
-/* Decode a symbolic name to a numeric value
- */
+/* Decode a symbolic name to a numeric value */
int decodeSyslogName(uchar *name, syslogName_t *codetab)
{
register syslogName_t *c;
@@ -538,22 +537,23 @@ int decodeSyslogName(uchar *name, syslogName_t *codetab)
ASSERT(name != NULL);
ASSERT(codetab != NULL);
- dbgprintf("symbolic name: %s", name);
- if (isdigit((int) *name))
- {
- dbgprintf("\n");
+ DBGPRINTF("symbolic name: %s", name);
+ if(isdigit((int) *name)) {
+ DBGPRINTF("\n");
return (atoi((char*) name));
}
strncpy((char*) buf, (char*) name, 79);
- for (p = buf; *p; p++)
+ for(p = buf; *p; p++) {
if (isupper((int) *p))
*p = tolower((int) *p);
- for (c = codetab; c->c_name; c++)
- if (!strcmp((char*) buf, (char*) c->c_name))
- {
- dbgprintf(" ==> %d\n", c->c_val);
+ }
+ for(c = codetab; c->c_name; c++) {
+ if(!strcmp((char*) buf, (char*) c->c_name)) {
+ DBGPRINTF(" ==> %d\n", c->c_val);
return (c->c_val);
}
+ }
+ DBGPRINTF("\n");
return (-1);
}
@@ -630,6 +630,28 @@ finalize_it:
RETiRet;
}
+/* Returns 1 if the given string contains a non-escaped glob(3)
+ * wildcard character and 0 otherwise (or if the string is empty).
+ */
+int
+containsGlobWildcard(char *str)
+{
+ char *p;
+ if(!str) {
+ return 0;
+ }
+ /* From Linux Programmer's Guide:
+ * "A string is a wildcard pattern if it contains one of the characters '?', '*' or '['"
+ * "One can remove the special meaning of '?', '*' and '[' by preceding them by a backslash"
+ */
+ for(p = str; *p != '\0'; p++) {
+ if((*p == '?' || *p == '*' || *p == '[') &&
+ (p == str || *(p-1) != '\\')) {
+ return 1;
+ }
+ }
+ return 0;
+}
/* vim:set ai:
*/