PatchworkOS
966e257
A non-POSIX operating system.
Theme:
Default
Round
Robot
Loading...
Searching...
No Matches
argsplit.h
Go to the documentation of this file.
1
#ifndef _SYS_ARGSPLIT_H
2
#define _SYS_ARGSPLIT_H 1
3
4
#include <
stdint.h
>
5
6
#if defined(__cplusplus)
7
extern
"C"
8
{
9
#endif
10
11
#include "
_internal/config.h
"
12
13
/**
14
* @brief Standardized argument parsing
15
* @ingroup libstd
16
* @defgroup libstd_sys_argsplit Argument parsing
17
*
18
* The `sys/argsplit.h` header provides a system for standardized argument parsing, allowing arguments to be parsed in
19
* the same way in various parts of the operating system.
20
*
21
* @{
22
*/
23
24
/**
25
* @brief Standardized argument parsing function.
26
*
27
* The `argsplit()` function parses a input string and splits it into a NULL-terminated array of strings factoring in
28
* escape chars spaces and quotation marks.
29
*
30
* @param str The input string to be parsed.
31
* @param maxLen The maximum length of the input string.
32
* @param count A pointer to a `uint64_t` where the number of parsed arguments will be stored.
33
* @return On success, returns a `NULL`-terminated array of strings (the parsed arguments). On failure, returns `NULL`.
34
*/
35
const
char
**
argsplit
(
const
char
* str,
uint64_t
maxLen,
uint64_t
*
count
);
36
37
/**
38
* @brief Standardized argument parsing function using a provided buffer.
39
*
40
* The `argsplit_buf()` function is similar to `argsplit()` but uses a pre-allocated buffer for storing the parsed
41
* arguments, useful for memory management.
42
*
43
* @param buf A pointer to the buffer to be used for storing the parsed arguments.
44
* @param size The size of the provided buffer.
45
* @param str The input string to be parsed.
46
* @param maxLen The maximum length of the input string.
47
* @param count A pointer to a `uint64_t` where the number of parsed arguments will be stored.
48
* @return On success, returns a `NULL`-terminated array of strings (the parsed arguments) stored within the provided
49
* buffer. On failure, returns `NULL`.
50
*/
51
const
char
**
argsplit_buf
(
void
* buf,
uint64_t
size,
const
char
* str,
uint64_t
maxLen,
uint64_t
*
count
);
52
53
#if defined(__cplusplus)
54
}
55
#endif
56
57
#endif
58
59
/** @} */
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.
Definition
argsplit_buf.c:3
argsplit
const char ** argsplit(const char *str, uint64_t maxLen, uint64_t *count)
Standardized argument parsing function.
Definition
argsplit.c:3
config.h
count
static atomic_long count
Definition
main.c:10
stdint.h
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:17
include
libstd
sys
argsplit.h
Generated on Mon Dec 15 2025 21:55:53 for PatchworkOS by
1.9.8