*/
#define MAX_STACK (32)
typedef struct dict_ctx_stack_frame_t {
+ fr_dict_t *dict; //!< The dictionary before the current BEGIN-PROTOCOL block.
char *filename; //!< name of the file we're reading
int line; //!< line number of this file
fr_dict_attr_t const *da; //!< the da we care about
typedef struct {
fr_dict_t *dict; //!< Protocol dictionary we're inserting attributes into.
- fr_dict_t *old_dict; //!< The dictionary before the current BEGIN-PROTOCOL block.
dict_ctx_stack_frame_t stack[MAX_STACK]; //!< stack of attributes to track
int stack_depth; //!< points to the last used stack frame
ctx->stack_depth++;
memset(&ctx->stack[ctx->stack_depth], 0, sizeof(ctx->stack[ctx->stack_depth]));
+ ctx->stack[ctx->stack_depth].dict = ctx->stack[ctx->stack_depth - 1].dict;
ctx->stack[ctx->stack_depth].da = da;
ctx->stack[ctx->stack_depth].filename = ctx->stack[ctx->stack_depth - 1].filename;
ctx->stack[ctx->stack_depth].line = ctx->stack[ctx->stack_depth - 1].line;
if (strcasecmp(argv[0], "BEGIN-PROTOCOL") == 0) {
fr_dict_t *found;
- ctx->old_dict = ctx->dict;
-
if (argc != 2) {
fr_strerror_printf_push("Invalid BEGIN-PROTOCOL entry");
goto error;
goto error;
}
- /*
- * Switch back to old values.
- *
- * @todo - use the stack for dictionaries.
- */
- ctx->dict = ctx->old_dict;
-
/*
* Applies fixups to any attributes added
* to the protocol dictionary. Note that
}
ctx->stack_depth--;
+ ctx->dict = ctx->stack[ctx->stack_depth].dict;
continue;
}
memset(&ctx, 0, sizeof(ctx));
ctx.dict = dict;
+ ctx.stack[0].dict = dict;
ctx.stack[0].da = dict->root;
ctx.stack[0].nest = FR_TYPE_MAX;
memset(&ctx, 0, sizeof(ctx));
ctx.dict = dict;
+ ctx.stack[0].dict = dict;
ctx.stack[0].da = dict->root;
ctx.stack[0].nest = FR_TYPE_MAX;