From: Eric Bollengier Date: Mon, 2 Apr 2007 19:34:31 +0000 (+0000) Subject: ebl update X-Git-Tag: Release-7.0.0~6626 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=769ce4389d9a72a642fdd24b708d7d6a6551de4b;p=bacula%2Fbacula ebl update git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4500 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/patches/testing/breg.c b/bacula/patches/testing/breg.c index 83cb0b57f5..07bca726e7 100644 --- a/bacula/patches/testing/breg.c +++ b/bacula/patches/testing/breg.c @@ -52,9 +52,6 @@ BREGEXP *new_bregexp(const char *motif) return NULL; } - static int _start[RE_NREGS]; - static int _end[RE_NREGS]; - self->result = get_pool_memory(PM_FNAME); self->result[0] = '\0'; @@ -102,15 +99,20 @@ void free_bregexps(alist *bregexps) /* Apply all regexps to fname */ -char *apply_bregexps(const char *fname, alist *bregexps) +bool apply_bregexps(const char *fname, alist *bregexps, char **result) { BREGEXP *elt; + bool ok=false; + char *ret = (char *) fname; foreach_alist(elt, bregexps) { ret = elt->replace(ret); + ok = ok || elt->success; } Dmsg2(500, "bregexp: fname=%s ret=%s\n", fname, ret); - return ret; + + *result = ret; + return ok; } /* return an alist of BREGEXP or return NULL if it's not a @@ -149,7 +151,7 @@ bool BREGEXP::extract_regexp(const char *motif) if (!(sep == '!' || sep == ':' || sep == ';' || - sep == 'ยง' || + sep == '|' || sep == ',' || sep == '&' || sep == '%' || @@ -163,7 +165,6 @@ bool BREGEXP::extract_regexp(const char *motif) char *search = (char *) motif + 1; int options = REG_EXTENDED | REG_NEWLINE; bool ok = false; - bool found_motif = false; /* extract 1st part */ char *dest = expr = bstrdup(motif); @@ -234,6 +235,7 @@ bool BREGEXP::extract_regexp(const char *motif) /* return regexp->result */ char *BREGEXP::replace(const char *fname) { + success = false; /* use this.success to known if it's ok */ int flen = strlen(fname); int rc = re_search(&preg, (BREGEX_CAST char*) fname, flen, 0, flen, ®s); @@ -247,7 +249,7 @@ char *BREGEXP::replace(const char *fname) if (len) { result = check_pool_memory_size(result, len); edit_subst(fname, ®s); - + success = true; Dmsg2(500, "bregexp: len = %i, result_len = %i\n", len, strlen(result)); } else { /* error in substitution */ diff --git a/bacula/patches/testing/breg.h b/bacula/patches/testing/breg.h index 606575af84..991ad5a2d3 100644 --- a/bacula/patches/testing/breg.h +++ b/bacula/patches/testing/breg.h @@ -60,7 +60,9 @@ class BREGEXP { public: POOLMEM *result; /* match result */ - char *replace(const char *fname); + bool success; /* match is ok */ + + char *replace(const char *fname); /* return this.result */ void debug(); /* private */ @@ -90,7 +92,8 @@ void free_bregexp(BREGEXP *script); /* fill an alist with BREGEXP from where */ alist *get_bregexps(const char *where); -char *apply_bregexps(const char *fname, alist *bregexps); +/* apply every regexps from the alist */ +bool apply_bregexps(const char *fname, alist *bregexps, char **result); /* foreach_alist free RUNSCRIPT */ void free_bregexps(alist *bregexps); /* you have to free alist */ diff --git a/bacula/patches/testing/bregtest.c b/bacula/patches/testing/bregtest.c index 150bcb2394..f8cbb92c25 100644 --- a/bacula/patches/testing/bregtest.c +++ b/bacula/patches/testing/bregtest.c @@ -135,7 +135,7 @@ int main(int argc, char *const *argv) while (fgets(data, sizeof(data)-1, fd)) { strip_trailing_newline(data); - p = apply_bregexps(data, list); + apply_bregexps(data, list, &p); printf("%s => %s\n", data, p); } fclose(fd);