cli_utils.h
Source: samples/common/core/cli_utils.h
C utility functions for CLI flag parsing.
Functions
parse_int_or_default
Parse a decimal integer from a string, returning a default on failure.
Parameters:
| Name | Type | Description |
|---|---|---|
text |
const char * |
Null-terminated string to parse (may be NULL). |
dflt |
int |
Value returned when text is NULL or not a valid integer. |
Returns: Parsed integer, or dflt.
parse_u64_hex_or_default
Parse a uint64 from a string (auto-detecting hex via 0x prefix).
Parameters:
| Name | Type | Description |
|---|---|---|
text |
const char * |
Null-terminated string to parse (may be NULL). |
dflt |
uint64_t |
Value returned when text is NULL or not a valid integer. |
Returns: Parsed value, or dflt.
get_flag_value
Extract the value portion of a "--key=value" flag.
Parameters:
| Name | Type | Description |
|---|---|---|
arg |
const char * |
The full argument string (e.g. "--iterations=10"). |
key |
const char * |
The key to match, including leading dashes (e.g. "--iterations"). |
Returns: Pointer to the value substring after '=', or NULL if arg does not match key.