aboutsummaryrefslogtreecommitdiff
path: root/include/minishell.h
blob: 3398461929557aae30f5038514a84d379e29ea9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   minishell.h                                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/26 15:33:51 by cacharle          #+#    #+#             */
/*   Updated: 2020/02/28 15:30:10 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */
#include <stdio.h>  // for debugging - dont remove

#ifndef MINISHELL_H
# define MINISHELL_H

# include <stdlib.h>
# include <string.h>
# include <unistd.h>
# include <fcntl.h>
# include <dirent.h>
# include <sys/wait.h>
# include <signal.h>
# include <sys/stat.h>
# include <stdbool.h>

# include "libft.h"
# include "libft_ht.h"
# include "libft_lst.h"
# include "libft_util.h"

# include "ms_parse.h"

# define MS_PATH_KEY "PATH"
# define MS_PIPE_WRITE 1
# define MS_PIPE_READ 0

typedef t_ftht*			t_path;
typedef t_ftht*			t_env;

/*
** eval.c
*/

typedef struct
{
	t_status_type		type;
	union
	{
		char			*error_msg;
		char			*arg;
		int				code;
	}					value;
}						t_status;

typedef enum
{
	STYPE_ERROR,
	STYPE_ARG,
	STYPE_FILE,
	// ...
}						t_status_type;

int						ms_eval(t_path path, t_env env, t_ast *ast);

/*
** path.c
*/

t_path					ms_path_update(t_path path, char *path_var);

/*
** env.c
*/

t_env					ms_env_from_array(char **envp);
char					**ms_env_to_array(t_env env);

/*
** builtin*.c - directory with all builtin commands
*/

int                     ms_echo(char **argv);
int                     ms_cd(t_env env, char **argv);
int                     ms_pwd(void);
int                     ms_export(t_env env, char **argv);
int                     ms_unset(t_env env, char **argv);
int                     ms_env(t_env env);
int                     ms_exit(void);

/*
** util.c - various utilitary functions
*/

void					ms_ht_del_str_entry(t_ftht_content *content);

#endif