📝」 doc: Added doc in .h for parsing and tokenizer

This commit is contained in:
2024-05-19 14:21:03 +02:00
parent 10915c369c
commit c4c8ca8bf1
3 changed files with 120 additions and 3 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */ /* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
/* Updated: 2024/05/18 20:50:05 by adjoly ### ########.fr */ /* Updated: 2024/05/19 13:45:01 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,8 +14,7 @@
# define PARSING_H # define PARSING_H
# include "libft.h" # include "libft.h"
# include "tokenizer.h"
# define HEREDOC_FD -2
typedef struct s_cmd typedef struct s_cmd
{ {
@ -25,7 +24,18 @@ typedef struct s_cmd
int outfile; int outfile;
} t_cmd; } t_cmd;
/**
* @brief Take the argv of a command a split the argv and the command it self
*
* @param The full argv of the command
*
* @return (t_cmd *) cmd and argv splited into a struct
*/
t_cmd *split_cmd(char *cmd_av); t_cmd *split_cmd(char *cmd_av);
/*
* @deprecated
*/
t_list *split_pipe(char *readline); t_list *split_pipe(char *readline);
#endif #endif

39
include/prompt.h Normal file
View File

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* prompt.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/19 13:48:05 by adjoly #+# #+# */
/* Updated: 2024/05/19 14:20:45 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PROMPT_H
# define PROMPT_H
/**
* @brief return the short hostname from /etc/hostname
* or return nixos if file doesn't exist or is empty
*
* @return (char *) The short hostname
*/
char *get_hostname(void);
/**
* @brief return the pwd (from the env), and if in home put a ~
* replacing the home directory
*
* @return (char *) the pwd
*/
char *get_pwd(void);
/**
* @brief return the full prompt
*
* @prompt (char *) the prompt
*/
char *get_prompt(void);
#endif

68
include/tokenizer.h Normal file
View File

@ -0,0 +1,68 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tokenizer.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/18 20:14:15 by adjoly #+# #+# */
/* Updated: 2024/05/19 14:02:58 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TOKENIZER_H
# define TOKENIZER_H
# include "libft.h"
# include <stdbool.h>
typedef enum s_redirection_sign
{
HEREDOC,
INFILE,
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;
/**
* @brief Convert the raw command into a t_token that contains the argv of the command an a linked list of redirection
*
* @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);
/**
* @brief **
*
* @param
*
* @return ()
*
*/
/**
* @brief Convert the readline output, split all command and put it in linked list of t_token (given by t_token function)
*
* @param readline The readline output
*
* @return (t_list *) Linked list of t_token
*
*/
t_list *tokenizer(char *readline);
#endif