saved changes before repartition
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/08/01 17:18:21 by sede-san #+# #+# */
|
||||
/* Updated: 2025/08/02 17:55:22 by sede-san ### ########.fr */
|
||||
/* Updated: 2025/08/20 22:22:40 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -16,18 +16,12 @@
|
||||
# include <string.h>
|
||||
# include <stdio.h>
|
||||
|
||||
typedef int (*t_builtin_func)(int argc, char const *argv[]);
|
||||
|
||||
typedef struct s_builtin
|
||||
{
|
||||
const char *name;
|
||||
t_builtin_func function;
|
||||
} t_builtin;
|
||||
|
||||
// cd.c
|
||||
|
||||
int cd_builtin(int argc, char const *argv[]);
|
||||
|
||||
# define CD_HELP
|
||||
|
||||
// echo.c
|
||||
|
||||
typedef struct s_echo_flags
|
||||
@@ -37,24 +31,40 @@ typedef struct s_echo_flags
|
||||
|
||||
int echo_builtin(int argc, char const *argv[]);
|
||||
|
||||
// env.c
|
||||
# define ECHO_HELP
|
||||
|
||||
int env_builtin(int argc, char const *argv[]);
|
||||
// // env.c
|
||||
|
||||
// int env_builtin(int argc, char const *argv[], char **envp);
|
||||
|
||||
// exit.c
|
||||
|
||||
int exit_builtin(int argc, char const *argv[]);
|
||||
|
||||
# define EXIT_HELP
|
||||
|
||||
// export.c
|
||||
|
||||
int export_builtin(int argc, char const *argv[]);
|
||||
int export_builtin(int argc, char const *argv[], char **envp);
|
||||
|
||||
# define EXPORT_HELP
|
||||
|
||||
// printenv.c
|
||||
|
||||
int printenv_builtin(int argc, char const *argv[], char const *envp[]);
|
||||
|
||||
# define PRINTENV_HELP
|
||||
|
||||
// pwd.c
|
||||
|
||||
int pwd_builtin(int argc, char const *argv[]);
|
||||
|
||||
# define PWD_HELP
|
||||
|
||||
// unset.c
|
||||
|
||||
int unset_builtin(int argc, char const *argv[]);
|
||||
int unset_builtin(int argc, char const *argv[], char **envp);
|
||||
|
||||
# define UNSET_HELP
|
||||
|
||||
#endif
|
||||
|
||||
20
include/history.h
Normal file
20
include/history.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* history.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/08/20 22:07:04 by sede-san #+# #+# */
|
||||
/* Updated: 2025/08/21 14:43:08 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef HISTORY_H
|
||||
# define HISTORY_H
|
||||
|
||||
|
||||
|
||||
// history.c
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/31 03:42:51 by sede-san #+# #+# */
|
||||
/* Updated: 2025/08/03 22:56:35 by sede-san ### ########.fr */
|
||||
/* Updated: 2025/08/21 14:55:18 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# define MINISHELL_H
|
||||
|
||||
# include "builtins.h"
|
||||
# include "history.h"
|
||||
# include "libft.h"
|
||||
# include "get_next_line.h"
|
||||
# include <fcntl.h>
|
||||
@@ -26,32 +27,61 @@ typedef struct s_cmd
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
char **envp;
|
||||
} t_cmd;
|
||||
} t_cmd;
|
||||
|
||||
# define HISTORY_FILE "/.minishell_history"
|
||||
typedef struct s_history
|
||||
{
|
||||
char *hist_file;
|
||||
size_t hist_file_size;
|
||||
t_cdlist hist;
|
||||
size_t hist_size;
|
||||
} t_history;
|
||||
|
||||
typedef struct s_minishell
|
||||
{
|
||||
char *history_file;
|
||||
char **envp;
|
||||
} t_minishell;
|
||||
char **envp;
|
||||
t_history *history;
|
||||
char *history_file;
|
||||
} t_minishell;
|
||||
|
||||
/* ******************************** Features ******************************** */
|
||||
|
||||
/* History */
|
||||
|
||||
// history.c
|
||||
void ms_add_history(const char *line);
|
||||
int ms_read_history(const char *hist_file);
|
||||
void ms_write_history(const char *hist_file);
|
||||
|
||||
/* ******************************* Commands ********************************* */
|
||||
|
||||
typedef int (*t_msh_cmdfunc)(char **args, char **env, t_minishell* minshell);
|
||||
// command_utils.c
|
||||
|
||||
int is_absolutepath(char const *cmd);
|
||||
int is_builtin(t_cmd *cmd);
|
||||
int is_local(char const *cmd);
|
||||
|
||||
// exec.c
|
||||
|
||||
int exec_cmd(char *cmd, char **args, t_minishell *minishell);
|
||||
int exec_cmd(t_cmd *cmd, char **envp);
|
||||
int exec_builtin(t_cmd *cmd, char **envp);
|
||||
|
||||
// parse.c
|
||||
|
||||
t_cmd parse_cmd(char *line, t_minishell *minishell);
|
||||
|
||||
// signals.c
|
||||
|
||||
void init_signal(void);
|
||||
|
||||
/* ********************************* Utils ********************************** */
|
||||
|
||||
// get_hostname.c
|
||||
char *get_hostname(void);
|
||||
|
||||
/* ******************************** Builtins ******************************** */
|
||||
|
||||
// builtin_utils.c
|
||||
int is_builtin(t_cmd *cmd);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user