feat: added internal variables
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/29 22:09:51 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/08 19:42:50 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/14 01:15:34 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# include "ft_args.h"
|
||||
# include "minishell.h"
|
||||
# include "core.h"
|
||||
# include "variables.h"
|
||||
|
||||
typedef uint8_t (*t_builtin_func)(t_command cmd, t_minishell *minishell);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/22 19:10:13 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/13 20:06:08 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/14 01:25:43 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -63,15 +63,9 @@ typedef struct s_redirection
|
||||
typedef struct s_variables
|
||||
{
|
||||
t_hashmap *environment;
|
||||
// char **internal;
|
||||
t_hashmap *internal;
|
||||
} t_variables;
|
||||
|
||||
typedef struct s_prompt
|
||||
{
|
||||
const char *ps1; // primary prompt string
|
||||
const char *ps2; // secondary prompt string for multiline input
|
||||
} t_prompt;
|
||||
|
||||
/**
|
||||
* @brief Main minishell structure containing global state information
|
||||
*
|
||||
@@ -84,7 +78,6 @@ typedef struct s_minishell
|
||||
{
|
||||
t_variables variables;
|
||||
t_hashmap *builtins;
|
||||
t_prompt prompt;
|
||||
uint8_t exit_status;
|
||||
bool exit;
|
||||
} t_minishell;
|
||||
@@ -149,8 +142,8 @@ extern char **get_envp(t_minishell *msh);
|
||||
|
||||
extern void free_envp(char **envp);
|
||||
|
||||
extern char *get_env(const char *env_name, t_minishell *msh);
|
||||
void handle_sigint_status(t_minishell *minishell);
|
||||
bool handle_eof(char *line, t_minishell *minishell);
|
||||
|
||||
extern void unset_env(const char *env_name, t_minishell *msh);
|
||||
|
||||
#endif /* CORE_H */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/02/10 22:28:01 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/10 23:24:16 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/14 01:11:38 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
|
||||
extern void syntax_error_unexpected_token(t_token *token);
|
||||
extern void malloc_error(void);
|
||||
extern void command_not_found_error(const char *command);
|
||||
|
||||
#endif /* ERRORS_H */
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/20 16:35:10 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/13 20:12:25 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/14 01:13:42 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -42,7 +42,4 @@
|
||||
# include <term.h> // tgetent(3), tgetflag(3), tgetnum(3),
|
||||
// tgetstr(3), tgoto(3), tputs(3)
|
||||
|
||||
void handle_sigint_status(t_minishell *minishell);
|
||||
bool handle_eof(char *line, t_minishell *minishell);
|
||||
|
||||
#endif /* MINISHELL_H */
|
||||
|
||||
43
include/variables.h
Normal file
43
include/variables.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* variables.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/02/13 21:45:35 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/14 01:24:49 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef VARIABLES_H
|
||||
# define VARIABLES_H
|
||||
|
||||
# include "minishell.h"
|
||||
# include "core.h"
|
||||
|
||||
// variables.c
|
||||
|
||||
extern char *get_var(const char *name, t_minishell *minishell);
|
||||
extern void set_var(const char *name, char *value, t_minishell *minishell);
|
||||
extern void unset_var(const char *name, t_minishell *minishell);
|
||||
|
||||
// environment.c
|
||||
|
||||
extern char *get_env(const char *name, t_minishell *minishell);
|
||||
extern void set_env(const char *name, char *value, t_minishell *minishell);
|
||||
extern void unset_env(const char *name, t_minishell *minishell);
|
||||
|
||||
extern void set_envp(char **envp, t_minishell *minishell);
|
||||
extern char **get_envp(t_minishell *minishell);
|
||||
extern void free_envp(char **envp);
|
||||
|
||||
// internal.c
|
||||
|
||||
extern char *get_int(const char *name, t_minishell *minishell);
|
||||
extern void set_int(const char *name, char *value, t_minishell *minishell);
|
||||
extern void unset_int(const char *name, t_minishell *minishell);
|
||||
|
||||
extern void set_intp(t_minishell *minishell);
|
||||
|
||||
#endif /* VARIABLES_H */
|
||||
Reference in New Issue
Block a user