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

Function parse_boolean

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

* Parse a boolean value. * * Last argument (ctx->args) is retrieved to determine storage size and * location. */

Source from the content-addressed store, hash-verified

11215 * location.
11216 */
11217static int
11218parse_boolean(struct context *ctx, const struct token *token,
11219 const char *str, unsigned int len,
11220 void *buf, unsigned int size)
11221{
11222 const struct arg *arg = pop_args(ctx);
11223 unsigned int i;
11224 int ret;
11225
11226 /* Argument is expected. */
11227 if (!arg)
11228 return -1;
11229 for (i = 0; boolean_name[i]; ++i)
11230 if (!strcmp_partial(boolean_name[i], str, len))
11231 break;
11232 /* Process token as integer. */
11233 if (boolean_name[i])
11234 str = i & 1 ? "1" : "0";
11235 push_args(ctx, arg);
11236 ret = parse_int(ctx, token, str, strlen(str), buf, size);
11237 return ret > 0 ? (int)len : ret;
11238}
11239
11240/** Parse port and update context. */
11241static int

Callers

nothing calls this directly

Calls 4

pop_argsFunction · 0.85
strcmp_partialFunction · 0.85
push_argsFunction · 0.85
parse_intFunction · 0.85

Tested by

no test coverage detected