You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
/**
|
|
* Command argument splitting
|
|
*
|
|
* Created on 2020/02/28.
|
|
*/
|
|
|
|
#ifndef VCOM_CONSOLE_SPLIT_ARGV_H
|
|
#define VCOM_CONSOLE_SPLIT_ARGV_H
|
|
|
|
/**
|
|
* @brief Split command line into arguments in place
|
|
*
|
|
* - This function finds whitespace-separated arguments in the given input line.
|
|
*
|
|
* 'abc def 1 20 .3' -> [ 'abc', 'def', '1', '20', '.3' ]
|
|
*
|
|
* - Argument which include spaces may be surrounded with quotes. In this case
|
|
* spaces are preserved and quotes are stripped.
|
|
*
|
|
* 'abc "123 456" def' -> [ 'abc', '123 456', 'def' ]
|
|
*
|
|
* - Escape sequences may be used to produce backslash, double quote, and space:
|
|
*
|
|
* 'a\ b\\c\"' -> [ 'a b\c"' ]
|
|
*
|
|
* Pointers to at most argv_size - 1 arguments are returned in argv array.
|
|
* The pointer after the last one (i.e. argv[argc]) is set to NULL.
|
|
*
|
|
* @param line pointer to buffer to parse; it is modified in place
|
|
* @param argv array where the pointers to arguments are written
|
|
* @param argv_size number of elements in argv_array (max. number of arguments)
|
|
* @return number of arguments found (argc)
|
|
*/
|
|
size_t console_split_argv(char *line, char **argv, size_t argv_size);
|
|
|
|
#endif //VCOM_CONSOLE_SPLIT_ARGV_H
|
|
|