]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/run_conf.c
Ensure that StorageId is updated after write
[bacula/bacula] / bacula / src / dird / run_conf.c
index 5fe71ab044d6c31b6781e5f82e5092a16751ea1a..8aad42da37a5fd6043cbe9e7af69764689eaba45 100644 (file)
@@ -1,26 +1,26 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2012 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.
@@ -32,7 +32,6 @@
  *
  *     Kern Sibbald, May MM
  *
- *     Version $Id$
  */
 
 #include "bacula.h"
@@ -163,6 +162,8 @@ static struct s_kw RunFields[] = {
    {"priority",          'p'},
    {"spooldata",         's'},
    {"writepartafterjob", 'W'},
+   {"maxrunschedtime",   'm'},
+   {"accurate",          'a'},
    {NULL,                 0}
 };
 
@@ -183,10 +184,10 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int i, j;
    bool found;
+   utime_t utime;
    int token, state, state2 = 0, code = 0, code2 = 0;
    int options = lc->options;
    RUN **run = (RUN **)(item->value);
-   RUN *trun;
    char *p;
    RES *res;
 
@@ -200,7 +201,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
    for (found=true; found; ) {
       found = false;
       token = lex_get_token(lc, T_NAME);
-      for (i=0; RunFields[i].name; i++) {
+      for (i=0; !found && RunFields[i].name; i++) {
          if (strcasecmp(lc->str, RunFields[i].name) == 0) {
             found = true;
             if (lex_get_token(lc, T_ALL) != T_EQUALS) {
@@ -305,6 +306,27 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
                   lrun.msgs = (MSGS *)res;
                }
                break;
+            case 'm':           /* max run sched time */
+               token = lex_get_token(lc, T_QUOTED_STRING); 
+               if (!duration_to_utime(lc->str, &utime)) {
+                  scan_err1(lc, _("expected a time period, got: %s"), lc->str);
+                  return;
+               }
+               lrun.MaxRunSchedTime = utime;
+               lrun.MaxRunSchedTime_set = true;
+               break;
+            case 'a':           /* accurate */
+               token = lex_get_token(lc, T_NAME);
+               if (strcasecmp(lc->str, "yes") == 0 || strcasecmp(lc->str, "true") == 0) {
+                  lrun.accurate = true;
+                  lrun.accurate_set = true;
+               } else if (strcasecmp(lc->str, "no") == 0 || strcasecmp(lc->str, "false") == 0) {
+                  lrun.accurate = false;
+                  lrun.accurate_set = true;
+               } else {
+                  scan_err1(lc, _("Expect a YES or NO, got: %s"), lc->str);
+               }
+               break;
             default:
                scan_err1(lc, _("Expected a keyword name, got: %s"), lc->str);
                /* NOT REACHED */
@@ -623,16 +645,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 */