summaryrefslogtreecommitdiffstats
path: root/runtime/srutils.c
diff options
context:
space:
mode:
authorMartin Carpenter <mcarpenter@free.fr>2012-11-27 09:35:48 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2013-03-21 16:03:46 +0100
commit5e6ba49ef3ae3bc79c2dc1aa160900a5f776c72a (patch)
tree6a3fc109a86692b26fa80bbf717c8afa702b9ca2 /runtime/srutils.c
parent8cc6969c732c1d26cc699983d201124004a6526f (diff)
downloadrsyslog-5e6ba49ef3ae3bc79c2dc1aa160900a5f776c72a.tar.gz
rsyslog-5e6ba49ef3ae3bc79c2dc1aa160900a5f776c72a.tar.bz2
rsyslog-5e6ba49ef3ae3bc79c2dc1aa160900a5f776c72a.zip
Fix for glob(3)s that lack GLOB_NOMAGIC
Conflicts: configure.ac
Diffstat (limited to 'runtime/srutils.c')
-rw-r--r--runtime/srutils.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/srutils.c b/runtime/srutils.c
index 7b485b23..6a509b4a 100644
--- a/runtime/srutils.c
+++ b/runtime/srutils.c
@@ -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:
*/