cmdline: fix dynamic tokens interface
[dpdk.git] / app / test-pmd / cmdline_flow.c
index 25d5982..9533df1 100644 (file)
@@ -224,7 +224,6 @@ struct context {
        enum index prev; /**< Index of the last token seen. */
        int next_num; /**< Number of entries in next[]. */
        int args_num; /**< Number of entries in args[]. */
-       uint32_t reparse:1; /**< Start over from the beginning. */
        uint32_t eol:1; /**< EOL has been detected. */
        uint32_t last:1; /**< No more arguments. */
        uint16_t port; /**< Current port ID (for completions). */
@@ -2612,7 +2611,6 @@ cmd_flow_context_init(struct context *ctx)
        ctx->prev = ZERO;
        ctx->next_num = 0;
        ctx->args_num = 0;
-       ctx->reparse = 0;
        ctx->eol = 0;
        ctx->last = 0;
        ctx->port = 0;
@@ -2633,9 +2631,6 @@ cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
        int i;
 
        (void)hdr;
-       /* Restart as requested. */
-       if (ctx->reparse)
-               cmd_flow_context_init(ctx);
        token = &token_list[ctx->curr];
        /* Check argument length. */
        ctx->eol = 0;
@@ -2711,8 +2706,6 @@ cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
        int i;
 
        (void)hdr;
-       /* Tell cmd_flow_parse() that context must be reinitialized. */
-       ctx->reparse = 1;
        /* Count number of tokens in current list. */
        if (ctx->next_num)
                list = ctx->next[ctx->next_num - 1];
@@ -2746,8 +2739,6 @@ cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
        int i;
 
        (void)hdr;
-       /* Tell cmd_flow_parse() that context must be reinitialized. */
-       ctx->reparse = 1;
        /* Count number of tokens in current list. */
        if (ctx->next_num)
                list = ctx->next[ctx->next_num - 1];
@@ -2782,8 +2773,6 @@ cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
        const struct token *token = &token_list[ctx->prev];
 
        (void)hdr;
-       /* Tell cmd_flow_parse() that context must be reinitialized. */
-       ctx->reparse = 1;
        if (!size)
                return -1;
        /* Set token type and update global help with details. */
@@ -2809,12 +2798,12 @@ static struct cmdline_token_hdr cmd_flow_token_hdr = {
 /** Populate the next dynamic token. */
 static void
 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
-            cmdline_parse_token_hdr_t *(*hdrs)[])
+            cmdline_parse_token_hdr_t **hdr_inst)
 {
        struct context *ctx = &cmd_flow_context;
 
        /* Always reinitialize context before requesting the first token. */
-       if (!(hdr - *hdrs))
+       if (!(hdr_inst - cmd_flow.tokens))
                cmd_flow_context_init(ctx);
        /* Return NULL when no more tokens are expected. */
        if (!ctx->next_num && ctx->curr) {