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 regular expressions.
27 * If you define BACULA_REGEX, bregex will be built with the
28 * Bacula bregex library, which is the same code that we
29 * use on Win32, thus using Linux, you can test your Win32
30 * expressions. Otherwise, this program will link with the
31 * system library routines.
33 //#define BACULA_REGEX
44 "Usage: bregtest [-d debug_level] [-s] -f <data-file> -e /test/test2/\n"
45 " -f specify file of data to be matched\n"
46 " -e specify expression\n"
48 " -d <nn> set debug level to <nn>\n"
49 " -dt print timestamp in debug output\n"
50 " -? print this message.\n"
57 int main(int argc, char *const *argv)
66 setlocale(LC_ALL, "");
67 bindtextdomain("bacula", LOCALEDIR);
70 while ((ch = getopt(argc, argv, "sd:f:e:")) != -1) {
72 case 'd': /* set debug level */
76 debug_level = atoi(optarg);
77 if (debug_level <= 0) {
105 printf("A data file must be specified.\n");
110 printf("An expression must be specified.\n");
119 list = get_bregexps(expr);
122 printf("Can't use %s as 'sed' expression\n", expr);
126 fd = fopen(fname, "r");
128 printf(_("Could not open data file: %s\n"), fname);
132 while (fgets(data, sizeof(data)-1, fd)) {
133 strip_trailing_newline(data);
134 apply_bregexps(data, list, &p);
138 printf("%s => %s\n", data, p);
152 * test avec un sed et faire un diff
153 * test avec une boucle pour voir les fuites