src/findlib/find.c
int
find_files(JCR *jcr, FF_PKT *ff, int file_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level),
           int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level))
{
   ff->file_save = file_save;
   ff->plugin_save = plugin_save;

   /* This is the new way */
   findFILESET *fileset = ff->fileset;
   if (fileset) {
      int i, j;
      /* TODO: We probably need be move the initialization in the fileset loop,
       * at this place flags options are "concatenated" accross Include {} blocks
       * (not only Options{} blocks inside a Include{})
       */
      ff->flags = 0;
      for (i=0; i<fileset->include_list.size(); i++) {
         findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
         fileset->incexe = incexe;

         /* Here, we reset some values between two different Include{} */
         strcpy(ff->VerifyOpts, "V");
         strcpy(ff->AccurateOpts, "Cmcs");  /* mtime+ctime+size by default */
         strcpy(ff->BaseJobOpts, "Jspug5"); /* size+perm+user+group+chk  */
         ff->plugin = NULL;
         ff->opt_plugin = false;

         /*
          * By setting all options, we in effect OR the global options
          *   which is what we want.
          */
         for (j=0; j<incexe->opts_list.size(); j++) {
            findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
            /* TODO options are "simply" reset by Options block that come next
             * For example :
             * Options { IgnoreCase = yes }
             * ATTN: some plugins use AddOptions() that create extra Option block
             * Also see accept_file() below that could suffer of the same problem
             */
            ff->flags |= fo->flags;
            /* If the compress option was set in the previous block, overwrite the
             * algorithm only if defined
             */
            if ((ff->flags & FO_COMPRESS) && fo->Compress_algo != 0) {
               ff->Compress_algo = fo->Compress_algo;
               ff->Compress_level = fo->Compress_level;
            }
            ff->strip_path = fo->strip_path;
            ff->fstypes = fo->fstype;
            ff->drivetypes = fo->drivetype;
            if (fo->plugin != NULL) {
               ff->plugin = fo->plugin; /* TODO: generate a plugin event ? */
               ff->opt_plugin = true;
            }
            bstrncat(ff->VerifyOpts, fo->VerifyOpts, sizeof(ff->VerifyOpts)); /* TODO: Concat or replace? */
            if (fo->AccurateOpts[0]) {
               bstrncpy(ff->AccurateOpts, fo->AccurateOpts, sizeof(ff->AccurateOpts));
            }
            if (fo->BaseJobOpts[0]) {
               bstrncpy(ff->BaseJobOpts, fo->BaseJobOpts, sizeof(ff->BaseJobOpts));
            }
         }
         Dmsg4(50, "Verify=<%s> Accurate=<%s> BaseJob=<%s> flags=<%lld>\n",
               ff->VerifyOpts, ff->AccurateOpts, ff->BaseJobOpts, ff->flags);
         dlistString *node;
         foreach_dlist(node, &incexe->name_list) {
            char *fname = node->c_str();
            Dmsg1(dbglvl, "F %s\n", fname);

            ff->top_fname = fname;
            /* Convert the filename if needed */
            if (ff->snapshot_convert_fct) {
               ff->snapshot_convert_fct(jcr, ff, &incexe->name_list, node);
            }

            if (find_one_file(jcr, ff, our_callback, ff->top_fname, (dev_t)-1, true) == 0) {
               return 0;                  /* error return */
            }

            if (job_canceled(jcr)) {
               return 0;
            }
         }
         foreach_dlist(node, &incexe->plugin_list) {
            char *fname = node->c_str();
            if (!plugin_save) {
               Jmsg(jcr, M_FATAL, 0, _("Plugin: \"%s\" not found.\n"), fname);
               return 0;
            }
            Dmsg1(dbglvl, "PluginCommand: %s\n", fname);
            ff->top_fname = fname;
            ff->cmd_plugin = true;

            /* Make sure that opt plugin is not set
             * The current implementation doesn't allow option plugin
             * and command plugin to run at the same time
             */
            ff->opt_plugin = false;
            ff->plugin = NULL;

            plugin_save(jcr, ff, true);
            ff->cmd_plugin = false;
            if (job_canceled(jcr)) {
               return 0;
            }
         }
      }
   }
   return 1;
}
/*
 * Call this subroutine with a callback subroutine as the first
 * argument and a packet as the second argument, this packet
 * will be passed back to the callback subroutine as the last
 * argument.
 *
 */
Call this subroutine with a callback subroutine as the first
argument and a packet as the second argument, this packet
will be passed back to the callback subroutine as the last
argument.
Call this subroutine with a callback subroutine as the first argument and a packet as the second argument this packet will be passed back to the callback subroutine as the last argument .
int
find_files(JCR *jcr, FF_PKT *ff, int file_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level),
           int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level))
{
   ff->file_save = file_save;
   ff->plugin_save = plugin_save;
   findFILESET *fileset = ff->fileset;
   if (fileset) {
      int i, j;
      ff->flags = 0;
      for (i=0; i<fileset->include_list.size(); i++) {
         findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
         fileset->incexe = incexe;
         strcpy(ff->VerifyOpts, "V");
         strcpy(ff->AccurateOpts, "Cmcs");  
         strcpy(ff->BaseJobOpts, "Jspug5"); 
         ff->plugin = NULL;
         ff->opt_plugin = false;
         for (j=0; j<incexe->opts_list.size(); j++) {
            findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
            ff->flags |= fo->flags;
            if ((ff->flags & FO_COMPRESS) && fo->Compress_algo != 0) {
               ff->Compress_algo = fo->Compress_algo;
               ff->Compress_level = fo->Compress_level;
            }
            ff->strip_path = fo->strip_path;
            ff->fstypes = fo->fstype;
            ff->drivetypes = fo->drivetype;
            if (fo->plugin != NULL) {
               ff->plugin = fo->plugin; 
               ff->opt_plugin = true;
            }
            bstrncat(ff->VerifyOpts, fo->VerifyOpts, sizeof(ff->VerifyOpts)); 
            if (fo->AccurateOpts[0]) {
               bstrncpy(ff->AccurateOpts, fo->AccurateOpts, sizeof(ff->AccurateOpts));
            }
            if (fo->BaseJobOpts[0]) {
               bstrncpy(ff->BaseJobOpts, fo->BaseJobOpts, sizeof(ff->BaseJobOpts));
            }
         }
         Dmsg4(50, "Verify=<%s> Accurate=<%s> BaseJob=<%s> flags=<%lld>\n",
               ff->VerifyOpts, ff->AccurateOpts, ff->BaseJobOpts, ff->flags);
         dlistString *node;
         foreach_dlist(node, &incexe->name_list) {
            char *fname = node->c_str();
            Dmsg1(dbglvl, "F %s\n", fname);
            ff->top_fname = fname;
            if (ff->snapshot_convert_fct) {
               ff->snapshot_convert_fct(jcr, ff, &incexe->name_list, node);
            }
            if (find_one_file(jcr, ff, our_callback, ff->top_fname, (dev_t)-1, true) == 0) {
               return 0;                  
            }
            if (job_canceled(jcr)) {
               return 0;
            }
         }
         foreach_dlist(node, &incexe->plugin_list) {
            char *fname = node->c_str();
            if (!plugin_save) {
               Jmsg(jcr, M_FATAL, 0, _("Plugin: \"%s\" not found.\n"), fname);
               return 0;
            }
            Dmsg1(dbglvl, "PluginCommand: %s\n", fname);
            ff->top_fname = fname;
            ff->cmd_plugin = true;
            ff->opt_plugin = false;
            ff->plugin = NULL;
            plugin_save(jcr, ff, true);
            ff->cmd_plugin = false;
            if (job_canceled(jcr)) {
               return 0;
            }
         }
      }
   }
   return 1;
}
int find_files ( JCR * jcr , FF_PKT * ff , int file_save ( JCR * jcr , FF_PKT * ff_pkt , bool top_level ) , int plugin_save ( JCR * jcr , FF_PKT * ff_pkt , bool top_level ) ) { ff -> file_save = file_save ; ff -> plugin_save = plugin_save ; findFILESET * fileset = ff -> fileset ; if ( fileset ) { int i , j ; ff -> flags = 0 ; for ( i = 0 ; i < fileset -> include_list . size ( ) ; i ++ ) { findINCEXE * incexe = ( findINCEXE * ) fileset -> include_list . get ( i ) ; fileset -> incexe = incexe ; strcpy ( ff -> VerifyOpts , " " ) ; strcpy ( ff -> AccurateOpts , " " ) ; strcpy ( ff -> BaseJobOpts , " " ) ; ff -> plugin = NULL ; ff -> opt_plugin = false ; for ( j = 0 ; j < incexe -> opts_list . size ( ) ; j ++ ) { findFOPTS * fo = ( findFOPTS * ) incexe -> opts_list . get ( j ) ; ff -> flags |= fo -> flags ; if ( ( ff -> flags & FO_COMPRESS ) && fo -> Compress_algo != 0 ) { ff -> Compress_algo = fo -> Compress_algo ; ff -> Compress_level = fo -> Compress_level ; } ff -> strip_path = fo -> strip_path ; ff -> fstypes = fo -> fstype ; ff -> drivetypes = fo -> drivetype ; if ( fo -> plugin != NULL ) { ff -> plugin = fo -> plugin ; ff -> opt_plugin = true ; } bstrncat ( ff -> VerifyOpts , fo -> VerifyOpts , sizeof ( ff -> VerifyOpts ) ) ; if ( fo -> AccurateOpts [ 0 ] ) { bstrncpy ( ff -> AccurateOpts , fo -> AccurateOpts , sizeof ( ff -> AccurateOpts ) ) ; } if ( fo -> BaseJobOpts [ 0 ] ) { bstrncpy ( ff -> BaseJobOpts , fo -> BaseJobOpts , sizeof ( ff -> BaseJobOpts ) ) ; } } Dmsg4 ( 50 , " \n " , ff -> VerifyOpts , ff -> AccurateOpts , ff -> BaseJobOpts , ff -> flags ) ; dlistString * node ; foreach_dlist ( node , & incexe -> name_list ) { char * fname = node -> c_str ( ) ; Dmsg1 ( dbglvl , " \n " , fname ) ; ff -> top_fname = fname ; if ( ff -> snapshot_convert_fct ) { ff -> snapshot_convert_fct ( jcr , ff , & incexe -> name_list , node ) ; } if ( find_one_file ( jcr , ff , our_callback , ff -> top_fname , ( dev_t ) - 1 , true ) == 0 ) { return 0 ; } if ( job_canceled ( jcr ) ) { return 0 ; } } foreach_dlist ( node , & incexe -> plugin_list ) { char * fname = node -> c_str ( ) ; if ( ! plugin_save ) { Jmsg ( jcr , M_FATAL , 0 , _ ( " \" \" \n " ) , fname ) ; return 0 ; } Dmsg1 ( dbglvl , " \n " , fname ) ; ff -> top_fname = fname ; ff -> cmd_plugin = true ; ff -> opt_plugin = false ; ff -> plugin = NULL ; plugin_save ( jcr , ff , true ) ; ff -> cmd_plugin = false ; if ( job_canceled ( jcr ) ) { return 0 ; } } } } return 1 ; }
Call this subroutine with a callback subroutine as the first
 argument and a packet as the second argument, this packet
 will be passed back to the callback subroutine as the last
 argument.
Call this subroutine with a callback subroutine as the first argument and a packet as the second argument this packet will be passed back to the callback subroutine as the last argument .
/* This is the new way */ /* TODO: We probably need be move the initialization in the fileset loop,
       * at this place flags options are "concatenated" accross Include {} blocks
       * (not only Options{} blocks inside a Include{})
       */ /* Here, we reset some values between two different Include{} */ /* mtime+ctime+size by default */ /* size+perm+user+group+chk  */ /*
          * By setting all options, we in effect OR the global options
          *   which is what we want.
          */ /* TODO options are "simply" reset by Options block that come next
             * For example :
             * Options { IgnoreCase = yes }
             * ATTN: some plugins use AddOptions() that create extra Option block
             * Also see accept_file() below that could suffer of the same problem
             */ /* If the compress option was set in the previous block, overwrite the
             * algorithm only if defined
             */ /* TODO: generate a plugin event ? */ /* TODO: Concat or replace? */ /* Convert the filename if needed */ /* error return */ /* Make sure that opt plugin is not set
             * The current implementation doesn't allow option plugin
             * and command plugin to run at the same time
             */