2 * Bacula BREGEXP Structure definition for FileDaemon
3 * Eric Bollengier March 2007
7 Bacula® - The Network Backup Solution
9 Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
11 The main author of Bacula is Kern Sibbald, with contributions from
12 many others, a complete list can be found in the file AUTHORS.
13 This program is Free Software; you can redistribute it and/or
14 modify it under the terms of version two of the GNU General Public
15 License as published by the Free Software Foundation and included
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 Bacula® is a registered trademark of Kern Sibbald.
29 The licensor of Bacula is the Free Software Foundation Europe
30 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
31 Switzerland, email:ftf@fsfeurope.org.
48 * #include "lib/breg.h"
50 * BREGEXP *breg = new_bregexp("!/prod!/test!");
51 * char *filename = breg->replace("/prod/data.dat");
53 * char *filename = breg->result;
60 * Structure for BREGEXP ressource
64 POOLMEM *result; /* match result */
65 bool success; /* match is ok */
67 char *replace(const char *fname); /* return this.result */
71 POOLMEM *expr; /* search epression */
72 POOLMEM *subst; /* substitution */
73 regex_t preg; /* regex_t result of regcomp() */
74 regmatch_t regs[BREG_NREGS]; /* contains match */
75 char *eor; /* end of regexp in expr */
77 char *return_fname(const char *fname, int len); /* return fname as result */
78 char *edit_subst(const char *fname, regmatch_t regs[]);
79 int compute_dest_len(const char *fname, regmatch_t regs[]);
80 bool extract_regexp(const char *motif);
83 /* create new BREGEXP and compile regex_t */
84 BREGEXP *new_bregexp(const char *motif);
86 /* launch each bregexp on filename */
87 int run_bregexp(alist *bregexps, const char *fname);
89 /* free BREGEXP (and all POOLMEM) */
90 void free_bregexp(BREGEXP *script);
92 /* fill an alist with BREGEXP from where */
93 alist *get_bregexps(const char *where);
95 /* apply every regexps from the alist */
96 bool apply_bregexps(const char *fname, alist *bregexps, char **result);
98 /* foreach_alist free RUNSCRIPT */
99 void free_bregexps(alist *bregexps); /* you have to free alist */
101 /* get regexp size */
102 int bregexp_get_build_where_size(char *strip_prefix,
106 /* get a bregexp string from user arguments
107 * you must allocate it with bregexp_get_build_where_size();
109 char *bregexp_build_where(char *dest, int str_size,
114 /* escape a string to regexp format (sep and \)
115 * dest must be long enough (dest = 2*src + 1)
117 char *bregexp_escape_string(char *dest, const char *src, const char sep);
119 #endif /* __BREG_H_ */