/*
+ * Old style
+ *
* Routines used to keep and match include and exclude
* filename/pathname patterns.
*
* Note, this file is used for the old style include and
* excludes, so is deprecated. The new style code is
- * found in find.c.
+ * found in find.c.
* This code is still used for lists in testls and bextract.
*
* 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 as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ 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 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., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
#endif
/* Fold case in fnmatch() on Win32 */
-#ifdef WIN32
+#ifdef HAVE_WIN32
static const int fnmode = FNM_CASEFOLD;
#else
static const int fnmode = 0;
#undef bmalloc
#define bmalloc(x) sm_malloc(__FILE__, __LINE__, x)
-extern const int win32_client;
int
-match_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt), void *his_pkt)
+match_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt, bool), void *his_pkt)
{
ff->callback = callback;
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) {
- return 0; /* error return */
- }
+ if (find_one_file(jcr, ff, callback, his_pkt, inc->fname, (dev_t)-1, 1) ==0) {
+ return 0; /* error return */
+ }
}
}
return 1;
/* prefixed = preceded with options */
if (prefixed) {
for (rp=fname; *rp && *rp != ' '; rp++) {
- switch (*rp) {
+ switch (*rp) {
case 'a': /* alway replace */
case '0': /* no option */
- break;
+ break;
case 'f':
- inc->options |= FO_MULTIFS;
- break;
+ inc->options |= FO_MULTIFS;
+ break;
case 'h': /* no recursion */
- inc->options |= FO_NO_RECURSION;
- break;
+ inc->options |= FO_NO_RECURSION;
+ break;
case 'M': /* MD5 */
- inc->options |= FO_MD5;
- break;
+ inc->options |= FO_MD5;
+ break;
case 'n':
- inc->options |= FO_NOREPLACE;
- break;
+ inc->options |= FO_NOREPLACE;
+ break;
case 'p': /* use portable data format */
- inc->options |= FO_PORTABLE;
- break;
+ inc->options |= FO_PORTABLE;
+ break;
case 'r': /* read fifo */
- inc->options |= FO_READFIFO;
- break;
+ inc->options |= FO_READFIFO;
+ break;
case 'S':
- inc->options |= FO_SHA1;
- break;
+ inc->options |= FO_SHA1;
+ break;
case 's':
- inc->options |= FO_SPARSE;
- break;
+ inc->options |= FO_SPARSE;
+ break;
case 'm':
- inc->options |= FO_MTIMEONLY;
- break;
+ inc->options |= FO_MTIMEONLY;
+ break;
case 'k':
- inc->options |= FO_KEEPATIME;
- break;
+ inc->options |= FO_KEEPATIME;
+ break;
case 'V': /* verify options */
- /* Copy Verify Options */
+ /* Copy Verify Options */
for (j=0; *rp && *rp != ':'; rp++) {
- inc->VerifyOpts[j] = *rp;
- if (j < (int)sizeof(inc->VerifyOpts) - 1) {
- j++;
- }
- }
- inc->VerifyOpts[j] = 0;
- break;
+ inc->VerifyOpts[j] = *rp;
+ if (j < (int)sizeof(inc->VerifyOpts) - 1) {
+ j++;
+ }
+ }
+ inc->VerifyOpts[j] = 0;
+ break;
case 'w':
- inc->options |= FO_IF_NEWER;
- break;
+ inc->options |= FO_IF_NEWER;
+ break;
case 'A':
- inc->options |= FO_ACL;
- break;
+ inc->options |= FO_ACL;
+ break;
case 'Z': /* gzip compression */
- inc->options |= FO_GZIP;
+ inc->options |= FO_GZIP;
inc->level = *++rp - '0';
Dmsg1(200, "Compression level=%d\n", inc->level);
- break;
- default:
- Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *rp);
- break;
- }
+ break;
+ case 'K':
+ inc->options |= FO_NOATIME;
+ break;
+ default:
+ Emsg1(M_ERROR, 0, _("Unknown include/exclude option: %c\n"), *rp);
+ break;
+ }
}
/* Skip past space(s) */
for ( ; *rp == ' '; rp++)
- {}
+ {}
} else {
rp = fname;
}
inc->pattern = 0;
for (p=inc->fname; *p; p++) {
if (*p == '*' || *p == '[' || *p == '?') {
- inc->pattern = 1;
- break;
+ inc->pattern = 1;
+ break;
}
}
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
/* Convert any \'s into /'s */
for (p=inc->fname; *p; p++) {
if (*p == '\\') {
struct s_included_file *next;
/* Walk to end of list */
for (next=ff->included_files_list; next->next; next=next->next)
- { }
+ { }
next->next = inc;
}
Dmsg1(50, "add_fname_to_include fname=%s\n", inc->fname);
Dmsg1(20, "Add name to exclude: %s\n", fname);
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
if (strchr(fname, '/') || strchr(fname, '\\')) {
#else
if (strchr(fname, '/')) {
exc->next = *list;
exc->len = len;
strcpy(exc->fname, fname);
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
/* Convert any \'s into /'s */
for (char *p=exc->fname; *p; p++) {
if (*p == '\\') {
for ( ; inc; inc=inc->next ) {
if (inc->pattern) {
- if (fnmatch(inc->fname, file, fnmode|FNM_LEADING_DIR) == 0) {
- return 1;
- }
- continue;
+ if (fnmatch(inc->fname, file, fnmode|FNM_LEADING_DIR) == 0) {
+ return 1;
+ }
+ continue;
}
/*
* No wild cards. We accept a match to the
Dmsg2(900, "pat=%s file=%s\n", inc->fname, file);
len = strlen(file);
if (inc->len == len && strcmp(inc->fname, file) == 0) {
- return 1;
+ return 1;
}
if (inc->len < len && file[inc->len] == '/' &&
- strncmp(inc->fname, file, inc->len) == 0) {
- return 1;
+ strncmp(inc->fname, file, inc->len) == 0) {
+ return 1;
}
if (inc->len == 1 && inc->fname[0] == '/') {
- return 1;
+ return 1;
}
}
return 0;
for ( ; exc; exc=exc->next ) {
if (fnmatch(exc->fname, file, fnmode|FNM_PATHNAME) == 0) {
Dmsg2(900, "Match exc pat=%s: file=%s:\n", exc->fname, file);
- return 1;
+ return 1;
}
Dmsg2(900, "No match exc pat=%s: file=%s:\n", exc->fname, file);
}
{
const char *p;
+#if defined(HAVE_WIN32)
/*
* ***NB*** this removes the drive from the exclude
* rule. Why?????
*/
- if (win32_client && file[1] == ':') {
+ if (file[1] == ':') {
file += 2;
}
+#endif
if (file_in_excluded_list(ff->excluded_paths_list, file)) {
return 1;
for (p = file; *p; p++) {
/* Match from the beginning of a component only */
if ((p == file || (*p != '/' && *(p-1) == '/'))
- && file_in_excluded_list(ff->excluded_files_list, p)) {
- return 1;
+ && file_in_excluded_list(ff->excluded_files_list, p)) {
+ return 1;
}
}
return 0;