mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
31 lines
682 B
C
31 lines
682 B
C
#include <targp.h>
|
|
|
|
#include <memory.hpp>
|
|
#include <convert.h>
|
|
|
|
void targp_parse(const char *cmd, char **argv, int *argc)
|
|
{
|
|
const char delim[] = " ";
|
|
|
|
char *token = strtok((char *)cmd, delim);
|
|
while (token != NULL)
|
|
{
|
|
char *quote = strchr(token, '"');
|
|
if (quote != NULL)
|
|
{
|
|
memmove(quote, quote + 1, strlen(quote));
|
|
char *endQuote = strchr(quote, '"');
|
|
if (endQuote != NULL)
|
|
*endQuote = '\0';
|
|
}
|
|
|
|
char *arg = (char *)kmalloc(strlen(token) + 1);
|
|
strcpy(arg, token);
|
|
|
|
argv[(*argc)++] = arg;
|
|
|
|
token = strtok(NULL, delim);
|
|
}
|
|
argv[(*argc)] = NULL;
|
|
}
|