2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Test program for testing wild card expressions
27 #include "lib/fnmatch.h"
33 "Usage: bwild [-d debug_level] -f <data-file>\n"
34 " -f specify file of data to be matched\n"
35 " -i use case insenitive match\n"
36 " -l suppress line numbers\n"
37 " -n print lines that do not match\n"
38 " -? print this message.\n"
44 int main(int argc, char *const *argv)
51 bool match_only = true;
53 bool no_linenos = false;
57 setlocale(LC_ALL, "");
58 bindtextdomain("bacula", LOCALEDIR);
61 while ((ch = getopt(argc, argv, "d:f:in?")) != -1) {
63 case 'd': /* set debug level */
64 debug_level = atoi(optarg);
65 if (debug_level <= 0) {
74 case 'i': /* ignore case */
96 printf("A data file must be specified.\n");
103 printf("Enter a wild-card: ");
104 if (fgets(pat, sizeof(pat)-1, stdin) == NULL) {
107 strip_trailing_newline(pat);
111 fd = fopen(fname, "r");
113 printf(_("Could not open data file: %s\n"), fname);
117 while (fgets(data, sizeof(data)-1, fd)) {
118 strip_trailing_newline(data);
120 rc = fnmatch(pat, data, ic);
121 if ((match_only && rc == 0) || (!match_only && rc != 0)) {
123 printf("%s\n", data);
125 printf("%5d: %s\n", lineno, data);