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);
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;
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)
{
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;
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)
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");
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)) {
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;
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);
}
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;