|
PatchworkOS
19e446b
A non-POSIX operating system.
|
Standardized argument parsing. More...
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.
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. | |
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.
The caller is responsible for freeing the returned array, there is no need to free the strings as they re stored in the same buffer.
| str | The input string to be parsed. |
| maxLen | The maximum length of the input string. |
| count | A pointer to a uint64_t where the number of parsed arguments will be stored. |
NULL-terminated array of strings (the parsed arguments). On failure, returns NULL. Definition at line 3 of file argsplit.c.
| 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.
| buf | A pointer to the buffer to be used for storing the parsed arguments. |
| size | The size of the provided buffer. |
| str | The input string to be parsed. |
| maxLen | The maximum length of the input string. |
| count | A pointer to a uint64_t where the number of parsed arguments will be stored. |
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.