]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/parse_conf.c
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / lib / parse_conf.c
index a021e1905ea5c79865e36bdab13567f1a669c838..2c3ac1b43e3c0941b811c02427d695f284453cef 100755 (executable)
@@ -166,9 +166,10 @@ void init_resource(int type, struct res_items *items)
            *(int *)(items[i].value) = items[i].default_value;
         } else if (items[i].handler == store_int64) {
            *(int64_t *)(items[i].value) = items[i].default_value;
-        } else if (items[i].handler == store_size ||
-                   items[i].handler == store_time) {
-           *(uint64_t *)(items[i].value) = items[i].default_value;
+        } else if (items[i].handler == store_size) {
+           *(uint64_t *)(items[i].value) = (uint64_t)items[i].default_value;
+        } else if (items[i].handler == store_time) {
+           *(utime_t *)(items[i].value) = (utime_t)items[i].default_value;
         }
       }
       /* If this triggers, take a look at lib/parse_conf.h */
@@ -283,7 +284,7 @@ static void scan_types(LEX *lc, MSGS *msg, int dest_code, char *where, char *cmd
         str = &lc->str[0];
       }
       for (i=0; msg_types[i].name; i++) {
-        if (strcmp(str, msg_types[i].name) == 0) {
+        if (strcasecmp(str, msg_types[i].name) == 0) {
            msg_type = msg_types[i].token;
            found = TRUE;
            break;
@@ -367,7 +368,7 @@ void store_dir(LEX *lc, struct res_items *item, int index, int pass)
    lex_get_token(lc, T_STRING);
    if (pass == 1) {
       if (lc->str[0] != '|') {
-        do_shell_expansion(lc->str);
+        do_shell_expansion(lc->str, sizeof(lc->str));
       }
       *(item->value) = bstrdup(lc->str);
    }
@@ -455,7 +456,6 @@ void store_int64(LEX *lc, struct res_items *item, int index, int pass)
 void store_size(LEX *lc, struct res_items *item, int index, int pass)
 {
    int token;
-   double dvalue;
    uint64_t uvalue;
 
    Dmsg0(400, "Enter store_size\n");
@@ -463,13 +463,6 @@ void store_size(LEX *lc, struct res_items *item, int index, int pass)
    errno = 0;
    switch (token) {
    case T_NUMBER:
-      Dmsg2(400, "size num=:%s: %f\n", lc->str, strtod(lc->str, NULL)); 
-      dvalue = strtod(lc->str, NULL);
-      if (errno != 0 || token < 0) {
-         scan_err1(lc, "expected a size number, got: %s", lc->str);
-      }
-      *(uint64_t *)(item->value) = (uint64_t)dvalue;
-      break;
    case T_IDENTIFIER:
    case T_UNQUOTED_STRING:
       if (!size_to_uint64(lc->str, lc->str_len, &uvalue)) {
@@ -491,23 +484,27 @@ void store_size(LEX *lc, struct res_items *item, int index, int pass)
 void store_time(LEX *lc, struct res_items *item, int index, int pass)
 {
    int token; 
-   double value;
    utime_t utime;
+   char period[500];
 
    token = lex_get_token(lc, T_ALL);
    errno = 0;
    switch (token) {
    case T_NUMBER:
-      value = strtod(lc->str, NULL);
-      if (errno != 0 || value < 0) {
-         scan_err1(lc, "expected a time period, got: %s", lc->str);
-      }
-      *(utime_t *)(item->value) = (utime_t)value;
-      break;
    case T_IDENTIFIER:
    case T_UNQUOTED_STRING:
-      if (!duration_to_utime(lc->str, &utime)) {
-         scan_err1(lc, "expected a time period, got: %s", lc->str);
+      bstrncpy(period, lc->str, sizeof(period));
+      if (lc->ch == ' ') {
+        token = lex_get_token(lc, T_ALL);
+        switch (token) {
+        case T_IDENTIFIER:
+        case T_UNQUOTED_STRING:
+           bstrncat(period, lc->str, sizeof(period));
+           break;
+        }
+      }
+      if (!duration_to_utime(period, &utime)) {
+         scan_err1(lc, "expected a time period, got: %s", period);
       }
       *(utime_t *)(item->value) = utime;
       break;
@@ -515,7 +512,9 @@ void store_time(LEX *lc, struct res_items *item, int index, int pass)
       scan_err1(lc, "expected a time period, got: %s", lc->str);
       break;
    }
-   scan_to_eol(lc);
+   if (token != T_EOL) {
+      scan_to_eol(lc);
+   }
    set_bit(index, res_all.hdr.item_present);
 }
 
@@ -679,7 +678,8 @@ parse_config(char *cf)
                     if (i >= 0) {
                         Dmsg2(150, "level=%d id=%s\n", level, lc->str);
                         Dmsg1(150, "Keyword = %s\n", lc->str);
-                        scan_err1(lc, "Keyword %s not permitted in this resource", lc->str);
+                        scan_err1(lc, "Keyword \"%s\" not permitted in this resource.\n"
+                           "Perhaps you left the trailing brace off of the previous resource.", lc->str);
                        /* NOT REACHED */
                     }
                     break;
@@ -705,6 +705,9 @@ parse_config(char *cf)
               /* NOT REACHED */
         }
       }
+      if (state != p_none) {
+         scan_err0(lc, "End of conf file reached with unclosed resource.");
+      }
       if (debug_level > 50 && pass == 2) {
         int i;
         for (i=r_first; i<=r_last; i++) {