aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-03-30 22:27:16 +0200
committerCharles <sircharlesaze@gmail.com>2020-03-30 22:27:16 +0200
commit941099778b59da6b904c284e8a82affe4766124b (patch)
tree4457787a1b09408fcd1a5607109cc1c902c80af8
parent74787eefa2ac85d85b484d0ca5dffc6a2a13331d (diff)
downloadminishell-941099778b59da6b904c284e8a82affe4766124b.tar.gz
minishell-941099778b59da6b904c284e8a82affe4766124b.tar.bz2
minishell-941099778b59da6b904c284e8a82affe4766124b.zip
Added doc
-rw-r--r--Doxyfile8
-rw-r--r--Makefile2
-rw-r--r--README.md7
-rw-r--r--include/minishell.h15
-rw-r--r--include/ms_eval.h67
-rw-r--r--include/ms_parse.h83
m---------libft0
-rw-r--r--src/builtin/cd.c5
-rw-r--r--src/builtin/echo.c5
-rw-r--r--src/builtin/env.c5
-rw-r--r--src/builtin/exit.c4
-rw-r--r--src/builtin/export.c5
-rw-r--r--src/builtin/pwd.c4
-rw-r--r--src/builtin/unset.c5
-rw-r--r--src/env.c21
-rw-r--r--src/eval/eval.c (renamed from src/eval.c)49
-rw-r--r--src/eval/read.c89
-rw-r--r--src/eval/val.c69
-rw-r--r--src/main.c13
-rw-r--r--src/parse/ast.c63
-rw-r--r--src/parse/lexer.c5
-rw-r--r--src/parse/parse.c5
-rw-r--r--src/path.c24
-rw-r--r--src/utils.c (renamed from src/util.c)10
24 files changed, 442 insertions, 121 deletions
diff --git a/Doxyfile b/Doxyfile
index 1ef803b..5678aa2 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -275,7 +275,7 @@ TCL_SUBST =
# members will be omitted, etc.
# The default value is: NO.
-OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_FOR_C = YES
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
# Python sources only. Doxygen will then generate output that is more tailored
@@ -323,7 +323,7 @@ OPTIMIZE_OUTPUT_SLICE = NO
# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
# the files are not read by doxygen.
-EXTENSION_MAPPING =
+EXTENSION_MAPPING = .c=C .h=C
# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
# according to the Markdown format, which allows for more readable
@@ -491,7 +491,7 @@ EXTRACT_PACKAGE = NO
# included in the documentation.
# The default value is: NO.
-EXTRACT_STATIC = NO
+EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO,
@@ -829,7 +829,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
-INPUT = src include
+INPUT = src include libft/src libft/include
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
diff --git a/Makefile b/Makefile
index fb00518..57a4f39 100644
--- a/Makefile
+++ b/Makefile
@@ -85,8 +85,10 @@ libft_clean:
libft_fclean:
$(MAKE) -C $(LIBFTDIR) fclean
+.PHONY: doc
doc:
$(DOXYGEN) $(DOXYGEN_FILE)
+.PHONY: doc_clean
doc_clean:
$(RM) -r $(DOC_DIR)
diff --git a/README.md b/README.md
index 1b31543..4ab2ad4 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,11 @@ minishell project of school 42
>make test
```
+## Documentation
+
+Generate with `make doc` (clean with `make doc_clean`).
+You can then read the man pages in ./doc/man or open ./doc/html/index.html in your browser.
+
## TODO
### Mandatory
@@ -26,7 +31,7 @@ minishell project of school 42
- [ ] `'` and `"` should work like in bash except for multiline commands
- [ ] Redirections `<` `>` `>>` should work like in bash except for file descriptor aggregation
- [ ] Pipes | should work like in bash
-- [ ] Environment variables (`$` followed by characters) should work like in bash
+- [ ] Environment variables (`$` followed by characters) should work like in bash
- [ ] `$?` should work like in bash
- [ ] `ctrl-C`, `ctrl-D` and `ctrl-\` should have the same result as in bash
diff --git a/include/minishell.h b/include/minishell.h
index 04ab243..9931b15 100644
--- a/include/minishell.h
+++ b/include/minishell.h
@@ -14,6 +14,11 @@
#ifndef MINISHELL_H
# define MINISHELL_H
+/**
+** \file minishell.h
+** \brief Common header
+*/
+
# include <stdlib.h>
# include <string.h>
# include <unistd.h>
@@ -31,8 +36,16 @@
# include "ms_parse.h"
-# define MS_PATH_KEY "PATH"
+/**
+** \brief Pipe write index
+*/
+
# define MS_PIPE_WRITE 1
+
+/**
+** \brief Pipe read index
+*/
+
# define MS_PIPE_READ 0
typedef t_ftht* t_path;
diff --git a/include/ms_eval.h b/include/ms_eval.h
index 35e7355..12c2b7e 100644
--- a/include/ms_eval.h
+++ b/include/ms_eval.h
@@ -1,6 +1,11 @@
#ifndef MS_EVAL_H
# define MS_EVAL_H
+/**
+** \file ms_eval.h
+** \brief Evaluation module
+*/
+
/*
** arg:
** type ARG
@@ -19,33 +24,53 @@
** value fd
*/
-read state
- if redir:
- open file keep fd
+/**
+** \enum t_val_type
+** \brief A type for an evaluation node
+**
+** \param VAL_ERR error
+** \param VAL_ERR argument
+** \param VAL_REDIR redirection
+** \param VAL_SEXPR S-expression
+*/
+typedef enum
+{
+ VAL_ERR,
+ VAL_ARG,
+ VAL_EXEC,
+ VAL_REDIR_IN,
+ VAL_REDIR_OUT,
+ VAL_REDIR_APPEND,
+ VAL_CMD,
+ VAL_SEXPR,
+} t_val_type;
+
+/**
+** \brief An evaluation node struct
+** \param type type of node
+** \param data union of possible data
+** \param data::fd file descriptor for redirection node
+** \param data::str string for error, arguments, command
+*/
typedef struct
{
- t_status_type type;
+ t_val_type type;
union
{
- char *str;
- int code;
- int fd;
- } data;
-} t_val;
-
-
+ char *str;
+ int code;
+ int fd;
+ } data;
+} t_val;
-typedef enum
-{
- STYPE_ERROR,
- STYPE_ARG,
- STYPE_FILE,
- STYPE_SEXPR,
- // ...
-} t_status_type;
-
-int ms_eval(t_path path, t_env env, t_ast *ast);
+/**
+** \brief evaluate an AST
+** \param path path to commands executable
+** \param env environment variables
+** \param ast Abstract syntax tree to evaluate
+*/
+int ms_eval(t_path path, t_env env, t_ast *ast);
#endif
diff --git a/include/ms_parse.h b/include/ms_parse.h
index 74604e5..0810ec2 100644
--- a/include/ms_parse.h
+++ b/include/ms_parse.h
@@ -15,67 +15,49 @@
# include "minishell.h"
-/*
-** Context free grammar:
+/**
+** \file ms_parse.h
+** \brief Input parsing and AST manipulation
**
+** Context free grammar:
+** ```
** redir_in ::= '<' <string>
** redir_out ::= '>' <string>
** redir_append ::= '>>' <string>
** string ::= '\'' .+ '\'' | '"' .+ '"' | [^ ]+
** sep ::= '&&' | '||' | '|' | ';'
** expr ::= <redir_in> | <redir_out> | <redir_append> | <string>
-** sexpr ::= <expr>+
-** line ::= <sexpr> <sep> <line> | <sexpr>
+** cmd ::= <expr>+
+** line ::= <cmd> <sep> <line> | <cmd>
+** ```
*/
-/*
-** TAG_CMD: command name
-** TAG_ARG: command argument
-** TAG_ENDCMD: `;`
-** TAG_PIPE: `|`
-** TAG_AND: `&&`
-** TAG_OR: `||`
-** TAG_REDIR_OUT: `>`
-** TAG_REDIR_IN: `<`
-** TAG_REDIR_APPEND: `>>`
+/**
+** \brief AST node tag
+** \param TAG_STRING string
+** \param TAG_SEP `;` | `|` | `&&` | `||`
+** \param TAG_REDIR_OUT `>`
+** \param TAG_REDIR_IN `<`
+** \param TAG_REDIR_APPEND `>>`
*/
typedef enum
{
- TAG_CMD,
- TAG_ARG,
- TAG_ENDCMD,
- TAG_PIPE,
- TAG_AND,
- TAG_OR,
+ TAG_STRING,
+ TAG_SEP,
TAG_REDIR_OUT,
TAG_REDIR_IN,
- TAG_REDIR_APPEND
+ TAG_REDIR_APPEND,
+ TAG_CMD,
+ TAG_LINE,
} t_tag;
-/*
-** AST (Abstract Syntax Tree)
-** A node of the ast is represented by a tag (his type) and a content associated with it.
-** (i.e a TAG_CMD would be paired with the command executable name)
-** Each node also has children node which must be evaluated before him
-**
-** examle: "echo foo bar && ls"
-**
-** tags:
-** TAG_AND
-** / \
-** / \
-** TAG_CMD TAG_CMD
-** / \
-** TAG_ARG TAG_ARG
-**
-** content:
-** &&
-** / \
-** / \
-** echo ls
-** / \
-** foo bar
+/**
+** \brief AST (Abstract Syntax Tree)
+** \param tag tag (type) of node
+** \param content substring of the parsed string which corespond to tag
+** \param children_num number of children
+** \param children children nodes
*/
typedef struct s_ast
@@ -86,6 +68,11 @@ typedef struct s_ast
struct s_ast** children;
} t_ast;
+
+/*
+** lexer.c
+*/
+
char **ms_lexer(char *input);
/*
@@ -94,4 +81,12 @@ char **ms_lexer(char *input);
t_ast *ms_parse(char *input);
+/*
+** ast.c
+*/
+
+t_ast *ms_ast_new(t_tag tag);
+void ms_ast_destroy(t_ast *ast);
+void ms_ast_iter(t_ast *ast, void (*f)(void *f_arg, t_ast *children), void *arg);
+
#endif
diff --git a/libft b/libft
-Subproject 40ed37c023627726a5c9c6928284e9f042dc0fa
+Subproject 901402c99018422c994bdb297e3ba404969c88e
diff --git a/src/builtin/cd.c b/src/builtin/cd.c
index f82a876..fe806ec 100644
--- a/src/builtin/cd.c
+++ b/src/builtin/cd.c
@@ -1,3 +1,8 @@
+/**
+** \file cd.c
+** \brief `cd` builtin
+*/
+
#include "minishell.h"
int ms_cd(t_env env, char **argv)
diff --git a/src/builtin/echo.c b/src/builtin/echo.c
index b2bcee9..817da28 100644
--- a/src/builtin/echo.c
+++ b/src/builtin/echo.c
@@ -1,3 +1,8 @@
+/**
+** \file echo.c
+** \brief `echo` builtin
+*/
+
#include "minishell.h"
int ms_echo(char **argv)
diff --git a/src/builtin/env.c b/src/builtin/env.c
index 9e962ec..226b5b9 100644
--- a/src/builtin/env.c
+++ b/src/builtin/env.c
@@ -1,3 +1,8 @@
+/**
+** \file env.c
+** \brief `env` builtin
+*/
+
#include "minishell.h"
void st_print_env_variable(t_ftht_content *content)
diff --git a/src/builtin/exit.c b/src/builtin/exit.c
index e69de29..f4cc4fd 100644
--- a/src/builtin/exit.c
+++ b/src/builtin/exit.c
@@ -0,0 +1,4 @@
+/**
+** \file exit.c
+** \brief `exit` builtin
+*/
diff --git a/src/builtin/export.c b/src/builtin/export.c
index df27655..77d46c1 100644
--- a/src/builtin/export.c
+++ b/src/builtin/export.c
@@ -1,3 +1,8 @@
+/**
+** \file export.c
+** \brief `export` builtin
+*/
+
#include "minishell.h"
/* int ms_export(t_env env, char **argv) */
diff --git a/src/builtin/pwd.c b/src/builtin/pwd.c
index 2836852..326f834 100644
--- a/src/builtin/pwd.c
+++ b/src/builtin/pwd.c
@@ -1,3 +1,7 @@
+/**
+** \file pwd.c
+** \brief `pwd` builtin
+*/
#include "minishell.h"
int ms_pwd(void)
diff --git a/src/builtin/unset.c b/src/builtin/unset.c
index bc4327b..4d7c628 100644
--- a/src/builtin/unset.c
+++ b/src/builtin/unset.c
@@ -1,3 +1,8 @@
+/**
+** \file unset.c
+** \brief `unset` builtin
+*/
+
#include "minishell.h"
int ms_unset(t_env env, char **argv)
diff --git a/src/env.c b/src/env.c
index 04ab561..c019cb4 100644
--- a/src/env.c
+++ b/src/env.c
@@ -10,10 +10,25 @@
/* */
/* ************************************************************************** */
+/**
+** \file env.c
+** \brief Environment hash table manipulation
+*/
+
#include "minishell.h"
+/**
+** \brief Number of buckets of an environment hash table
+*/
+
#define MS_ENV_HT_SIZE 2048
+/**
+** \brief Convert array of string to environment hash table
+** \param envp array of string (each in the format `name=value`)
+** \return Environment hash table or NULL on error
+*/
+
t_env ms_env_from_array(char **envp)
{
t_env env;
@@ -42,6 +57,12 @@ t_env ms_env_from_array(char **envp)
return (env);
}
+/**
+** \brief Convert environment to array of string
+** \param env Environment hash table
+** \return Array of string on NULL on error
+*/
+
char **ms_env_to_array(t_env env)
{
(void)env;
diff --git a/src/eval.c b/src/eval/eval.c
index 907949d..8fca2c1 100644
--- a/src/eval.c
+++ b/src/eval/eval.c
@@ -1,48 +1,10 @@
-#include "minishell.h"
-
-t_val *val_new_redir(t_val_type type, char *filename)
-{
- t_val *val;
-
- if ((val = val_new(type)) == NULL)
- return (NULL);
- if (type == VAL_REDIR_IN)
- val->data.fd = open(filename, O_RDONLY);
- else if (type == VAL_REDIR_OUT)
- val->data.fd = open(filename, O_WRONLY);
- else if (type == VAL_REDIR_APPEND)
- val->data.fd = open(filename, O_RDWR);
- if (val->data.fd < 0)
- {
- free(val);
- return (NULL);
- }
- return (val);
-}
-
-t_val *val_new_err(char *msg)
-{
- t_val *val;
-
- if ((val == malloc(sizeof(t_val))) == NULL)
- return (NULL);
- val->type = VAL_ERR;
- if ((val->data.str = ft_strdup(msg)) == NULL)
- return (NULL);
- return (val);
-}
+/**
+** \file eval.c
+** \brief Evaluation of an AST
+*/
-t_val *read_ast(t_ast *ast)
-{
- t_val *val;
+#include "minishell.h"
- if (ast->tag == TAG_REDIR_IN)
- {
- val = val_new();
- val->type = VAL_REDIR_IN;
- val->value.fd = open(ast->content, O_RDONLY);
- }
-}
static bool check_node(t_ast *ast)
{
@@ -129,6 +91,7 @@ static char **get_args(t_ast *ast)
*/
}
+//reduce?
int ms_eval(t_path path, t_env env, t_ast *ast)
{
int status;
diff --git a/src/eval/read.c b/src/eval/read.c
new file mode 100644
index 0000000..1364fca
--- /dev/null
+++ b/src/eval/read.c
@@ -0,0 +1,89 @@
+/**
+** \file read.c
+** \brief Convert AST to value tree
+*/
+
+#include "ms_evalue.h"
+
+static t_value *read_cmd_args(t_value *value_cmd, t_ast *cmd)
+{
+
+}
+
+/* static void arg_count_iterator(int *counter, t_ast *child) */
+/* { */
+/* if (child == TAG_STRING) */
+/* (*counter)++; */
+/* } */
+/* */
+/* static void arg_add_iterator(t_value *value_cmd, t_ast *child) */
+/* { */
+/* if (child != TAG_STRING) */
+/* return ; */
+/* value_cmd_push( */
+/* } */
+
+/**
+** \brief Convert a command AST to a value
+** \param cmd Command AST
+** \return Converted value
+*/
+
+static t_value *read_cmd(t_ast *cmd)
+{
+ int i;
+ int arg_num;
+ t_value *value_cmd;
+
+ if (ast->children_num < 1 || ast->children[0]->type != TAG_STRING)
+ return (value_new_string(VAL_ERR, "Empty command");
+ arg_num = 0;
+ i = -1;
+ while (++i < ast->children_num)
+ if (ast->children[i]->type == TAG_STRING)
+ arg_num++;
+ if ((value_cmd = value_new_cmd(arg_num)) == NULL)
+ return (NULL);
+ i = -1;
+ while (++i < ast->children_num)
+ if (ast->children[i]->type == TAG_STRING)
+ {
+ if ((value_cmd->args[arg_num++] =
+ ft_strdup(ast->children[i]->contents)) == NULL)
+ return (NULL);
+ }
+ while (i-- > 0)
+ if (ast->children[i]->type != TAG_STRING)
+ {
+ if (ast->children[i]->tag == TAG_REDIR_IN
+ && value_cmd->in == NULL)
+ value_cmd->in = value_new_redir(VAL_REDIR_IN); // check null
+ else if (ast->children[i]->tag == TAG_REDIR_OUT
+ && value_cmd->out == NULL))
+ value_cmd->out = value_new_redir(VAL_REDIR_OUT);
+ else if (ast->children[i]->tag == TAG_REDIR_APPEND
+ && value_cmd->append == NULL))
+ value_cmd->append = value_new_redir(VAL_REDIR_APPEND);
+ }
+ return (value_cmd);
+}
+
+/**
+** \brief Convert an AST to value
+** \param ast AST to convert
+** \return Converted value
+*/
+
+t_value *eval_read(t_ast *ast)
+{
+ t_value *value;
+
+ /* if (ast->tag == TAG_REDIR_IN) */
+ /* return (value_new_redir(VAL_REDIR_IN)); */
+ /* else if (ast->tag == TAG_REDIR_OUT) */
+ /* return (value_new_redir(VAL_REDIR_OUT)); */
+ /* else if (ast->tag == TAG_REDIR_APPEND) */
+ /* return (value_new_redir(VAL_REDIR_APPEND)); */
+ else if (ast->tag == TAG_CMD)
+ return (read_cmd(ast));
+}
diff --git a/src/eval/val.c b/src/eval/val.c
new file mode 100644
index 0000000..3293972
--- /dev/null
+++ b/src/eval/val.c
@@ -0,0 +1,69 @@
+/**
+** \file val.c
+** \brief Evaluation value manipulation
+*/
+
+#include "ms_evalue.h"
+
+/**
+** \brief Allocate memory for a t_value and set his type
+** \param type Type of valueue
+** \return The allocated value
+*/
+
+t_value *value_new(t_value_type type)
+{
+ t_value *value;
+
+ if ((value = (t_value*)malloc(sizeof(t_value*))) == NULL)
+ return (NULL);
+ value->type = type;
+ return (value);
+}
+
+/**
+** \brief Create a new redirection value from a filename
+** \param type Type of redirection and value
+** \param filename Name of the file to open
+** \return Redirection value
+** \warning Undefined behavior on none redirection type.
+*/
+
+t_value *value_new_redir(t_value_type type, char *filename)
+{
+ t_value *value;
+
+ if ((value = value_new(type)) == NULL)
+ return (NULL);
+ if (type == VAL_REDIR_IN)
+ value->data.fd = open(filename, O_RDONLY);
+ else if (type == VAL_REDIR_OUT)
+ value->data.fd = open(filename, O_WRONLY | O_CREAT);
+ else if (type == VAL_REDIR_APPEND)
+ value->data.fd = open(filename, O_APPEND | O_CREAT);
+ if (value->data.fd < 0)
+ {
+ free(value);
+ return (NULL);
+ }
+ return (value);
+}
+
+/**
+** \brief Create a new string value (i.e error, arg, cmd)
+** \param type String value type
+** \param str String data
+** \return String value
+*/
+
+t_value *value_new_string(t_value_type type, char *str)
+{
+ t_value *value;
+
+ if ((value == malloc(sizeof(t_value))) == NULL)
+ return (NULL);
+ value->type = type;
+ if ((value->data.str = ft_strdup(str)) == NULL)
+ return (NULL);
+ return (value);
+}
diff --git a/src/main.c b/src/main.c
index 11e4517..52b5baa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -10,8 +10,21 @@
/* */
/* ************************************************************************** */
+/**
+** \file main.c
+** \brief Minishell entrypoint
+*/
+
#include "minishell.h"
+/**
+** \brief Program entrypoint
+** \param argc Number of arguments in `argv`
+** \param argv Array of string, argument of the program
+** \param envp NULL terminated array of string representing the environment
+** \return 0 if ok, 1 otherwise
+*/
+
int main(int argc, char **argv, const char **envp)
{
t_path path;
diff --git a/src/parse/ast.c b/src/parse/ast.c
new file mode 100644
index 0000000..f566832
--- /dev/null
+++ b/src/parse/ast.c
@@ -0,0 +1,63 @@
+/**
+** \file ast.c
+** \brief AST manipulation
+*/
+
+#include "ms_parse.h"
+
+/**
+** \brief Create a new AST node with default values
+** \param tag Tag of the node
+** \return The allocated node
+*/
+
+t_ast *ms_ast_new(t_tag tag)
+{
+ t_ast *ast;
+
+ if ((ast = (t_ast*)malloc(sizeof(t_ast))) == NULL)
+ return (NULL);
+ ast->tag = tag;
+ ast->content = NULL;
+ ast->children_num = 0;
+ ast->children = NULL;
+ return (ast);
+}
+
+/**
+** \brief Destroy an allocated AST
+** \warning Assumes that `content`, `children` and the node itself have been malloc'd
+** \param ast AST to destroy
+*/
+
+void ms_ast_destroy(t_ast *ast)
+{
+ int i;
+
+ if (ast == NULL)
+ return ;
+ i = -1;
+ while (++i < ast->children_num)
+ ms_ast_destroy(ast->children[i]);
+ free(ast->children);
+ free(ast->content);
+ free(ast);
+}
+
+/**
+** \brief Iterate over an AST node's childs
+** \param f Function applied to each child, take `arg` has his first argument.
+** \param arg Pointer that will be passed to `f`, to keep information between iterations
+*/
+
+void ms_ast_iter(
+ t_ast *ast,
+ void (*f)(void *f_arg, t_ast *children),
+ void *arg)
+{
+ int i;
+
+ i = -1;
+ while (++i < ast->children_num)
+ f(arg, ast->children[i]);
+}
diff --git a/src/parse/lexer.c b/src/parse/lexer.c
index b5caba2..d8f1254 100644
--- a/src/parse/lexer.c
+++ b/src/parse/lexer.c
@@ -1,3 +1,8 @@
+/**
+** \file lexer.c
+** \brief Lexer
+*/
+
#include "minishell.h"
char **ms_lexer(char *input)
diff --git a/src/parse/parse.c b/src/parse/parse.c
index bdd0144..41b82c2 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -1,3 +1,8 @@
+/**
+** \file parse.c
+** \brief Parser
+*/
+
#include "minishell.h"
t_ast *ms_parse(char *input)
diff --git a/src/path.c b/src/path.c
index 3ac12d9..c2b6582 100644
--- a/src/path.c
+++ b/src/path.c
@@ -10,12 +10,24 @@
/* */
/* ************************************************************************** */
+/**
+** \file path.c
+** \brief Path hash table manipulation
+*/
+
#include "minishell.h"
+/**
+** \brief Number of buckets of a path hash table
+*/
+
#define MS_PATH_HT_SIZE 4096
-/*
-** Update `path` with all files in the directory named `dirname`.
+/**
+** \brief Update `path` with all files in the directory named `dirname`.
+** \param path Path hash table
+** \param dirname directory name
+** \return Same path or NULL on error
*/
static t_path st_path_dir_update(t_path path, char *dirname)
@@ -38,9 +50,11 @@ static t_path st_path_dir_update(t_path path, char *dirname)
return (path);
}
-/*
-** Update (or create if `path` is NULL) `path` according to `path_str`
-** (each directory is separated by a ':').
+/**
+** \brief Update the path
+** \param path Path hash table or NULL to create a new one
+** \param path_var PATH environment variable where each directory is separated by a ':'
+** \return The updated/created path hash table or NULL on error
*/
t_path ms_path_update(t_path path, char *path_var)
diff --git a/src/util.c b/src/utils.c
index 188b762..2b655bf 100644
--- a/src/util.c
+++ b/src/utils.c
@@ -10,10 +10,16 @@
/* */
/* ************************************************************************** */
+/**
+** \file utils.c
+** \brief Various functions
+*/
+
#include "minishell.h"
-/*
-** delete a hash table entry containing a allocated string key and value
+/**
+** \brief Delete function for a entry containing a allocated key and value
+** \param content Hash table entry content
*/
void ms_ht_del_str_entry(t_ftht_content *content)