X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fdird%2Frun_conf.c;h=23b8732ceca49d2c3a56f566cc445ff5a93d548f;hb=c5f4a68937116a768e6d85bc576a5fd41a56e93a;hp=b92ee123e74d384bcc9b232af57a6d743d27cc90;hpb=fbe26e3316ee5253da5bd448aa516374044ccf47;p=bacula%2Fbacula diff --git a/bacula/src/dird/run_conf.c b/bacula/src/dird/run_conf.c index b92ee123e7..23b8732cec 100644 --- a/bacula/src/dird/run_conf.c +++ b/bacula/src/dird/run_conf.c @@ -1,26 +1,26 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 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 plus additions - that are listed in the file LICENSE. + modify it under the terms of version three of the GNU Affero 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 + You should have received a copy of the GNU Affero 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. + Bacula® is a registered trademark of Kern Sibbald. The licensor of Bacula is the Free Software Foundation Europe (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. @@ -186,7 +186,6 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) int token, state, state2 = 0, code = 0, code2 = 0; int options = lc->options; RUN **run = (RUN **)(item->value); - RUN *trun; char *p; RES *res; @@ -339,6 +338,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) for ( ; token != T_EOL; (token = lex_get_token(lc, T_ALL))) { int len; bool pm = false; + bool am = false; switch (token) { case T_NUMBER: state = s_mday; @@ -434,6 +434,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")); @@ -441,20 +442,19 @@ 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 = false; - } else if (p[len-2] == 'p') { - pm = true; - } else { - scan_err0(lc, _("Bad time specification.")); - /* NOT REACHED */ - } - } else { - pm = false; + 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 @@ -467,13 +467,14 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) code += 12; } /* am */ - } else if (code == 12) { + } 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; @@ -621,16 +622,24 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) } /* Allocate run record, copy new stuff into it, - * and link it into the list of run records + * and append it to the list of run records * in the schedule resource. */ if (pass == 2) { - trun = (RUN *)malloc(sizeof(RUN)); - memcpy(trun, &lrun, sizeof(RUN)); - if (*run) { - trun->next = *run; + RUN *tail; + + /* Create new run record */ + RUN *nrun = (RUN *)malloc(sizeof(RUN)); + memcpy(nrun, &lrun, sizeof(RUN)); + nrun ->next = NULL; + + if (!*run) { /* if empty list */ + *run = nrun; /* add new record */ + } else { + for (tail = *run; tail->next; tail=tail->next) + { } + tail->next = nrun; } - *run = trun; } lc->options = options; /* restore scanner options */