src/filed/job.c
void add_file_to_fileset(JCR *jcr, const char *fname, bool is_file)
{
   findFILESET *fileset = jcr->ff->fileset;
   char *p;
   BPIPE *bpipe;
   POOLMEM *fn;
   FILE *ffd;
   char buf[1000];
   int ch;
   int stat;

   p = (char *)fname;
   ch = (uint8_t)*p;
   switch (ch) {
   case '|':
      Dmsg1(100, "Doing | of '%s' include on client.\n", p + 1);
      p++;                            /* skip over | */
      fn = get_pool_memory(PM_FNAME);
      fn = edit_job_codes(jcr, fn, p, "", job_code_callback_filed);
      bpipe = open_bpipe(fn, 0, "r");
      if (!bpipe) {
         berrno be;
         Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
            p, be.bstrerror());
         free_pool_memory(fn);
         return;
      }
      free_pool_memory(fn);
      while (fgets(buf, sizeof(buf), bpipe->rfd)) {
         strip_trailing_junk(buf);
         if (*buf) {            /* Avoid empty lines */
            append_file(jcr, fileset->incexe, buf, is_file);
         }
      }
      if ((stat=close_bpipe(bpipe)) != 0) {
         berrno be;
         Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. stat=%d: ERR=%s\n"),
            p, be.code(stat), be.bstrerror(stat));
         return;
      }
      break;
   case '<':
      Dmsg1(100, "Doing < of '%s' include on client.\n", p + 1);
      p++;                      /* skip over < */
      if ((ffd = fopen(p, "rb")) == NULL) {
         berrno be;
         Jmsg(jcr, M_FATAL, 0,
              _("Cannot open FileSet input file: %s. ERR=%s\n"),
            p, be.bstrerror());
         return;
      }
      while (fgets(buf, sizeof(buf), ffd)) {
         strip_trailing_junk(buf);
         append_file(jcr, fileset->incexe, buf, is_file);
      }
      fclose(ffd);
      break;
   default:
      append_file(jcr, fileset->incexe, fname, is_file);
      break;
   }
}
/**
 * Add fname to include/exclude fileset list. First check for
 * | and < and if necessary perform command.
 */
Add fname to include/exclude fileset list. First check for
| and < and if necessary perform command.
Add fname to include / exclude fileset list . First check for | and < and if necessary perform command .
void add_file_to_fileset(JCR *jcr, const char *fname, bool is_file)
{
   findFILESET *fileset = jcr->ff->fileset;
   char *p;
   BPIPE *bpipe;
   POOLMEM *fn;
   FILE *ffd;
   char buf[1000];
   int ch;
   int stat;
   p = (char *)fname;
   ch = (uint8_t)*p;
   switch (ch) {
   case '|':
      Dmsg1(100, "Doing | of '%s' include on client.\n", p + 1);
      p++;                            
      fn = get_pool_memory(PM_FNAME);
      fn = edit_job_codes(jcr, fn, p, "", job_code_callback_filed);
      bpipe = open_bpipe(fn, 0, "r");
      if (!bpipe) {
         berrno be;
         Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
            p, be.bstrerror());
         free_pool_memory(fn);
         return;
      }
      free_pool_memory(fn);
      while (fgets(buf, sizeof(buf), bpipe->rfd)) {
         strip_trailing_junk(buf);
         if (*buf) {            
            append_file(jcr, fileset->incexe, buf, is_file);
         }
      }
      if ((stat=close_bpipe(bpipe)) != 0) {
         berrno be;
         Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. stat=%d: ERR=%s\n"),
            p, be.code(stat), be.bstrerror(stat));
         return;
      }
      break;
   case '<':
      Dmsg1(100, "Doing < of '%s' include on client.\n", p + 1);
      p++;                      
      if ((ffd = fopen(p, "rb")) == NULL) {
         berrno be;
         Jmsg(jcr, M_FATAL, 0,
              _("Cannot open FileSet input file: %s. ERR=%s\n"),
            p, be.bstrerror());
         return;
      }
      while (fgets(buf, sizeof(buf), ffd)) {
         strip_trailing_junk(buf);
         append_file(jcr, fileset->incexe, buf, is_file);
      }
      fclose(ffd);
      break;
   default:
      append_file(jcr, fileset->incexe, fname, is_file);
      break;
   }
}
void add_file_to_fileset ( JCR * jcr , const char * fname , bool is_file ) { findFILESET * fileset = jcr -> ff -> fileset ; char * p ; BPIPE * bpipe ; POOLMEM * fn ; FILE * ffd ; char buf [ 1000 ] ; int ch ; int stat ; p = ( char * ) fname ; ch = ( uint8_t ) * p ; switch ( ch ) { case ' ' : Dmsg1 ( 100 , " \n " , p + 1 ) ; p ++ ; fn = get_pool_memory ( PM_FNAME ) ; fn = edit_job_codes ( jcr , fn , p , " " , job_code_callback_filed ) ; bpipe = open_bpipe ( fn , 0 , " " ) ; if ( ! bpipe ) { berrno be ; Jmsg ( jcr , M_FATAL , 0 , _ ( " \n " ) , p , be . bstrerror ( ) ) ; free_pool_memory ( fn ) ; return ; } free_pool_memory ( fn ) ; while ( fgets ( buf , sizeof ( buf ) , bpipe -> rfd ) ) { strip_trailing_junk ( buf ) ; if ( * buf ) { append_file ( jcr , fileset -> incexe , buf , is_file ) ; } } if ( ( stat = close_bpipe ( bpipe ) ) != 0 ) { berrno be ; Jmsg ( jcr , M_FATAL , 0 , _ ( " \n " ) , p , be . code ( stat ) , be . bstrerror ( stat ) ) ; return ; } break ; case ' ' : Dmsg1 ( 100 , " \n " , p + 1 ) ; p ++ ; if ( ( ffd = fopen ( p , " " ) ) == NULL ) { berrno be ; Jmsg ( jcr , M_FATAL , 0 , _ ( " \n " ) , p , be . bstrerror ( ) ) ; return ; } while ( fgets ( buf , sizeof ( buf ) , ffd ) ) { strip_trailing_junk ( buf ) ; append_file ( jcr , fileset -> incexe , buf , is_file ) ; } fclose ( ffd ) ; break ; default : append_file ( jcr , fileset -> incexe , fname , is_file ) ; break ; } }
Add fname to include/exclude fileset list.
Add fname to include / exclude fileset list .
/* skip over | */ /* Avoid empty lines */ /* skip over < */