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 * Bacula BREGEXP Structure definition for FileDaemon
22 * Eric Bollengier March 2007
39 * #include "lib/breg.h"
41 * BREGEXP *breg = new_bregexp("!/prod!/test!");
42 * char *filename = breg->replace("/prod/data.dat");
44 * char *filename = breg->result;
51 * Structure for BREGEXP ressource
55 POOLMEM *result; /* match result */
56 bool success; /* match is ok */
58 char *replace(const char *fname); /* return this.result */
62 POOLMEM *expr; /* search epression */
63 POOLMEM *subst; /* substitution */
64 regex_t preg; /* regex_t result of regcomp() */
65 regmatch_t regs[BREG_NREGS]; /* contains match */
66 char *eor; /* end of regexp in expr */
68 char *return_fname(const char *fname, int len); /* return fname as result */
69 char *edit_subst(const char *fname, regmatch_t breg[]);
70 int compute_dest_len(const char *fname, regmatch_t breg[]);
71 bool extract_regexp(const char *motif);
74 /* create new BREGEXP and compile regex_t */
75 BREGEXP *new_bregexp(const char *motif);
77 /* launch each bregexp on filename */
78 int run_bregexp(alist *bregexps, const char *fname);
80 /* free BREGEXP (and all POOLMEM) */
81 void free_bregexp(BREGEXP *script);
83 /* fill an alist with BREGEXP from where */
84 alist *get_bregexps(const char *where);
86 /* apply every regexps from the alist */
87 bool apply_bregexps(const char *fname, alist *bregexps, char **result);
89 /* foreach_alist free RUNSCRIPT */
90 void free_bregexps(alist *bregexps); /* you have to free alist */
93 int bregexp_get_build_where_size(char *strip_prefix,
97 /* get a bregexp string from user arguments
98 * you must allocate it with bregexp_get_build_where_size();
100 char *bregexp_build_where(char *dest, int str_size,
105 /* escape a string to regexp format (sep and \)
106 * dest must be long enough (dest = 2*src + 1)
108 char *bregexp_escape_string(char *dest, const char *src, const char sep);
110 #endif /* __BREG_H_ */