2 * Main configuration file parser for Bacula Directors,
3 * some parts may be split into separate files such as
4 * the schedule configuration (run_config.c).
6 * Note, the configuration file parser consists of three parts
8 * 1. The generic lexical scanner in lib/lex.c and lib/lex.h
10 * 2. The generic config scanner in lib/parse_config.c and
12 * These files contain the parser code, some utility
13 * routines, and the common store routines (name, int,
16 * 3. The daemon specific file, which contains the Resource
17 * definitions as well as any specific store routines
18 * for the resource records.
20 * Kern Sibbald, January MM
25 Copyright (C) 2000-2004 Kern Sibbald and John Walker
27 This program is free software; you can redistribute it and/or
28 modify it under the terms of the GNU General Public License as
29 published by the Free Software Foundation; either version 2 of
30 the License, or (at your option) any later version.
32 This program is distributed in the hope that it will be useful,
33 but WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 General Public License for more details.
37 You should have received a copy of the GNU General Public
38 License along with this program; if not, write to the Free
39 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
47 /* Define the first and last resource ID record
48 * types. Note, these should be unique for each
49 * daemon though not a requirement.
51 int r_first = R_FIRST;
54 /* Imported subroutines */
55 extern void store_run(LEX *lc, RES_ITEM *item, int index, int pass);
56 extern void store_finc(LEX *lc, RES_ITEM *item, int index, int pass);
57 extern void store_inc(LEX *lc, RES_ITEM *item, int index, int pass);
60 /* Forward referenced subroutines */
62 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass);
63 void store_level(LEX *lc, RES_ITEM *item, int index, int pass);
64 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass);
65 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass);
68 /* We build the current resource here as we are
69 * scanning the resource configuration definition,
70 * then move it to allocated memory when the resource
74 int res_all_size = sizeof(res_all);
77 /* Definition of records permitted within each
78 * resource with the routine to process the record
79 * information. NOTE! quoted names must be in lower case.
84 * name handler value code flags default_value
86 static RES_ITEM dir_items[] = {
87 {"name", store_name, ITEM(res_dir.hdr.name), 0, ITEM_REQUIRED, 0},
88 {"description", store_str, ITEM(res_dir.hdr.desc), 0, 0, 0},
89 {"messages", store_res, ITEM(res_dir.messages), R_MSGS, 0, 0},
90 {"dirport", store_pint, ITEM(res_dir.DIRport), 0, ITEM_DEFAULT, 9101},
91 {"diraddress", store_str, ITEM(res_dir.DIRaddr), 0, 0, 0},
92 {"queryfile", store_dir, ITEM(res_dir.query_file), 0, ITEM_REQUIRED, 0},
93 {"workingdirectory", store_dir, ITEM(res_dir.working_directory), 0, ITEM_REQUIRED, 0},
94 {"piddirectory",store_dir, ITEM(res_dir.pid_directory), 0, ITEM_REQUIRED, 0},
95 {"subsysdirectory", store_dir, ITEM(res_dir.subsys_directory), 0, 0, 0},
96 {"requiressl", store_yesno, ITEM(res_dir.require_ssl), 1, ITEM_DEFAULT, 0},
97 {"enablessl", store_yesno, ITEM(res_dir.enable_ssl), 1, ITEM_DEFAULT, 0},
98 {"maximumconcurrentjobs", store_pint, ITEM(res_dir.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
99 {"password", store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0},
100 {"fdconnecttimeout", store_time,ITEM(res_dir.FDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
101 {"sdconnecttimeout", store_time,ITEM(res_dir.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
102 {NULL, NULL, NULL, 0, 0, 0}
108 * name handler value code flags default_value
110 static RES_ITEM con_items[] = {
111 {"name", store_name, ITEM(res_con.hdr.name), 0, ITEM_REQUIRED, 0},
112 {"description", store_str, ITEM(res_con.hdr.desc), 0, 0, 0},
113 {"enablessl", store_yesno, ITEM(res_con.enable_ssl), 1, ITEM_DEFAULT, 0},
114 {"password", store_password, ITEM(res_con.password), 0, ITEM_REQUIRED, 0},
115 {"jobacl", store_acl, ITEM(res_con.ACL_lists), Job_ACL, 0, 0},
116 {"clientacl", store_acl, ITEM(res_con.ACL_lists), Client_ACL, 0, 0},
117 {"storageacl", store_acl, ITEM(res_con.ACL_lists), Storage_ACL, 0, 0},
118 {"scheduleacl", store_acl, ITEM(res_con.ACL_lists), Schedule_ACL, 0, 0},
119 {"runacl", store_acl, ITEM(res_con.ACL_lists), Run_ACL, 0, 0},
120 {"poolacl", store_acl, ITEM(res_con.ACL_lists), Pool_ACL, 0, 0},
121 {"commandacl", store_acl, ITEM(res_con.ACL_lists), Command_ACL, 0, 0},
122 {"filesetacl", store_acl, ITEM(res_con.ACL_lists), FileSet_ACL, 0, 0},
123 {"catalogacl", store_acl, ITEM(res_con.ACL_lists), Catalog_ACL, 0, 0},
124 {NULL, NULL, NULL, 0, 0, 0}
129 * Client or File daemon resource
131 * name handler value code flags default_value
134 static RES_ITEM cli_items[] = {
135 {"name", store_name, ITEM(res_client.hdr.name), 0, ITEM_REQUIRED, 0},
136 {"description", store_str, ITEM(res_client.hdr.desc), 0, 0, 0},
137 {"address", store_str, ITEM(res_client.address), 0, ITEM_REQUIRED, 0},
138 {"fdaddress", store_str, ITEM(res_client.address), 0, 0, 0},
139 {"fdport", store_pint, ITEM(res_client.FDport), 0, ITEM_DEFAULT, 9102},
140 {"password", store_password, ITEM(res_client.password), 0, ITEM_REQUIRED, 0},
141 {"fdpassword", store_password, ITEM(res_client.password), 0, 0, 0},
142 {"catalog", store_res, ITEM(res_client.catalog), R_CATALOG, 0, 0},
143 {"fileretention", store_time, ITEM(res_client.FileRetention), 0, ITEM_DEFAULT, 60*60*24*60},
144 {"jobretention", store_time, ITEM(res_client.JobRetention), 0, ITEM_DEFAULT, 60*60*24*180},
145 {"autoprune", store_yesno, ITEM(res_client.AutoPrune), 1, ITEM_DEFAULT, 1},
146 {"enablessl", store_yesno, ITEM(res_client.enable_ssl), 1, ITEM_DEFAULT, 0},
147 {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
148 {NULL, NULL, NULL, 0, 0, 0}
151 /* Storage daemon resource
153 * name handler value code flags default_value
155 static RES_ITEM store_items[] = {
156 {"name", store_name, ITEM(res_store.hdr.name), 0, ITEM_REQUIRED, 0},
157 {"description", store_str, ITEM(res_store.hdr.desc), 0, 0, 0},
158 {"sdport", store_pint, ITEM(res_store.SDport), 0, ITEM_DEFAULT, 9103},
159 {"address", store_str, ITEM(res_store.address), 0, ITEM_REQUIRED, 0},
160 {"sdaddress", store_str, ITEM(res_store.address), 0, 0, 0},
161 {"password", store_password, ITEM(res_store.password), 0, ITEM_REQUIRED, 0},
162 {"sdpassword", store_password, ITEM(res_store.password), 0, 0, 0},
163 {"device", store_strname, ITEM(res_store.dev_name), 0, ITEM_REQUIRED, 0},
164 {"sddevicename", store_strname, ITEM(res_store.dev_name), 0, 0, 0},
165 {"mediatype", store_strname, ITEM(res_store.media_type), 0, ITEM_REQUIRED, 0},
166 {"autochanger", store_yesno, ITEM(res_store.autochanger), 1, ITEM_DEFAULT, 0},
167 {"enablessl", store_yesno, ITEM(res_store.enable_ssl), 1, ITEM_DEFAULT, 0},
168 {"maximumconcurrentjobs", store_pint, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
169 {"sddport", store_pint, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */
170 {NULL, NULL, NULL, 0, 0, 0}
174 * Catalog Resource Directives
176 * name handler value code flags default_value
178 static RES_ITEM cat_items[] = {
179 {"name", store_name, ITEM(res_cat.hdr.name), 0, ITEM_REQUIRED, 0},
180 {"description", store_str, ITEM(res_cat.hdr.desc), 0, 0, 0},
181 {"address", store_str, ITEM(res_cat.db_address), 0, 0, 0},
182 {"dbaddress", store_str, ITEM(res_cat.db_address), 0, 0, 0},
183 {"dbport", store_pint, ITEM(res_cat.db_port), 0, 0, 0},
184 /* keep this password as store_str for the moment */
185 {"password", store_str, ITEM(res_cat.db_password), 0, 0, 0},
186 {"dbpassword", store_str, ITEM(res_cat.db_password), 0, 0, 0},
187 {"user", store_str, ITEM(res_cat.db_user), 0, 0, 0},
188 {"dbname", store_str, ITEM(res_cat.db_name), 0, ITEM_REQUIRED, 0},
189 {"dbsocket", store_str, ITEM(res_cat.db_socket), 0, 0, 0},
190 {NULL, NULL, NULL, 0, 0, 0}
194 * Job Resource Directives
196 * name handler value code flags default_value
198 RES_ITEM job_items[] = {
199 {"name", store_name, ITEM(res_job.hdr.name), 0, ITEM_REQUIRED, 0},
200 {"description", store_str, ITEM(res_job.hdr.desc), 0, 0, 0},
201 {"type", store_jobtype, ITEM(res_job.JobType), 0, ITEM_REQUIRED, 0},
202 {"level", store_level, ITEM(res_job.level), 0, 0, 0},
203 {"messages", store_res, ITEM(res_job.messages), R_MSGS, ITEM_REQUIRED, 0},
204 {"storage", store_res, ITEM(res_job.storage), R_STORAGE, ITEM_REQUIRED, 0},
205 {"pool", store_res, ITEM(res_job.pool), R_POOL, ITEM_REQUIRED, 0},
206 {"fullbackuppool", store_res, ITEM(res_job.full_pool), R_POOL, 0, 0},
207 {"incrementalbackuppool", store_res, ITEM(res_job.inc_pool), R_POOL, 0, 0},
208 {"differentialbackuppool", store_res, ITEM(res_job.dif_pool), R_POOL, 0, 0},
209 {"client", store_res, ITEM(res_job.client), R_CLIENT, ITEM_REQUIRED, 0},
210 {"fileset", store_res, ITEM(res_job.fileset), R_FILESET, ITEM_REQUIRED, 0},
211 {"schedule", store_res, ITEM(res_job.schedule), R_SCHEDULE, 0, 0},
212 {"verifyjob", store_res, ITEM(res_job.verify_job), R_JOB, 0, 0},
213 {"jobdefs", store_res, ITEM(res_job.jobdefs), R_JOBDEFS, 0, 0},
214 {"where", store_dir, ITEM(res_job.RestoreWhere), 0, 0, 0},
215 {"bootstrap",store_dir, ITEM(res_job.RestoreBootstrap), 0, 0, 0},
216 {"writebootstrap",store_dir, ITEM(res_job.WriteBootstrap), 0, 0, 0},
217 {"replace", store_replace, ITEM(res_job.replace), 0, ITEM_DEFAULT, REPLACE_ALWAYS},
218 {"maxruntime", store_time, ITEM(res_job.MaxRunTime), 0, 0, 0},
219 {"maxwaittime", store_time, ITEM(res_job.MaxWaitTime), 0, 0, 0},
220 {"maxstartdelay",store_time, ITEM(res_job.MaxStartDelay), 0, 0, 0},
221 {"jobretention", store_time, ITEM(res_job.JobRetention), 0, 0, 0},
222 {"prefixlinks", store_yesno, ITEM(res_job.PrefixLinks), 1, ITEM_DEFAULT, 0},
223 {"prunejobs", store_yesno, ITEM(res_job.PruneJobs), 1, ITEM_DEFAULT, 0},
224 {"prunefiles", store_yesno, ITEM(res_job.PruneFiles), 1, ITEM_DEFAULT, 0},
225 {"prunevolumes",store_yesno, ITEM(res_job.PruneVolumes), 1, ITEM_DEFAULT, 0},
226 {"spoolattributes",store_yesno, ITEM(res_job.SpoolAttributes), 1, ITEM_DEFAULT, 0},
227 {"spooldata", store_yesno, ITEM(res_job.spool_data), 1, ITEM_DEFAULT, 0},
228 {"runbeforejob", store_str, ITEM(res_job.RunBeforeJob), 0, 0, 0},
229 {"runafterjob", store_str, ITEM(res_job.RunAfterJob), 0, 0, 0},
230 {"runafterfailedjob", store_str, ITEM(res_job.RunAfterFailedJob), 0, 0, 0},
231 {"clientrunbeforejob", store_str, ITEM(res_job.ClientRunBeforeJob), 0, 0, 0},
232 {"clientrunafterjob", store_str, ITEM(res_job.ClientRunAfterJob), 0, 0, 0},
233 {"maximumconcurrentjobs", store_pint, ITEM(res_job.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
234 {"rescheduleonerror", store_yesno, ITEM(res_job.RescheduleOnError), 1, ITEM_DEFAULT, 0},
235 {"rescheduleinterval", store_time, ITEM(res_job.RescheduleInterval), 0, ITEM_DEFAULT, 60 * 30},
236 {"rescheduletimes", store_pint, ITEM(res_job.RescheduleTimes), 0, 0, 0},
237 {"priority", store_pint, ITEM(res_job.Priority), 0, ITEM_DEFAULT, 10},
238 {NULL, NULL, NULL, 0, 0, 0}
243 * name handler value code flags default_value
245 static RES_ITEM fs_items[] = {
246 {"name", store_name, ITEM(res_fs.hdr.name), 0, ITEM_REQUIRED, 0},
247 {"description", store_str, ITEM(res_fs.hdr.desc), 0, 0, 0},
248 {"include", store_inc, NULL, 0, ITEM_NO_EQUALS, 0},
249 {"exclude", store_inc, NULL, 1, ITEM_NO_EQUALS, 0},
250 {NULL, NULL, NULL, 0, 0, 0}
253 /* Schedule -- see run_conf.c */
256 * name handler value code flags default_value
258 static RES_ITEM sch_items[] = {
259 {"name", store_name, ITEM(res_sch.hdr.name), 0, ITEM_REQUIRED, 0},
260 {"description", store_str, ITEM(res_sch.hdr.desc), 0, 0, 0},
261 {"run", store_run, ITEM(res_sch.run), 0, 0, 0},
262 {NULL, NULL, NULL, 0, 0, 0}
267 * name handler value code flags default_value
269 static RES_ITEM pool_items[] = {
270 {"name", store_name, ITEM(res_pool.hdr.name), 0, ITEM_REQUIRED, 0},
271 {"description", store_str, ITEM(res_pool.hdr.desc), 0, 0, 0},
272 {"pooltype", store_strname, ITEM(res_pool.pool_type), 0, ITEM_REQUIRED, 0},
273 {"labelformat", store_strname, ITEM(res_pool.label_format), 0, 0, 0},
274 {"cleaningprefix", store_strname, ITEM(res_pool.cleaning_prefix), 0, 0, 0},
275 {"usecatalog", store_yesno, ITEM(res_pool.use_catalog), 1, ITEM_DEFAULT, 1},
276 {"usevolumeonce", store_yesno, ITEM(res_pool.use_volume_once), 1, 0, 0},
277 {"purgeoldestvolume", store_yesno, ITEM(res_pool.purge_oldest_volume), 1, 0, 0},
278 {"recycleoldestvolume", store_yesno, ITEM(res_pool.recycle_oldest_volume), 1, 0, 0},
279 {"recyclecurrentvolume", store_yesno, ITEM(res_pool.recycle_current_volume), 1, 0, 0},
280 {"maximumvolumes", store_pint, ITEM(res_pool.max_volumes), 0, 0, 0},
281 {"maximumvolumejobs", store_pint, ITEM(res_pool.MaxVolJobs), 0, 0, 0},
282 {"maximumvolumefiles", store_pint, ITEM(res_pool.MaxVolFiles), 0, 0, 0},
283 {"maximumvolumebytes", store_size, ITEM(res_pool.MaxVolBytes), 0, 0, 0},
284 {"acceptanyvolume", store_yesno, ITEM(res_pool.accept_any_volume), 1, ITEM_DEFAULT, 1},
285 {"catalogfiles", store_yesno, ITEM(res_pool.catalog_files), 1, ITEM_DEFAULT, 1},
286 {"volumeretention", store_time, ITEM(res_pool.VolRetention), 0, ITEM_DEFAULT, 60*60*24*365},
287 {"volumeuseduration", store_time, ITEM(res_pool.VolUseDuration),0, 0, 0},
288 {"autoprune", store_yesno, ITEM(res_pool.AutoPrune), 1, ITEM_DEFAULT, 1},
289 {"recycle", store_yesno, ITEM(res_pool.Recycle), 1, ITEM_DEFAULT, 1},
290 {NULL, NULL, NULL, 0, 0, 0}
295 * name handler value code flags default_value
297 static RES_ITEM counter_items[] = {
298 {"name", store_name, ITEM(res_counter.hdr.name), 0, ITEM_REQUIRED, 0},
299 {"description", store_str, ITEM(res_counter.hdr.desc), 0, 0, 0},
300 {"minimum", store_int, ITEM(res_counter.MinValue), 0, ITEM_DEFAULT, 0},
301 {"maximum", store_pint, ITEM(res_counter.MaxValue), 0, ITEM_DEFAULT, INT32_MAX},
302 {"wrapcounter", store_res, ITEM(res_counter.WrapCounter), R_COUNTER, 0, 0},
303 {"catalog", store_res, ITEM(res_counter.Catalog), R_CATALOG, 0, 0},
304 {NULL, NULL, NULL, 0, 0, 0}
308 /* Message resource */
309 extern RES_ITEM msgs_items[];
312 * This is the master resource definition.
313 * It must have one item for each of the resources.
315 * NOTE!!! keep it in the same order as the R_codes
316 * or eliminate all resources[rindex].name
318 * name items rcode res_head
320 RES_TABLE resources[] = {
321 {"director", dir_items, R_DIRECTOR, NULL},
322 {"client", cli_items, R_CLIENT, NULL},
323 {"job", job_items, R_JOB, NULL},
324 {"storage", store_items, R_STORAGE, NULL},
325 {"catalog", cat_items, R_CATALOG, NULL},
326 {"schedule", sch_items, R_SCHEDULE, NULL},
327 {"fileset", fs_items, R_FILESET, NULL},
328 {"pool", pool_items, R_POOL, NULL},
329 {"messages", msgs_items, R_MSGS, NULL},
330 {"counter", counter_items, R_COUNTER, NULL},
331 {"console", con_items, R_CONSOLE, NULL},
332 {"jobdefs", job_items, R_JOBDEFS, NULL},
333 {NULL, NULL, 0, NULL}
337 /* Keywords (RHS) permitted in Job Level records
339 * level_name level job_type
341 struct s_jl joblevels[] = {
342 {"Full", L_FULL, JT_BACKUP},
343 {"Base", L_BASE, JT_BACKUP},
344 {"Incremental", L_INCREMENTAL, JT_BACKUP},
345 {"Differential", L_DIFFERENTIAL, JT_BACKUP},
346 {"Since", L_SINCE, JT_BACKUP},
347 {"Catalog", L_VERIFY_CATALOG, JT_VERIFY},
348 {"InitCatalog", L_VERIFY_INIT, JT_VERIFY},
349 {"VolumeToCatalog", L_VERIFY_VOLUME_TO_CATALOG, JT_VERIFY},
350 {"DiskToCatalog", L_VERIFY_DISK_TO_CATALOG, JT_VERIFY},
351 {"Data", L_VERIFY_DATA, JT_VERIFY},
352 {" ", L_NONE, JT_ADMIN},
353 {" ", L_NONE, JT_RESTORE},
357 /* Keywords (RHS) permitted in Job type records
361 struct s_jt jobtypes[] = {
362 {"backup", JT_BACKUP},
364 {"verify", JT_VERIFY},
365 {"restore", JT_RESTORE},
369 #ifdef old_deprecated_code
371 /* Keywords (RHS) permitted in Backup and Verify records */
372 static struct s_kw BakVerFields[] = {
379 /* Keywords (RHS) permitted in Restore records */
380 static struct s_kw RestoreFields[] = {
383 {"jobid", 'J'}, /* JobId to restore */
384 {"where", 'W'}, /* root of restore */
385 {"replace", 'R'}, /* replacement options */
386 {"bootstrap", 'B'}, /* bootstrap file */
391 /* Options permitted in Restore replace= */
392 struct s_kw ReplaceOptions[] = {
393 {"always", REPLACE_ALWAYS},
394 {"ifnewer", REPLACE_IFNEWER},
395 {"ifolder", REPLACE_IFOLDER},
396 {"never", REPLACE_NEVER},
400 char *level_to_str(int level)
403 static char level_no[30];
404 char *str = level_no;
406 bsnprintf(level_no, sizeof(level_no), "%d", level); /* default if not found */
407 for (i=0; joblevels[i].level_name; i++) {
408 if (level == joblevels[i].level) {
409 str = joblevels[i].level_name;
416 /* Dump contents of resource */
417 void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
419 URES *res = (URES *)reshdr;
421 char ed1[100], ed2[100];
424 sendit(sock, "No %s resource defined\n", res_to_str(type));
427 if (type < 0) { /* no recursion */
433 sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n",
434 reshdr->name, res->res_dir.MaxConcurrentJobs,
435 edit_uint64(res->res_dir.FDConnectTimeout, ed1),
436 edit_uint64(res->res_dir.SDConnectTimeout, ed2));
437 if (res->res_dir.query_file) {
438 sendit(sock, " query_file=%s\n", res->res_dir.query_file);
440 if (res->res_dir.messages) {
441 sendit(sock, " --> ");
442 dump_resource(-R_MSGS, (RES *)res->res_dir.messages, sendit, sock);
446 sendit(sock, "Console: name=%s SSL=%d\n",
447 res->res_con.hdr.name, res->res_con.enable_ssl);
450 if (res->res_counter.WrapCounter) {
451 sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n",
452 res->res_counter.hdr.name, res->res_counter.MinValue,
453 res->res_counter.MaxValue, res->res_counter.CurrentValue,
454 res->res_counter.WrapCounter->hdr.name);
456 sendit(sock, "Counter: name=%s min=%d max=%d\n",
457 res->res_counter.hdr.name, res->res_counter.MinValue,
458 res->res_counter.MaxValue);
460 if (res->res_counter.Catalog) {
461 sendit(sock, " --> ");
462 dump_resource(-R_CATALOG, (RES *)res->res_counter.Catalog, sendit, sock);
467 sendit(sock, "Client: name=%s address=%s FDport=%d MaxJobs=%u\n",
468 res->res_client.hdr.name, res->res_client.address, res->res_client.FDport,
469 res->res_client.MaxConcurrentJobs);
470 sendit(sock, " JobRetention=%s FileRetention=%s AutoPrune=%d\n",
471 edit_utime(res->res_client.JobRetention, ed1),
472 edit_utime(res->res_client.FileRetention, ed2),
473 res->res_client.AutoPrune);
474 if (res->res_client.catalog) {
475 sendit(sock, " --> ");
476 dump_resource(-R_CATALOG, (RES *)res->res_client.catalog, sendit, sock);
480 sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n\
481 DeviceName=%s MediaType=%s\n",
482 res->res_store.hdr.name, res->res_store.address, res->res_store.SDport,
483 res->res_store.MaxConcurrentJobs,
484 res->res_store.dev_name, res->res_store.media_type);
487 sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n\
489 res->res_cat.hdr.name, NPRT(res->res_cat.db_address),
490 res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user));
494 sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n",
495 type == R_JOB ? "Job" : "JobDefs",
496 res->res_job.hdr.name, res->res_job.JobType,
497 level_to_str(res->res_job.level), res->res_job.Priority,
498 res->res_job.MaxConcurrentJobs);
499 sendit(sock, " Resched=%d Times=%d Interval=%s Spool=%d\n",
500 res->res_job.RescheduleOnError, res->res_job.RescheduleTimes,
501 edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1),
502 res->res_job.spool_data);
503 if (res->res_job.client) {
504 sendit(sock, " --> ");
505 dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock);
507 if (res->res_job.fileset) {
508 sendit(sock, " --> ");
509 dump_resource(-R_FILESET, (RES *)res->res_job.fileset, sendit, sock);
511 if (res->res_job.schedule) {
512 sendit(sock, " --> ");
513 dump_resource(-R_SCHEDULE, (RES *)res->res_job.schedule, sendit, sock);
515 if (res->res_job.RestoreWhere) {
516 sendit(sock, " --> Where=%s\n", NPRT(res->res_job.RestoreWhere));
518 if (res->res_job.RestoreBootstrap) {
519 sendit(sock, " --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap));
521 if (res->res_job.RunBeforeJob) {
522 sendit(sock, " --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob));
524 if (res->res_job.RunAfterJob) {
525 sendit(sock, " --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob));
527 if (res->res_job.RunAfterFailedJob) {
528 sendit(sock, " --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob));
530 if (res->res_job.WriteBootstrap) {
531 sendit(sock, " --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap));
533 if (res->res_job.storage) {
534 sendit(sock, " --> ");
535 dump_resource(-R_STORAGE, (RES *)res->res_job.storage, sendit, sock);
537 if (res->res_job.pool) {
538 sendit(sock, " --> ");
539 dump_resource(-R_POOL, (RES *)res->res_job.pool, sendit, sock);
541 if (res->res_job.full_pool) {
542 sendit(sock, " --> ");
543 dump_resource(-R_POOL, (RES *)res->res_job.full_pool, sendit, sock);
545 if (res->res_job.inc_pool) {
546 sendit(sock, " --> ");
547 dump_resource(-R_POOL, (RES *)res->res_job.inc_pool, sendit, sock);
549 if (res->res_job.dif_pool) {
550 sendit(sock, " --> ");
551 dump_resource(-R_POOL, (RES *)res->res_job.dif_pool, sendit, sock);
553 if (res->res_job.verify_job) {
554 sendit(sock, " --> ");
555 dump_resource(-type, (RES *)res->res_job.verify_job, sendit, sock);
558 if (res->res_job.messages) {
559 sendit(sock, " --> ");
560 dump_resource(-R_MSGS, (RES *)res->res_job.messages, sendit, sock);
564 sendit(sock, "FileSet: name=%s\n", res->res_fs.hdr.name);
565 for (int i=0; i<res->res_fs.num_includes; i++) {
566 INCEXE *incexe = res->res_fs.include_items[i];
567 for (int j=0; j<incexe->name_list.size(); j++) {
568 sendit(sock, " Inc: %s\n", incexe->name_list.get(j));
571 for (int i=0; i<res->res_fs.num_excludes; i++) {
572 INCEXE *incexe = res->res_fs.exclude_items[i];
573 for (int j=0; j<incexe->name_list.size(); j++) {
574 sendit(sock, " Exc: %s\n", incexe->name_list.get(j));
579 if (res->res_sch.run) {
581 RUN *run = res->res_sch.run;
582 char buf[1000], num[30];
583 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
588 sendit(sock, " --> Run Level=%s\n", level_to_str(run->level));
589 bstrncpy(buf, " hour=", sizeof(buf));
590 for (i=0; i<24; i++) {
591 if (bit_is_set(i, run->hour)) {
592 bsnprintf(num, sizeof(num), "%d ", i);
593 bstrncat(buf, num, sizeof(buf));
596 bstrncat(buf, "\n", sizeof(buf));
598 bstrncpy(buf, " mday=", sizeof(buf));
599 for (i=0; i<31; i++) {
600 if (bit_is_set(i, run->mday)) {
601 bsnprintf(num, sizeof(num), "%d ", i);
602 bstrncat(buf, num, sizeof(buf));
605 bstrncat(buf, "\n", sizeof(buf));
607 bstrncpy(buf, " month=", sizeof(buf));
608 for (i=0; i<12; i++) {
609 if (bit_is_set(i, run->month)) {
610 bsnprintf(num, sizeof(num), "%d ", i);
611 bstrncat(buf, num, sizeof(buf));
614 bstrncat(buf, "\n", sizeof(buf));
616 bstrncpy(buf, " wday=", sizeof(buf));
617 for (i=0; i<7; i++) {
618 if (bit_is_set(i, run->wday)) {
619 bsnprintf(num, sizeof(num), "%d ", i);
620 bstrncat(buf, num, sizeof(buf));
623 bstrncat(buf, "\n", sizeof(buf));
625 bstrncpy(buf, " wom=", sizeof(buf));
626 for (i=0; i<5; i++) {
627 if (bit_is_set(i, run->wom)) {
628 bsnprintf(num, sizeof(num), "%d ", i);
629 bstrncat(buf, num, sizeof(buf));
632 bstrncat(buf, "\n", sizeof(buf));
634 bstrncpy(buf, " woy=", sizeof(buf));
635 for (i=0; i<54; i++) {
636 if (bit_is_set(i, run->woy)) {
637 bsnprintf(num, sizeof(num), "%d ", i);
638 bstrncat(buf, num, sizeof(buf));
641 bstrncat(buf, "\n", sizeof(buf));
643 sendit(sock, " mins=%d\n", run->minute);
645 sendit(sock, " --> ");
646 dump_resource(-R_POOL, (RES *)run->pool, sendit, sock);
649 sendit(sock, " --> ");
650 dump_resource(-R_STORAGE, (RES *)run->storage, sendit, sock);
653 sendit(sock, " --> ");
654 dump_resource(-R_MSGS, (RES *)run->msgs, sendit, sock);
656 /* If another Run record is chained in, go print it */
662 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
666 sendit(sock, "Pool: name=%s PoolType=%s\n", res->res_pool.hdr.name,
667 res->res_pool.pool_type);
668 sendit(sock, " use_cat=%d use_once=%d acpt_any=%d cat_files=%d\n",
669 res->res_pool.use_catalog, res->res_pool.use_volume_once,
670 res->res_pool.accept_any_volume, res->res_pool.catalog_files);
671 sendit(sock, " max_vols=%d auto_prune=%d VolRetention=%s\n",
672 res->res_pool.max_volumes, res->res_pool.AutoPrune,
673 edit_utime(res->res_pool.VolRetention, ed1));
674 sendit(sock, " VolUse=%s recycle=%d LabelFormat=%s\n",
675 edit_utime(res->res_pool.VolUseDuration, ed1),
676 res->res_pool.Recycle,
677 NPRT(res->res_pool.label_format));
678 sendit(sock, " CleaningPrefix=%s\n",
679 NPRT(res->res_pool.cleaning_prefix));
680 sendit(sock, " recyleOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n",
681 res->res_pool.purge_oldest_volume,
682 res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles);
685 sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
686 if (res->res_msgs.mail_cmd)
687 sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd);
688 if (res->res_msgs.operator_cmd)
689 sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd);
692 sendit(sock, "Unknown resource type %d in dump_resource.\n", type);
695 if (recurse && res->res_dir.hdr.next) {
696 dump_resource(type, res->res_dir.hdr.next, sendit, sock);
701 * Free all the members of an INCEXE structure
703 static void free_incexe(INCEXE *incexe)
705 incexe->name_list.destroy();
706 for (int i=0; i<incexe->num_opts; i++) {
707 FOPTS *fopt = incexe->opts_list[i];
708 fopt->match.destroy();
709 fopt->base_list.destroy();
712 if (incexe->opts_list) {
713 free(incexe->opts_list);
719 * Free memory of resource -- called when daemon terminates.
720 * NB, we don't need to worry about freeing any references
721 * to other resources as they will be freed when that
722 * resource chain is traversed. Mainly we worry about freeing
723 * allocated strings (names).
725 void free_resource(RES *sres, int type)
728 RES *nres; /* next resource if linked */
729 URES *res = (URES *)sres;
734 /* common stuff -- free the resource name and description */
735 nres = (RES *)res->res_dir.hdr.next;
736 if (res->res_dir.hdr.name) {
737 free(res->res_dir.hdr.name);
739 if (res->res_dir.hdr.desc) {
740 free(res->res_dir.hdr.desc);
745 if (res->res_dir.working_directory) {
746 free(res->res_dir.working_directory);
748 if (res->res_dir.pid_directory) {
749 free(res->res_dir.pid_directory);
751 if (res->res_dir.subsys_directory) {
752 free(res->res_dir.subsys_directory);
754 if (res->res_dir.password) {
755 free(res->res_dir.password);
757 if (res->res_dir.query_file) {
758 free(res->res_dir.query_file);
760 if (res->res_dir.DIRaddr) {
761 free(res->res_dir.DIRaddr);
767 if (res->res_con.password) {
768 free(res->res_con.password);
770 for (int i=0; i<Num_ACL; i++) {
771 if (res->res_con.ACL_lists[i]) {
772 delete res->res_con.ACL_lists[i];
773 res->res_con.ACL_lists[i] = NULL;
778 if (res->res_client.address) {
779 free(res->res_client.address);
781 if (res->res_client.password) {
782 free(res->res_client.password);
786 if (res->res_store.address) {
787 free(res->res_store.address);
789 if (res->res_store.password) {
790 free(res->res_store.password);
792 if (res->res_store.media_type) {
793 free(res->res_store.media_type);
795 if (res->res_store.dev_name) {
796 free(res->res_store.dev_name);
800 if (res->res_cat.db_address) {
801 free(res->res_cat.db_address);
803 if (res->res_cat.db_socket) {
804 free(res->res_cat.db_socket);
806 if (res->res_cat.db_user) {
807 free(res->res_cat.db_user);
809 if (res->res_cat.db_name) {
810 free(res->res_cat.db_name);
812 if (res->res_cat.db_password) {
813 free(res->res_cat.db_password);
817 if ((num=res->res_fs.num_includes)) {
819 free_incexe(res->res_fs.include_items[num]);
821 free(res->res_fs.include_items);
823 res->res_fs.num_includes = 0;
824 if ((num=res->res_fs.num_excludes)) {
826 free_incexe(res->res_fs.exclude_items[num]);
828 free(res->res_fs.exclude_items);
830 res->res_fs.num_excludes = 0;
833 if (res->res_pool.pool_type) {
834 free(res->res_pool.pool_type);
836 if (res->res_pool.label_format) {
837 free(res->res_pool.label_format);
839 if (res->res_pool.cleaning_prefix) {
840 free(res->res_pool.cleaning_prefix);
844 if (res->res_sch.run) {
846 nrun = res->res_sch.run;
856 if (res->res_job.RestoreWhere) {
857 free(res->res_job.RestoreWhere);
859 if (res->res_job.RestoreBootstrap) {
860 free(res->res_job.RestoreBootstrap);
862 if (res->res_job.WriteBootstrap) {
863 free(res->res_job.WriteBootstrap);
865 if (res->res_job.RunBeforeJob) {
866 free(res->res_job.RunBeforeJob);
868 if (res->res_job.RunAfterJob) {
869 free(res->res_job.RunAfterJob);
871 if (res->res_job.RunAfterFailedJob) {
872 free(res->res_job.RunAfterFailedJob);
874 if (res->res_job.ClientRunBeforeJob) {
875 free(res->res_job.ClientRunBeforeJob);
877 if (res->res_job.ClientRunAfterJob) {
878 free(res->res_job.ClientRunAfterJob);
882 if (res->res_msgs.mail_cmd) {
883 free(res->res_msgs.mail_cmd);
885 if (res->res_msgs.operator_cmd) {
886 free(res->res_msgs.operator_cmd);
888 free_msgs_res((MSGS *)res); /* free message resource */
892 printf("Unknown resource type %d in free_resource.\n", type);
894 /* Common stuff again -- free the resource, recurse to next one */
899 free_resource(nres, type);
904 * Save the new resource by chaining it into the head list for
905 * the resource. If this is pass 2, we update any resource
906 * pointers because they may not have been defined until
909 void save_resource(int type, RES_ITEM *items, int pass)
912 int rindex = type - r_first;
916 /* Check Job requirements after applying JobDefs */
917 if (type != R_JOB && type != R_JOBDEFS) {
919 * Ensure that all required items are present
921 for (i=0; items[i].name; i++) {
922 if (items[i].flags & ITEM_REQUIRED) {
923 if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
924 Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n",
925 items[i].name, resources[rindex]);
928 /* If this triggers, take a look at lib/parse_conf.h */
929 if (i >= MAX_RES_ITEMS) {
930 Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]);
936 * During pass 2 in each "store" routine, we looked up pointers
937 * to all the resources referrenced in the current resource, now we
938 * must copy their addresses from the static record to the allocated
943 /* Resources not containing a resource */
952 /* Resources containing another resource */
954 if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) {
955 Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name);
957 res->res_dir.messages = res_all.res_dir.messages;
961 if ((res = (URES *)GetResWithName(type, res_all.res_dir.hdr.name)) == NULL) {
962 Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n",
963 res_all.res_dir.hdr.name);
965 res->res_job.messages = res_all.res_job.messages;
966 res->res_job.schedule = res_all.res_job.schedule;
967 res->res_job.client = res_all.res_job.client;
968 res->res_job.fileset = res_all.res_job.fileset;
969 res->res_job.storage = res_all.res_job.storage;
970 res->res_job.pool = res_all.res_job.pool;
971 res->res_job.full_pool = res_all.res_job.full_pool;
972 res->res_job.inc_pool = res_all.res_job.inc_pool;
973 res->res_job.dif_pool = res_all.res_job.dif_pool;
974 res->res_job.verify_job = res_all.res_job.verify_job;
975 res->res_job.jobdefs = res_all.res_job.jobdefs;
978 if ((res = (URES *)GetResWithName(R_COUNTER, res_all.res_counter.hdr.name)) == NULL) {
979 Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name);
981 res->res_counter.Catalog = res_all.res_counter.Catalog;
982 res->res_counter.WrapCounter = res_all.res_counter.WrapCounter;
986 if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_client.hdr.name)) == NULL) {
987 Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name);
989 res->res_client.catalog = res_all.res_client.catalog;
993 * Schedule is a bit different in that it contains a RUN record
994 * chain which isn't a "named" resource. This chain was linked
995 * in by run_conf.c during pass 2, so here we jam the pointer
996 * into the Schedule resource.
998 if ((res = (URES *)GetResWithName(R_SCHEDULE, res_all.res_client.hdr.name)) == NULL) {
999 Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name);
1001 res->res_sch.run = res_all.res_sch.run;
1004 Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type);
1008 /* Note, the resource name was already saved during pass 1,
1009 * so here, we can just release it.
1011 if (res_all.res_dir.hdr.name) {
1012 free(res_all.res_dir.hdr.name);
1013 res_all.res_dir.hdr.name = NULL;
1015 if (res_all.res_dir.hdr.desc) {
1016 free(res_all.res_dir.hdr.desc);
1017 res_all.res_dir.hdr.desc = NULL;
1023 * The following code is only executed during pass 1
1027 size = sizeof(DIRRES);
1030 size = sizeof(CONRES);
1033 size =sizeof(CLIENT);
1036 size = sizeof(STORE);
1046 size = sizeof(FILESET);
1049 size = sizeof(SCHED);
1052 size = sizeof(POOL);
1055 size = sizeof(MSGS);
1058 size = sizeof(COUNTER);
1061 printf("Unknown resource type %d in save_resrouce.\n", type);
1068 if (type == R_JOBDEFS) {
1069 Dmsg0(200, "Storing JobDefs definition.\n");
1071 res = (URES *)malloc(size);
1072 memcpy(res, &res_all, size);
1073 if (!resources[rindex].res_head) {
1074 resources[rindex].res_head = (RES *)res; /* store first entry */
1075 Dmsg3(200, "Inserting first %s res: %s index=%d\n", res_to_str(type),
1076 res->res_dir.hdr.name, rindex);
1079 /* Add new res to end of chain */
1080 for (next=resources[rindex].res_head; next->next; next=next->next) {
1081 if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
1082 Emsg2(M_ERROR_TERM, 0,
1083 _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
1084 resources[rindex].name, res->res_dir.hdr.name);
1087 next->next = (RES *)res;
1088 Dmsg4(200, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
1089 res->res_dir.hdr.name, rindex, pass);
1095 * Store JobType (backup, verify, restore)
1098 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass)
1102 token = lex_get_token(lc, T_NAME);
1103 /* Store the type both pass 1 and pass 2 */
1104 for (i=0; jobtypes[i].type_name; i++) {
1105 if (strcasecmp(lc->str, jobtypes[i].type_name) == 0) {
1106 *(int *)(item->value) = jobtypes[i].job_type;
1112 scan_err1(lc, "Expected a Job Type keyword, got: %s", lc->str);
1115 set_bit(index, res_all.hdr.item_present);
1119 * Store Job Level (Full, Incremental, ...)
1122 void store_level(LEX *lc, RES_ITEM *item, int index, int pass)
1126 token = lex_get_token(lc, T_NAME);
1127 /* Store the level pass 2 so that type is defined */
1128 for (i=0; joblevels[i].level_name; i++) {
1129 if (strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1130 *(int *)(item->value) = joblevels[i].level;
1136 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1139 set_bit(index, res_all.hdr.item_present);
1142 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass)
1145 token = lex_get_token(lc, T_NAME);
1146 /* Scan Replacement options */
1147 for (i=0; ReplaceOptions[i].name; i++) {
1148 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1149 *(int *)(item->value) = ReplaceOptions[i].token;
1155 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1158 set_bit(index, res_all.hdr.item_present);
1162 * Store ACL (access control list)
1165 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass)
1170 token = lex_get_token(lc, T_NAME);
1172 if (((alist **)item->value)[item->code] == NULL) {
1173 ((alist **)item->value)[item->code] = new alist(10, owned_by_alist);
1174 // Dmsg1(400, "Defined new ACL alist at %d\n", item->code);
1176 ((alist **)item->value)[item->code]->append(bstrdup(lc->str));
1177 // Dmsg2(400, "Appended to %d %s\n", item->code, lc->str);
1179 token = lex_get_token(lc, T_ALL);
1180 if (token == T_COMMA) {
1181 continue; /* get another ACL */
1185 set_bit(index, res_all.hdr.item_present);
1189 #ifdef old_deprecated_code
1191 * Store backup/verify info for Job record
1193 * Note, this code is used for both BACKUP and VERIFY jobs
1195 * Backup = Client=<client-name> FileSet=<FileSet-name> Level=<level>
1197 static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass)
1201 int options = lc->options;
1203 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1206 ((JOB *)(item->value))->JobType = item->code;
1207 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1210 Dmsg1(150, "store_backup got token=%s\n", lex_tok_to_str(token));
1212 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1213 scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str);
1215 Dmsg1(190, "Got keyword: %s\n", lc->str);
1216 for (i=0; BakVerFields[i].name; i++) {
1217 if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
1219 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1220 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1222 token = lex_get_token(lc, T_NAME);
1223 Dmsg1(190, "Got value: %s\n", lc->str);
1224 switch (BakVerFields[i].token) {
1226 /* Find Client Resource */
1228 res = GetResWithName(R_CLIENT, lc->str);
1230 scan_err1(lc, "Could not find specified Client Resource: %s",
1233 res_all.res_job.client = (CLIENT *)res;
1237 /* Find FileSet Resource */
1239 res = GetResWithName(R_FILESET, lc->str);
1241 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1244 res_all.res_job.fileset = (FILESET *)res;
1249 for (i=0; joblevels[i].level_name; i++) {
1250 if (joblevels[i].job_type == item->code &&
1251 strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1252 ((JOB *)(item->value))->level = joblevels[i].level;
1258 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1263 } /* end if strcmp() */
1266 scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str);
1269 lc->options = options; /* reset original options */
1270 set_bit(index, res_all.hdr.item_present);
1274 * Store restore info for Job record
1276 * Restore = JobId=<job-id> Where=<root-directory> Replace=<options> Bootstrap=<file>
1279 static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
1283 int options = lc->options;
1285 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1287 Dmsg0(190, "Enter store_restore()\n");
1289 ((JOB *)(item->value))->JobType = item->code;
1290 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1293 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1294 scan_err1(lc, "expected a name, got: %s", lc->str);
1296 for (i=0; RestoreFields[i].name; i++) {
1297 Dmsg1(190, "Restore kw=%s\n", lc->str);
1298 if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
1300 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1301 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1303 token = lex_get_token(lc, T_ALL);
1304 Dmsg1(190, "Restore value=%s\n", lc->str);
1305 switch (RestoreFields[i].token) {
1308 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1309 scan_err1(lc, "Expected a Restore bootstrap file, got: %s", lc->str);
1312 res_all.res_job.RestoreBootstrap = bstrdup(lc->str);
1316 /* Find Client Resource */
1318 res = GetResWithName(R_CLIENT, lc->str);
1320 scan_err1(lc, "Could not find specified Client Resource: %s",
1323 res_all.res_job.client = (CLIENT *)res;
1327 /* Find FileSet Resource */
1329 res = GetResWithName(R_FILESET, lc->str);
1331 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1334 res_all.res_job.fileset = (FILESET *)res;
1339 if (token != T_NUMBER) {
1340 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1343 res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
1344 Dmsg1(190, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
1346 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1351 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1352 scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str);
1355 res_all.res_job.RestoreWhere = bstrdup(lc->str);
1359 /* Replacement options */
1360 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1361 scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
1363 /* Fix to scan Replacement options */
1364 for (i=0; ReplaceOptions[i].name; i++) {
1365 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1366 ((JOB *)(item->value))->replace = ReplaceOptions[i].token;
1372 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1377 } /* end if strcmp() */
1380 scan_err1(lc, "%s not a valid Restore keyword", lc->str);
1383 lc->options = options; /* reset original options */
1384 set_bit(index, res_all.hdr.item_present);