This commit is contained in:
LuckyLaszlo
2021-10-03 19:17:19 +02:00
commit 93de7422bf
7 changed files with 158 additions and 0 deletions

15
.gitignore vendored Normal file
View File

@@ -0,0 +1,15 @@
.DS_Store
*.o
*.swp
*.out
*.exe
*.stackdump
*.a
*.so
*.dSYM
.vscode
*.lnk
memo
memo.txt
minishell
*.zip

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "libft"]
path = libft
url = https://github.com/LuckyLaszlo/libft

63
Makefile Normal file
View File

@@ -0,0 +1,63 @@
NAME = minishell
CC = clang
CFLAGS = -Wall -Wextra -Werror $(INCLUDES) -g
VPATH = $(DIR_SRCS)
DIR_SRCS = src
INCLUDES = -I$(HEADERS_D) -I$(LIBFT_D)
HEADERS_D = ./header
HEADERS = minishell.h
LIBS = -L $(LIBFT_D) -lft \
-lreadline
LIBFT_D = ./libft
LIBFT = $(LIBFT_D)/libft.a
SRCS = main.c
DIR_OBJS = builds
OBJS = $(SRCS:%.c=$(DIR_OBJS)/%.o)
# --------------------
# ------ RULES -------
# --------------------
all: subsystem $(NAME)
subsystem:
@cd $(LIBFT_D) && $(MAKE)
$(LIBFT): # dispensable. utile seulement pour un appel direct à $(NAME), si $(LIBFT) n'existe pas
cd $(LIBFT_D) && $(MAKE)
$(DIR_OBJS)/%.o: %.c | $(DIR_OBJS)
$(CC) $(CFLAGS) -c $< -o $@
$(DIR_OBJS):
mkdir $@
$(OBJS): $(HEADERS:%=$(HEADERS_D)/%)
$(NAME): $(OBJS) $(LIBFT)
$(CC) $(OBJS) -o $(NAME) $(LIBS)
clean:
rm -f $(OBJS)
fclean: clean
rm -f $(NAME)
re: fclean all
valgrind: $(NAME)
valgrind --leak-check=full --leak-resolution=low --show-reachable=yes ./$(NAME)
run: $(NAME)
./$(NAME)
.PHONY : all clean fclean re bonus subsystem run valgrind

69
header/minishell.h Normal file
View File

@@ -0,0 +1,69 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/03 19:14:46 by lperrey #+# #+# */
/* Updated: 2021/10/03 19:14:49 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_H
# define MINISHELL_H
# include "libft.h"
# include <fcntl.h>
# include <unistd.h>
# include <stdlib.h>
# include <string.h>
# include <errno.h>
# include <sys/wait.h>
# include <sys/stat.h>
# include <sys/types.h>
# include <sys/time.h>
# include <sys/resource.h>
# include <signal.h>
# include <dirent.h>
# include <termios.h>
# include <curses.h>
# include <term.h>
# include <stdio.h>
# include <readline/readline.h> // sudo apt install libreadline-dev
# include <readline/history.h>
/*
** <stdio.h>: printf(), perror(), readline()
** <unistd.h>: access(), unlink()
** <signal.h>: sigaction()
** <readline/readline.h>,
** <readline/history.h>,
** lib readline (-lreadline),
** readline(), rl_clear_history(), rl_on_new_line(),
** rl_replace_line(), rl_redisplay(), add_history()
** ------------------
** <fcntl.h>: open()
** <unistd.h>: read(), write(), close(), fork(), getcwd(), chdir(),
** stat(), lstat(), fstat(), execve(), dup(), dup2(), pipe(),
** isatty(), ttyname(), ttyslot(), ioctl(),
** tcsetattr(), tcgetattr()
** <stdlib.h>: malloc(), free(), exit(), getenv()
** <string.h>: strerror(), define NULL, define size_t
** <errno.h>: define errno
** <sys/wait.h>: wait(), waitpid()
** <sys/resource.h>,
** <sys/time.h>: wait3(), wait4()
** <signal.h>: signal(), kill()
** <dirent.h>: opendir(), readdir(), closedir()
** <termios.h>: tcsetattr(), tcgetattr()
** <curses.h>,
** <term.h>: tgetent(), tgetflag(), tgetnum(),
** tgetstr(), tgoto(), tputs()
** ------------------
** <sys/stat.h>: open(), stat(), lstat(), fstat()
** <sys/types.h>: open(), wait(), waitpid(), wait3(), wait4(), kill()
** stat(), lstat(), fstat(), opendir(), closedir()
*/
#endif

1
libft Submodule

Submodule libft added at 1401fddfcd

BIN
minishell.en.subject.pdf Normal file

Binary file not shown.

7
src/main.c Normal file
View File

@@ -0,0 +1,7 @@
#include "minishell.h"
int main(void)
{
return (0);
}