2024-05-19 14:21:03 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* tokenizer.h :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2024/05/18 20:14:15 by adjoly #+# #+# */
|
2024-05-23 20:53:07 +02:00
|
|
|
/* Updated: 2024/05/23 12:11:42 by adjoly ### ########.fr */
|
2024-05-19 14:21:03 +02:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2024-05-23 20:53:07 +02:00
|
|
|
#ifndef TOKENIZER_H
|
2024-05-19 14:21:03 +02:00
|
|
|
# define TOKENIZER_H
|
|
|
|
|
|
|
|
# include "libft.h"
|
|
|
|
|
2024-05-23 20:53:07 +02:00
|
|
|
typedef enum s_redirection_sign
|
2024-05-19 14:21:03 +02:00
|
|
|
{
|
|
|
|
INFILE,
|
2024-05-23 20:53:07 +02:00
|
|
|
HEREDOC,
|
2024-05-19 14:21:03 +02:00
|
|
|
OUTFILE,
|
|
|
|
OUT_APPEND,
|
|
|
|
} t_redirection_sign;
|
|
|
|
|
|
|
|
typedef struct s_redirection
|
|
|
|
{
|
|
|
|
char *file_name;
|
|
|
|
t_redirection_sign sign;
|
|
|
|
} t_redirection;
|
|
|
|
|
|
|
|
typedef struct s_token
|
|
|
|
{
|
|
|
|
char *argv;
|
|
|
|
t_list *redirection;
|
|
|
|
} t_token;
|
|
|
|
|
|
|
|
/**
|
2024-05-23 20:53:07 +02:00
|
|
|
* @brief Convert the raw command into a t_token that contains
|
|
|
|
* the argv of the command an a linked list of redirection
|
2024-05-19 14:21:03 +02:00
|
|
|
*
|
|
|
|
* @param cmd A string that containt the command to tokenize
|
|
|
|
*
|
|
|
|
* @return (t_token *) The tokenized version of the command
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
t_token *__to_token(char *cmd);
|
|
|
|
|
|
|
|
/**
|
2024-05-23 20:53:07 +02:00
|
|
|
* @brief
|
2024-05-19 14:21:03 +02:00
|
|
|
*
|
2024-05-23 20:53:07 +02:00
|
|
|
* @param The readline output
|
2024-05-19 14:21:03 +02:00
|
|
|
*
|
2024-05-23 20:53:07 +02:00
|
|
|
* @return (t_list *) A linked lst of all the command splited
|
2024-05-19 14:21:03 +02:00
|
|
|
*
|
|
|
|
*/
|
2024-05-23 20:53:07 +02:00
|
|
|
t_list *__split_pipe(char *readline);
|
2024-05-19 14:21:03 +02:00
|
|
|
|
|
|
|
/**
|
2024-05-23 20:53:07 +02:00
|
|
|
* @brief Convert the readline output, split all command and put
|
|
|
|
* it in linked list of t_token (given by t_token function)
|
2024-05-19 14:21:03 +02:00
|
|
|
*
|
|
|
|
* @param readline The readline output
|
|
|
|
*
|
|
|
|
* @return (t_list *) Linked list of t_token
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
t_list *tokenizer(char *readline);
|
|
|
|
|
|
|
|
#endif
|