]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/tools/testfind.c
update version
[bacula/bacula] / bacula / src / tools / testfind.c
index 57528e309dd6db2fd802be11375c19a0f00f3a72..15e4ac67f5114593a0dbefce1be2dc963e0f189b 100644 (file)
@@ -6,7 +6,7 @@
    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
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
    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
+   You should have received a copy of the GNU Affero 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 John Walker.
+   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.
@@ -35,6 +35,7 @@
 #include "bacula.h"
 #include "dird/dird.h"
 #include "findlib/find.h"
+#include "ch.h"
 
 #if defined(HAVE_WIN32)
 #define isatty(fd) (fd==0)
@@ -44,6 +45,7 @@
 int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
 int generate_job_event(JCR *jcr, const char *event) { return 1; }
 void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) { }
+extern bool parse_dir_config(CONFIG *config, const char *configfile, int exit_code);
 
 /* Global variables */
 static int num_files = 0;
@@ -52,10 +54,11 @@ static int max_path_len = 0;
 static int trunc_fname = 0;
 static int trunc_path = 0;
 static int attrs = 0;
+static CONFIG *config;
 
 static JCR *jcr;
 
-static int print_file(FF_PKT *ff, void *pkt, bool);
+static int print_file(JCR *jcr, FF_PKT *ff, bool);
 static void count_files(FF_PKT *ff);
 static bool copy_fileset(FF_PKT *ff, JCR *jcr);
 static void set_options(findFOPTS *fo, const char *opts);
@@ -97,6 +100,7 @@ main (int argc, char *const *argv)
    setlocale(LC_ALL, "");
    bindtextdomain("bacula", LOCALEDIR);
    textdomain("bacula");
+   lmgr_init_thread();
 
    while ((ch = getopt(argc, argv, "ac:d:f:?")) != -1) {
       switch (ch) {
@@ -133,7 +137,8 @@ main (int argc, char *const *argv)
    argc -= optind;
    argv += optind;
 
-   parse_config(configfile);
+   config = new_config_parser();
+   parse_dir_config(config, configfile, M_ERROR_TERM);
 
    MSGS *msg;
 
@@ -166,7 +171,12 @@ main (int argc, char *const *argv)
    find_files(jcr, ff, print_file, NULL);
 
    free_jcr(jcr);
-   free_config_resources();
+   if (config) {
+      config->free_resources();
+      free(config);
+      config = NULL;
+   }
+   
    term_last_jobs_list();
 
    /* Clean up fileset */
@@ -234,11 +244,12 @@ main (int argc, char *const *argv)
    term_msg();
 
    close_memory_pool();
+   lmgr_cleanup_main();
    sm_dump(false);
    exit(0);
 }
 
-static int print_file(FF_PKT *ff, void *pkt, bool top_level) 
+static int print_file(JCR *jcr, FF_PKT *ff, bool top_level) 
 {
 
    switch (ff->type) {
@@ -478,15 +489,15 @@ static bool copy_fileset(FF_PKT *ff, JCR *jcr)
             set_options(current_opts, fo->opts);
 
             for (k=0; k<fo->regex.size(); k++) {
-               // bnet_fsend(fd, "R %s\n", fo->regex.get(k));
+               // fd->fsend("R %s\n", fo->regex.get(k));
                current_opts->regex.append(bstrdup((const char *)fo->regex.get(k)));
             }
             for (k=0; k<fo->regexdir.size(); k++) {
-               // bnet_fsend(fd, "RD %s\n", fo->regexdir.get(k));
+               // fd->fsend("RD %s\n", fo->regexdir.get(k));
                current_opts->regexdir.append(bstrdup((const char *)fo->regexdir.get(k)));
             }
             for (k=0; k<fo->regexfile.size(); k++) {
-               // bnet_fsend(fd, "RF %s\n", fo->regexfile.get(k));
+               // fd->fsend("RF %s\n", fo->regexfile.get(k));
                current_opts->regexfile.append(bstrdup((const char *)fo->regexfile.get(k)));
             }
             for (k=0; k<fo->wild.size(); k++) {
@@ -619,10 +630,22 @@ static void set_options(findFOPTS *fo, const char *opts)
       case 'W':
          fo->flags |= FO_ENHANCEDWILD;
          break;
-      case 'Z':                 /* gzip compression */
-         fo->flags |= FO_GZIP;
-         fo->GZIP_level = *++p - '0';
-         Dmsg1(200, "Compression level=%d\n", fo->GZIP_level);
+      case 'Z':                 /* compression */
+         p++;                   /* skip Z */
+         if (*p >= '0' && *p <= '9') {
+            fo->flags |= FO_COMPRESS;
+            fo->Compress_algo = COMPRESS_GZIP;
+            fo->Compress_level = *p - '0';
+         }
+         else if (*p == 'o') {
+            fo->flags |= FO_COMPRESS;
+            fo->Compress_algo = COMPRESS_LZO1X;
+            fo->Compress_level = 1; /* not used with LZO */
+         }
+         Dmsg2(200, "Compression alg=%d level=%d\n", fo->Compress_algo, fo->Compress_level);
+         break;
+      case 'X':
+         fo->flags |= FO_XATTR;
          break;
       default:
          Emsg1(M_ERROR, 0, _("Unknown include/exclude option: %c\n"), *p);