2 * Test program for testing regular expressions.
8 Bacula
\81Â
\81® - The Network Backup Solution
10 Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
12 The main author of Bacula is Kern Sibbald, with contributions from
13 many others, a complete list can be found in the file AUTHORS.
14 This program is Free Software; you can redistribute it and/or
15 modify it under the terms of version two of the GNU General Public
16 License as published by the Free Software Foundation plus additions
17 that are listed in the file LICENSE.
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 Bacula
\81Â
\81® is a registered trademark of John Walker.
30 The licensor of Bacula is the Free Software Foundation Europe
31 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Z
\81Ã
\81¼rich,
32 Switzerland, email:ftf@fsfeurope.org.
36 * If you define BACULA_REGEX, bregex will be built with the
37 * Bacula bregex library, which is the same code that we
38 * use on Win32, thus using Linux, you can test your Win32
39 * expressions. Otherwise, this program will link with the
40 * system library routines.
42 //#define BACULA_REGEX
53 "Usage: bregtest [-d debug_level] [-s] -f <data-file> -e /test/test2/\n"
54 " -f specify file of data to be matched\n"
55 " -e specify expression\n"
57 " -? print this message.\n"
64 int main(int argc, char *const *argv)
73 setlocale(LC_ALL, "");
74 bindtextdomain("bacula", LOCALEDIR);
77 while ((ch = getopt(argc, argv, "sd:f:e:")) != -1) {
79 case 'd': /* set debug level */
80 debug_level = atoi(optarg);
81 if (debug_level <= 0) {
108 printf("A data file must be specified.\n");
113 printf("An expression must be specified.\n");
122 list = get_bregexps(expr);
125 printf("Can't use %s as 'sed' expression\n", expr);
129 fd = fopen(fname, "r");
131 printf(_("Could not open data file: %s\n"), fname);
135 while (fgets(data, sizeof(data)-1, fd)) {
136 strip_trailing_newline(data);
137 apply_bregexps(data, list, &p);
141 printf("%s => %s\n", data, p);
155 * test avec un sed et faire un diff
156 * test avec une boucle pour voir les fuites