]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_bison: Pass struct nft_ctx to parser_init()
authorPhil Sutter <phil@nwl.cc>
Fri, 13 Apr 2018 14:52:35 +0000 (16:52 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 14 Apr 2018 11:53:02 +0000 (13:53 +0200)
Signature of parser_init() got quite huge, so simply pass the whole
context pointer to it - most of the parameters are just taken from there
anyway.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/parser.h
src/libnftables.c
src/parser_bison.y

index 7961275742bc2d8686620df9b6072814385d9b4c..ea41ca038a0214779d3963d29a17a5f56d872731 100644 (file)
@@ -31,10 +31,8 @@ struct parser_state {
 
 struct mnl_socket;
 
-extern void parser_init(struct mnl_socket *nf_sock, struct nft_cache *cache,
-                       struct parser_state *state, struct list_head *msgs,
-                       struct list_head *cmds, unsigned int debug_level,
-                       struct output_ctx *octx);
+extern void parser_init(struct nft_ctx *nft, struct parser_state *state,
+                       struct list_head *msgs, struct list_head *cmds);
 extern int nft_parse(struct nft_ctx *ctx, void *, struct parser_state *state);
 
 extern void *scanner_init(struct parser_state *state);
index 56a98ab1aaefeeb2284d3de3afeea2b0852fca49..f336dbc3e3f4366cc9244d4dd68b29cdc55b3dc2 100644 (file)
@@ -408,8 +408,7 @@ int nft_run_cmd_from_buffer(struct nft_ctx *nft, char *buf, size_t buflen)
        nlbuf = xzalloc(nlbuflen);
        snprintf(nlbuf, nlbuflen, "%s\n", buf);
 
-       parser_init(nft->nf_sock, &nft->cache, &state,
-                   &msgs, &cmds, nft->debug_mask, &nft->output);
+       parser_init(nft, &state, &msgs, &cmds);
        scanner = scanner_init(&state);
        scanner_push_buffer(scanner, &indesc_cmdline, nlbuf);
 
@@ -445,8 +444,7 @@ int nft_run_cmd_from_filename(struct nft_ctx *nft, const char *filename)
        if (!strcmp(filename, "-"))
                filename = "/dev/stdin";
 
-       parser_init(nft->nf_sock, &nft->cache, &state,
-                   &msgs, &cmds, nft->debug_mask, &nft->output);
+       parser_init(nft, &state, &msgs, &cmds);
        scanner = scanner_init(&state);
        if (scanner_read_file(scanner, filename, &internal_location) < 0) {
                rc = -1;
index 1ca5d4048c288e9b67d4cc5017fac7378fc9f364..e2440be15aa2f13228e2d83cb353785d4adfe585 100644 (file)
 
 #include "parser_bison.h"
 
-void parser_init(struct mnl_socket *nf_sock, struct nft_cache *cache,
-                struct parser_state *state, struct list_head *msgs,
-                struct list_head *cmds, unsigned int debug_mask,
-                struct output_ctx *octx)
+void parser_init(struct nft_ctx *nft, struct parser_state *state,
+                struct list_head *msgs, struct list_head *cmds)
 {
        memset(state, 0, sizeof(*state));
        init_list_head(&state->top_scope.symbols);
        state->msgs = msgs;
        state->cmds = cmds;
        state->scopes[0] = scope_init(&state->top_scope, NULL);
-       state->ectx.cache = cache;
+       state->ectx.cache = &nft->cache;
        state->ectx.msgs = msgs;
-       state->ectx.nf_sock = nf_sock;
-       state->ectx.debug_mask = debug_mask;
-       state->ectx.octx = octx;
+       state->ectx.nf_sock = nft->nf_sock;
+       state->ectx.debug_mask = nft->debug_mask;
+       state->ectx.octx = &nft->output;
 }
 
 static void yyerror(struct location *loc, struct nft_ctx *nft, void *scanner,