feat: modifs y a tarpin longtemps jsais plus
This commit is contained in:
parent
f136728d78
commit
b8e2931a77
4 changed files with 19 additions and 8 deletions
|
@ -1,7 +1,13 @@
|
|||
#ifndef COMMAND_H
|
||||
#define COMMAND_H
|
||||
|
||||
#include "parse.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
struct Args {
|
||||
unsigned int argc;
|
||||
size_t argv_size;
|
||||
char **argv;
|
||||
};
|
||||
|
||||
unsigned char invoke(struct Args args);
|
||||
|
||||
|
|
10
src/main.c
10
src/main.c
|
@ -19,5 +19,15 @@ int main() {
|
|||
free(input_line);
|
||||
|
||||
invoke(args);
|
||||
{
|
||||
unsigned int i = 0;
|
||||
while (i < args.argc) {
|
||||
free(args.argv[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (args.argv != NULL) {
|
||||
free(args.argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ struct Args parse(char *line) {
|
|||
struct Args args;
|
||||
args.argc = 0;
|
||||
args.argv_size = 0;
|
||||
args.argv = NULL;
|
||||
|
||||
parse_worker(&args, line, 0, line);
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
#ifndef PARSE_H
|
||||
#define PARSE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct Args {
|
||||
unsigned int argc;
|
||||
size_t argv_size;
|
||||
char **argv;
|
||||
};
|
||||
#include "command.h"
|
||||
|
||||
void add_arg(struct Args *args, char *arg_ptr, unsigned int arg_length);
|
||||
void parse_worker(struct Args *args, char *arg_position, unsigned int arg_length, char *line);
|
||||
|
|
Loading…
Reference in a new issue