PatchworkOS
Loading...
Searching...
No Matches
Argument parsing

Standardized argument parsing. More...

Functions

const char ** argsplit (const char *str, uint64_t maxLen, uint64_t *count)
 Standardized argument parsing function.
 
const char ** argsplit_buf (void *buf, uint64_t size, const char *str, uint64_t maxLen, uint64_t *count)
 Standardized argument parsing function using a provided buffer.
 

Detailed Description

Standardized argument parsing.

The sys/argsplit.h header provides a system for standardized argument parsing, allowing arguments to be parsed in the same way in various parts of the operating system.

Function Documentation

◆ argsplit()

const char ** argsplit ( const char *  str,
uint64_t  maxLen,
uint64_t count 
)

Standardized argument parsing function.

The argsplit() function parses a input string and splits it into a NULL-terminated array of strings factoring in escape chars spaces and quotation marks.

Parameters
strThe input string to be parsed.
maxLenThe maximum length of the input string.
countA pointer to a uint64_t where the number of parsed arguments will be stored.
Returns
On success, returns a NULL-terminated array of strings (the parsed arguments). On failure, returns NULL.

Definition at line 3 of file argsplit.c.

References _argsplit_backend(), _argsplit_count_chars_and_args(), count, isspace(), malloc(), NULL, and UINT64_MAX.

Referenced by pipeline_init().

◆ argsplit_buf()

const char ** argsplit_buf ( void *  buf,
uint64_t  size,
const char *  str,
uint64_t  maxLen,
uint64_t count 
)

Standardized argument parsing function using a provided buffer.

The argsplit_buf() function is similar to argsplit() but uses a pre-allocated buffer for storing the parsed arguments, useful for memory management.

Parameters
bufA pointer to the buffer to be used for storing the parsed arguments.
sizeThe size of the provided buffer.
strThe input string to be parsed.
maxLenThe maximum length of the input string.
countA pointer to a uint64_t where the number of parsed arguments will be stored.
Returns
On success, returns a NULL-terminated array of strings (the parsed arguments) stored within the provided buffer. On failure, returns NULL.

Definition at line 3 of file argsplit_buf.c.

References _argsplit_backend(), _argsplit_count_chars_and_args(), count, isspace(), NULL, and UINT64_MAX.

Referenced by ctl_dispatch().