|
wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
|
Parse already-materialized argc/argv for named flags of the form --flag value. More...
#include "common/platform/sys/syscall.h"Go to the source code of this file.
Functions | |
| i64 | wired_cliargs_int (int argc, char **argv, const char *flag, i64 defval) |
| Find flag in argv and parse its following element as a non-negative base-10 integer. | |
| const char * | wired_cliargs_str (int argc, char **argv, const char *flag, const char *defval) |
| Find flag in argv and return a pointer to its following element. | |
| int | wired_cliargs_flag (int argc, char **argv, const char *flag) |
| Find flag anywhere in argv, including argv's last element (unlike wired_cliargs_int/wired_cliargs_str, no following value is expected). | |
| int | wired_cliargs_ipv4 (const char *s, u8 out[4]) |
| Parse a dotted-decimal IPv4 address ("a.b.c.d") into 4 bytes. | |
Parse already-materialized argc/argv for named flags of the form --flag value.
No libc: no getopt, no strtol, no strcmp.
This module only parses argv it is handed — it does not read the kernel stack itself. See cliargs.c's file comment for why raw stack extraction (from _start) is out of scope here.
| int wired_cliargs_flag | ( | int | argc, |
| char ** | argv, | ||
| const char * | flag ) |
Find flag anywhere in argv, including argv's last element (unlike wired_cliargs_int/wired_cliargs_str, no following value is expected).
| argc | argument count |
| argv | argument vector |
| flag | NUL-terminated flag to search for, e.g. "--verbose" |
Find flag in argv and parse its following element as a non-negative base-10 integer.
| argc | argument count |
| argv | argument vector (argv[0] is the program name, as usual) |
| flag | NUL-terminated flag to search for, e.g. "--port" |
| defval | value returned when the flag is absent, dangling (no following element), or its value is not purely digits |
| int wired_cliargs_ipv4 | ( | const char * | s, |
| u8 | out[4] ) |
Parse a dotted-decimal IPv4 address ("a.b.c.d") into 4 bytes.
Rejects (leaving out unchanged): any octet outside 0-255, a segment count other than 4, an empty segment, a non-digit character, or trailing garbage after the last octet. Leading zeros are accepted.
| s | NUL-terminated dotted-decimal string |
| out | 4-byte buffer receiving the parsed octets on success |
| const char * wired_cliargs_str | ( | int | argc, |
| char ** | argv, | ||
| const char * | flag, | ||
| const char * | defval ) |
Find flag in argv and return a pointer to its following element.
| argc | argument count |
| argv | argument vector |
| flag | NUL-terminated flag to search for, e.g. "--cert" |
| defval | value returned when the flag is absent or dangling |