]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/parse_conf.c
When invoking the mysql script, pass in $*
[bacula/bacula] / bacula / src / lib / parse_conf.c
index f6387640785670eb0ab8b1c1319e46d208e01d8f..87f0ceb21f3800bfd4b13db9d460f8dc63e2f863 100755 (executable)
@@ -191,69 +191,69 @@ void store_msgs(LEX *lc, struct res_items *item, int index, int pass)
    Dmsg2(200, "store_msgs pass=%d code=%d\n", pass, item->code);
    if (pass == 1) {
       switch (item->code) {
-        case MD_STDOUT:
-        case MD_STDERR:
-        case MD_SYSLOG:              /* syslog */
-        case MD_CONSOLE:
-           scan_types(lc, (MSGS *)(item->value), item->code, NULL, NULL);
-           break;
-        case MD_OPERATOR:            /* send to operator */
-        case MD_DIRECTOR:            /* send to Director */
-        case MD_MAIL:                /* mail */
-        case MD_MAIL_ON_ERROR:       /* mail if Job errors */
-           if (item->code == MD_OPERATOR) {
-              cmd = res_all.res_msgs.operator_cmd;
-           } else {
-              cmd = res_all.res_msgs.mail_cmd;
-           }
-           dest = get_pool_memory(PM_MESSAGE);
-           dest[0] = 0;
-           dest_len = 0;
-           /* Pick up comma separated list of destinations */
-           for ( ;; ) {
-              token = lex_get_token(lc, T_NAME);   /* scan destination */
-              dest = check_pool_memory_size(dest, dest_len + lc->str_len + 2);
-              if (dest[0] != 0) {
-                  strcat(dest, " ");  /* separate multiple destinations with space */
-                 dest_len++;
-              }
-              strcat(dest, lc->str);
-              dest_len += lc->str_len;
-               Dmsg2(100, "store_msgs newdest=%s: dest=%s:\n", lc->str, NPRT(dest));
-              token = lex_get_token(lc, T_ALL);
-              if (token == T_COMMA) { 
-                 continue;           /* get another destination */
-              }
-              if (token != T_EQUALS) {
-                  scan_err1(lc, "expected an =, got: %s", lc->str); 
-              }
-              break;
-           }
-            Dmsg1(200, "mail_cmd=%s\n", NPRT(cmd));
-           scan_types(lc, (MSGS *)(item->value), item->code, dest, cmd);
-           free_pool_memory(dest);
-            Dmsg0(200, "done with dest codes\n");
-           break;
-        case MD_FILE:                /* file */
-        case MD_APPEND:              /* append */
-           dest = get_pool_memory(PM_MESSAGE);
-           /* Pick up a single destination */
+      case MD_STDOUT:
+      case MD_STDERR:
+      case MD_SYSLOG:             /* syslog */
+      case MD_CONSOLE:
+        scan_types(lc, (MSGS *)(item->value), item->code, NULL, NULL);
+        break;
+      case MD_OPERATOR:           /* send to operator */
+      case MD_DIRECTOR:           /* send to Director */
+      case MD_MAIL:               /* mail */
+      case MD_MAIL_ON_ERROR:      /* mail if Job errors */
+        if (item->code == MD_OPERATOR) {
+           cmd = res_all.res_msgs.operator_cmd;
+        } else {
+           cmd = res_all.res_msgs.mail_cmd;
+        }
+        dest = get_pool_memory(PM_MESSAGE);
+        dest[0] = 0;
+        dest_len = 0;
+        /* Pick up comma separated list of destinations */
+        for ( ;; ) {
            token = lex_get_token(lc, T_NAME);   /* scan destination */
-           pm_strcpy(&dest, lc->str);
-           dest_len = lc->str_len;
+           dest = check_pool_memory_size(dest, dest_len + lc->str_len + 2);
+           if (dest[0] != 0) {
+               strcat(dest, " ");  /* separate multiple destinations with space */
+              dest_len++;
+           }
+           strcat(dest, lc->str);
+           dest_len += lc->str_len;
+            Dmsg2(100, "store_msgs newdest=%s: dest=%s:\n", lc->str, NPRT(dest));
            token = lex_get_token(lc, T_ALL);
-            Dmsg1(200, "store_msgs dest=%s:\n", NPRT(dest));
+           if (token == T_COMMA) { 
+              continue;           /* get another destination */
+           }
            if (token != T_EQUALS) {
                scan_err1(lc, "expected an =, got: %s", lc->str); 
            }
-           scan_types(lc, (MSGS *)(item->value), item->code, dest, NULL);
-           free_pool_memory(dest);
-            Dmsg0(200, "done with dest codes\n");
            break;
+        }
+         Dmsg1(200, "mail_cmd=%s\n", NPRT(cmd));
+        scan_types(lc, (MSGS *)(item->value), item->code, dest, cmd);
+        free_pool_memory(dest);
+         Dmsg0(200, "done with dest codes\n");
+        break;
+      case MD_FILE:               /* file */
+      case MD_APPEND:             /* append */
+        dest = get_pool_memory(PM_MESSAGE);
+        /* Pick up a single destination */
+        token = lex_get_token(lc, T_NAME);   /* scan destination */
+        pm_strcpy(&dest, lc->str);
+        dest_len = lc->str_len;
+        token = lex_get_token(lc, T_ALL);
+         Dmsg1(200, "store_msgs dest=%s:\n", NPRT(dest));
+        if (token != T_EQUALS) {
+            scan_err1(lc, "expected an =, got: %s", lc->str); 
+        }
+        scan_types(lc, (MSGS *)(item->value), item->code, dest, NULL);
+        free_pool_memory(dest);
+         Dmsg0(200, "done with dest codes\n");
+        break;
 
-        default:
-            scan_err1(lc, "Unknown item code: %d\n", item->code);
-           break;
+      default:
+         scan_err1(lc, "Unknown item code: %d\n", item->code);
+        break;
       }
    }
    scan_to_eol(lc);
@@ -284,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;
@@ -345,8 +345,6 @@ void store_strname(LEX *lc, struct res_items *item, int index, int pass)
    set_bit(index, res_all.hdr.item_present);
 }
 
-
-
 /* Store a string at specified address */
 void store_str(LEX *lc, struct res_items *item, int index, int pass)
 {
@@ -368,7 +366,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);
    }
@@ -414,7 +412,7 @@ void store_res(LEX *lc, struct res_items *item, int index, int pass)
    if (pass == 2) {
      res = GetResWithName(item->code, lc->str);
      if (res == NULL) {
-        scan_err3(lc, "Could not find Resource %s referenced on line %d : %s\n"
+        scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n")
           lc->str, lc->line_no, lc->line);
      }
      *(item->value) = (char *)res;
@@ -423,6 +421,32 @@ void store_res(LEX *lc, struct res_items *item, int index, int pass)
    set_bit(index, res_all.hdr.item_present);
 }
 
+/* Store default values for Resource from xxxDefs
+ * If we are in pass 2, do a lookup of the 
+ * resource and store everything not explicitly set
+ * in main resource.
+ *
+ * Note, here item points to the main resource (e.g. Job, not
+ *  the jobdefs, which we look up).
+ */
+void store_defs(LEX *lc, struct res_items *item, int index, int pass)
+{
+   RES *res;
+
+   lex_get_token(lc, T_NAME);
+   if (pass == 2) {
+     res = GetResWithName(item->code, lc->str);
+     if (res == NULL) {
+        scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"), 
+          lc->str, lc->line_no, lc->line);
+     }
+     /* for each item not set, we copy the field from item */
+     /* ***FIXME **** add code */
+   }
+   scan_to_eol(lc);
+}
+
+
 
 /* Store an integer at specified address */
 void store_int(LEX *lc, struct res_items *item, int index, int pass)
@@ -456,7 +480,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");
@@ -464,13 +487,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)) {
@@ -492,23 +508,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;
@@ -516,7 +536,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);
 }
 
@@ -680,7 +702,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;