From: <ri...@us...> - 2007-03-20 22:46:10
|
Revision: 4374 http://bacula.svn.sourceforge.net/bacula/?rev=4374&view=rev Author: ricozz Date: 2007-03-20 15:41:08 -0700 (Tue, 20 Mar 2007) Log Message: ----------- ebl update Modified Paths: -------------- trunk/bacula/patches/testing/breg.c Modified: trunk/bacula/patches/testing/breg.c =================================================================== --- trunk/bacula/patches/testing/breg.c 2007-03-20 22:36:28 UTC (rev 4373) +++ trunk/bacula/patches/testing/breg.c 2007-03-20 22:41:08 UTC (rev 4374) @@ -99,6 +99,17 @@ } } +char *apply_bregexps(const char *fname, alist *bregexps) +{ + BREGEXP *elt; + char *ret = (char *) fname; + foreach_alist(elt, bregexps) { + ret = elt->replace(ret); + } + return ret; +} + + bool BREGEXP::extract_regexp(const char *motif) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-03-31 11:35:22
|
Revision: 4474 http://bacula.svn.sourceforge.net/bacula/?rev=4474&view=rev Author: ricozz Date: 2007-03-31 04:35:22 -0700 (Sat, 31 Mar 2007) Log Message: ----------- ebl cleanup Modified Paths: -------------- trunk/bacula/patches/testing/breg.c Modified: trunk/bacula/patches/testing/breg.c =================================================================== --- trunk/bacula/patches/testing/breg.c 2007-03-31 11:33:20 UTC (rev 4473) +++ trunk/bacula/patches/testing/breg.c 2007-03-31 11:35:22 UTC (rev 4474) @@ -108,18 +108,6 @@ return ret; } -char *get_next_bregexp(char *where) -{ - char sep; - char *after; - bool ok=false; - - if (!where && !*where) { - return NULL; - } - -} - /* return an alist of BREGEXP or return NULL if it's not a * where=!tmp!opt!ig,!temp!opt!i */ @@ -342,21 +330,3 @@ printf("subst=[%s]\n", subst); printf("result=%s\n", result?result:"(null)"); } - -#ifdef TEST - -int main(int argc, char **argv) -{ - BREGEXP *reg; - - reg = new_bregexp(argv[1]); - - if (reg) { - reg->replace(argv[2]); - reg->debug(); - printf("%s => %s\n", argv[1], reg->result); - } - exit(0); -} - -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-03-31 21:04:09
|
Revision: 4479 http://bacula.svn.sourceforge.net/bacula/?rev=4479&view=rev Author: ricozz Date: 2007-03-31 14:03:45 -0700 (Sat, 31 Mar 2007) Log Message: ----------- ebl fix regexp separator Modified Paths: -------------- trunk/bacula/patches/testing/breg.c Modified: trunk/bacula/patches/testing/breg.c =================================================================== --- trunk/bacula/patches/testing/breg.c 2007-03-31 15:34:43 UTC (rev 4478) +++ trunk/bacula/patches/testing/breg.c 2007-03-31 21:03:45 UTC (rev 4479) @@ -135,10 +135,26 @@ bool BREGEXP::extract_regexp(const char *motif) { - if (!motif || (*motif == '\0')) { + if ( !motif ) { return false; } + char sep = motif[0]; + + if (!(sep == '!' || + sep == ':' || + sep == ';' || + sep == '\xA7' || + sep == ',' || + sep == '&' || + sep == '%' || + sep == '=' || + sep == '~' || + sep == '#' )) + { + return false; + } + char *search = (char *) motif + 1; char *replace; int options = REG_EXTENDED | REG_NEWLINE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-04-01 08:49:09
|
Revision: 4483 http://bacula.svn.sourceforge.net/bacula/?rev=4483&view=rev Author: ricozz Date: 2007-04-01 01:49:10 -0700 (Sun, 01 Apr 2007) Log Message: ----------- ebl cleanup Modified Paths: -------------- trunk/bacula/patches/testing/breg.c Modified: trunk/bacula/patches/testing/breg.c =================================================================== --- trunk/bacula/patches/testing/breg.c 2007-04-01 07:38:32 UTC (rev 4482) +++ trunk/bacula/patches/testing/breg.c 2007-04-01 08:49:10 UTC (rev 4483) @@ -88,6 +88,8 @@ free(self); } +/* Free a bregexps alist + */ void free_bregexps(alist *bregexps) { Dmsg0(500, "bregexp: freeing all BREGEXP object\n"); @@ -98,6 +100,8 @@ } } +/* Apply all regexps to fname + */ char *apply_bregexps(const char *fname, alist *bregexps) { BREGEXP *elt; @@ -105,6 +109,7 @@ foreach_alist(elt, bregexps) { ret = elt->replace(ret); } + Dmsg2(500, "bregexp: fname=%s ret=%s\n", fname, ret); return ret; } @@ -156,7 +161,6 @@ } char *search = (char *) motif + 1; - char *replace; int options = REG_EXTENDED | REG_NEWLINE; bool ok = false; bool found_motif = false; @@ -234,7 +238,7 @@ int rc = re_search(&preg, (BREGEX_CAST char*) fname, flen, 0, flen, ®s); if (rc < 0) { - Dmsg0(100, "E: regex mismatch\n"); + Dmsg0(500, "bregexp: regex mismatch\n"); return return_fname(fname, flen); } @@ -244,8 +248,10 @@ result = check_pool_memory_size(result, len); edit_subst(fname, ®s); + Dmsg2(500, "bregexp: len = %i, result_len = %i\n", len, strlen(result)); + } else { /* error in substitution */ - Dmsg0(100, "E: error in substitution\n"); + Dmsg0(100, "bregexp: error in substitution\n"); return return_fname(fname, flen); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-04-04 21:30:18
|
Revision: 4511 http://bacula.svn.sourceforge.net/bacula/?rev=4511&view=rev Author: ricozz Date: 2007-04-04 14:30:20 -0700 (Wed, 04 Apr 2007) Log Message: ----------- ebl fix Modified Paths: -------------- trunk/bacula/patches/testing/breg.c Modified: trunk/bacula/patches/testing/breg.c =================================================================== --- trunk/bacula/patches/testing/breg.c 2007-04-04 20:55:02 UTC (rev 4510) +++ trunk/bacula/patches/testing/breg.c 2007-04-04 21:30:20 UTC (rev 4511) @@ -393,19 +393,19 @@ *str_tmp = *ret = '\0'; - if (*strip_prefix) { + if (strip_prefix) { len += bsnprintf(ret, str_size - len, "!%s!!", bregexp_escape_string(str_tmp, strip_prefix, sep)); } - if (*add_suffix) { + if (add_suffix) { if (len) ret[len++] = ','; len += bsnprintf(ret + len, str_size - len, "!([^/])$!$1%s!", bregexp_escape_string(str_tmp, add_suffix, sep)); } - if (*add_prefix) { + if (add_prefix) { if (len) ret[len++] = ','; len += bsnprintf(ret + len, str_size - len, "!^!%s!", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-04-07 10:23:31
|
Revision: 4519 http://bacula.svn.sourceforge.net/bacula/?rev=4519&view=rev Author: ricozz Date: 2007-04-07 03:21:52 -0700 (Sat, 07 Apr 2007) Log Message: ----------- ebl use bmalloc instead of malloc Modified Paths: -------------- trunk/bacula/patches/testing/breg.c Modified: trunk/bacula/patches/testing/breg.c =================================================================== --- trunk/bacula/patches/testing/breg.c 2007-04-07 07:24:39 UTC (rev 4518) +++ trunk/bacula/patches/testing/breg.c 2007-04-07 10:21:52 UTC (rev 4519) @@ -43,7 +43,7 @@ BREGEXP *new_bregexp(const char *motif) { Dmsg0(500, "bregexp: creating new bregexp object\n"); - BREGEXP *self = (BREGEXP *)malloc(sizeof(BREGEXP)); + BREGEXP *self = (BREGEXP *)bmalloc(sizeof(BREGEXP)); memset(self, 0, sizeof(BREGEXP)); if (!self->extract_regexp(motif)) { @@ -57,7 +57,7 @@ #ifdef HAVE_REGEX_H /* TODO: que devient cette memoire... */ - self->_regs_match = (int *) malloc (2*RE_NREGS * sizeof(int)); + self->_regs_match = (int *) bmalloc (2*RE_NREGS * sizeof(int)); self->regs.num_regs = RE_NREGS; self->regs.start = self->_regs_match; @@ -82,7 +82,7 @@ free_pool_memory(self->result); } if (self->_regs_match) { - free(self->_regs_match); + bfree(self->_regs_match); } regfree(&self->preg); @@ -392,7 +392,7 @@ add_prefix?strlen(add_prefix)+5:0 + /* escape + 3*, + \0 */ add_suffix?strlen(add_suffix)+14:0 ) * 2 + 3 + 1; - char *ret = (char *) malloc(str_size*sizeof(char)); + char *ret = (char *) bmalloc(str_size*sizeof(char)); POOLMEM *str_tmp = get_memory(str_size); *str_tmp = *ret = '\0'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-04-07 10:44:00
|
Revision: 4520 http://bacula.svn.sourceforge.net/bacula/?rev=4520&view=rev Author: ricozz Date: 2007-04-07 03:43:59 -0700 (Sat, 07 Apr 2007) Log Message: ----------- ebl use bfree instead of free add bregexp_get_build_where_size and avoid malloc in build_where Modified Paths: -------------- trunk/bacula/patches/testing/breg.c Modified: trunk/bacula/patches/testing/breg.c =================================================================== --- trunk/bacula/patches/testing/breg.c 2007-04-07 10:21:52 UTC (rev 4519) +++ trunk/bacula/patches/testing/breg.c 2007-04-07 10:43:59 UTC (rev 4520) @@ -76,7 +76,7 @@ } if (self->expr) { - free(self->expr); + bfree(self->expr); } if (self->result) { free_pool_memory(self->result); @@ -86,7 +86,7 @@ } regfree(&self->preg); - free(self); + bfree(self); } /* Free a bregexps alist @@ -375,44 +375,58 @@ return ret; } -/* build a regexp string with user arguments - * don't forget to free ret - */ -char *bregexp_build_where(char *strip_prefix, - char *add_prefix, - char *add_suffix) +int bregexp_get_build_where_size(char *strip_prefix, + char *add_prefix, + char *add_suffix) { /* strip_prefix = !strip_prefix!!i 4 bytes * add_prefix = !^!add_prefix! 5 bytes * add_suffix = !([^/])$!$1add_suffix! 13 bytes */ - int len=0; - char sep = '!'; int str_size = (strip_prefix?strlen(strip_prefix)+4:0 + add_prefix?strlen(add_prefix)+5:0 + /* escape + 3*, + \0 */ add_suffix?strlen(add_suffix)+14:0 ) * 2 + 3 + 1; - char *ret = (char *) bmalloc(str_size*sizeof(char)); + return str_size; +} + +/* build a regexp string with user arguments + * Usage : + * + * int len = bregexp_get_build_where_size(a,b,c) ; + * char *dest = (char *) bmalloc (len * sizeof(char)); + * bregexp_build_where(dest, len, a, b, c); + * free(dest); + * + */ +char *bregexp_build_where(char *dest, int str_size, + char *strip_prefix, + char *add_prefix, + char *add_suffix) +{ + int len=0; + char sep = '!'; + POOLMEM *str_tmp = get_memory(str_size); - *str_tmp = *ret = '\0'; + *str_tmp = *dest = '\0'; if (strip_prefix) { - len += bsnprintf(ret, str_size - len, "!%s!!i", + len += bsnprintf(dest, str_size - len, "!%s!!i", bregexp_escape_string(str_tmp, strip_prefix, sep)); } if (add_suffix) { - if (len) ret[len++] = ','; + if (len) dest[len++] = ','; - len += bsnprintf(ret + len, str_size - len, "!([^/])$!$1%s!", + len += bsnprintf(dest + len, str_size - len, "!([^/])$!$1%s!", bregexp_escape_string(str_tmp, add_suffix, sep)); } if (add_prefix) { - if (len) ret[len++] = ','; + if (len) dest[len++] = ','; - len += bsnprintf(ret + len, str_size - len, "!^!%s!", + len += bsnprintf(dest + len, str_size - len, "!^!%s!", bregexp_escape_string(str_tmp, add_prefix, sep)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-04-21 15:05:27
|
Revision: 4581 http://bacula.svn.sourceforge.net/bacula/?rev=4581&view=rev Author: ricozz Date: 2007-04-21 08:05:27 -0700 (Sat, 21 Apr 2007) Log Message: ----------- ebl cleanup Modified Paths: -------------- trunk/bacula/patches/testing/breg.c Modified: trunk/bacula/patches/testing/breg.c =================================================================== --- trunk/bacula/patches/testing/breg.c 2007-04-21 09:34:06 UTC (rev 4580) +++ trunk/bacula/patches/testing/breg.c 2007-04-21 15:05:27 UTC (rev 4581) @@ -375,17 +375,20 @@ return ret; } +static char regexp_sep = '!'; +static char *str_strip_prefix = "!%s!!i"; +static char *str_add_prefix = "!^!%s!"; +static char *str_add_suffix = "!([^/])$!$1%s!"; + int bregexp_get_build_where_size(char *strip_prefix, char *add_prefix, char *add_suffix) { - /* strip_prefix = !strip_prefix!!i 4 bytes - * add_prefix = !^!add_prefix! 5 bytes - * add_suffix = !([^/])$!$1add_suffix! 13 bytes - */ - int str_size = ((strip_prefix?strlen(strip_prefix)+4:0) + - (add_prefix?strlen(add_prefix)+5 :0) + /* escape + 3*, + \0 */ - (add_suffix?strlen(add_suffix)+14 :0) ) * 2 + 3 + 1; + int str_size = ((strip_prefix?strlen(strip_prefix)+strlen(str_strip_prefix):0) + + (add_prefix?strlen(add_prefix)+strlen(str_add_prefix) :0) + + (add_suffix?strlen(add_suffix)+strlen(str_add_suffix) :0) ) + /* escape + 3*, + \0 */ + * 2 + 3 + 1; Dmsg1(1, "bregexp_get_build_where_size = %i\n", str_size); return str_size; @@ -397,7 +400,7 @@ * int len = bregexp_get_build_where_size(a,b,c) ; * char *dest = (char *) bmalloc (len * sizeof(char)); * bregexp_build_where(dest, len, a, b, c); - * free(dest); + * bfree(dest); * */ char *bregexp_build_where(char *dest, int str_size, @@ -406,29 +409,28 @@ char *add_suffix) { int len=0; - char sep = '!'; POOLMEM *str_tmp = get_memory(str_size); *str_tmp = *dest = '\0'; if (strip_prefix) { - len += bsnprintf(dest, str_size - len, "!%s!!i", - bregexp_escape_string(str_tmp, strip_prefix, sep)); + len += bsnprintf(dest, str_size - len, str_strip_prefix, + bregexp_escape_string(str_tmp, strip_prefix, regexp_sep)); } if (add_suffix) { if (len) dest[len++] = ','; - len += bsnprintf(dest + len, str_size - len, "!([^/])$!$1%s!", - bregexp_escape_string(str_tmp, add_suffix, sep)); + len += bsnprintf(dest + len, str_size - len, str_add_suffix, + bregexp_escape_string(str_tmp, add_suffix, regexp_sep)); } if (add_prefix) { if (len) dest[len++] = ','; - len += bsnprintf(dest + len, str_size - len, "!^!%s!", - bregexp_escape_string(str_tmp, add_prefix, sep)); + len += bsnprintf(dest + len, str_size - len, str_add_prefix, + bregexp_escape_string(str_tmp, add_prefix, regexp_sep)); } free_pool_memory(str_tmp); @@ -441,5 +443,5 @@ { printf("expr=[%s]\n", expr); printf("subst=[%s]\n", subst); - printf("result=%s\n", result?result:"(null)"); + printf("result=%s\n", NPRT(result)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-04-21 15:27:50
|
Revision: 4583 http://bacula.svn.sourceforge.net/bacula/?rev=4583&view=rev Author: ricozz Date: 2007-04-21 08:27:18 -0700 (Sat, 21 Apr 2007) Log Message: ----------- ebl add '/' regexp separator Modified Paths: -------------- trunk/bacula/patches/testing/breg.c Modified: trunk/bacula/patches/testing/breg.c =================================================================== --- trunk/bacula/patches/testing/breg.c 2007-04-21 15:08:20 UTC (rev 4582) +++ trunk/bacula/patches/testing/breg.c 2007-04-21 15:27:18 UTC (rev 4583) @@ -161,6 +161,7 @@ sep == '%' || sep == '=' || sep == '~' || + sep == '/' || sep == '#' )) { return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |