structure: moved core functions (init, run, clear) to core.h to prevent circular include
This commit is contained in:
52
include/core.h
Normal file
52
include/core.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* core.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/10/22 19:10:13 by sede-san #+# #+# */
|
||||||
|
/* Updated: 2025/10/22 19:27:19 by sede-san ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef CORE_H
|
||||||
|
# define CORE_H
|
||||||
|
|
||||||
|
# include "minishell.h"
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* Structures & Data Types */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
typedef struct s_minishell t_minishell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Main minishell structure containing global state information
|
||||||
|
*
|
||||||
|
* This structure holds the essential data for the minishell program,
|
||||||
|
* including the environment variables and the exit status of the last
|
||||||
|
* executed command.
|
||||||
|
*
|
||||||
|
* @param env Array of environment variable strings in "KEY=VALUE" format
|
||||||
|
* @param exit_status Exit status code of the last executed command (0-255)
|
||||||
|
*/
|
||||||
|
typedef struct s_minishell
|
||||||
|
{
|
||||||
|
char **env;
|
||||||
|
u_int8_t exit_status;
|
||||||
|
} t_minishell;
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* Functions */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/* minishell.c */
|
||||||
|
|
||||||
|
extern int minishell_init(t_minishell *minishell, char **envp);
|
||||||
|
|
||||||
|
extern u_int8_t minishell_run(t_minishell *minishell);
|
||||||
|
|
||||||
|
extern void minishell_clear(t_minishell *minishell);
|
||||||
|
|
||||||
|
#endif /* CORE_H */
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/10/20 16:35:10 by sede-san #+# #+# */
|
/* Created: 2025/10/20 16:35:10 by sede-san #+# #+# */
|
||||||
/* Updated: 2025/10/22 16:59:56 by sede-san ### ########.fr */
|
/* Updated: 2025/10/22 19:19:46 by sede-san ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
# define MINISHELL_H
|
# define MINISHELL_H
|
||||||
|
|
||||||
# include "libft.h"
|
# include "libft.h"
|
||||||
|
# include "core.h"
|
||||||
# include <readline/readline.h> // readline(3), rl_clear_history(),
|
# include <readline/readline.h> // readline(3), rl_clear_history(),
|
||||||
// rl_on_new_line(), rl_replace_line(),
|
// rl_on_new_line(), rl_replace_line(),
|
||||||
// rl_redisplay()
|
// rl_redisplay()
|
||||||
@@ -36,24 +37,4 @@
|
|||||||
# include <term.h> // tgetent(3), tgetflag(3), tgetnum(3),
|
# include <term.h> // tgetent(3), tgetflag(3), tgetnum(3),
|
||||||
// tgetstr(3), tgoto(3), tputs(3)
|
// tgetstr(3), tgoto(3), tputs(3)
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Structures & Data Types */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
typedef struct s_minishell t_minishell;
|
|
||||||
|
|
||||||
typedef struct s_minishell
|
|
||||||
{
|
|
||||||
char **env;
|
|
||||||
u_int8_t exit_status;
|
|
||||||
} t_minishell;
|
|
||||||
|
|
||||||
/* core/minishell.c */
|
|
||||||
|
|
||||||
extern int minishell_init(struct s_minishell *minishell, char **envp);
|
|
||||||
|
|
||||||
extern u_int8_t minishell_run(struct s_minishell *minishell);
|
|
||||||
|
|
||||||
extern void minishell_clear(struct s_minishell *minishell);
|
|
||||||
|
|
||||||
#endif /* MINISHELL_H */
|
#endif /* MINISHELL_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user