Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions includes/leaks.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef LEAKS_H
#define LEAKS_H
# define LEAKS_H

#include <stdlib.h>
# include <stdlib.h>

void end(void) __attribute__((destructor));


# endif
#endif
22 changes: 11 additions & 11 deletions includes/libft.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
# include <errno.h>
# include <limits.h>

#define __GNU_SOURCE
# define __GNU_SOURCE
# include <unistd.h>

#define EQUAL 0
#define FAIL -1
# define EQUAL 0
# define FAIL -1

typedef struct s_dlist
typedef struct s_dlist
{
struct s_dlist *prev;
void *content;
struct s_dlist *next;
} t_dlist;

typedef struct s_list
typedef struct s_list
{
void *content;
struct s_list *next;
Expand Down Expand Up @@ -51,10 +51,10 @@ int ft_issnack_case(int n);
int ft_toupper(int c);
int ft_tolower(int c);
void *ft_calloc(size_t count, size_t size);
char **ft_calloc2(size_t nmemb, size_t size);
char ***ft_calloc3(size_t nmemb, size_t size);
char **ft_realloc2(char **old, char *add);
char ***ft_realloc3(char ***old, char **add);
char **ft_calloc2(size_t nmemb, size_t size);
char ***ft_calloc3(size_t nmemb, size_t size);
char **ft_realloc2(char **old, char *add);
char ***ft_realloc3(char ***old, char **add);
char *ft_strdup(const char *src);
char *ft_substr(char const *s, size_t start, size_t len);
void ft_charjoin(char **old, char c);
Expand All @@ -75,8 +75,8 @@ void ft_lstadd_back(t_list **lst, t_list *new);
void ft_lstdelone(t_list *lst, void (*del)(void *));
void ft_lstclear(t_list **lst, void (*del)(void *));
void ft_lstiter(t_list *lst, void (*f)(void *));
t_list *ft_lstmap(t_list *lst, void *(*f)(void *),
void (*del)(void *));
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), \
void (*del)(void *));
int ft_setenv(char *name, char *value);
int ft_unsetenv(char *name);
char *ft_getenv(char *name);
Expand Down
188 changes: 98 additions & 90 deletions includes/minishell.h
Original file line number Diff line number Diff line change
@@ -1,109 +1,118 @@
#ifndef MINISHELL_H
#define MINISHELL_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <limits.h>
#include <signal.h>
#include <termios.h>
#include <termcap.h>
#include <ctype.h>
#include "queue.h"
#include "libft.h"

#define CTRL_SPACE 0
#define CTRLV 22
#define CTRLX 24
#define CTRLY 25
#define CTRLC 3
#define CTRLD 4
#define TAB 9
#define LF 10
#define ESC 27
#define DEL 126
#define BKS 127

#define SUCCESS 1
#define END 0
#define ERROR -1
#define FAIL -1
#define INIT -1
#define OUTOFRANGE -2
#define BUFFER_SIZE 1024
#define HASH_SIZE 29999

#define TRUE 1
#define FALSE 0

typedef enum u_token t_token;
typedef enum u_operator t_operator;
typedef enum u_exec_env t_exec_env;
# define MINISHELL_H

# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <stdbool.h>
# include <fcntl.h>
# include <unistd.h>
# include <errno.h>
# include <sys/ioctl.h>
# include <sys/wait.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <dirent.h>
# include <limits.h>
# include <signal.h>
# include <termios.h>
# include <termcap.h>
# include <ctype.h>
# include "queue.h"
# include "libft.h"

# define CTRL_SPACE 0
# define CTRLV 22
# define CTRLX 24
# define CTRLY 25
# define CTRLC 3
# define CTRLD 4
# define TAB 9
# define LF 10
# define ESC 27
# define DEL 126
# define BKS 127

# define SUCCESS 1
# define END 0
# define ERROR -1
# define FAIL -1
# define INIT -1
# define OUTOFRANGE -2
# define BUFFER_SIZE 1024
# define HASH_SIZE 29999

# define TRUE 1
# define FALSE 0

typedef enum e_token t_token;
typedef enum e_operator t_operator;
typedef enum e_exec_env t_exec_env;
typedef struct s_pos t_pos;
typedef struct s_ip t_ip;
typedef struct s_data t_data;
typedef struct s_gmr t_gmr;
typedef struct s_shell t_shell;
typedef struct s_stdfd t_stdfd;

enum u_token
typedef struct s_stdfd t_stdfd;

/*
* pipe : |
* redirect : >>, >, <, *, /
* left_brace : {
* right_brace : }
* semicolon : ;
* and : &
* andand : &&
* oror : ||
* identify : string
* input_end : end of input
* err : error
* token_num : dont care
*/
enum e_token
{
PIPE, // |
REDIRECT, // >>, >, <
LEFT_BRACE, // {
RIGHT_BRACE,// }
SEMICOLON, // ;
AND, // &
ANDAND, // &&
OROR, // ||
IDENTIFY, // String
INPUT_END, // End Of Input
ERR, // ERROR

TOKEN_NUM // don't care
PIPE,
REDIRECT,
LEFT_BRACE,
RIGHT_BRACE,
SEMICOLON,
AND,
ANDAND,
OROR,
IDENTIFY,
INPUT_END,
ERR,
TOKEN_NUM
};

enum u_operator
enum e_operator
{
ANDAND_OP,
OROR_OP,
NEWLINE_OP
};

enum u_exec_env
enum e_exec_env
{
MAINSHELL,
SUBSHELL
};

struct s_shell
{
t_list *var[HASH_SIZE];
t_dlist *hist_lst;
char *histfile_path;
char *clipboard_path;
int exit_status;
char *pwd;
t_list *var[HASH_SIZE];
t_dlist *hist_lst;
char *histfile_path;
char *clipboard_path;
int exit_status;
char *pwd;
};

struct s_pos
struct s_pos
{
int cursor;
int max_rg;
int max_lf;

bool is_select;
int select;
t_dlist *selectp;
int cursor;
int max_rg;
int max_lf;
bool is_select;
int select;
t_dlist *selectp;
};

struct s_ip
Expand All @@ -129,22 +138,21 @@ struct s_gmr

struct s_stdfd
{
int in;
int out;
int err;
int in;
int out;
int err;
};


// minishell
void minishell_end(t_shell *shell);

// prompt
void prompt(char *ps, t_dlist **line, t_shell *shell);
void term_mode(char *p, int arg_cols, int arg_rows);

// prompt_utils
// prompt_utils
void insert(t_dlist **lst, char c, t_pos *pos);
void backspace(t_pos *pos, t_dlist **cursor);
void backspace(t_pos *pos, t_dlist **cursor);
void esc(t_pos *pos, t_dlist **cursor, t_shell *shell);
void init_pos(t_pos *pos, char *ps);
void delete(t_pos *pos, t_dlist **cursor);
Expand Down
11 changes: 5 additions & 6 deletions includes/queue.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#ifndef QUEUE_H
#define QUEUE_H
# define QUEUE_H

#include <stdio.h>
#include <stdbool.h>
#include "libft.h"
# include <stdio.h>
# include <stdbool.h>
# include "libft.h"

typedef t_list * t_queue;
typedef t_list *t_queue;

void enq(t_queue *this, void *value);
//void *deq(t_queue *this, void (*del)(void *));
void *deq(t_queue *this);
void *front(t_queue *this);
int q_size(t_queue *this);
Expand Down
Loading