X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Ffindlib%2Fmatch.c;h=49a2e92a0dc4fd5d892bb934a1c42ce5632b8e22;hb=fd373cd53b020a947c216335bba6fce2fa8ddb52;hp=2e5bc262407655b0c1e7a433b86fbc85eab575e7;hpb=49839d5884780b05d5323732715f3f28d4b77171;p=bacula%2Fbacula diff --git a/bacula/src/findlib/match.c b/bacula/src/findlib/match.c index 2e5bc26240..49a2e92a0d 100644 --- a/bacula/src/findlib/match.c +++ b/bacula/src/findlib/match.c @@ -1,3 +1,30 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2008 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of Kern Sibbald. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ /* * Old style * @@ -12,20 +39,6 @@ * Kern E. Sibbald, December MMI * */ -/* - Copyright (C) 2001-2005 Kern Sibbald - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as amended with additional clauses defined in the - file LICENSE in the main source directory. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - the file LICENSE for additional details. - - */ #include "bacula.h" #include "find.h" @@ -51,9 +64,9 @@ static const int fnmode = 0; int -match_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt, bool), void *his_pkt) +match_files(JCR *jcr, FF_PKT *ff, int file_save(JCR *, FF_PKT *ff_pkt, bool)) { - ff->callback = callback; + ff->file_save = file_save; struct s_included_file *inc = NULL; @@ -63,7 +76,7 @@ match_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt, bool) bstrncat(ff->VerifyOpts, inc->VerifyOpts, sizeof(ff->VerifyOpts)); Dmsg1(100, "find_files: file=%s\n", inc->fname); if (!file_is_excluded(ff, inc->fname)) { - if (find_one_file(jcr, ff, callback, his_pkt, inc->fname, (dev_t)-1, 1) ==0) { + if (find_one_file(jcr, ff, file_save, inc->fname, (dev_t)-1, 1) ==0) { return 0; /* error return */ } } @@ -199,7 +212,7 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname) len = strlen(p); /* Zap trailing slashes. */ p += len - 1; - while (p > inc->fname && *p == '/') { + while (p > inc->fname && IsPathSeparator(*p)) { *p-- = 0; len--; } @@ -232,7 +245,8 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname) { } next->next = inc; } - Dmsg1(50, "add_fname_to_include fname=%s\n", inc->fname); + Dmsg3(00, "add_fname_to_include prefix=%d gzip=%d fname=%s\n", + prefixed, !!(inc->options & FO_GZIP), inc->fname); } /* @@ -246,11 +260,7 @@ void add_fname_to_exclude_list(FF_PKT *ff, const char *fname) Dmsg1(20, "Add name to exclude: %s\n", fname); -#if defined(HAVE_WIN32) - if (strchr(fname, '/') || strchr(fname, '\\')) { -#else - if (strchr(fname, '/')) { -#endif + if (first_path_separator(fname) != NULL) { list = &ff->excluded_paths_list; } else { list = &ff->excluded_files_list; @@ -322,11 +332,11 @@ int file_is_included(FF_PKT *ff, const char *file) if (inc->len == len && strcmp(inc->fname, file) == 0) { return 1; } - if (inc->len < len && file[inc->len] == '/' && + if (inc->len < len && IsPathSeparator(file[inc->len]) && strncmp(inc->fname, file, inc->len) == 0) { return 1; } - if (inc->len == 1 && inc->fname[0] == '/') { + if (inc->len == 1 && IsPathSeparator(inc->fname[0])) { return 1; } } @@ -382,7 +392,7 @@ int file_is_excluded(FF_PKT *ff, const char *file) /* Try each component */ for (p = file; *p; p++) { /* Match from the beginning of a component only */ - if ((p == file || (*p != '/' && *(p-1) == '/')) + if ((p == file || (!IsPathSeparator(*p) && IsPathSeparator(p[-1]))) && file_in_excluded_list(ff->excluded_files_list, p)) { return 1; }