mirror of
https://github.com/Savapitech/42sh.git
synced 2026-03-18 21:50:35 +01:00
61 lines
1.2 KiB
C
61 lines
1.2 KiB
C
/*
|
|
** EPITECH PROJECT, 2025
|
|
** __
|
|
** File description:
|
|
** _
|
|
*/
|
|
|
|
#ifndef EXEC_H
|
|
#define EXEC_H
|
|
#include "ast.h"
|
|
#include "env.h"
|
|
#include "shell.h"
|
|
|
|
#define DEFAULT_ARGS_CAP 1
|
|
|
|
typedef struct {
|
|
char **args;
|
|
size_t sz;
|
|
size_t cap;
|
|
} args_t;
|
|
|
|
enum flags {
|
|
F_PIPE = 1 << 0,
|
|
F_RED = 1 << 1,
|
|
F_EXIT = 1 << 2
|
|
};
|
|
|
|
typedef struct {
|
|
char *buffer;
|
|
env_t *env;
|
|
history_t *history;
|
|
ast_ctx_t *ctx;
|
|
ast_t *act_node;
|
|
size_t skip_i;
|
|
size_t skip_sz;
|
|
uint8_t flags;
|
|
size_t p_i;
|
|
size_t p_sz;
|
|
int rin_fd;
|
|
int rout_fd;
|
|
int pipes[2];
|
|
int pin_fd;
|
|
int pout_fd;
|
|
int in_fd;
|
|
int out_fd;
|
|
exec_ctx_t *exec_ctx;
|
|
} ef_t;
|
|
|
|
__attribute__((nonnull))
|
|
int execute(ef_t *ef);
|
|
bool ensure_args_capacity(args_t *args);
|
|
int exec_the_args(ef_t *ef, char **args);
|
|
void exit_child(int sig __attribute__((unused)));
|
|
int visit_loop(ef_t *ef, ast_t *node);
|
|
void handle_var_case(ast_t *node, exec_ctx_t *ctx, size_t *i, args_t *args);
|
|
bool handle_magic_quotes(ast_t *node, exec_ctx_t *ctx,
|
|
size_t *i, args_t *args);
|
|
bool handle_var(ast_t *node, size_t *i, exec_ctx_t *ctx, args_t *args);
|
|
char *get_values(exec_ctx_t *ctx, char *key);
|
|
#endif /* EXEC_H */
|