PatchworkOS
Loading...
Searching...
No Matches
Argument Vector

Argument Vector. More...

Data Structures

struct  argv_t
 Argument Vector structure. More...
 

Functions

uint64_t argv_init (argv_t *argv, const char **src)
 Initializes an argument vector from a source array of strings.
 
void argv_deinit (argv_t *argv)
 Deinitializes an argument vector, freeing any allocated memory.
 
const char * argv_get_strings (const argv_t *argv, uint64_t *length)
 Retrieves a pointer to the start of the first string.
 

Detailed Description

Argument Vector.

Function Documentation

◆ argv_deinit()

void argv_deinit ( argv_t argv)

Deinitializes an argument vector, freeing any allocated memory.

Parameters
argvPointer to the argument vector to deinitialize.

Definition at line 65 of file argv.c.

References argv_t::buffer, argv_t::empty, and free().

Referenced by process_free(), and process_init().

◆ argv_get_strings()

const char * argv_get_strings ( const argv_t argv,
uint64_t length 
)

Retrieves a pointer to the start of the first string.

Parameters
argvPointer to the argument vector.
lengthOutput parameter to store the total length of all strings in bytes, will be set to 0 if there are no strings.
Returns
Pointer to the start of the first string or NULL if there are no strings.

Definition at line 74 of file argv.c.

References argv_t::amount, argv_t::buffer, NULL, and argv_t::size.

Referenced by process_cmdline_read().

◆ argv_init()

uint64_t argv_init ( argv_t argv,
const char **  src 
)

Initializes an argument vector from a source array of strings.

Parameters
argvPointer to the argument vector to initialize.
srcNULL-terminated array of strings to copy into the argument vector. If NULL, initializes an empty argument vector.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 9 of file argv.c.

References argv_t::amount, argv_t::buffer, CONFIG_MAX_ARGC, argv_t::empty, ERR, malloc(), MAX_PATH, NULL, argv_t::size, strcpy(), strlen(), and strnlen_s().

Referenced by process_init().