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 * Bacula BREGEXP Structure definition for FileDaemon
21 * Eric Bollengier March 2007
38 * #include "lib/breg.h"
40 * BREGEXP *breg = new_bregexp("!/prod!/test!");
41 * char *filename = breg->replace("/prod/data.dat");
43 * char *filename = breg->result;
50 * Structure for BREGEXP ressource
54 POOLMEM *result; /* match result */
55 bool success; /* match is ok */
57 char *replace(const char *fname); /* return this.result */
61 POOLMEM *expr; /* search epression */
62 POOLMEM *subst; /* substitution */
63 regex_t preg; /* regex_t result of regcomp() */
64 regmatch_t regs[BREG_NREGS]; /* contains match */
65 char *eor; /* end of regexp in expr */
67 char *return_fname(const char *fname, int len); /* return fname as result */
68 char *edit_subst(const char *fname, regmatch_t breg[]);
69 int compute_dest_len(const char *fname, regmatch_t breg[]);
70 bool extract_regexp(const char *motif);
73 /* create new BREGEXP and compile regex_t */
74 BREGEXP *new_bregexp(const char *motif);
76 /* launch each bregexp on filename */
77 int run_bregexp(alist *bregexps, const char *fname);
79 /* free BREGEXP (and all POOLMEM) */
80 void free_bregexp(BREGEXP *script);
82 /* fill an alist with BREGEXP from where */
83 alist *get_bregexps(const char *where);
85 /* apply every regexps from the alist */
86 bool apply_bregexps(const char *fname, alist *bregexps, char **result);
88 /* foreach_alist free RUNSCRIPT */
89 void free_bregexps(alist *bregexps); /* you have to free alist */
92 int bregexp_get_build_where_size(char *strip_prefix,
96 /* get a bregexp string from user arguments
97 * you must allocate it with bregexp_get_build_where_size();
99 char *bregexp_build_where(char *dest, int str_size,
104 /* escape a string to regexp format (sep and \)
105 * dest must be long enough (dest = 2*src + 1)
107 char *bregexp_escape_string(char *dest, const char *src, const char sep);
109 #endif /* __BREG_H_ */