X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fdird%2Frun_conf.c;h=e7c2ad6c208f2114f3581f3c0da29f21c65fbaba;hb=c205f98aff775e96e18dc0af2f194e76f2ddaaa9;hp=162b4945e5825f6428fab63eab1b75746cdfaa63;hpb=85cda6b48d03d59d66c0612d4f8b49868d713834;p=bacula%2Fbacula diff --git a/bacula/src/dird/run_conf.c b/bacula/src/dird/run_conf.c index 162b4945e5..e7c2ad6c20 100644 --- a/bacula/src/dird/run_conf.c +++ b/bacula/src/dird/run_conf.c @@ -1,3 +1,30 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ /* * * Configuration parser for Director Run Configuration @@ -7,25 +34,17 @@ * * Version $Id$ */ -/* - Copyright (C) 2000-2005 Kern Sibbald - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as amended with additional clauses defined in the - file LICENSE in the main source directory. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - the file LICENSE for additional details. - - */ #include "bacula.h" #include "dird.h" +#if defined(_MSC_VER) +extern "C" { // work around visual compiler mangling variables + extern URES res_all; +} +#else extern URES res_all; +#endif extern struct s_jl joblevels[]; /* Forward referenced subroutines */ @@ -47,7 +66,7 @@ enum e_state { }; struct s_keyw { - const char *name; /* keyword */ + const char *name; /* keyword */ enum e_state state; /* parser state */ int code; /* state value */ }; @@ -191,10 +210,10 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) switch (RunFields[i].token) { case 's': /* Data spooling */ token = lex_get_token(lc, T_NAME); - if (strcasecmp(lc->str, "yes") == 0) { + if (strcasecmp(lc->str, "yes") == 0 || strcasecmp(lc->str, "true") == 0) { lrun.spool_data = true; lrun.spool_data_set = true; - } else if (strcasecmp(lc->str, "no") == 0) { + } else if (strcasecmp(lc->str, "no") == 0 || strcasecmp(lc->str, "false") == 0) { lrun.spool_data = false; lrun.spool_data_set = true; } else { @@ -203,10 +222,10 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) break; case 'W': /* Write part after job */ token = lex_get_token(lc, T_NAME); - if (strcasecmp(lc->str, "yes") == 0) { + if (strcasecmp(lc->str, "yes") == 0 || strcasecmp(lc->str, "true") == 0) { lrun.write_part_after_job = true; lrun.write_part_after_job_set = true; - } else if (strcasecmp(lc->str, "no") == 0) { + } else if (strcasecmp(lc->str, "no") == 0 || strcasecmp(lc->str, "false") == 0) { lrun.write_part_after_job = false; lrun.write_part_after_job_set = true; } else { @@ -257,7 +276,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) lrun.inc_pool = (POOL *)res; break; case 'd': - lrun.dif_pool = (POOL *)res; + lrun.diff_pool = (POOL *)res; break; } } @@ -318,7 +337,9 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) set_defaults(); for ( ; token != T_EOL; (token = lex_get_token(lc, T_ALL))) { - int len, pm = 0; + int len; + bool pm = false; + bool am = false; switch (token) { case T_NUMBER: state = s_mday; @@ -342,6 +363,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) code = atoi(lc->str+1); if (code < 0 || code > 53) { scan_err0(lc, _("Week number out of range (0-53)")); + /* NOT REACHED */ } state = s_woy; /* week of year */ break; @@ -413,6 +435,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) if (!have_hour) { clear_bits(0, 23, lrun.hour); } +// Dmsg1(000, "s_time=%s\n", lc->str); p = strchr(lc->str, ':'); if (!p) { scan_err0(lc, _("Time logic error.\n")); @@ -420,32 +443,39 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) } *p++ = 0; /* separate two halves */ code = atoi(lc->str); /* pick up hour */ + code2 = atoi(p); /* pick up minutes */ len = strlen(p); - if (len > 2 && p[len-1] == 'm') { - if (p[len-2] == 'a') { - pm = 0; - } else if (p[len-2] == 'p') { - pm = 1; - } else { - scan_err0(lc, _("Bad time specification.")); - /* NOT REACHED */ - } - } else { - pm = 0; + if (len >= 2) { + p += 2; } - code2 = atoi(p); /* pick up minutes */ + if (strcasecmp(p, "pm") == 0) { + pm = true; + } else if (strcasecmp(p, "am") == 0) { + am = true; + } else if (len != 2) { + scan_err0(lc, _("Bad time specification.")); + /* NOT REACHED */ + } + /* + * Note, according to NIST, 12am and 12pm are ambiguous and + * can be defined to anything. However, 12:01am is the same + * as 00:01 and 12:01pm is the same as 12:01, so we define + * 12am as 00:00 and 12pm as 12:00. + */ if (pm) { /* Convert to 24 hour time */ - if (code == 12) { - code -= 12; - } else { + if (code != 12) { code += 12; } + /* am */ + } else if (am && code == 12) { + code -= 12; } if (code < 0 || code > 23 || code2 < 0 || code2 > 59) { scan_err0(lc, _("Bad time specification.")); /* NOT REACHED */ } +// Dmsg2(000, "hour=%d min=%d\n", code, code2); set_bit(code, lrun.hour); lrun.minute = code2; have_hour = true;