-static int match_volume(BSR *bsr, BSR_VOLUME *volume, VOLUME_LABEL *volrec, int done);
-static int match_sesstime(BSR *bsr, BSR_SESSTIME *sesstime, DEV_RECORD *rec, int done);
-static int match_sessid(BSR *bsr, BSR_SESSID *sessid, DEV_RECORD *rec, int done);
-static int match_client(BSR *bsr, BSR_CLIENT *client, SESSION_LABEL *sessrec, int done);
-static int match_job(BSR *bsr, BSR_JOB *job, SESSION_LABEL *sessrec, int done);
-static int match_job_type(BSR *bsr, BSR_JOBTYPE *job_type, SESSION_LABEL *sessrec, int done);
-static int match_job_level(BSR *bsr, BSR_JOBLEVEL *job_level, SESSION_LABEL *sessrec, int done);
-static int match_jobid(BSR *bsr, BSR_JOBID *jobid, SESSION_LABEL *sessrec, int done);
-static int match_findex(BSR *bsr, BSR_FINDEX *findex, DEV_RECORD *rec, int done);
-static int match_volfile(BSR *bsr, BSR_VOLFILE *volfile, DEV_RECORD *rec, int done);
-static int match_stream(BSR *bsr, BSR_STREAM *stream, DEV_RECORD *rec, int done);
-static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec, int done);
+static int match_volume(BSR *bsr, BSR_VOLUME *volume, VOLUME_LABEL *volrec, bool done);
+static int match_sesstime(BSR *bsr, BSR_SESSTIME *sesstime, DEV_RECORD *rec, bool done);
+static int match_sessid(BSR *bsr, BSR_SESSID *sessid, DEV_RECORD *rec);
+static int match_client(BSR *bsr, BSR_CLIENT *client, SESSION_LABEL *sessrec, bool done);
+static int match_job(BSR *bsr, BSR_JOB *job, SESSION_LABEL *sessrec, bool done);
+static int match_job_type(BSR *bsr, BSR_JOBTYPE *job_type, SESSION_LABEL *sessrec, bool done);
+static int match_job_level(BSR *bsr, BSR_JOBLEVEL *job_level, SESSION_LABEL *sessrec, bool done);
+static int match_jobid(BSR *bsr, BSR_JOBID *jobid, SESSION_LABEL *sessrec, bool done);
+static int match_findex(BSR *bsr, BSR_FINDEX *findex, DEV_RECORD *rec, bool done);
+static int match_volfile(BSR *bsr, BSR_VOLFILE *volfile, DEV_RECORD *rec, bool done);
+static int match_stream(BSR *bsr, BSR_STREAM *stream, DEV_RECORD *rec, bool done);
+static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec, bool done);
+static int match_block_sesstime(BSR *bsr, BSR_SESSTIME *sesstime, DEV_BLOCK *block);
+static int match_block_sessid(BSR *bsr, BSR_SESSID *sessid, DEV_BLOCK *block);
+static BSR *find_smallest_volfile(BSR *fbsr, BSR *bsr);
+
+
+/*********************************************************************
+ *
+ * If possible, position the archive device (tape) to read the
+ * next block.
+ */
+void position_bsr_block(BSR *bsr, DEV_BLOCK *block)
+{
+ /* To be implemented */
+}
+
+/*********************************************************************
+ *
+ * Do fast block rejection based on bootstrap records.
+ * use_fast_rejection will be set if we have VolSessionId and VolSessTime
+ * in each record. When BlockVer is >= 2, we have those in the block header
+ * so can do fast rejection.
+ *
+ * returns: 1 if block may contain valid records
+ * 0 if block may be skipped (i.e. it contains no records of
+ * that can match the bsr).
+ *
+ */
+int match_bsr_block(BSR *bsr, DEV_BLOCK *block)
+{
+ if (!bsr || !bsr->use_fast_rejection || (block->BlockVer < 2)) {
+ return 1; /* cannot fast reject */
+ }
+
+ for ( ; bsr; bsr=bsr->next) {
+ if (!match_block_sesstime(bsr, bsr->sesstime, block)) {
+ continue;
+ }
+ if (!match_block_sessid(bsr, bsr->sessid, block)) {
+ continue;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+static int match_block_sesstime(BSR *bsr, BSR_SESSTIME *sesstime, DEV_BLOCK *block)
+{
+ if (!sesstime) {
+ return 1; /* no specification matches all */
+ }
+ if (sesstime->sesstime == block->VolSessionTime) {
+ return 1;
+ }
+ if (sesstime->next) {
+ return match_block_sesstime(bsr, sesstime->next, block);
+ }
+ return 0;
+}
+
+static int match_block_sessid(BSR *bsr, BSR_SESSID *sessid, DEV_BLOCK *block)
+{
+ if (!sessid) {
+ return 1; /* no specification matches all */
+ }
+ if (sessid->sessid <= block->VolSessionId && sessid->sessid2 >= block->VolSessionId) {
+ return 1;
+ }
+ if (sessid->next) {
+ return match_block_sessid(bsr, sessid->next, block);
+ }
+ return 0;
+}
+