updated libft

This commit is contained in:
djonker 2023-10-26 18:33:37 +02:00
parent 8ddc311148
commit 2c4dbe102d
643 changed files with 4262 additions and 3536 deletions

View File

@ -1,12 +1,12 @@
# **************************************************************************** #
# #
# .--. _ #
# Makefile |o_o || | #
# Makefile :+: :+: #
# |:_/ || |_ _ ___ __ #
# By: djonker <djonker@student.codam.nl> // \ \ __| | | \ \/ / #
# (| | )|_| |_| |> < #
# Created: 2023/02/15 02:12:27 by djonker /'\_ _/`\__|\__,_/_/\_\ #
# Updated: 2023/02/19 19:18:27 by djonker \___)=(___/ #
# Updated: 2023/10/26 18:01:45 by houtworm ######## odam.nl #
# #
# **************************************************************************** #
@ -42,7 +42,7 @@ fclean: clean
re: fclean all
$(OBJ): $(SRC)
$(OBJ): $(SRC) pipex.h Makefile
@mkdir -p $(dir $@)
@printf "\e[1;34mBuilding $@\n\e[0;00m"
@$(CC) $(CFLAGS) -c $(@:obj/%.o=src/%.c) -o $@

8
libft/.gitignore vendored
View File

@ -1,8 +0,0 @@
*.pdf
*.o
*.a
LICENSE
obj
tests/tmp
.git
.ccls-cache

View File

@ -1,18 +1,18 @@
# **************************************************************************** #
# #
# :::::::: #
# Makefile |o_o || | #
# Makefile :+: :+: #
# +:+ #
# By: djonker <marvin@codam.nl> +#+ #
# +#+ #
# Created: 2020/10/27 15:02:02 by djonker #+# #+# #
# Updated: 2023/02/23 15:40:38 by houtworm \___)=(___/ #
# Updated: 2023/10/26 18:29:23 by houtworm ######## odam.nl #
# #
# **************************************************************************** #
NAME =libft.a
CC =gcc
FC =-Wall -Werror -Wextra -fsanitize=address
FC =-Wall -Werror -Wextra# -g -fsanitize=address
FAR =ar -rs
RM =rm -f
SRC =src/ft_atoi.c \
@ -138,7 +138,24 @@ SRC =src/ft_atoi.c \
src/ft_islneg.c \
src/ft_ldeclen.c \
src/ft_isallbyte.c \
src/ft_getpwd.c
src/ft_getuser.c \
src/ft_gethome.c \
src/ft_getpwd.c \
src/ft_vastrjoin.c \
src/ft_vafree.c \
src/ft_intrchr.c \
src/ft_system.c \
src/ft_getpaths.c \
src/ft_getenvval.c \
src/ft_seminit.c \
src/ft_semwait.c \
src/ft_semfree.c \
src/ft_gettimemsdate.c \
src/ft_mkdir.c \
src/ft_rmdir.c \
src/ft_abspathcmd.c \
src/ft_cppbzero.c \
src/ft_cpptostr.c
BSRC =src/ft_lstadd_back.c \
src/ft_lstadd_front.c \
src/ft_lstclear.c \

View File

@ -1,10 +1,33 @@
# Functions
## striteri
void ft_striteri(char *s, void (*f)(unsigned int, char*));
# Libft
Libft is a self written implementation of some of the standard c function.\
It also includes a lot of undocumented functions not in the standard c library.\
Nonetheless the functions have been named somewhat properly and the code should be easy to read.
# Tester
## general
check for -Wall -Werror -Wextra
Think of more edge cases for all functions
## add tests extra
check if function exists in .h and run the tests for that fucntion
---
## Todo
#### Write ft_striteri
`void ft_striteri(char *s, void (*f)(unsigned int, char*));`
---
## Usage
1. Simply clone or download the repository
2. Run `make` in the cloned directory
3. You can include the created libft.a in your own programs
---
## Tester
#### Todo
- Add striteri test
- check for -Wall -Werror -Wextra
- Think of more edge cases for all functions
- Extra functions, check if function exists in .h and run the tests for that fucntion
- putchar 4 should print 0
#### Usage
1. Download test.sh and the tests folder into your own project directory
2. Make the file executable `chmod +x test.sh`
3. Run `./test.sh` to start the test
---
[This project is part of the studies at 42](https://42.fr/en/homepage/)

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* libft.h |o_o || | */
/* libft.h :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/11 16:02:53 by djonker #+# #+# */
/* Updated: 2023/03/05 20:30:31 by houtworm \___)=(___/ */
/* Updated: 2023/10/25 07:05:24 by djonker ######## odam.nl */
/* */
/* ************************************************************************** */
@ -16,6 +16,9 @@
# include <unistd.h>
# include <stdlib.h>
# include <stdarg.h>
# include <fcntl.h>
# include <sys/stat.h>
# include <sys/wait.h>
typedef struct s_list
{
@ -160,5 +163,24 @@ int ft_islneg(long long n);
char *ft_dtoa(long double n);
int ft_isallbyte(char *str, char byte);
char *ft_getpwd(char **envp, int slash);
char *ft_getuser(char **envp);
char *ft_gethome(char **envp);
char *ft_getos(void);
char *ft_gethost(void);
char *ft_vastrjoin(int n, ...);
void ft_vafree(int n, ...);
int ft_intrchr(const char *s, int c);
char *ft_system(char *command, char **envp, char *file);
char **ft_getpaths(char **envp, int i);
char *ft_getenvval(char **envp, char *var);
char *ft_abspathcmd(char **paths, char *command);
void ft_cppbzero(char **cpp);
char *ft_cpptostr(char **cpp);
int ft_seminit(char *file, int number);
int ft_semwait(char *file);
int ft_semfree(char *file);
long long ft_gettimemsdate(char **envp, char *file);
int ft_mkdir(char *dirname, char **envp);
int ft_rmdir(char *dirname, char **envp);
#endif

34
libft/src/ft_abspathcmd.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_abspathcmd.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/03/20 16:39:22 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:55:36 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
char *ft_abspathcmd(char **paths, char *cmd)
{
char *absolute;
int i;
i = 0;
if (!paths)
return (cmd);
if (cmd && ft_chrstr('/', cmd))
absolute = ft_strdup(cmd);
else
absolute = ft_strjoin(paths[i], cmd);
while (access(absolute, F_OK) && paths[i] && !ft_chrstr('/', cmd))
{
free(absolute);
i++;
absolute = ft_strjoin(paths[i], cmd);
}
return (absolute);
}

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_around.c :+: :+: :+: */
/* ft_around.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 07:26:00 by djonker #+# #+# */
/* Updated: 2023/02/07 00:42:07 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:55:37 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_arrlen.c :+: :+: :+: */
/* ft_arrlen.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/06 17:38:27 by djonker #+# #+# */
/* Updated: 2023/02/07 00:42:08 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:55:38 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_atodec.c :+: :+: :+: */
/* ft_atodec.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 05:48:34 by djonker #+# #+# */
/* Updated: 2023/02/07 00:42:08 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:55:41 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_atof.c :+: :+: :+: */
/* ft_atof.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 05:48:34 by djonker #+# #+# */
/* Updated: 2023/02/07 00:42:08 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:55:42 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* ft_atoi.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 19:08:11 by djonker #+# #+# */
/* Updated: 2023/02/07 00:42:09 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:55:42 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_atol.c :+: :+: :+: */
/* ft_atol.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 19:08:11 by djonker #+# #+# */
/* Updated: 2023/02/07 00:36:46 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:55:43 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_atou.c |o_o || | */
/* ft_atou.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 19:08:11 by djonker #+# #+# */
/* Updated: 2023/03/05 21:13:18 by houtworm \___)=(___/ */
/* Updated: 2023/10/18 16:55:43 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_bitswap.c :+: :+: :+: */
/* ft_bitswap.c :+: :+: */
/* +:+ */
/* By: djonker <djonker@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2021/05/17 06:29:44 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:18 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:55:44 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_btoi.c :+: :+: :+: */
/* ft_btoi.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/01/18 13:44:56 by djonker #+# #+# */
/* Updated: 2023/02/07 00:36:46 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:55:44 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_bzero.c |o_o || | */
/* ft_bzero.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 08:35:25 by djonker #+# #+# */
/* Updated: 2023/02/22 02:01:25 by djonker \___)=(___/ */
/* Updated: 2023/10/18 16:55:45 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_calloc.c |o_o || | */
/* ft_calloc.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 21:20:32 by djonker #+# #+# */
/* Updated: 2023/02/25 16:18:01 by houtworm \___)=(___/ */
/* Updated: 2023/10/25 05:52:55 by djonker ######## odam.nl */
/* */
/* ************************************************************************** */
@ -25,7 +25,7 @@ void *ft_calloc(size_t count, size_t size)
}
p = malloc(count * size);
if (p == NULL)
return (0x0);
exit(1);
if (p)
{
t = p;

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_chrstr.c :+: :+: :+: */
/* ft_chrstr.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/15 02:30:48 by djonker #+# #+# */
/* Updated: 2023/02/07 00:36:47 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:55:46 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_cntarg.c |o_o || | */
/* +:+ +:+ +:+ */
/* By: houtworm <codam@houtworm.net> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/07 00:38:26 by houtworm #+# #+# */
/* Updated: 2023/02/21 01:43:17 by houtworm \___)=(___/ */
/* :::::::: */
/* ft_cntarg.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/02/07 00:38:26 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:56:12 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* .--. _ */
/* ft_cntchr.c :+: :+: :+: */
/* |:_/ || |_ _ ___ __ */
/* By: djonker <djonker@student.codam.nl> // \ \ __| | | \ \/ / */
/* (| | )|_| |_| |> < */
/* Created: 2021/06/11 17:23:36 by djonker /'\_ _/`\__|\__,_/_/\_\ */
/* Updated: 2023/02/07 00:38:41 by houtworm ### ########.fr */
/* :::::::: */
/* ft_cntchr.c :+: :+: */
/* +:+ */
/* By: djonker <djonker@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2021/06/11 17:23:36 by djonker #+# #+# */
/* Updated: 2023/10/18 16:56:12 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_cntwrd.c :+: :+: :+: */
/* ft_cntwrd.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/21 20:37:04 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:43 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:13 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_cntwrds.c :+: :+: :+: */
/* ft_cntwrds.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/21 20:37:04 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:44 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:13 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

25
libft/src/ft_cppbzero.c Normal file
View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_cppbzero.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/09/18 12:17:56 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:56:14 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
void ft_cppbzero(char **cpp)
{
int i;
i = 0;
while (cpp[i])
{
ft_bzero(cpp[i], ft_strlen(cpp[i]));
i++;
}
}

36
libft/src/ft_cpptostr.c Normal file
View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_cpptostr.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/09/18 12:17:01 by houtworm #+# #+# */
/* Updated: 2023/10/19 00:19:29 by djonker ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
char *ft_cpptostr(char **cpp)
{
int i;
char *ret;
char *temp;
char *temp2;
i = 1;
if (cpp[0])
temp2 = ft_strdup(cpp[0]);
while (cpp[i])
{
temp = ft_strjoin(temp2, cpp[i]);
free(temp2);
temp2 = ft_strdup(temp);
free(temp);
i++;
}
ret = ft_strdup(temp2);
free(temp2);
return (ret);
}

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_ddtoi.c :+: :+: :+: */
/* ft_ddtoi.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/01/31 01:24:28 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:44 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:15 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_declen.c :+: :+: :+: */
/* ft_declen.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 04:29:09 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:45 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:15 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_dtoa.c :+: :+: :+: */
/* ft_dtoa.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 03:46:17 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:46 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:16 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_dtoh.c :+: :+: :+: */
/* ft_dtoh.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/01/31 02:22:34 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:47 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:16 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_factor.c :+: :+: :+: */
/* ft_factor.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/01 04:03:20 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:48 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:25 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_fczero.c :+: :+: :+: */
/* ft_fczero.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 04:29:09 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:49 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:25 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_flolen.c :+: :+: :+: */
/* ft_flolen.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 04:00:01 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:50 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:26 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_fnprim.c :+: :+: :+: */
/* ft_fnprim.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/01 04:42:24 by djonker #+# #+# */
/* Updated: 2023/02/07 00:38:50 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:26 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_frearr.c :+: :+: :+: */
/* ft_frearr.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/12/11 21:54:13 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:42 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:27 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_frenarr.c :+: :+: :+: */
/* ft_frenarr.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/12/11 21:54:13 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:47 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:27 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_fround.c :+: :+: :+: */
/* ft_fround.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 07:42:16 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:49 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:28 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_ftoa.c :+: :+: :+: */
/* ft_ftoa.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 03:46:17 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:49 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:28 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_ftoi.c :+: :+: :+: */
/* ft_ftoi.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 21:30:30 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:50 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:56:29 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

34
libft/src/ft_getenvval.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_getenvval.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/02/17 02:40:22 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:56:29 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
char *ft_getenvval(char **envp, char *var)
{
char *value;
int i;
char *temp;
temp = ft_strjoin(var, "=");
i = -1;
while (envp[++i])
if (ft_strncmp(envp[i], temp, ft_strlen(temp)) == 0)
break ;
if (!envp[i])
{
free(temp);
return (NULL);
}
value = ft_substr(envp[i], ft_strlen(temp), ft_strlen(envp[i]));
free(temp);
return (value);
}

28
libft/src/ft_gethome.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_gethome.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/02/17 02:40:22 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:56:39 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
char *ft_gethome(char **envp)
{
char *home;
int i;
i = -1;
while (envp[++i])
if (ft_strncmp(envp[i], "HOME=", 5) == 0)
break ;
if (!envp[i])
return (NULL);
home = ft_substr(envp[i], 5, ft_strlen(envp[i]));
return (home);
}

27
libft/src/ft_gethost.c Normal file
View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_gethost.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/10/09 07:45:51 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:59:03 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../../minishell.h"
char *ft_gethost(void)
{
int fd;
char *line;
char *host;
fd = open("/etc/hostname", O_RDONLY);
get_next_line(fd, &line);
host = ft_strdup(line);
free(line);
close(fd);
return (host);
}

60
libft/src/ft_getos.c Normal file
View File

@ -0,0 +1,60 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_getos.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/10/09 07:45:51 by houtworm #+# #+# */
/* Updated: 2023/10/19 00:22:24 by djonker ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../../minishell.h"
char *ft_getosfromline(char *line)
{
int ret;
char *os;
int i;
ret = 0;
i = 0;
while (line[i] != '\"')
i++;
i++;
os = ft_calloc(ft_strlen(line), 8);
while (line[i] != ' ' && line[i] != '\"')
{
os[ret] = line[i];
ret++;
i++;
}
os[ret] = '\0';
return (os);
}
char *ft_getos(void)
{
int fd;
char *line;
int ret;
char *os;
fd = open("/etc/os-release", O_RDONLY);
ret = 1;
while (ret > 0)
{
ret = get_next_line(fd, &line);
if (!ft_strncmp(line, "PRETTY_NAME:", 7))
{
os = ft_getosfromline(line);
free(line);
close(fd);
return (os);
}
free (line);
}
close(fd);
return (NULL);
}

42
libft/src/ft_getpaths.c Normal file
View File

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_getpaths.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/03/20 16:39:22 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:59:06 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
char **ft_getpaths(char **envp, int i)
{
char **paths;
char **temp;
char *firsttemp;
i = -1;
while (envp[++i])
if (ft_strncmp(envp[i], "PATH=", 5) == 0)
break ;
if (!envp[i])
return (0);
else
temp = ft_split(envp[i], ':');
if (!temp)
return (0);
paths = ft_calloc(sizeof(char *) * (ft_arrlen(temp) + 1), 1);
firsttemp = ft_substr(temp[0], 5, ft_strlen(temp[0]));
if (!paths || !firsttemp)
return (0);
paths[0] = ft_strjoin(firsttemp, "/");
free(firsttemp);
i = 0;
while (temp[++i])
paths[i] = ft_strjoin(temp[i], "/");
ft_frearr(temp);
return (paths);
}

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* .--. _ */
/* ft_getpwd.c |o_o || | */
/* |:_/ || |_ _ ___ __ */
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
/* (| | )|_| |_| |> < */
/* Created: 2023/02/17 02:40:22 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
/* Updated: 2023/02/17 02:55:28 by houtworm \___)=(___/ */
/* :::::::: */
/* ft_getpwd.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/02/17 02:40:22 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:59:07 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_gettimemsdate.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/10/17 20:10:03 by houtworm #+# #+# */
/* Updated: 2023/10/19 00:04:18 by djonker ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
long long ft_gettimemsdate(char **envp, char *file)
{
char *date;
long long currenttime;
date = ft_system("date +%s%3N", envp, file);
currenttime = ft_atol(date);
free(date);
return (currenttime);
}

28
libft/src/ft_getuser.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_getuser.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/02/17 02:40:22 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:59:09 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
char *ft_getuser(char **envp)
{
char *user;
int i;
i = -1;
while (envp[++i])
if (ft_strncmp(envp[i], "USER=", 5) == 0)
break ;
if (!envp[i])
return (NULL);
user = ft_substr(envp[i], 5, ft_strlen(envp[i]));
return (user);
}

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_htod.c :+: :+: :+: */
/* ft_htod.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/01/31 03:18:45 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:51 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:59:10 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_htoi.c :+: :+: :+: */
/* ft_htoi.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/01/31 01:24:28 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:52 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:59:11 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_iftof.c :+: :+: :+: */
/* ft_iftof.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/02/02 22:27:51 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:52 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:59:12 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_intlen.c :+: :+: :+: */
/* ft_intlen.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/13 02:04:46 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:54 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:59:14 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

28
libft/src/ft_intrchr.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_intrchr.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/11 16:14:50 by djonker #+# #+# */
/* Updated: 2023/10/18 16:59:15 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
int ft_intrchr(const char *s, int c)
{
int i;
if (!s)
return (-1);
i = 0;
while (s[i] != '\0')
i++;
i--;
while (i >= 0 && s[i] != c)
i--;
return (i);
}

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* .--. _ */
/* ft_isallbyte.c |o_o || | */
/* |:_/ || |_ _ ___ __ */
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
/* (| | )|_| |_| |> < */
/* Created: 2023/02/21 01:43:42 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
/* Updated: 2023/02/21 01:43:44 by houtworm \___)=(___/ */
/* :::::::: */
/* ft_isallbyte.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/02/21 01:43:42 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:59:16 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
@ -14,6 +14,8 @@
int ft_isallbyte(char *str, char byte)
{
if (!str)
return (1);
while (*str == byte)
str++;
if (!*str)

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_isalnum.c :+: :+: :+: */
/* ft_isalnum.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/11 15:56:37 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:54 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:59:16 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_isalpha.c :+: :+: :+: */
/* ft_isalpha.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 19:10:41 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:55 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:59:17 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_isascii.c :+: :+: :+: */
/* ft_isascii.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 19:10:41 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:56 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:59:18 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_isdigit.c :+: :+: :+: */
/* ft_isdigit.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 19:10:41 by djonker #+# #+# */
/* Updated: 2023/02/07 00:39:56 by houtworm ### ########.fr */
/* Updated: 2023/10/18 16:59:19 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_islneg.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: houtworm <codam@houtworm.net> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/25 11:39:27 by houtworm #+# #+# */
/* Updated: 2023/02/07 00:39:57 by houtworm ### ########.fr */
/* :::::::: */
/* ft_islneg.c :+: :+: */
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2022/12/25 11:39:27 by houtworm #+# #+# */
/* Updated: 2023/10/18 16:59:20 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_islowc.c :+: :+: :+: */
/* ft_islowc.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */