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 *sesrec);
38 static int match_job(BSR_JOB *job, SESSION_LABEL *sesrec);
39 static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sesrec);
40 static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sesrec);
41 static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sesrec);
42 static int match_file_index(BSR_FINDEX *findex, DEV_RECORD *rec);
43 static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sesrec);
45 /*********************************************************************
47 * Match Bootstrap records
50 int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sesrec)
55 if (match_one_bsr(bsr, rec, volrec, sesrec)) {
58 return match_bsr(bsr->next, rec, volrec, sesrec);
61 static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sesrec)
63 if (strcmp(bsr->VolumeName, volrec->VolName) != 0) {
66 if (!match_client(bsr->client, sesrec)) {
69 if (!match_sessid(bsr->sessid, rec)) {
72 if (!match_sesstime(bsr->sesstime, rec)) {
75 if (!match_job(bsr->job, sesrec)) {
78 if (!match_file_index(bsr->FileIndex, rec)) {
81 if (!match_job_type(bsr->JobType, sesrec)) {
84 if (!match_job_level(bsr->JobLevel, sesrec)) {
87 if (!match_jobid(bsr->JobId, sesrec)) {
93 static int match_client(BSR_CLIENT *client, SESSION_LABEL *sesrec)
96 return 1; /* no specification matches all */
98 if (strcmp(client->ClientName, sesrec->ClientName) == 0) {
102 return match_client(client->next, sesrec);
107 static int match_job(BSR_JOB *job, SESSION_LABEL *sesrec)
110 return 1; /* no specification matches all */
112 if (strcmp(job->Job, sesrec->Job) == 0) {
117 return match_job(job->next, sesrec);
123 static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sesrec)
126 return 1; /* no specification matches all */
128 if (job_type->JobType == sesrec->JobType) {
131 if (job_type->next) {
132 return match_job_type(job_type->next, sesrec);
137 static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sesrec)
140 return 1; /* no specification matches all */
142 if (job_level->JobLevel == sesrec->JobLevel) {
145 if (job_level->next) {
146 return match_job_level(job_level->next, sesrec);
151 static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sesrec)
154 return 1; /* no specification matches all */
156 if (jobid->JobId == sesrec->JobId) {
161 return match_jobid(jobid->next, sesrec);
167 static int match_file_index(BSR_FINDEX *findex, DEV_RECORD *rec)
170 return 1; /* no specification matches all */
172 if (findex->findex >= rec->FileIndex && findex->findex2 <= rec->FileIndex) {
177 return match_file_index(findex->next, rec);
183 static int match_sessid(BSR_SESSID *sessid, DEV_RECORD *rec)
186 return 1; /* no specification matches all */
188 if (sessid->sessid >= rec->VolSessionId && sessid->sessid2 <= rec->VolSessionId) {
193 return match_sessid(sessid->next, rec);
198 static int match_sesstime(BSR_SESSTIME *sesstime, DEV_RECORD *rec)
201 return 1; /* no specification matches all */
203 if (sesstime->sesstime == rec->VolSessionTime) {
207 if (sesstime->next) {
208 return match_sesstime(sesstime->next, rec);