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;
53 static RES *sres_head[R_LAST - R_FIRST + 1];
54 RES **res_head = sres_head;
56 /* Imported subroutines */
57 extern void store_run(LEX *lc, RES_ITEM *item, int index, int pass);
58 extern void store_finc(LEX *lc, RES_ITEM *item, int index, int pass);
59 extern void store_inc(LEX *lc, RES_ITEM *item, int index, int pass);
62 /* Forward referenced subroutines */
64 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass);
65 void store_level(LEX *lc, RES_ITEM *item, int index, int pass);
66 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass);
67 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass);
70 /* We build the current resource here as we are
71 * scanning the resource configuration definition,
72 * then move it to allocated memory when the resource
76 int res_all_size = sizeof(res_all);
79 /* Definition of records permitted within each
80 * resource with the routine to process the record
81 * information. NOTE! quoted names must be in lower case.
86 * name handler value code flags default_value
88 static RES_ITEM dir_items[] = {
89 {"name", store_name, ITEM(res_dir.hdr.name), 0, ITEM_REQUIRED, 0},
90 {"description", store_str, ITEM(res_dir.hdr.desc), 0, 0, 0},
91 {"messages", store_res, ITEM(res_dir.messages), R_MSGS, 0, 0},
92 {"dirport", store_addresses_port, ITEM(res_dir.DIRaddrs), 0, ITEM_DEFAULT, 9101},
93 {"diraddress", store_addresses_address, ITEM(res_dir.DIRaddrs), 0, ITEM_DEFAULT, 9101},
94 {"diraddresses",store_addresses, ITEM(res_dir.DIRaddrs), 0, ITEM_DEFAULT, 9101},
95 {"queryfile", store_dir, ITEM(res_dir.query_file), 0, ITEM_REQUIRED, 0},
96 {"workingdirectory", store_dir, ITEM(res_dir.working_directory), 0, ITEM_REQUIRED, 0},
97 {"piddirectory",store_dir, ITEM(res_dir.pid_directory), 0, ITEM_REQUIRED, 0},
98 {"subsysdirectory", store_dir, ITEM(res_dir.subsys_directory), 0, 0, 0},
99 {"requiressl", store_yesno, ITEM(res_dir.require_ssl), 1, ITEM_DEFAULT, 0},
100 {"enablessl", store_yesno, ITEM(res_dir.enable_ssl), 1, ITEM_DEFAULT, 0},
101 {"maximumconcurrentjobs", store_pint, ITEM(res_dir.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
102 {"password", store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0},
103 {"fdconnecttimeout", store_time,ITEM(res_dir.FDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
104 {"sdconnecttimeout", store_time,ITEM(res_dir.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
105 {NULL, NULL, NULL, 0, 0, 0}
111 * name handler value code flags default_value
113 static RES_ITEM con_items[] = {
114 {"name", store_name, ITEM(res_con.hdr.name), 0, ITEM_REQUIRED, 0},
115 {"description", store_str, ITEM(res_con.hdr.desc), 0, 0, 0},
116 {"enablessl", store_yesno, ITEM(res_con.enable_ssl), 1, ITEM_DEFAULT, 0},
117 {"password", store_password, ITEM(res_con.password), 0, ITEM_REQUIRED, 0},
118 {"jobacl", store_acl, ITEM(res_con.ACL_lists), Job_ACL, 0, 0},
119 {"clientacl", store_acl, ITEM(res_con.ACL_lists), Client_ACL, 0, 0},
120 {"storageacl", store_acl, ITEM(res_con.ACL_lists), Storage_ACL, 0, 0},
121 {"scheduleacl", store_acl, ITEM(res_con.ACL_lists), Schedule_ACL, 0, 0},
122 {"runacl", store_acl, ITEM(res_con.ACL_lists), Run_ACL, 0, 0},
123 {"poolacl", store_acl, ITEM(res_con.ACL_lists), Pool_ACL, 0, 0},
124 {"commandacl", store_acl, ITEM(res_con.ACL_lists), Command_ACL, 0, 0},
125 {"filesetacl", store_acl, ITEM(res_con.ACL_lists), FileSet_ACL, 0, 0},
126 {"catalogacl", store_acl, ITEM(res_con.ACL_lists), Catalog_ACL, 0, 0},
127 {NULL, NULL, NULL, 0, 0, 0}
132 * Client or File daemon resource
134 * name handler value code flags default_value
137 static RES_ITEM cli_items[] = {
138 {"name", store_name, ITEM(res_client.hdr.name), 0, ITEM_REQUIRED, 0},
139 {"description", store_str, ITEM(res_client.hdr.desc), 0, 0, 0},
140 {"address", store_str, ITEM(res_client.address), 0, ITEM_REQUIRED, 0},
141 {"fdaddress", store_str, ITEM(res_client.address), 0, 0, 0},
142 {"fdport", store_pint, ITEM(res_client.FDport), 0, ITEM_DEFAULT, 9102},
143 {"password", store_password, ITEM(res_client.password), 0, ITEM_REQUIRED, 0},
144 {"fdpassword", store_password, ITEM(res_client.password), 0, 0, 0},
145 {"catalog", store_res, ITEM(res_client.catalog), R_CATALOG, 0, 0},
146 {"fileretention", store_time, ITEM(res_client.FileRetention), 0, ITEM_DEFAULT, 60*60*24*60},
147 {"jobretention", store_time, ITEM(res_client.JobRetention), 0, ITEM_DEFAULT, 60*60*24*180},
148 {"autoprune", store_yesno, ITEM(res_client.AutoPrune), 1, ITEM_DEFAULT, 1},
149 {"enablessl", store_yesno, ITEM(res_client.enable_ssl), 1, ITEM_DEFAULT, 0},
150 {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
151 {NULL, NULL, NULL, 0, 0, 0}
154 /* Storage daemon resource
156 * name handler value code flags default_value
158 static RES_ITEM store_items[] = {
159 {"name", store_name, ITEM(res_store.hdr.name), 0, ITEM_REQUIRED, 0},
160 {"description", store_str, ITEM(res_store.hdr.desc), 0, 0, 0},
161 {"sdport", store_pint, ITEM(res_store.SDport), 0, ITEM_DEFAULT, 9103},
162 {"address", store_str, ITEM(res_store.address), 0, ITEM_REQUIRED, 0},
163 {"sdaddress", store_str, ITEM(res_store.address), 0, 0, 0},
164 {"password", store_password, ITEM(res_store.password), 0, ITEM_REQUIRED, 0},
165 {"sdpassword", store_password, ITEM(res_store.password), 0, 0, 0},
166 {"device", store_strname, ITEM(res_store.dev_name), 0, ITEM_REQUIRED, 0},
167 {"sddevicename", store_strname, ITEM(res_store.dev_name), 0, 0, 0},
168 {"mediatype", store_strname, ITEM(res_store.media_type), 0, ITEM_REQUIRED, 0},
169 {"autochanger", store_yesno, ITEM(res_store.autochanger), 1, ITEM_DEFAULT, 0},
170 {"enablessl", store_yesno, ITEM(res_store.enable_ssl), 1, ITEM_DEFAULT, 0},
171 {"maximumconcurrentjobs", store_pint, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
172 {"sddport", store_pint, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */
173 {NULL, NULL, NULL, 0, 0, 0}
177 * Catalog Resource Directives
179 * name handler value code flags default_value
181 static RES_ITEM cat_items[] = {
182 {"name", store_name, ITEM(res_cat.hdr.name), 0, ITEM_REQUIRED, 0},
183 {"description", store_str, ITEM(res_cat.hdr.desc), 0, 0, 0},
184 {"address", store_str, ITEM(res_cat.db_address), 0, 0, 0},
185 {"dbaddress", store_str, ITEM(res_cat.db_address), 0, 0, 0},
186 {"dbport", store_pint, ITEM(res_cat.db_port), 0, 0, 0},
187 /* keep this password as store_str for the moment */
188 {"password", store_str, ITEM(res_cat.db_password), 0, 0, 0},
189 {"dbpassword", store_str, ITEM(res_cat.db_password), 0, 0, 0},
190 {"user", store_str, ITEM(res_cat.db_user), 0, 0, 0},
191 {"dbname", store_str, ITEM(res_cat.db_name), 0, ITEM_REQUIRED, 0},
192 {"dbsocket", store_str, ITEM(res_cat.db_socket), 0, 0, 0},
193 {NULL, NULL, NULL, 0, 0, 0}
197 * Job Resource Directives
199 * name handler value code flags default_value
201 RES_ITEM job_items[] = {
202 {"name", store_name, ITEM(res_job.hdr.name), 0, ITEM_REQUIRED, 0},
203 {"description", store_str, ITEM(res_job.hdr.desc), 0, 0, 0},
204 {"type", store_jobtype, ITEM(res_job.JobType), 0, ITEM_REQUIRED, 0},
205 {"level", store_level, ITEM(res_job.level), 0, 0, 0},
206 {"messages", store_res, ITEM(res_job.messages), R_MSGS, ITEM_REQUIRED, 0},
207 {"storage", store_res, ITEM(res_job.storage), R_STORAGE, ITEM_REQUIRED, 0},
208 {"pool", store_res, ITEM(res_job.pool), R_POOL, ITEM_REQUIRED, 0},
209 {"fullbackuppool", store_res, ITEM(res_job.full_pool), R_POOL, 0, 0},
210 {"incrementalbackuppool", store_res, ITEM(res_job.inc_pool), R_POOL, 0, 0},
211 {"differentialbackuppool", store_res, ITEM(res_job.dif_pool), R_POOL, 0, 0},
212 {"client", store_res, ITEM(res_job.client), R_CLIENT, ITEM_REQUIRED, 0},
213 {"fileset", store_res, ITEM(res_job.fileset), R_FILESET, ITEM_REQUIRED, 0},
214 {"schedule", store_res, ITEM(res_job.schedule), R_SCHEDULE, 0, 0},
215 {"verifyjob", store_res, ITEM(res_job.verify_job), R_JOB, 0, 0},
216 {"jobdefs", store_res, ITEM(res_job.jobdefs), R_JOBDEFS, 0, 0},
217 {"where", store_dir, ITEM(res_job.RestoreWhere), 0, 0, 0},
218 {"bootstrap",store_dir, ITEM(res_job.RestoreBootstrap), 0, 0, 0},
219 {"writebootstrap",store_dir, ITEM(res_job.WriteBootstrap), 0, 0, 0},
220 {"replace", store_replace, ITEM(res_job.replace), 0, ITEM_DEFAULT, REPLACE_ALWAYS},
221 {"maxruntime", store_time, ITEM(res_job.MaxRunTime), 0, 0, 0},
222 {"maxwaittime", store_time, ITEM(res_job.MaxWaitTime), 0, 0, 0},
223 {"maxstartdelay",store_time, ITEM(res_job.MaxStartDelay), 0, 0, 0},
224 {"jobretention", store_time, ITEM(res_job.JobRetention), 0, 0, 0},
225 {"prefixlinks", store_yesno, ITEM(res_job.PrefixLinks), 1, ITEM_DEFAULT, 0},
226 {"prunejobs", store_yesno, ITEM(res_job.PruneJobs), 1, ITEM_DEFAULT, 0},
227 {"prunefiles", store_yesno, ITEM(res_job.PruneFiles), 1, ITEM_DEFAULT, 0},
228 {"prunevolumes",store_yesno, ITEM(res_job.PruneVolumes), 1, ITEM_DEFAULT, 0},
229 {"spoolattributes",store_yesno, ITEM(res_job.SpoolAttributes), 1, ITEM_DEFAULT, 0},
230 {"spooldata", store_yesno, ITEM(res_job.spool_data), 1, ITEM_DEFAULT, 0},
231 {"runbeforejob", store_str, ITEM(res_job.RunBeforeJob), 0, 0, 0},
232 {"runafterjob", store_str, ITEM(res_job.RunAfterJob), 0, 0, 0},
233 {"runafterfailedjob", store_str, ITEM(res_job.RunAfterFailedJob), 0, 0, 0},
234 {"clientrunbeforejob", store_str, ITEM(res_job.ClientRunBeforeJob), 0, 0, 0},
235 {"clientrunafterjob", store_str, ITEM(res_job.ClientRunAfterJob), 0, 0, 0},
236 {"maximumconcurrentjobs", store_pint, ITEM(res_job.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
237 {"rescheduleonerror", store_yesno, ITEM(res_job.RescheduleOnError), 1, ITEM_DEFAULT, 0},
238 {"rescheduleinterval", store_time, ITEM(res_job.RescheduleInterval), 0, ITEM_DEFAULT, 60 * 30},
239 {"rescheduletimes", store_pint, ITEM(res_job.RescheduleTimes), 0, 0, 0},
240 {"priority", store_pint, ITEM(res_job.Priority), 0, ITEM_DEFAULT, 10},
241 {NULL, NULL, NULL, 0, 0, 0}
246 * name handler value code flags default_value
248 static RES_ITEM fs_items[] = {
249 {"name", store_name, ITEM(res_fs.hdr.name), 0, ITEM_REQUIRED, 0},
250 {"description", store_str, ITEM(res_fs.hdr.desc), 0, 0, 0},
251 {"include", store_inc, NULL, 0, ITEM_NO_EQUALS, 0},
252 {"exclude", store_inc, NULL, 1, ITEM_NO_EQUALS, 0},
253 {NULL, NULL, NULL, 0, 0, 0}
256 /* Schedule -- see run_conf.c */
259 * name handler value code flags default_value
261 static RES_ITEM sch_items[] = {
262 {"name", store_name, ITEM(res_sch.hdr.name), 0, ITEM_REQUIRED, 0},
263 {"description", store_str, ITEM(res_sch.hdr.desc), 0, 0, 0},
264 {"run", store_run, ITEM(res_sch.run), 0, 0, 0},
265 {NULL, NULL, NULL, 0, 0, 0}
270 * name handler value code flags default_value
272 static RES_ITEM pool_items[] = {
273 {"name", store_name, ITEM(res_pool.hdr.name), 0, ITEM_REQUIRED, 0},
274 {"description", store_str, ITEM(res_pool.hdr.desc), 0, 0, 0},
275 {"pooltype", store_strname, ITEM(res_pool.pool_type), 0, ITEM_REQUIRED, 0},
276 {"labelformat", store_strname, ITEM(res_pool.label_format), 0, 0, 0},
277 {"cleaningprefix", store_strname, ITEM(res_pool.cleaning_prefix), 0, 0, 0},
278 {"usecatalog", store_yesno, ITEM(res_pool.use_catalog), 1, ITEM_DEFAULT, 1},
279 {"usevolumeonce", store_yesno, ITEM(res_pool.use_volume_once), 1, 0, 0},
280 {"purgeoldestvolume", store_yesno, ITEM(res_pool.purge_oldest_volume), 1, 0, 0},
281 {"recycleoldestvolume", store_yesno, ITEM(res_pool.recycle_oldest_volume), 1, 0, 0},
282 {"recyclecurrentvolume", store_yesno, ITEM(res_pool.recycle_current_volume), 1, 0, 0},
283 {"maximumvolumes", store_pint, ITEM(res_pool.max_volumes), 0, 0, 0},
284 {"maximumvolumejobs", store_pint, ITEM(res_pool.MaxVolJobs), 0, 0, 0},
285 {"maximumvolumefiles", store_pint, ITEM(res_pool.MaxVolFiles), 0, 0, 0},
286 {"maximumvolumebytes", store_size, ITEM(res_pool.MaxVolBytes), 0, 0, 0},
287 {"acceptanyvolume", store_yesno, ITEM(res_pool.accept_any_volume), 1, ITEM_DEFAULT, 1},
288 {"catalogfiles", store_yesno, ITEM(res_pool.catalog_files), 1, ITEM_DEFAULT, 1},
289 {"volumeretention", store_time, ITEM(res_pool.VolRetention), 0, ITEM_DEFAULT, 60*60*24*365},
290 {"volumeuseduration", store_time, ITEM(res_pool.VolUseDuration),0, 0, 0},
291 {"autoprune", store_yesno, ITEM(res_pool.AutoPrune), 1, ITEM_DEFAULT, 1},
292 {"recycle", store_yesno, ITEM(res_pool.Recycle), 1, ITEM_DEFAULT, 1},
293 {NULL, NULL, NULL, 0, 0, 0}
298 * name handler value code flags default_value
300 static RES_ITEM counter_items[] = {
301 {"name", store_name, ITEM(res_counter.hdr.name), 0, ITEM_REQUIRED, 0},
302 {"description", store_str, ITEM(res_counter.hdr.desc), 0, 0, 0},
303 {"minimum", store_int, ITEM(res_counter.MinValue), 0, ITEM_DEFAULT, 0},
304 {"maximum", store_pint, ITEM(res_counter.MaxValue), 0, ITEM_DEFAULT, INT32_MAX},
305 {"wrapcounter", store_res, ITEM(res_counter.WrapCounter), R_COUNTER, 0, 0},
306 {"catalog", store_res, ITEM(res_counter.Catalog), R_CATALOG, 0, 0},
307 {NULL, NULL, NULL, 0, 0, 0}
311 /* Message resource */
312 extern RES_ITEM msgs_items[];
315 * This is the master resource definition.
316 * It must have one item for each of the resources.
318 * NOTE!!! keep it in the same order as the R_codes
319 * or eliminate all resources[rindex].name
321 * name items rcode res_head
323 RES_TABLE resources[] = {
324 {"director", dir_items, R_DIRECTOR},
325 {"client", cli_items, R_CLIENT},
326 {"job", job_items, R_JOB},
327 {"storage", store_items, R_STORAGE},
328 {"catalog", cat_items, R_CATALOG},
329 {"schedule", sch_items, R_SCHEDULE},
330 {"fileset", fs_items, R_FILESET},
331 {"pool", pool_items, R_POOL},
332 {"messages", msgs_items, R_MSGS},
333 {"counter", counter_items, R_COUNTER},
334 {"console", con_items, R_CONSOLE},
335 {"jobdefs", job_items, R_JOBDEFS},
340 /* Keywords (RHS) permitted in Job Level records
342 * level_name level job_type
344 struct s_jl joblevels[] = {
345 {"Full", L_FULL, JT_BACKUP},
346 {"Base", L_BASE, JT_BACKUP},
347 {"Incremental", L_INCREMENTAL, JT_BACKUP},
348 {"Differential", L_DIFFERENTIAL, JT_BACKUP},
349 {"Since", L_SINCE, JT_BACKUP},
350 {"Catalog", L_VERIFY_CATALOG, JT_VERIFY},
351 {"InitCatalog", L_VERIFY_INIT, JT_VERIFY},
352 {"VolumeToCatalog", L_VERIFY_VOLUME_TO_CATALOG, JT_VERIFY},
353 {"DiskToCatalog", L_VERIFY_DISK_TO_CATALOG, JT_VERIFY},
354 {"Data", L_VERIFY_DATA, JT_VERIFY},
355 {" ", L_NONE, JT_ADMIN},
356 {" ", L_NONE, JT_RESTORE},
360 /* Keywords (RHS) permitted in Job type records
364 struct s_jt jobtypes[] = {
365 {"backup", JT_BACKUP},
367 {"verify", JT_VERIFY},
368 {"restore", JT_RESTORE},
372 #ifdef old_deprecated_code
374 /* Keywords (RHS) permitted in Backup and Verify records */
375 static struct s_kw BakVerFields[] = {
382 /* Keywords (RHS) permitted in Restore records */
383 static struct s_kw RestoreFields[] = {
386 {"jobid", 'J'}, /* JobId to restore */
387 {"where", 'W'}, /* root of restore */
388 {"replace", 'R'}, /* replacement options */
389 {"bootstrap", 'B'}, /* bootstrap file */
394 /* Options permitted in Restore replace= */
395 struct s_kw ReplaceOptions[] = {
396 {"always", REPLACE_ALWAYS},
397 {"ifnewer", REPLACE_IFNEWER},
398 {"ifolder", REPLACE_IFOLDER},
399 {"never", REPLACE_NEVER},
403 const char *level_to_str(int level)
406 static char level_no[30];
407 const char *str = level_no;
409 bsnprintf(level_no, sizeof(level_no), "%d", level); /* default if not found */
410 for (i=0; joblevels[i].level_name; i++) {
411 if (level == joblevels[i].level) {
412 str = joblevels[i].level_name;
419 /* Dump contents of resource */
420 void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
422 URES *res = (URES *)reshdr;
424 char ed1[100], ed2[100];
427 sendit(sock, "No %s resource defined\n", res_to_str(type));
430 if (type < 0) { /* no recursion */
436 sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n",
437 reshdr->name, res->res_dir.MaxConcurrentJobs,
438 edit_uint64(res->res_dir.FDConnectTimeout, ed1),
439 edit_uint64(res->res_dir.SDConnectTimeout, ed2));
440 if (res->res_dir.query_file) {
441 sendit(sock, " query_file=%s\n", res->res_dir.query_file);
443 if (res->res_dir.messages) {
444 sendit(sock, " --> ");
445 dump_resource(-R_MSGS, (RES *)res->res_dir.messages, sendit, sock);
449 sendit(sock, "Console: name=%s SSL=%d\n",
450 res->res_con.hdr.name, res->res_con.enable_ssl);
453 if (res->res_counter.WrapCounter) {
454 sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n",
455 res->res_counter.hdr.name, res->res_counter.MinValue,
456 res->res_counter.MaxValue, res->res_counter.CurrentValue,
457 res->res_counter.WrapCounter->hdr.name);
459 sendit(sock, "Counter: name=%s min=%d max=%d\n",
460 res->res_counter.hdr.name, res->res_counter.MinValue,
461 res->res_counter.MaxValue);
463 if (res->res_counter.Catalog) {
464 sendit(sock, " --> ");
465 dump_resource(-R_CATALOG, (RES *)res->res_counter.Catalog, sendit, sock);
470 sendit(sock, "Client: name=%s address=%s FDport=%d MaxJobs=%u\n",
471 res->res_client.hdr.name, res->res_client.address, res->res_client.FDport,
472 res->res_client.MaxConcurrentJobs);
473 sendit(sock, " JobRetention=%s FileRetention=%s AutoPrune=%d\n",
474 edit_utime(res->res_client.JobRetention, ed1),
475 edit_utime(res->res_client.FileRetention, ed2),
476 res->res_client.AutoPrune);
477 if (res->res_client.catalog) {
478 sendit(sock, " --> ");
479 dump_resource(-R_CATALOG, (RES *)res->res_client.catalog, sendit, sock);
483 sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n\
484 DeviceName=%s MediaType=%s\n",
485 res->res_store.hdr.name, res->res_store.address, res->res_store.SDport,
486 res->res_store.MaxConcurrentJobs,
487 res->res_store.dev_name, res->res_store.media_type);
490 sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n\
492 res->res_cat.hdr.name, NPRT(res->res_cat.db_address),
493 res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user));
497 sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n",
498 type == R_JOB ? "Job" : "JobDefs",
499 res->res_job.hdr.name, res->res_job.JobType,
500 level_to_str(res->res_job.level), res->res_job.Priority,
501 res->res_job.MaxConcurrentJobs);
502 sendit(sock, " Resched=%d Times=%d Interval=%s Spool=%d\n",
503 res->res_job.RescheduleOnError, res->res_job.RescheduleTimes,
504 edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1),
505 res->res_job.spool_data);
506 if (res->res_job.client) {
507 sendit(sock, " --> ");
508 dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock);
510 if (res->res_job.fileset) {
511 sendit(sock, " --> ");
512 dump_resource(-R_FILESET, (RES *)res->res_job.fileset, sendit, sock);
514 if (res->res_job.schedule) {
515 sendit(sock, " --> ");
516 dump_resource(-R_SCHEDULE, (RES *)res->res_job.schedule, sendit, sock);
518 if (res->res_job.RestoreWhere) {
519 sendit(sock, " --> Where=%s\n", NPRT(res->res_job.RestoreWhere));
521 if (res->res_job.RestoreBootstrap) {
522 sendit(sock, " --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap));
524 if (res->res_job.RunBeforeJob) {
525 sendit(sock, " --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob));
527 if (res->res_job.RunAfterJob) {
528 sendit(sock, " --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob));
530 if (res->res_job.RunAfterFailedJob) {
531 sendit(sock, " --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob));
533 if (res->res_job.WriteBootstrap) {
534 sendit(sock, " --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap));
536 if (res->res_job.storage) {
537 sendit(sock, " --> ");
538 dump_resource(-R_STORAGE, (RES *)res->res_job.storage, sendit, sock);
540 if (res->res_job.pool) {
541 sendit(sock, " --> ");
542 dump_resource(-R_POOL, (RES *)res->res_job.pool, sendit, sock);
544 if (res->res_job.full_pool) {
545 sendit(sock, " --> ");
546 dump_resource(-R_POOL, (RES *)res->res_job.full_pool, sendit, sock);
548 if (res->res_job.inc_pool) {
549 sendit(sock, " --> ");
550 dump_resource(-R_POOL, (RES *)res->res_job.inc_pool, sendit, sock);
552 if (res->res_job.dif_pool) {
553 sendit(sock, " --> ");
554 dump_resource(-R_POOL, (RES *)res->res_job.dif_pool, sendit, sock);
556 if (res->res_job.verify_job) {
557 sendit(sock, " --> ");
558 dump_resource(-type, (RES *)res->res_job.verify_job, sendit, sock);
561 if (res->res_job.messages) {
562 sendit(sock, " --> ");
563 dump_resource(-R_MSGS, (RES *)res->res_job.messages, sendit, sock);
569 sendit(sock, "FileSet: name=%s\n", res->res_fs.hdr.name);
570 for (i=0; i<res->res_fs.num_includes; i++) {
571 INCEXE *incexe = res->res_fs.include_items[i];
572 for (j=0; j<incexe->num_opts; j++) {
573 FOPTS *fo = incexe->opts_list[j];
574 sendit(sock, " O %s\n", fo->opts);
575 for (k=0; k<fo->regex.size(); k++) {
576 sendit(sock, " R %s\n", fo->regex.get(k));
578 for (k=0; k<fo->wild.size(); k++) {
579 sendit(sock, " W %s\n", fo->wild.get(k));
581 for (k=0; k<fo->base.size(); k++) {
582 sendit(sock, " B %s\n", fo->base.get(k));
584 sendit(sock, " N\n");
586 for (j=0; j<incexe->name_list.size(); j++) {
587 sendit(sock, " I %s\n", incexe->name_list.get(j));
589 if (incexe->name_list.size()) {
590 sendit(sock, " N\n");
594 for (i=0; i<res->res_fs.num_excludes; i++) {
595 INCEXE *incexe = res->res_fs.exclude_items[i];
596 for (j=0; j<incexe->name_list.size(); j++) {
597 sendit(sock, " E %s\n", incexe->name_list.get(j));
599 if (incexe->name_list.size()) {
600 sendit(sock, " N\n");
606 if (res->res_sch.run) {
608 RUN *run = res->res_sch.run;
609 char buf[1000], num[30];
610 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
615 sendit(sock, " --> Run Level=%s\n", level_to_str(run->level));
616 bstrncpy(buf, " hour=", sizeof(buf));
617 for (i=0; i<24; i++) {
618 if (bit_is_set(i, run->hour)) {
619 bsnprintf(num, sizeof(num), "%d ", i);
620 bstrncat(buf, num, sizeof(buf));
623 bstrncat(buf, "\n", sizeof(buf));
625 bstrncpy(buf, " mday=", sizeof(buf));
626 for (i=0; i<31; i++) {
627 if (bit_is_set(i, run->mday)) {
628 bsnprintf(num, sizeof(num), "%d ", i);
629 bstrncat(buf, num, sizeof(buf));
632 bstrncat(buf, "\n", sizeof(buf));
634 bstrncpy(buf, " month=", sizeof(buf));
635 for (i=0; i<12; i++) {
636 if (bit_is_set(i, run->month)) {
637 bsnprintf(num, sizeof(num), "%d ", i);
638 bstrncat(buf, num, sizeof(buf));
641 bstrncat(buf, "\n", sizeof(buf));
643 bstrncpy(buf, " wday=", sizeof(buf));
644 for (i=0; i<7; i++) {
645 if (bit_is_set(i, run->wday)) {
646 bsnprintf(num, sizeof(num), "%d ", i);
647 bstrncat(buf, num, sizeof(buf));
650 bstrncat(buf, "\n", sizeof(buf));
652 bstrncpy(buf, " wom=", sizeof(buf));
653 for (i=0; i<5; i++) {
654 if (bit_is_set(i, run->wom)) {
655 bsnprintf(num, sizeof(num), "%d ", i);
656 bstrncat(buf, num, sizeof(buf));
659 bstrncat(buf, "\n", sizeof(buf));
661 bstrncpy(buf, " woy=", sizeof(buf));
662 for (i=0; i<54; i++) {
663 if (bit_is_set(i, run->woy)) {
664 bsnprintf(num, sizeof(num), "%d ", i);
665 bstrncat(buf, num, sizeof(buf));
668 bstrncat(buf, "\n", sizeof(buf));
670 sendit(sock, " mins=%d\n", run->minute);
672 sendit(sock, " --> ");
673 dump_resource(-R_POOL, (RES *)run->pool, sendit, sock);
676 sendit(sock, " --> ");
677 dump_resource(-R_STORAGE, (RES *)run->storage, sendit, sock);
680 sendit(sock, " --> ");
681 dump_resource(-R_MSGS, (RES *)run->msgs, sendit, sock);
683 /* If another Run record is chained in, go print it */
689 sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
693 sendit(sock, "Pool: name=%s PoolType=%s\n", res->res_pool.hdr.name,
694 res->res_pool.pool_type);
695 sendit(sock, " use_cat=%d use_once=%d acpt_any=%d cat_files=%d\n",
696 res->res_pool.use_catalog, res->res_pool.use_volume_once,
697 res->res_pool.accept_any_volume, res->res_pool.catalog_files);
698 sendit(sock, " max_vols=%d auto_prune=%d VolRetention=%s\n",
699 res->res_pool.max_volumes, res->res_pool.AutoPrune,
700 edit_utime(res->res_pool.VolRetention, ed1));
701 sendit(sock, " VolUse=%s recycle=%d LabelFormat=%s\n",
702 edit_utime(res->res_pool.VolUseDuration, ed1),
703 res->res_pool.Recycle,
704 NPRT(res->res_pool.label_format));
705 sendit(sock, " CleaningPrefix=%s\n",
706 NPRT(res->res_pool.cleaning_prefix));
707 sendit(sock, " recyleOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n",
708 res->res_pool.purge_oldest_volume,
709 res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles);
712 sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
713 if (res->res_msgs.mail_cmd)
714 sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd);
715 if (res->res_msgs.operator_cmd)
716 sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd);
719 sendit(sock, "Unknown resource type %d in dump_resource.\n", type);
722 if (recurse && res->res_dir.hdr.next) {
723 dump_resource(type, res->res_dir.hdr.next, sendit, sock);
728 * Free all the members of an INCEXE structure
730 static void free_incexe(INCEXE *incexe)
732 incexe->name_list.destroy();
733 for (int i=0; i<incexe->num_opts; i++) {
734 FOPTS *fopt = incexe->opts_list[i];
735 fopt->regex.destroy();
736 fopt->wild.destroy();
737 fopt->base.destroy();
740 if (incexe->opts_list) {
741 free(incexe->opts_list);
747 * Free memory of resource -- called when daemon terminates.
748 * NB, we don't need to worry about freeing any references
749 * to other resources as they will be freed when that
750 * resource chain is traversed. Mainly we worry about freeing
751 * allocated strings (names).
753 void free_resource(RES *sres, int type)
756 RES *nres; /* next resource if linked */
757 URES *res = (URES *)sres;
762 /* common stuff -- free the resource name and description */
763 nres = (RES *)res->res_dir.hdr.next;
764 if (res->res_dir.hdr.name) {
765 free(res->res_dir.hdr.name);
767 if (res->res_dir.hdr.desc) {
768 free(res->res_dir.hdr.desc);
773 if (res->res_dir.working_directory) {
774 free(res->res_dir.working_directory);
776 if (res->res_dir.pid_directory) {
777 free(res->res_dir.pid_directory);
779 if (res->res_dir.subsys_directory) {
780 free(res->res_dir.subsys_directory);
782 if (res->res_dir.password) {
783 free(res->res_dir.password);
785 if (res->res_dir.query_file) {
786 free(res->res_dir.query_file);
788 if (res->res_dir.DIRaddrs) {
789 free_addresses(res->res_dir.DIRaddrs);
795 if (res->res_con.password) {
796 free(res->res_con.password);
798 for (int i=0; i<Num_ACL; i++) {
799 if (res->res_con.ACL_lists[i]) {
800 delete res->res_con.ACL_lists[i];
801 res->res_con.ACL_lists[i] = NULL;
806 if (res->res_client.address) {
807 free(res->res_client.address);
809 if (res->res_client.password) {
810 free(res->res_client.password);
814 if (res->res_store.address) {
815 free(res->res_store.address);
817 if (res->res_store.password) {
818 free(res->res_store.password);
820 if (res->res_store.media_type) {
821 free(res->res_store.media_type);
823 if (res->res_store.dev_name) {
824 free(res->res_store.dev_name);
828 if (res->res_cat.db_address) {
829 free(res->res_cat.db_address);
831 if (res->res_cat.db_socket) {
832 free(res->res_cat.db_socket);
834 if (res->res_cat.db_user) {
835 free(res->res_cat.db_user);
837 if (res->res_cat.db_name) {
838 free(res->res_cat.db_name);
840 if (res->res_cat.db_password) {
841 free(res->res_cat.db_password);
845 if ((num=res->res_fs.num_includes)) {
847 free_incexe(res->res_fs.include_items[num]);
849 free(res->res_fs.include_items);
851 res->res_fs.num_includes = 0;
852 if ((num=res->res_fs.num_excludes)) {
854 free_incexe(res->res_fs.exclude_items[num]);
856 free(res->res_fs.exclude_items);
858 res->res_fs.num_excludes = 0;
861 if (res->res_pool.pool_type) {
862 free(res->res_pool.pool_type);
864 if (res->res_pool.label_format) {
865 free(res->res_pool.label_format);
867 if (res->res_pool.cleaning_prefix) {
868 free(res->res_pool.cleaning_prefix);
872 if (res->res_sch.run) {
874 nrun = res->res_sch.run;
884 if (res->res_job.RestoreWhere) {
885 free(res->res_job.RestoreWhere);
887 if (res->res_job.RestoreBootstrap) {
888 free(res->res_job.RestoreBootstrap);
890 if (res->res_job.WriteBootstrap) {
891 free(res->res_job.WriteBootstrap);
893 if (res->res_job.RunBeforeJob) {
894 free(res->res_job.RunBeforeJob);
896 if (res->res_job.RunAfterJob) {
897 free(res->res_job.RunAfterJob);
899 if (res->res_job.RunAfterFailedJob) {
900 free(res->res_job.RunAfterFailedJob);
902 if (res->res_job.ClientRunBeforeJob) {
903 free(res->res_job.ClientRunBeforeJob);
905 if (res->res_job.ClientRunAfterJob) {
906 free(res->res_job.ClientRunAfterJob);
910 if (res->res_msgs.mail_cmd) {
911 free(res->res_msgs.mail_cmd);
913 if (res->res_msgs.operator_cmd) {
914 free(res->res_msgs.operator_cmd);
916 free_msgs_res((MSGS *)res); /* free message resource */
920 printf("Unknown resource type %d in free_resource.\n", type);
922 /* Common stuff again -- free the resource, recurse to next one */
927 free_resource(nres, type);
932 * Save the new resource by chaining it into the head list for
933 * the resource. If this is pass 2, we update any resource
934 * pointers because they may not have been defined until
937 void save_resource(int type, RES_ITEM *items, int pass)
940 int rindex = type - r_first;
944 /* Check Job requirements after applying JobDefs */
945 if (type != R_JOB && type != R_JOBDEFS) {
947 * Ensure that all required items are present
949 for (i=0; items[i].name; i++) {
950 if (items[i].flags & ITEM_REQUIRED) {
951 if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
952 Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n",
953 items[i].name, resources[rindex]);
956 /* If this triggers, take a look at lib/parse_conf.h */
957 if (i >= MAX_RES_ITEMS) {
958 Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]);
964 * During pass 2 in each "store" routine, we looked up pointers
965 * to all the resources referrenced in the current resource, now we
966 * must copy their addresses from the static record to the allocated
971 /* Resources not containing a resource */
980 /* Resources containing another resource */
982 if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) {
983 Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name);
985 res->res_dir.messages = res_all.res_dir.messages;
989 if ((res = (URES *)GetResWithName(type, res_all.res_dir.hdr.name)) == NULL) {
990 Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n",
991 res_all.res_dir.hdr.name);
993 res->res_job.messages = res_all.res_job.messages;
994 res->res_job.schedule = res_all.res_job.schedule;
995 res->res_job.client = res_all.res_job.client;
996 res->res_job.fileset = res_all.res_job.fileset;
997 res->res_job.storage = res_all.res_job.storage;
998 res->res_job.pool = res_all.res_job.pool;
999 res->res_job.full_pool = res_all.res_job.full_pool;
1000 res->res_job.inc_pool = res_all.res_job.inc_pool;
1001 res->res_job.dif_pool = res_all.res_job.dif_pool;
1002 res->res_job.verify_job = res_all.res_job.verify_job;
1003 res->res_job.jobdefs = res_all.res_job.jobdefs;
1006 if ((res = (URES *)GetResWithName(R_COUNTER, res_all.res_counter.hdr.name)) == NULL) {
1007 Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name);
1009 res->res_counter.Catalog = res_all.res_counter.Catalog;
1010 res->res_counter.WrapCounter = res_all.res_counter.WrapCounter;
1014 if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_client.hdr.name)) == NULL) {
1015 Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name);
1017 res->res_client.catalog = res_all.res_client.catalog;
1021 * Schedule is a bit different in that it contains a RUN record
1022 * chain which isn't a "named" resource. This chain was linked
1023 * in by run_conf.c during pass 2, so here we jam the pointer
1024 * into the Schedule resource.
1026 if ((res = (URES *)GetResWithName(R_SCHEDULE, res_all.res_client.hdr.name)) == NULL) {
1027 Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name);
1029 res->res_sch.run = res_all.res_sch.run;
1032 Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type);
1036 /* Note, the resource name was already saved during pass 1,
1037 * so here, we can just release it.
1039 if (res_all.res_dir.hdr.name) {
1040 free(res_all.res_dir.hdr.name);
1041 res_all.res_dir.hdr.name = NULL;
1043 if (res_all.res_dir.hdr.desc) {
1044 free(res_all.res_dir.hdr.desc);
1045 res_all.res_dir.hdr.desc = NULL;
1051 * The following code is only executed during pass 1
1055 size = sizeof(DIRRES);
1058 size = sizeof(CONRES);
1061 size =sizeof(CLIENT);
1064 size = sizeof(STORE);
1074 size = sizeof(FILESET);
1077 size = sizeof(SCHED);
1080 size = sizeof(POOL);
1083 size = sizeof(MSGS);
1086 size = sizeof(COUNTER);
1089 printf("Unknown resource type %d in save_resrouce.\n", type);
1096 res = (URES *)malloc(size);
1097 memcpy(res, &res_all, size);
1098 if (!res_head[rindex]) {
1099 res_head[rindex] = (RES *)res; /* store first entry */
1100 Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
1101 res->res_dir.hdr.name, rindex);
1104 /* Add new res to end of chain */
1105 for (next=res_head[rindex]; next->next; next=next->next) {
1106 if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
1107 Emsg2(M_ERROR_TERM, 0,
1108 _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
1109 resources[rindex].name, res->res_dir.hdr.name);
1112 next->next = (RES *)res;
1113 Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
1114 res->res_dir.hdr.name, rindex, pass);
1120 * Store JobType (backup, verify, restore)
1123 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass)
1127 token = lex_get_token(lc, T_NAME);
1128 /* Store the type both pass 1 and pass 2 */
1129 for (i=0; jobtypes[i].type_name; i++) {
1130 if (strcasecmp(lc->str, jobtypes[i].type_name) == 0) {
1131 *(int *)(item->value) = jobtypes[i].job_type;
1137 scan_err1(lc, "Expected a Job Type keyword, got: %s", lc->str);
1140 set_bit(index, res_all.hdr.item_present);
1144 * Store Job Level (Full, Incremental, ...)
1147 void store_level(LEX *lc, RES_ITEM *item, int index, int pass)
1151 token = lex_get_token(lc, T_NAME);
1152 /* Store the level pass 2 so that type is defined */
1153 for (i=0; joblevels[i].level_name; i++) {
1154 if (strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1155 *(int *)(item->value) = joblevels[i].level;
1161 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1164 set_bit(index, res_all.hdr.item_present);
1167 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass)
1170 token = lex_get_token(lc, T_NAME);
1171 /* Scan Replacement options */
1172 for (i=0; ReplaceOptions[i].name; i++) {
1173 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1174 *(int *)(item->value) = ReplaceOptions[i].token;
1180 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1183 set_bit(index, res_all.hdr.item_present);
1187 * Store ACL (access control list)
1190 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass)
1195 token = lex_get_token(lc, T_NAME);
1197 if (((alist **)item->value)[item->code] == NULL) {
1198 ((alist **)item->value)[item->code] = new alist(10, owned_by_alist);
1199 // Dmsg1(900, "Defined new ACL alist at %d\n", item->code);
1201 ((alist **)item->value)[item->code]->append(bstrdup(lc->str));
1202 // Dmsg2(900, "Appended to %d %s\n", item->code, lc->str);
1204 token = lex_get_token(lc, T_ALL);
1205 if (token == T_COMMA) {
1206 continue; /* get another ACL */
1210 set_bit(index, res_all.hdr.item_present);
1214 #ifdef old_deprecated_code
1216 * Store backup/verify info for Job record
1218 * Note, this code is used for both BACKUP and VERIFY jobs
1220 * Backup = Client=<client-name> FileSet=<FileSet-name> Level=<level>
1222 static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass)
1226 int options = lc->options;
1228 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1231 ((JOB *)(item->value))->JobType = item->code;
1232 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1235 Dmsg1(900, "store_backup got token=%s\n", lex_tok_to_str(token));
1237 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1238 scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str);
1240 Dmsg1(900, "Got keyword: %s\n", lc->str);
1241 for (i=0; BakVerFields[i].name; i++) {
1242 if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
1244 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1245 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1247 token = lex_get_token(lc, T_NAME);
1248 Dmsg1(900, "Got value: %s\n", lc->str);
1249 switch (BakVerFields[i].token) {
1251 /* Find Client Resource */
1253 res = GetResWithName(R_CLIENT, lc->str);
1255 scan_err1(lc, "Could not find specified Client Resource: %s",
1258 res_all.res_job.client = (CLIENT *)res;
1262 /* Find FileSet Resource */
1264 res = GetResWithName(R_FILESET, lc->str);
1266 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1269 res_all.res_job.fileset = (FILESET *)res;
1274 for (i=0; joblevels[i].level_name; i++) {
1275 if (joblevels[i].job_type == item->code &&
1276 strcasecmp(lc->str, joblevels[i].level_name) == 0) {
1277 ((JOB *)(item->value))->level = joblevels[i].level;
1283 scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
1288 } /* end if strcmp() */
1291 scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str);
1294 lc->options = options; /* reset original options */
1295 set_bit(index, res_all.hdr.item_present);
1299 * Store restore info for Job record
1301 * Restore = JobId=<job-id> Where=<root-directory> Replace=<options> Bootstrap=<file>
1304 static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
1308 int options = lc->options;
1310 lc->options |= LOPT_NO_IDENT; /* make spaces significant */
1312 Dmsg0(900, "Enter store_restore()\n");
1314 ((JOB *)(item->value))->JobType = item->code;
1315 while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
1318 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1319 scan_err1(lc, "expected a name, got: %s", lc->str);
1321 for (i=0; RestoreFields[i].name; i++) {
1322 Dmsg1(900, "Restore kw=%s\n", lc->str);
1323 if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
1325 if (lex_get_token(lc, T_ALL) != T_EQUALS) {
1326 scan_err1(lc, "Expected an equals, got: %s", lc->str);
1328 token = lex_get_token(lc, T_ALL);
1329 Dmsg1(900, "Restore value=%s\n", lc->str);
1330 switch (RestoreFields[i].token) {
1333 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1334 scan_err1(lc, "Expected a Restore bootstrap file, got: %s", lc->str);
1337 res_all.res_job.RestoreBootstrap = bstrdup(lc->str);
1341 /* Find Client Resource */
1343 res = GetResWithName(R_CLIENT, lc->str);
1345 scan_err1(lc, "Could not find specified Client Resource: %s",
1348 res_all.res_job.client = (CLIENT *)res;
1352 /* Find FileSet Resource */
1354 res = GetResWithName(R_FILESET, lc->str);
1356 scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
1359 res_all.res_job.fileset = (FILESET *)res;
1364 if (token != T_NUMBER) {
1365 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1368 res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
1369 Dmsg1(900, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
1371 scan_err1(lc, "expected an integer number, got: %s", lc->str);
1376 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1377 scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str);
1380 res_all.res_job.RestoreWhere = bstrdup(lc->str);
1384 /* Replacement options */
1385 if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
1386 scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
1388 /* Fix to scan Replacement options */
1389 for (i=0; ReplaceOptions[i].name; i++) {
1390 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
1391 ((JOB *)(item->value))->replace = ReplaceOptions[i].token;
1397 scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
1402 } /* end if strcmp() */
1405 scan_err1(lc, "%s not a valid Restore keyword", lc->str);
1408 lc->options = options; /* reset original options */
1409 set_bit(index, res_all.hdr.item_present);