]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/parse_conf.c
Fix typo in buffer sizes off by factor of 10
[bacula/bacula] / bacula / src / lib / parse_conf.c
index 09f4d1c7562edb8eee594bc67b173edc7e8b1b99..9e856f4a938eaaf35dce1a02257d0919621043e3 100644 (file)
@@ -213,6 +213,8 @@ static void init_resource(CONFIG *config, int type, RES_ITEM *items, int pass)
             *(int64_t *)(items[i].value) = items[i].default_value;
          } else if (items[i].handler == store_size64) {
             *(uint64_t *)(items[i].value) = (uint64_t)items[i].default_value;
+         } else if (items[i].handler == store_speed) {
+            *(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;
          } else if (pass == 1 && items[i].handler == store_addresses) {
@@ -627,14 +629,20 @@ void store_int64(LEX *lc, RES_ITEM *item, int index, int pass)
    set_bit(index, res_all.hdr.item_present);
 }
 
+enum store_unit_type {
+   STORE_SIZE,
+   STORE_SPEED
+} ;
+
 /* Store a size in bytes */
-static void store_size(LEX *lc, RES_ITEM *item, int index, int pass, bool size32)
+static void store_int_unit(LEX *lc, RES_ITEM *item, int index, int pass, 
+                           bool size32, enum store_unit_type type)
 {
    int token;
    uint64_t uvalue;
    char bsize[500];
 
-   Dmsg0(900, "Enter store_size\n");
+   Dmsg0(900, "Enter store_unit\n");
    token = lex_get_token(lc, T_SKIP_EOL);
    errno = 0;
    switch (token) {
@@ -653,9 +661,16 @@ static void store_size(LEX *lc, RES_ITEM *item, int index, int pass, bool size32
             break;
          }
       }
-      if (!size_to_uint64(bsize, strlen(bsize), &uvalue)) {
-         scan_err1(lc, _("expected a size number, got: %s"), lc->str);
-         return;
+      if (type == STORE_SIZE) {
+         if (!size_to_uint64(bsize, strlen(bsize), &uvalue)) {
+            scan_err1(lc, _("expected a size number, got: %s"), lc->str);
+            return;
+         }
+      } else {
+         if (!speed_to_uint64(bsize, strlen(bsize), &uvalue)) {
+            scan_err1(lc, _("expected a speed number, got: %s"), lc->str);
+            return;
+         }
       }
       if (size32) {
          *(uint32_t *)(item->value) = (uint32_t)uvalue;
@@ -664,28 +679,34 @@ static void store_size(LEX *lc, RES_ITEM *item, int index, int pass, bool size32
       }
       break;
    default:
-      scan_err1(lc, _("expected a size, got: %s"), lc->str);
+      scan_err2(lc, _("expected a %s, got: %s"), 
+                (type == STORE_SIZE)?_("size"):_("speed"), lc->str);
       return;
    }
    if (token != T_EOL) {
       scan_to_eol(lc);
    }
    set_bit(index, res_all.hdr.item_present);
-   Dmsg0(900, "Leave store_size\n");
+   Dmsg0(900, "Leave store_unit\n");
 }
 
 /* Store a size in bytes */
 void store_size32(LEX *lc, RES_ITEM *item, int index, int pass)
 {
-   store_size(lc, item, index, pass, true /* 32 bit */);
+   store_int_unit(lc, item, index, pass, true /* 32 bit */, STORE_SIZE);
 }
 
 /* Store a size in bytes */
 void store_size64(LEX *lc, RES_ITEM *item, int index, int pass)
 {
-   store_size(lc, item, index, pass, false /* not 32 bit */);
+   store_int_unit(lc, item, index, pass, false /* not 32 bit */, STORE_SIZE);
 }
 
+/* Store a speed in bytes/s */
+void store_speed(LEX *lc, RES_ITEM *item, int index, int pass)
+{
+   store_int_unit(lc, item, index, pass, false /* 64 bit */, STORE_SPEED);
+}
 
 /* Store a time period in seconds */
 void store_time(LEX *lc, RES_ITEM *item, int index, int pass)