src/stored/match_bsr.c
static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
                     SESSION_LABEL *sessrec, bool done, JCR *jcr)
{
   Dmsg0(dbglevel, "Enter match_all\n");
   if (bsr->done) {
      goto no_match;
   }
   if (!match_volume(bsr, bsr->volume, volrec, 1)) {
      Dmsg2(dbglevel, "bsr fail bsr_vol=%s != rec read_vol=%s\n", bsr->volume->VolumeName,
            volrec->VolumeName);
      goto no_match;
   }
   Dmsg2(dbglevel, "OK bsr match bsr_vol=%s read_vol=%s\n", bsr->volume->VolumeName,
            volrec->VolumeName);

   if (!match_voladdr(bsr, bsr->voladdr, rec, 1)) {
      if (bsr->voladdr) {
         Dmsg3(dbglevel, "Fail on Addr=%llu. bsr=%llu,%llu\n",
               get_record_address(rec), bsr->voladdr->saddr, bsr->voladdr->eaddr);
         dump_record(rec);
      }
      goto no_match;
   }

   if (!match_sesstime(bsr, bsr->sesstime, rec, 1)) {
      Dmsg2(dbglevel, "Fail on sesstime. bsr=%u rec=%u\n",
         bsr->sesstime->sesstime, rec->VolSessionTime);
      goto no_match;
   }

   /* NOTE!! This test MUST come after the sesstime test */
   if (!match_sessid(bsr, bsr->sessid, rec)) {
      Dmsg2(dbglevel, "Fail on sessid. bsr=%u rec=%u\n",
         bsr->sessid->sessid, rec->VolSessionId);
      goto no_match;
   }

   /* NOTE!! This test MUST come after sesstime and sessid tests */
   if (!match_findex(bsr, rec, 1)) {
      Dmsg3(dbglevel, "Fail on findex=%d. bsr=%d,%d\n",
         rec->FileIndex, bsr->FileIndex->findex, bsr->FileIndex->findex2);
      goto no_match;
   }
   if (bsr->FileIndex) {
      Dmsg3(dbglevel, "match on findex=%d. bsr=%d,%d\n",
            rec->FileIndex, bsr->FileIndex->findex, bsr->FileIndex->findex2);
   }

   if (!match_fileregex(bsr, rec, jcr)) {
     Dmsg1(dbglevel, "Fail on fileregex='%s'\n", NPRT(bsr->fileregex));
     goto no_match;
   }

   /* This flag is set by match_fileregex (and perhaps other tests) */
   if (bsr->skip_file) {
      Dmsg1(dbglevel, "Skipping findex=%d\n", rec->FileIndex);
      goto no_match;
   }

   /*
    * If a count was specified and we have a FileIndex, assume
    *   it is a Bacula created bsr (or the equivalent). We
    *   then save the bsr where the match occurred so that
    *   after processing the record or records, we can update
    *   the found count. I.e. rec->bsr points to the bsr that
    *   satisfied the match.
    */
   if (bsr->count && bsr->FileIndex) {
      rec->bsr = bsr;
      Dmsg0(dbglevel, "Leave match_all 1\n");
      return 1;                       /* this is a complete match */
   }

   /*
    * The selections below are not used by Bacula's
    *   restore command, and don't work because of
    *   the rec->bsr = bsr optimization above.
    */
   if (!match_jobid(bsr, bsr->JobId, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on JobId\n");
      goto no_match;

   }
   if (!match_job(bsr, bsr->job, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on Job\n");
      goto no_match;
   }
   if (!match_client(bsr, bsr->client, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on Client\n");
      goto no_match;
   }
   if (!match_job_type(bsr, bsr->JobType, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on Job type\n");
      goto no_match;
   }
   if (!match_job_level(bsr, bsr->JobLevel, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on Job level\n");
      goto no_match;
   }
   if (!match_stream(bsr, bsr->stream, rec, 1)) {
      Dmsg0(dbglevel, "fail on stream\n");
      goto no_match;
   }
   return 1;

no_match:
   if (bsr->next) {
      return match_all(bsr->next, rec, volrec, sessrec, bsr->done && done, jcr);
   }
   if (bsr->done && done) {
      Dmsg0(dbglevel, "Leave match all -1\n");
      return -1;
   }
   Dmsg0(dbglevel, "Leave match all 0\n");
   return 0;
}
/*
 * Match all the components of current record
 *   returns  1 on match
 *   returns  0 no match
 *   returns -1 no additional matches possible
 */
Match all the components of current record
returns  1 on match
returns  0 no match
returns -1 no additional matches possible
Match all the components of current record returns 1 on match returns 0 no match returns - 1 no additional matches possible
static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
                     SESSION_LABEL *sessrec, bool done, JCR *jcr)
{
   Dmsg0(dbglevel, "Enter match_all\n");
   if (bsr->done) {
      goto no_match;
   }
   if (!match_volume(bsr, bsr->volume, volrec, 1)) {
      Dmsg2(dbglevel, "bsr fail bsr_vol=%s != rec read_vol=%s\n", bsr->volume->VolumeName,
            volrec->VolumeName);
      goto no_match;
   }
   Dmsg2(dbglevel, "OK bsr match bsr_vol=%s read_vol=%s\n", bsr->volume->VolumeName,
            volrec->VolumeName);
   if (!match_voladdr(bsr, bsr->voladdr, rec, 1)) {
      if (bsr->voladdr) {
         Dmsg3(dbglevel, "Fail on Addr=%llu. bsr=%llu,%llu\n",
               get_record_address(rec), bsr->voladdr->saddr, bsr->voladdr->eaddr);
         dump_record(rec);
      }
      goto no_match;
   }
   if (!match_sesstime(bsr, bsr->sesstime, rec, 1)) {
      Dmsg2(dbglevel, "Fail on sesstime. bsr=%u rec=%u\n",
         bsr->sesstime->sesstime, rec->VolSessionTime);
      goto no_match;
   }
   if (!match_sessid(bsr, bsr->sessid, rec)) {
      Dmsg2(dbglevel, "Fail on sessid. bsr=%u rec=%u\n",
         bsr->sessid->sessid, rec->VolSessionId);
      goto no_match;
   }
   if (!match_findex(bsr, rec, 1)) {
      Dmsg3(dbglevel, "Fail on findex=%d. bsr=%d,%d\n",
         rec->FileIndex, bsr->FileIndex->findex, bsr->FileIndex->findex2);
      goto no_match;
   }
   if (bsr->FileIndex) {
      Dmsg3(dbglevel, "match on findex=%d. bsr=%d,%d\n",
            rec->FileIndex, bsr->FileIndex->findex, bsr->FileIndex->findex2);
   }
   if (!match_fileregex(bsr, rec, jcr)) {
     Dmsg1(dbglevel, "Fail on fileregex='%s'\n", NPRT(bsr->fileregex));
     goto no_match;
   }
   if (bsr->skip_file) {
      Dmsg1(dbglevel, "Skipping findex=%d\n", rec->FileIndex);
      goto no_match;
   }
   if (bsr->count && bsr->FileIndex) {
      rec->bsr = bsr;
      Dmsg0(dbglevel, "Leave match_all 1\n");
      return 1;                       
   }
   if (!match_jobid(bsr, bsr->JobId, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on JobId\n");
      goto no_match;
   }
   if (!match_job(bsr, bsr->job, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on Job\n");
      goto no_match;
   }
   if (!match_client(bsr, bsr->client, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on Client\n");
      goto no_match;
   }
   if (!match_job_type(bsr, bsr->JobType, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on Job type\n");
      goto no_match;
   }
   if (!match_job_level(bsr, bsr->JobLevel, sessrec, 1)) {
      Dmsg0(dbglevel, "fail on Job level\n");
      goto no_match;
   }
   if (!match_stream(bsr, bsr->stream, rec, 1)) {
      Dmsg0(dbglevel, "fail on stream\n");
      goto no_match;
   }
   return 1;
no_match:
   if (bsr->next) {
      return match_all(bsr->next, rec, volrec, sessrec, bsr->done && done, jcr);
   }
   if (bsr->done && done) {
      Dmsg0(dbglevel, "Leave match all -1\n");
      return -1;
   }
   Dmsg0(dbglevel, "Leave match all 0\n");
   return 0;
}
static int match_all ( BSR * bsr , DEV_RECORD * rec , VOLUME_LABEL * volrec , SESSION_LABEL * sessrec , bool done , JCR * jcr ) { Dmsg0 ( dbglevel , " \n " ) ; if ( bsr -> done ) { goto no_match ; } if ( ! match_volume ( bsr , bsr -> volume , volrec , 1 ) ) { Dmsg2 ( dbglevel , " \n " , bsr -> volume -> VolumeName , volrec -> VolumeName ) ; goto no_match ; } Dmsg2 ( dbglevel , " \n " , bsr -> volume -> VolumeName , volrec -> VolumeName ) ; if ( ! match_voladdr ( bsr , bsr -> voladdr , rec , 1 ) ) { if ( bsr -> voladdr ) { Dmsg3 ( dbglevel , " \n " , get_record_address ( rec ) , bsr -> voladdr -> saddr , bsr -> voladdr -> eaddr ) ; dump_record ( rec ) ; } goto no_match ; } if ( ! match_sesstime ( bsr , bsr -> sesstime , rec , 1 ) ) { Dmsg2 ( dbglevel , " \n " , bsr -> sesstime -> sesstime , rec -> VolSessionTime ) ; goto no_match ; } if ( ! match_sessid ( bsr , bsr -> sessid , rec ) ) { Dmsg2 ( dbglevel , " \n " , bsr -> sessid -> sessid , rec -> VolSessionId ) ; goto no_match ; } if ( ! match_findex ( bsr , rec , 1 ) ) { Dmsg3 ( dbglevel , " \n " , rec -> FileIndex , bsr -> FileIndex -> findex , bsr -> FileIndex -> findex2 ) ; goto no_match ; } if ( bsr -> FileIndex ) { Dmsg3 ( dbglevel , " \n " , rec -> FileIndex , bsr -> FileIndex -> findex , bsr -> FileIndex -> findex2 ) ; } if ( ! match_fileregex ( bsr , rec , jcr ) ) { Dmsg1 ( dbglevel , " \n " , NPRT ( bsr -> fileregex ) ) ; goto no_match ; } if ( bsr -> skip_file ) { Dmsg1 ( dbglevel , " \n " , rec -> FileIndex ) ; goto no_match ; } if ( bsr -> count && bsr -> FileIndex ) { rec -> bsr = bsr ; Dmsg0 ( dbglevel , " \n " ) ; return 1 ; } if ( ! match_jobid ( bsr , bsr -> JobId , sessrec , 1 ) ) { Dmsg0 ( dbglevel , " \n " ) ; goto no_match ; } if ( ! match_job ( bsr , bsr -> job , sessrec , 1 ) ) { Dmsg0 ( dbglevel , " \n " ) ; goto no_match ; } if ( ! match_client ( bsr , bsr -> client , sessrec , 1 ) ) { Dmsg0 ( dbglevel , " \n " ) ; goto no_match ; } if ( ! match_job_type ( bsr , bsr -> JobType , sessrec , 1 ) ) { Dmsg0 ( dbglevel , " \n " ) ; goto no_match ; } if ( ! match_job_level ( bsr , bsr -> JobLevel , sessrec , 1 ) ) { Dmsg0 ( dbglevel , " \n " ) ; goto no_match ; } if ( ! match_stream ( bsr , bsr -> stream , rec , 1 ) ) { Dmsg0 ( dbglevel , " \n " ) ; goto no_match ; } return 1 ; no_match : if ( bsr -> next ) { return match_all ( bsr -> next , rec , volrec , sessrec , bsr -> done && done , jcr ) ; } if ( bsr -> done && done ) { Dmsg0 ( dbglevel , " \n " ) ; return -1 ; } Dmsg0 ( dbglevel , " \n " ) ; return 0 ; }
Match all the components of current record
   returns  1 on match
   returns  0 no match
   returns -1 no additional matches possible
Match all the components of current record returns 1 on match returns 0 no match returns - 1 no additional matches possible
/* NOTE!! This test MUST come after the sesstime test */ /* NOTE!! This test MUST come after sesstime and sessid tests */ /* This flag is set by match_fileregex (and perhaps other tests) */ /*
    * If a count was specified and we have a FileIndex, assume
    *   it is a Bacula created bsr (or the equivalent). We
    *   then save the bsr where the match occurred so that
    *   after processing the record or records, we can update
    *   the found count. I.e. rec->bsr points to the bsr that
    *   satisfied the match.
    */ /* this is a complete match */ /*
    * The selections below are not used by Bacula's
    *   restore command, and don't work because of
    *   the rec->bsr = bsr optimization above.
    */