2 * Test program for testing wild card expressions
8 Bacula® - The Network Backup Solution
10 Copyright (C) 2006-2014 Free Software Foundation Europe e.V.
12 The main author of Bacula is Kern Sibbald, with contributions from many
13 others, a complete list can be found in the file AUTHORS.
15 You may use this file and others of this release according to the
16 license defined in the LICENSE file, which includes the Affero General
17 Public License, v3.0 ("AGPLv3") and some additional permissions and
18 terms pursuant to its AGPLv3 Section 7.
20 Bacula® is a registered trademark of Kern Sibbald.
24 #include "lib/fnmatch.h"
30 "Usage: bwild [-d debug_level] -f <data-file>\n"
31 " -f specify file of data to be matched\n"
32 " -i use case insenitive match\n"
33 " -l suppress line numbers\n"
34 " -n print lines that do not match\n"
35 " -? print this message.\n"
41 int main(int argc, char *const *argv)
48 bool match_only = true;
50 bool no_linenos = false;
54 setlocale(LC_ALL, "");
55 bindtextdomain("bacula", LOCALEDIR);
58 while ((ch = getopt(argc, argv, "d:f:in?")) != -1) {
60 case 'd': /* set debug level */
61 debug_level = atoi(optarg);
62 if (debug_level <= 0) {
71 case 'i': /* ignore case */
93 printf("A data file must be specified.\n");
100 printf("Enter a wild-card: ");
101 if (fgets(pat, sizeof(pat)-1, stdin) == NULL) {
104 strip_trailing_newline(pat);
108 fd = fopen(fname, "r");
110 printf(_("Could not open data file: %s\n"), fname);
114 while (fgets(data, sizeof(data)-1, fd)) {
115 strip_trailing_newline(data);
117 rc = fnmatch(pat, data, ic);
118 if ((match_only && rc == 0) || (!match_only && rc != 0)) {
120 printf("%s\n", data);
122 printf("%5d: %s\n", lineno, data);