2 * Bacula BREGEXP Structure definition for FileDaemon
3 * Eric Bollengier March 2007
7 Bacula® - The Network Backup Solution
9 Copyright (C) 2006-2014 Free Software Foundation Europe e.V.
11 The main author of Bacula is Kern Sibbald, with contributions from many
12 others, a complete list can be found in the file AUTHORS.
14 You may use this file and others of this release according to the
15 license defined in the LICENSE file, which includes the Affero General
16 Public License, v3.0 ("AGPLv3") and some additional permissions and
17 terms pursuant to its AGPLv3 Section 7.
19 Bacula® is a registered trademark of Kern Sibbald.
36 * #include "lib/breg.h"
38 * BREGEXP *breg = new_bregexp("!/prod!/test!");
39 * char *filename = breg->replace("/prod/data.dat");
41 * char *filename = breg->result;
48 * Structure for BREGEXP ressource
52 POOLMEM *result; /* match result */
53 bool success; /* match is ok */
55 char *replace(const char *fname); /* return this.result */
59 POOLMEM *expr; /* search epression */
60 POOLMEM *subst; /* substitution */
61 regex_t preg; /* regex_t result of regcomp() */
62 regmatch_t regs[BREG_NREGS]; /* contains match */
63 char *eor; /* end of regexp in expr */
65 char *return_fname(const char *fname, int len); /* return fname as result */
66 char *edit_subst(const char *fname, regmatch_t pmatch[]);
67 int compute_dest_len(const char *fname, regmatch_t pmatch[]);
68 bool extract_regexp(const char *motif);
71 /* create new BREGEXP and compile regex_t */
72 BREGEXP *new_bregexp(const char *motif);
74 /* launch each bregexp on filename */
75 int run_bregexp(alist *bregexps, const char *fname);
77 /* free BREGEXP (and all POOLMEM) */
78 void free_bregexp(BREGEXP *script);
80 /* fill an alist with BREGEXP from where */
81 alist *get_bregexps(const char *where);
83 /* apply every regexps from the alist */
84 bool apply_bregexps(const char *fname, alist *bregexps, char **result);
86 /* foreach_alist free RUNSCRIPT */
87 void free_bregexps(alist *bregexps); /* you have to free alist */
90 int bregexp_get_build_where_size(char *strip_prefix,
94 /* get a bregexp string from user arguments
95 * you must allocate it with bregexp_get_build_where_size();
97 char *bregexp_build_where(char *dest, int str_size,
102 /* escape a string to regexp format (sep and \)
103 * dest must be long enough (dest = 2*src + 1)
105 char *bregexp_escape_string(char *dest, const char *src, const char sep);
107 #endif /* __BREG_H_ */