aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ast.h73
-rw-r--r--include/eval.h28
-rw-r--r--include/minishell.h36
-rw-r--r--include/parse.h10
4 files changed, 86 insertions, 61 deletions
diff --git a/include/ast.h b/include/ast.h
index 754956a..0d14779 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -1,7 +1,19 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ast.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:05:38 by charles #+# #+# */
+/* Updated: 2020/04/01 17:52:43 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
#ifndef AST_H
# define AST_H
-/**
+/*
** \file ast.h
** \brief AST structs
*/
@@ -11,7 +23,7 @@
# include "libft_mem.h"
# include "libft_util.h"
-/**
+/*
** \brief Separator type
** \param SEP_END Regular command end `;`
** \param SEP_PIPE Pipe output of left to right `|`
@@ -19,59 +31,60 @@
** \param SEP_OR Execute right if left status != 0 `||`
*/
-typedef enum
+typedef enum e_sep
{
SEP_END,
SEP_PIPE,
SEP_AND,
SEP_OR,
-} t_sep;
+} t_sep;
struct s_ast;
-/**
+/*
** \brief Line struct
** \param left AST to the left of separator
** \param right AST to the right of separator
** \param sep Type of separator
*/
-typedef struct
+typedef struct s_line
{
- struct s_ast *left;
- struct s_ast *right;
- t_sep sep;
-} t_line;
+ struct s_ast *left;
+ struct s_ast *right;
+ t_sep sep;
+} t_line;
-/**
+/*
** \brief Command struct
-** \param argv Array of string, all arguments beginning with executable name
+** \param argv Array of string,
+** all arguments beginning with executable name
** \param in STDIN redirection filename
** \param out STDOUT redirection filename
** \param is_append True if out redirection is append to file
*/
-typedef struct
+typedef struct s_cmd
{
- char **argv;
- char *in;
- char *out;
- bool is_append;
-} t_cmd;
+ char **argv;
+ char *in;
+ char *out;
+ bool is_append;
+} t_cmd;
-/**
+/*
** \brief AST node tag (type)
** \param TAG_CMD Command AST node
** \param TAG_LINE Line AST node
*/
-typedef enum
+typedef enum e_ast_tag
{
TAG_CMD,
TAG_LINE,
-} t_ast_tag;
+} t_ast_tag;
-/**
+/*
** \brief AST node struct
** \param tag Node tag
** \param data Union containning possible node data
@@ -79,17 +92,17 @@ typedef enum
** \param data::line Line struct
*/
-typedef struct s_ast
+typedef struct s_ast
{
- t_ast_tag tag;
+ t_ast_tag tag;
union
{
- t_line line;
- t_cmd cmd;
- } data;
-} t_ast;
+ t_line line;
+ t_cmd cmd;
+ } data;
+} t_ast;
-t_ast *ast_new(t_ast_tag tag, void *data);
-void ast_destroy(t_ast *ast);
+t_ast *ast_new(t_ast_tag tag, void *data);
+void ast_destroy(t_ast *ast);
#endif
diff --git a/include/eval.h b/include/eval.h
index 55cd497..31f729b 100644
--- a/include/eval.h
+++ b/include/eval.h
@@ -1,7 +1,19 @@
-#ifndef MS_EVAL_H
-# define MS_EVAL_H
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* eval.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:05:30 by charles #+# #+# */
+/* Updated: 2020/04/01 17:53:26 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
-/**
+#ifndef EVAL_H
+# define EVAL_H
+
+/*
** \file eval.h
** \brief Evaluation module
*/
@@ -9,23 +21,23 @@
# include "minishell.h"
# include "ast.h"
-/**
+/*
** \brief Evaluation state struct
*/
typedef struct
{
- int pipe_in[2]; // need stack pipe
+ int pipe_in[2];
int pipe_out[2];
t_path path;
t_env env;
} t_eval_state;
-/**
+/*
** \brief Evaluation status struct
*/
-typedef struct
+typedef struct s_eval_status
{
char *err;
int status;
@@ -42,7 +54,7 @@ int eval(t_eval_state *state, t_ast *ast);
*/
bool exec_is_path(char *path_str);
-bool exec_is_valid(char *exec_path);
+bool exec_is_valid(char *exec_path);
char *exec_search_path(t_path path, char *path_var, char *exec_name);
/*
diff --git a/include/minishell.h b/include/minishell.h
index a3970dd..b883fc2 100644
--- a/include/minishell.h
+++ b/include/minishell.h
@@ -6,15 +6,15 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/26 15:33:51 by cacharle #+# #+# */
-/* Updated: 2020/02/28 15:30:10 by cacharle ### ########.fr */
+/* Updated: 2020/04/01 17:54:36 by charles ### ########.fr */
/* */
/* ************************************************************************** */
-#include <stdio.h> // for debugging - dont remove
#ifndef MINISHELL_H
# define MINISHELL_H
+#include <stdio.h> // for debugging - dont remove
-/**
+/*
** \file minishell.h
** \brief Common header
*/
@@ -34,19 +34,19 @@
# include "libft_lst.h"
# include "libft_util.h"
-/**
+/*
** \brief Value of pipe entry if closed
*/
# define PIPE_CLOSED -1
-/**
+/*
** \brief Pipe write index
*/
# define PIPE_WRITE 1
-/**
+/*
** \brief Pipe read index
*/
@@ -74,33 +74,33 @@ char **env_to_array(t_env env);
** builtin*.c - directory with all builtin commands
*/
-/**
+/*
** \brief Type of a builtin main function
*/
typedef int (*t_builtin_func)(char **argv, t_env env);
-/**
+/*
** \brief Entry of builtin lookup array
** \param name Executable name of builtin
** \param func Associated function
*/
-struct s_builtin_entry
+struct s_builtin_entry
{
- char *name;
- t_builtin_func func;
+ char *name;
+ t_builtin_func func;
};
int builtin_dispatch_run(char **argv, t_env env);
bool builtin_check_exec_name(char *exec_name);
-int builtin_echo(char **argv, t_env env);
-int builtin_cd(char **argv, t_env env);
-int builtin_pwd(char **argv, t_env env);
-int builtin_export(char **argv, t_env env);
-int builtin_unset(char **argv, t_env env);
-int builtin_env(char **argv, t_env env);
-int builtin_exit(char **argv, t_env env);
+int builtin_echo(char **argv, t_env env);
+int builtin_cd(char **argv, t_env env);
+int builtin_pwd(char **argv, t_env env);
+int builtin_export(char **argv, t_env env);
+int builtin_unset(char **argv, t_env env);
+int builtin_env(char **argv, t_env env);
+int builtin_exit(char **argv, t_env env);
/*
** util.c - various utilitary functions
diff --git a/include/parse.h b/include/parse.h
index c9710d7..bc86230 100644
--- a/include/parse.h
+++ b/include/parse.h
@@ -1,22 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* parse.h :+: :+: :+: */
+/* parse.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 09:00:00 by cacharle #+# #+# */
-/* Updated: 2020/02/28 14:57:58 by cacharle ### ########.fr */
+/* Updated: 2020/04/01 17:49:45 by charles ### ########.fr */
/* */
/* ************************************************************************** */
-#ifndef MS_PARSE_H
-# define MS_PARSE_H
+#ifndef PARSE_H
+# define PARSE_H
# include "minishell.h"
# include "ast.h"
-/**
+/*
** \file parse.h
** \brief Input parsing and AST manipulation
**