extern RES_TABLE resources[];
extern RES **res_head;
-#ifdef HAVE_WIN32
+#if defined(_MSC_VER)
// work around visual studio name manling preventing external linkage since res_all
// is declared as a different type when instantiated.
extern "C" CURES res_all;
-extern "C" int res_all_size;
#else
extern CURES res_all;
-extern int res_all_size;
#endif
+extern int res_all_size;
extern brwlock_t res_lock; /* resource lock */
{"director", store_msgs, ITEM(res_msgs), MD_DIRECTOR, 0, 0},
{"console", store_msgs, ITEM(res_msgs), MD_CONSOLE, 0, 0},
{"operator", store_msgs, ITEM(res_msgs), MD_OPERATOR, 0, 0},
- {NULL, NULL, NULL, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
struct s_mtypes {
*/
static void scan_types(LEX *lc, MSGS *msg, int dest_code, char *where, char *cmd)
{
- int i, found, quit, is_not;
+ int i;
+ bool found, is_not;
int msg_type = 0;
char *str;
- for (quit=0; !quit;) {
+ for ( ;; ) {
lex_get_token(lc, T_NAME); /* expect at least one type */
- found = FALSE;
+ found = false;
if (lc->str[0] == '!') {
- is_not = TRUE;
+ is_not = true;
str = &lc->str[1];
} else {
- is_not = FALSE;
+ is_not = false;
str = &lc->str[0];
}
for (i=0; msg_types[i].name; i++) {
if (strcasecmp(str, msg_types[i].name) == 0) {
msg_type = msg_types[i].token;
- found = TRUE;
+ found = true;
break;
}
}
for (i=1; i<=M_MAX; i++) { /* yes set all types */
add_msg_dest(msg, dest_code, i, where, cmd);
}
+ } else if (is_not) {
+ rem_msg_dest(msg, dest_code, msg_type, where);
} else {
- if (is_not) {
- rem_msg_dest(msg, dest_code, msg_type, where);
- } else {
- add_msg_dest(msg, dest_code, msg_type, where, cmd);
- }
+ add_msg_dest(msg, dest_code, msg_type, where, cmd);
}
if (lc->ch != ',') {
break;
* scan_error handler is to die on an error.
*/
int
-parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error)
+parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type)
{
LEX *lc = NULL;
int token, i, pass;
} else {
lex_set_default_error_handler(lc);
}
+ lex_set_error_handler_error_type(lc, err_type) ;
bstrncpy(lc->str, cf, sizeof(lc->str));
lc->fname = lc->str;
scan_err2(lc, _("Cannot open config file \"%s\": %s\n"),
free(lc);
return 0;
}
+ lex_set_error_handler_error_type(lc, err_type) ;
while ((token=lex_get_token(lc, T_ALL)) != T_EOF) {
Dmsg1(900, "parse got token=%s\n", lex_tok_to_str(token));
switch (state) {
level--;
state = p_none;
Dmsg0(900, "T_EOB => define new resource\n");
+ if (res_all.hdr.name == NULL) {
+ scan_err0(lc, _("Name not specified for resource"));
+ }
save_resource(res_type, items, pass); /* save resource */
break;