2 * Match Bootstrap Records (used for restores) against
5 * Kern Sibbald, June MMII
11 Copyright (C) 2002 Kern Sibbald and John Walker
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of
16 the License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public
24 License along with this program; if not, write to the Free
25 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
34 /* Forward references */
35 static int match_sesstime(BSR_SESSTIME *sesstime, DEV_RECORD *rec);
36 static int match_sessid(BSR_SESSID *sessid, DEV_RECORD *rec);
37 static int match_client(BSR_CLIENT *client, SESSION_LABEL *sessrec);
38 static int match_job(BSR_JOB *job, SESSION_LABEL *sessrec);
39 static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sessrec);
40 static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sessrec);
41 static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sessrec);
42 static int match_findex(BSR_FINDEX *findex, DEV_RECORD *rec);
43 static int match_volfile(BSR_VOLFILE *volfile, DEV_RECORD *rec);
44 static int match_stream(BSR_STREAM *stream, DEV_RECORD *rec);
45 static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec);
47 /*********************************************************************
49 * Match Bootstrap records
52 int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec)
57 if (match_one_bsr(bsr, rec, volrec, sessrec)) {
60 return match_bsr(bsr->next, rec, volrec, sessrec);
63 static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec)
65 if (strcmp(bsr->VolumeName, volrec->VolName) != 0) {
68 if (!match_volfile(bsr->volfile, rec)) {
71 if (!match_sesstime(bsr->sesstime, rec)) {
74 if (!match_sessid(bsr->sessid, rec)) {
77 if (!match_jobid(bsr->JobId, sessrec)) {
80 if (!match_job(bsr->job, sessrec)) {
83 if (!match_client(bsr->client, sessrec)) {
86 if (!match_findex(bsr->FileIndex, rec)) {
89 if (!match_job_type(bsr->JobType, sessrec)) {
92 if (!match_job_level(bsr->JobLevel, sessrec)) {
95 if (!match_stream(bsr->stream, rec)) {
101 static int match_client(BSR_CLIENT *client, SESSION_LABEL *sessrec)
104 return 1; /* no specification matches all */
106 if (strcmp(client->ClientName, sessrec->ClientName) == 0) {
110 return match_client(client->next, sessrec);
115 static int match_job(BSR_JOB *job, SESSION_LABEL *sessrec)
118 return 1; /* no specification matches all */
120 if (strcmp(job->Job, sessrec->Job) == 0) {
125 return match_job(job->next, sessrec);
131 static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sessrec)
134 return 1; /* no specification matches all */
136 if (job_type->JobType == sessrec->JobType) {
139 if (job_type->next) {
140 return match_job_type(job_type->next, sessrec);
145 static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sessrec)
148 return 1; /* no specification matches all */
150 if (job_level->JobLevel == sessrec->JobLevel) {
153 if (job_level->next) {
154 return match_job_level(job_level->next, sessrec);
159 static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sessrec)
162 return 1; /* no specification matches all */
164 if (jobid->JobId <= sessrec->JobId && jobid->JobId2 >= sessrec->JobId) {
169 return match_jobid(jobid->next, sessrec);
175 static int match_volfile(BSR_VOLFILE *volfile, DEV_RECORD *rec)
178 return 1; /* no specification matches all */
180 if (volfile->sfile <= rec->File && volfile->efile >= rec->File) {
185 return match_volfile(volfile->next, rec);
190 static int match_stream(BSR_STREAM *stream, DEV_RECORD *rec)
193 return 1; /* no specification matches all */
195 if (stream->stream == rec->Stream) {
199 return match_stream(stream->next, rec);
204 static int match_findex(BSR_FINDEX *findex, DEV_RECORD *rec)
207 return 1; /* no specification matches all */
209 if (findex->findex <= rec->FileIndex && findex->findex2 >= rec->FileIndex) {
214 return match_findex(findex->next, rec);
220 static int match_sessid(BSR_SESSID *sessid, DEV_RECORD *rec)
223 return 1; /* no specification matches all */
225 if (sessid->sessid <= rec->VolSessionId && sessid->sessid2 >= rec->VolSessionId) {
230 return match_sessid(sessid->next, rec);
235 static int match_sesstime(BSR_SESSTIME *sesstime, DEV_RECORD *rec)
238 return 1; /* no specification matches all */
240 if (sesstime->sesstime == rec->VolSessionTime) {
244 if (sesstime->next) {
245 return match_sesstime(sesstime->next, rec);