/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2011 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.
*
* Kern Sibbald, January MM
*
- * Version $Id$
*/
*(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) {
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) {
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;
}
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)