MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cmd_flow_parse

Function cmd_flow_parse

dpdk/app/test-pmd/cmdline_flow.c:12223–12297  ·  view source on GitHub ↗

Parse a token (cmdline API). */

Source from the content-addressed store, hash-verified

12221
12222/** Parse a token (cmdline API). */
12223static int
12224cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
12225 unsigned int size)
12226{
12227 struct context *ctx = &cmd_flow_context;
12228 const struct token *token;
12229 const enum index *list;
12230 int len;
12231 int i;
12232
12233 (void)hdr;
12234 token = &token_list[ctx->curr];
12235 /* Check argument length. */
12236 ctx->eol = 0;
12237 ctx->last = 1;
12238 for (len = 0; src[len]; ++len)
12239 if (src[len] == '#' || isspace(src[len]))
12240 break;
12241 if (!len)
12242 return -1;
12243 /* Last argument and EOL detection. */
12244 for (i = len; src[i]; ++i)
12245 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
12246 break;
12247 else if (!isspace(src[i])) {
12248 ctx->last = 0;
12249 break;
12250 }
12251 for (; src[i]; ++i)
12252 if (src[i] == '\r' || src[i] == '\n') {
12253 ctx->eol = 1;
12254 break;
12255 }
12256 /* Initialize context if necessary. */
12257 if (!ctx->next_num) {
12258 if (!token->next)
12259 return 0;
12260 ctx->next[ctx->next_num++] = token->next[0];
12261 }
12262 /* Process argument through candidates. */
12263 ctx->prev = ctx->curr;
12264 list = ctx->next[ctx->next_num - 1];
12265 for (i = 0; list[i]; ++i) {
12266 const struct token *next = &token_list[list[i]];
12267 int tmp;
12268
12269 ctx->curr = list[i];
12270 if (next->call)
12271 tmp = next->call(ctx, next, src, len, result, size);
12272 else
12273 tmp = parse_default(ctx, next, src, len, result, size);
12274 if (tmp == -1 || tmp != len)
12275 continue;
12276 token = next;
12277 break;
12278 }
12279 if (!list[i])
12280 return -1;

Callers 1

flow_parseFunction · 0.85

Calls 2

isspaceFunction · 0.85
parse_defaultFunction · 0.85

Tested by

no test coverage detected