*
* Version $Id$
*/
-
/*
Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
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 along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
res_all.hdr.rcode = type;
res_all.hdr.refcnt = 1;
+ /* Set defaults in each item */
for (i=0; items[i].name; i++) {
Dmsg3(900, "Item=%s def=%s defval=%d\n", items[i].name,
(items[i].flags & ITEM_DEFAULT) ? "yes" : "no",
scan_err3(lc, _("Missing 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 res */
-#ifdef xxx
- for (int i=0; item->name;; i++, item++) {
- if (bit_is_set(i, res->item_present)) {
- Dmsg2(900, "Item %d is present in %s\n", i, res->name);
- } else {
- Dmsg2(900, "Item %d is not present in %s\n", i, res->name);
- }
- }
- /* ***FIXME **** add code */
-#endif
}
scan_to_eol(lc);
}
{
int token;
uint64_t uvalue;
+ char bsize[500];
Dmsg0(900, "Enter store_size\n");
token = lex_get_token(lc, T_SKIP_EOL);
case T_NUMBER:
case T_IDENTIFIER:
case T_UNQUOTED_STRING:
- if (!size_to_uint64(lc->str, lc->str_len, &uvalue)) {
+ bstrncpy(bsize, lc->str, sizeof(bsize)); /* save first part */
+ /* if terminated by space, scan and get modifier */
+ while (lc->ch == ' ') {
+ token = lex_get_token(lc, T_ALL);
+ switch (token) {
+ case T_NUMBER:
+ case T_IDENTIFIER:
+ case T_UNQUOTED_STRING:
+ bstrncat(bsize, lc->str, sizeof(bsize));
+ break;
+ }
+ }
+ if (!size_to_uint64(bsize, strlen(bsize), &uvalue)) {
scan_err1(lc, _("expected a size number, got: %s"), lc->str);
}
*(uint64_t *)(item->value) = uvalue;
scan_err1(lc, _("expected a size, 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);
Dmsg0(900, "Leave store_size\n");
}
case T_NUMBER:
case T_IDENTIFIER:
case T_UNQUOTED_STRING:
- bstrncpy(period, lc->str, sizeof(period));
- if (lc->ch == ' ') {
+ bstrncpy(period, lc->str, sizeof(period)); /* get first part */
+ /* if terminated by space, scan and get modifier */
+ while (lc->ch == ' ') {
token = lex_get_token(lc, T_ALL);
switch (token) {
+ case T_NUMBER:
case T_IDENTIFIER:
case T_UNQUOTED_STRING:
bstrncat(period, lc->str, sizeof(period));
} else if (strcasecmp(lc->str, "no") == 0) {
*(int *)(item->value) &= ~(item->code);
} else {
- scan_err1(lc, _("Expect a YES or NO, got: %s"), lc->str);
+ scan_err3(lc, _("Expect a %s or %s, got: %s"), "YES", "NO", lc->str); /* YES and NO must not be translated */
}
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
}
}
if (i != 0) {
- scan_err1(lc, "Expected a Tape Label keyword, got: %s", lc->str);
+ scan_err1(lc, _("Expected a Tape Label keyword, got: %s"), lc->str);
}
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
* Parse configuration file
*
* Return 0 if reading failed, 1 otherwise
+ * Note, the default behavior unless you have set an alternate
+ * scan_error handler is to die on an error.
*/
int
parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error)
for (pass=1; pass <= 2; pass++) {
Dmsg1(900, "parse_config pass %d\n", pass);
if ((lc = lex_open_file(lc, cf, scan_error)) == NULL) {
+ berrno be;
+ /* We must create a lex packet to print the error */
lc = (LEX *)malloc(sizeof(LEX));
memset(lc, 0, sizeof(LEX));
if (scan_error) {
lc->scan_error = scan_error;
} else {
- lc->scan_error = s_err;
+ lex_set_default_error_handler(lc);
}
bstrncpy(lc->str, cf, sizeof(lc->str));
lc->fname = lc->str;
- berrno be;
- scan_err2(lc, _("Cannot open config file %s: %s\n"),
+ scan_err2(lc, _("Cannot open config file \"%s\": %s\n"),
lc->str, be.strerror());
free(lc);
return 0;
return 0;
}
}
- Dmsg1(900, "calling handler for %s\n", items[i].name);
+ Dmsg1(800, "calling handler for %s\n", items[i].name);
/* Call item handler */
items[i].handler(lc, &items[i], i, pass);
i = -1;