globmatch: Add globmatch to wrap fnmatch
[src/app-framework-binder.git] / src / globmatch.h
diff --git a/src/globmatch.h b/src/globmatch.h
new file mode 100644 (file)
index 0000000..2f05c16
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018, 2019 "IoT.bzh"
+ * Author: José Bollo <jose.bollo@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#define GLOB    '*'
+
+extern unsigned globmatch(const char *pat, const char *str);
+extern unsigned globmatchi(const char *pat, const char *str);
+
+#if WITH_FNMATCH
+
+#include <fnmatch.h>
+
+#else
+
+#define        FNM_PATHNAME    (1 << 0)        /* No wildcard can ever match `/'.  */
+#define        FNM_NOESCAPE    (1 << 1)        /* Backslashes don't quote special chars.  */
+#define        FNM_PERIOD      (1 << 2)        /* Leading `.' is matched only explicitly.  */
+#define FNM_FILE_NAME  FNM_PATHNAME    /* Preferred GNU name.  */
+#define FNM_LEADING_DIR (1 << 3)       /* Ignore `/...' after a match.  */
+#define FNM_CASEFOLD   (1 << 4)        /* Compare without regard to case.  */
+#define FNM_EXTMATCH   (1 << 5)        /* Use ksh-like extended matching. */
+#define        FNM_NOMATCH     1
+
+extern int fnmatch(const char *pattern, const char *string, int flags);
+
+#endif