mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
redirection parsing: define types in own files
This commit is contained in:
parent
06ebcf132a
commit
cf517bb7f8
8 changed files with 92 additions and 43 deletions
2
Makefile
2
Makefile
|
|
@ -50,7 +50,7 @@ srcs = \
|
||||||
src/parser/wordsplit/tokenizing_6_10.c \
|
src/parser/wordsplit/tokenizing_6_10.c \
|
||||||
src/parser/wordsplit/wordsplit.c \
|
src/parser/wordsplit/wordsplit.c \
|
||||||
src/parser/wordsplit/wordsplit_utils.c \
|
src/parser/wordsplit/wordsplit_utils.c \
|
||||||
src/postprocess/redirections/redirections.c \
|
src/postprocess/redirections/redirection_parsing.c \
|
||||||
|
|
||||||
objs = $(srcs:.c=.o)
|
objs = $(srcs:.c=.o)
|
||||||
export objs
|
export objs
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/21 12:24:57 by khais #+# #+# */
|
/* Created: 2025/02/21 12:24:57 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/07 12:29:16 by khais ### ########.fr */
|
/* Updated: 2025/03/07 13:12:12 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,12 +14,11 @@
|
||||||
# define SIMPLE_CMD_H
|
# define SIMPLE_CMD_H
|
||||||
|
|
||||||
# include "../wordlist/wordlist.h"
|
# include "../wordlist/wordlist.h"
|
||||||
# include "../../postprocess/redirections/redirections.h"
|
|
||||||
|
|
||||||
typedef struct s_simple_cmd
|
typedef struct s_simple_cmd
|
||||||
{
|
{
|
||||||
t_wordlist *words;
|
t_wordlist *words;
|
||||||
t_redir_list *redirections;
|
struct s_redirection_list *redirections;
|
||||||
} t_simple_cmd;
|
} t_simple_cmd;
|
||||||
|
|
||||||
t_simple_cmd *simple_cmd_from_wordlist(t_wordlist *words);
|
t_simple_cmd *simple_cmd_from_wordlist(t_wordlist *words);
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,20 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* redirections.h :+: :+: :+: */
|
/* redirection.h :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/07 11:59:31 by khais #+# #+# */
|
/* Created: 2025/03/07 14:26:06 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/07 14:23:48 by khais ### ########.fr */
|
/* Updated: 2025/03/07 14:44:12 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef REDIRECTIONS_H
|
#ifndef REDIRECTION_H
|
||||||
# define REDIRECTIONS_H
|
# define REDIRECTION_H
|
||||||
|
|
||||||
# include "../../parser/worddesc/worddesc.h"
|
# include "../../parser/worddesc/worddesc.h"
|
||||||
|
# include "redirection_type.h"
|
||||||
/*
|
|
||||||
** Type of redirection.
|
|
||||||
*/
|
|
||||||
typedef enum e_redirection_type
|
|
||||||
{
|
|
||||||
// Invalid
|
|
||||||
REDIR_INVALID,
|
|
||||||
// <
|
|
||||||
REDIR_INPUT,
|
|
||||||
// >
|
|
||||||
REDIR_OUTPUT,
|
|
||||||
// <<
|
|
||||||
REDIR_HERE_DOC,
|
|
||||||
// >>
|
|
||||||
REDIR_APPEND,
|
|
||||||
} t_redir_type;
|
|
||||||
|
|
||||||
typedef struct s_redirection
|
typedef struct s_redirection
|
||||||
{
|
{
|
||||||
|
|
@ -41,14 +25,4 @@ typedef struct s_redirection
|
||||||
t_worddesc *marker;
|
t_worddesc *marker;
|
||||||
} t_redirection;
|
} t_redirection;
|
||||||
|
|
||||||
typedef struct s_redirection_list
|
#endif // REDIRECTION_BASICS_H
|
||||||
{
|
|
||||||
t_redirection *redirection;
|
|
||||||
struct s_redirection_list *next;
|
|
||||||
} t_redir_list;
|
|
||||||
|
|
||||||
struct s_simple_cmd;
|
|
||||||
|
|
||||||
struct s_simple_cmd *parse_redirections(struct s_simple_cmd *cmd);
|
|
||||||
|
|
||||||
#endif // REDIRECTIONS_H
|
|
||||||
24
src/postprocess/redirections/redirection_list.h
Normal file
24
src/postprocess/redirections/redirection_list.h
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* redirection_list.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/03/07 14:29:32 by khais #+# #+# */
|
||||||
|
/* Updated: 2025/03/07 14:43:50 by khais ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef REDIRECTION_LIST_H
|
||||||
|
# define REDIRECTION_LIST_H
|
||||||
|
|
||||||
|
# include "redirection.h"
|
||||||
|
|
||||||
|
typedef struct s_redirection_list
|
||||||
|
{
|
||||||
|
t_redirection *redirection;
|
||||||
|
struct s_redirection_list *next;
|
||||||
|
} t_redir_list;
|
||||||
|
|
||||||
|
#endif // REDIRECTION_LIST_H
|
||||||
|
|
@ -6,12 +6,11 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/07 12:30:04 by khais #+# #+# */
|
/* Created: 2025/03/07 12:30:04 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/07 12:32:02 by khais ### ########.fr */
|
/* Updated: 2025/03/07 14:43:06 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "redirections.h"
|
#include "redirection_parsing.h"
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
struct s_simple_cmd *parse_redirections(struct s_simple_cmd *cmd)
|
struct s_simple_cmd *parse_redirections(struct s_simple_cmd *cmd)
|
||||||
{
|
{
|
||||||
20
src/postprocess/redirections/redirection_parsing.h
Normal file
20
src/postprocess/redirections/redirection_parsing.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* redirection_parsing.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/03/07 11:59:31 by khais #+# #+# */
|
||||||
|
/* Updated: 2025/03/07 14:38:30 by khais ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef REDIRECTION_PARSING_H
|
||||||
|
# define REDIRECTION_PARSING_H
|
||||||
|
|
||||||
|
# include "../../parser/simple_cmd/simple_cmd.h"
|
||||||
|
|
||||||
|
t_simple_cmd *parse_redirections(t_simple_cmd *cmd);
|
||||||
|
|
||||||
|
#endif // REDIRECTIONS_H
|
||||||
33
src/postprocess/redirections/redirection_type.h
Normal file
33
src/postprocess/redirections/redirection_type.h
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* redirection_type.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/03/07 14:37:12 by khais #+# #+# */
|
||||||
|
/* Updated: 2025/03/07 14:44:31 by khais ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef REDIRECTION_TYPE_H
|
||||||
|
# define REDIRECTION_TYPE_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Type of redirection.
|
||||||
|
*/
|
||||||
|
typedef enum e_redirection_type
|
||||||
|
{
|
||||||
|
// Invalid
|
||||||
|
REDIR_INVALID,
|
||||||
|
// <
|
||||||
|
REDIR_INPUT,
|
||||||
|
// >
|
||||||
|
REDIR_OUTPUT,
|
||||||
|
// <<
|
||||||
|
REDIR_HERE_DOC,
|
||||||
|
// >>
|
||||||
|
REDIR_APPEND,
|
||||||
|
} t_redir_type;
|
||||||
|
|
||||||
|
#endif // REDIRECTION_TYPE_H
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/07 11:55:37 by khais #+# #+# */
|
/* Created: 2025/03/07 11:55:37 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/07 12:00:13 by khais ### ########.fr */
|
/* Updated: 2025/03/07 14:43:15 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "../src/parser/simple_cmd/simple_cmd.h"
|
#include "../src/parser/simple_cmd/simple_cmd.h"
|
||||||
#include "../src/parser/wordsplit/wordsplit.h"
|
#include "../src/parser/wordsplit/wordsplit.h"
|
||||||
#include "../src/postprocess/redirections/redirections.h"
|
#include "../src/postprocess/redirections/redirection_parsing.h"
|
||||||
|
|
||||||
static t_simple_cmd *parse_simple_cmd(char *input)
|
static t_simple_cmd *parse_simple_cmd(char *input)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue