Adding for the norm
This commit is contained in:
parent
4f5cf3cf10
commit
84b7e3e1e9
12 changed files with 873 additions and 591 deletions
36
sources/builtin/env.c
Normal file
36
sources/builtin/env.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* env.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/07 14:22:50 by rparodi #+# #+# */
|
||||
/* Updated: 2024/08/07 14:23:14 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/env.h"
|
||||
#include "me/string/string.h"
|
||||
#include "me/hash/hasher.h"
|
||||
#include "me/hashmap/hashmap_env.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_str.h"
|
||||
#include <cstddef>
|
||||
#include <stdlib.h>
|
||||
|
||||
void env(t_str *envp)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (envp[i] != NULL)
|
||||
{
|
||||
printf("%s\n", envp[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
36
sources/builtin/export.c
Normal file
36
sources/builtin/export.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* export.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/07 14:13:41 by rparodi #+# #+# */
|
||||
/* Updated: 2024/08/07 14:22:23 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/env.h"
|
||||
#include "me/string/string.h"
|
||||
#include "me/hash/hasher.h"
|
||||
#include "me/hashmap/hashmap_env.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_str.h"
|
||||
#include <cstddef>
|
||||
#include <stdlib.h>
|
||||
|
||||
void export(t_str *envp)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (envp[i] != NULL)
|
||||
{
|
||||
printf("%s\n", envp[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
45
sources/builtin/pwd.c
Normal file
45
sources/builtin/pwd.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* pwd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/07 13:58:37 by rparodi #+# #+# */
|
||||
/* Updated: 2024/08/07 14:07:39 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/env.h"
|
||||
#include "me/string/string.h"
|
||||
#include "me/hash/hasher.h"
|
||||
#include "me/hashmap/hashmap_env.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_str.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void pwd(void)
|
||||
{
|
||||
t_str str;
|
||||
t_usize size;
|
||||
|
||||
size = 1024;
|
||||
str = (t_str)mem_alloc((size + 1) * sizeof(t_i8));
|
||||
if (str == NULL)
|
||||
me_abort("Error allocating for pwd builtin");
|
||||
while (getcwd(str, size) == NULL)
|
||||
{
|
||||
if (str)
|
||||
free(str);
|
||||
size *= 2;
|
||||
str = (t_str)mem_alloc(sizeof(t_i8) * size);
|
||||
if (str == NULL)
|
||||
me_abort("Error allocating for pwd builtin");
|
||||
}
|
||||
printf("%s\n", str);
|
||||
free(str);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue