2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2006-2014 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
21 * Test program for testing regular expressions.
28 * If you define BACULA_REGEX, bregex will be built with the
29 * Bacula bregex library, which is the same code that we
30 * use on Win32, thus using Linux, you can test your Win32
31 * expressions. Otherwise, this program will link with the
32 * system library routines.
34 //#define BACULA_REGEX
45 "Usage: bregtest [-d debug_level] [-s] -f <data-file> -e /test/test2/\n"
46 " -f specify file of data to be matched\n"
47 " -e specify expression\n"
49 " -d <nn> set debug level to <nn>\n"
50 " -dt print timestamp in debug output\n"
51 " -? print this message.\n"
58 int main(int argc, char *const *argv)
67 setlocale(LC_ALL, "");
68 bindtextdomain("bacula", LOCALEDIR);
71 while ((ch = getopt(argc, argv, "sd:f:e:")) != -1) {
73 case 'd': /* set debug level */
77 debug_level = atoi(optarg);
78 if (debug_level <= 0) {
106 printf("A data file must be specified.\n");
111 printf("An expression must be specified.\n");
120 list = get_bregexps(expr);
123 printf("Can't use %s as 'sed' expression\n", expr);
127 fd = fopen(fname, "r");
129 printf(_("Could not open data file: %s\n"), fname);
133 while (fgets(data, sizeof(data)-1, fd)) {
134 strip_trailing_newline(data);
135 apply_bregexps(data, list, &p);
139 printf("%s => %s\n", data, p);
153 * test avec un sed et faire un diff
154 * test avec une boucle pour voir les fuites