Skip to content

Commit 12b1c6d

Browse files
committed
load files
0 parents  commit 12b1c6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1405
-0
lines changed

.DS_Store

12 KB
Binary file not shown.

Makefile

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# **************************************************************************** #
2+
# #
3+
# ::: :::::::: #
4+
# Makefile :+: :+: :+: #
5+
# +:+ +:+ +:+ #
6+
# By: zskeeter <[email protected]> +#+ +:+ +#+ #
7+
# +#+#+#+#+#+ +#+ #
8+
# Created: 2020/10/31 18:40:15 by zskeeter #+# #+# #
9+
# Updated: 2021/04/25 20:32:16 by zskeeter ### ########.fr #
10+
# #
11+
# **************************************************************************** #
12+
13+
NAME = libft.a
14+
SRCS = ft_memset.c ft_atoi.c ft_bzero.c ft_memmove.c ft_memcpy.c ft_memccpy.c \
15+
ft_memchr.c ft_memcmp.c ft_strlen.c ft_strlcpy.c ft_strlcat.c \
16+
ft_strchr.c ft_strrchr.c ft_strnstr.c ft_strncmp.c ft_strdup.c \
17+
ft_isalpha.c ft_isdigit.c ft_isalnum.c ft_isascii.c ft_isprint.c \
18+
ft_toupper.c ft_tolower.c ft_calloc.c \
19+
ft_substr.c ft_strjoin.c ft_strtrim.c ft_itoa.c ft_split.c \
20+
ft_strmapi.c ft_putchar_fd.c ft_putstr_fd.c ft_putendl_fd.c \
21+
ft_putnbr_fd.c
22+
23+
BNS = ft_lstnew.c ft_lstadd_front.c ft_lstsize.c \
24+
ft_lstlast.c ft_lstadd_back.c ft_lstdelone.c ft_lstclear.c \
25+
ft_lstiter.c ft_lstmap.c
26+
27+
SRCOBJS = $(SRCS:.c=.o)
28+
BNSOBJS = $(BNS:.c=.o)
29+
30+
CC = gcc
31+
CFLAGS = -Wall -Wextra -Werror
32+
33+
all: $(NAME)
34+
35+
$(NAME): $(SRCOBJS) libft.h
36+
ar -rcs $(NAME) $(SRCOBJS)
37+
38+
bonus: $(SRCOBJS) $(BNSOBJS) libft.h
39+
ar -rcs $(NAME) $(SRCOBJS) $(BNSOBJS)
40+
41+
clean:
42+
rm -f $(SRCOBJS) $(BNSOBJS)
43+
44+
fclean: clean
45+
rm -f $(NAME) $(BNSOBJS)
46+
47+
re: clean fclean all

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
My realization of some standard C functions

ft_atoi.c

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_atoi.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:53:42 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:55:59 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "libft.h"
14+
15+
int ft_atoi(const char *str)
16+
{
17+
int res;
18+
int pos;
19+
20+
pos = 1;
21+
res = 0;
22+
while (*str && ft_strchr(" \n\t\v\f\r", *str))
23+
str++;
24+
if (*str == '-')
25+
pos = -1;
26+
if (ft_strchr("+-", *str))
27+
str++;
28+
while (*str && *str >= '0' && *str <= '9')
29+
{
30+
res = (*str - '0') + (res * 10);
31+
str++;
32+
}
33+
return (res * pos);
34+
}

ft_atoi.o

1.04 KB
Binary file not shown.

ft_bzero.c

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_bzero.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:53:46 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:53:46 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "libft.h"
14+
15+
void ft_bzero(void *s, size_t n)
16+
{
17+
size_t i;
18+
unsigned char *str;
19+
20+
if (n == 0)
21+
return ;
22+
str = (unsigned char *)s;
23+
i = 0;
24+
while (i < n)
25+
{
26+
str[i] = (unsigned char)0;
27+
i++;
28+
}
29+
}

ft_bzero.o

700 Bytes
Binary file not shown.

ft_calloc.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_calloc.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:53:48 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:53:48 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "libft.h"
14+
15+
void *ft_calloc(size_t count, size_t size)
16+
{
17+
void *res;
18+
19+
res = NULL;
20+
if (!(res = malloc(size * count)))
21+
return (NULL);
22+
ft_bzero(res, count * size);
23+
return (res);
24+
}

ft_calloc.o

784 Bytes
Binary file not shown.

ft_isalnum.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isalnum.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:53:51 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:53:51 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
int ft_isalnum(int c)
14+
{
15+
return ((c >= 65 && c <= 90) ||
16+
(c >= 97 && c <= 122) ||
17+
(c >= 48 && c <= 57));
18+
}

ft_isalnum.o

712 Bytes
Binary file not shown.

ft_isalpha.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isalpha.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:53:54 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:53:54 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include <stdio.h>
14+
15+
int ft_isalpha(int c)
16+
{
17+
return ((c >= 65 && c <= 90) || (c >= 97 && c <= 122));
18+
}

ft_isalpha.o

688 Bytes
Binary file not shown.

ft_isascii.c

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isascii.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:53:57 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:53:57 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
int ft_isascii(int c)
14+
{
15+
return (c >= 0 && c <= 127);
16+
}

ft_isascii.o

656 Bytes
Binary file not shown.

ft_isdigit.c

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isdigit.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:54:00 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:54:00 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
int ft_isdigit(int c)
14+
{
15+
return (c >= 48 && c <= 57);
16+
}

ft_isdigit.o

656 Bytes
Binary file not shown.

ft_isprint.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isprint.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:54:02 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:54:03 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "libft.h"
14+
15+
int ft_isprint(int c)
16+
{
17+
return (c >= 32 && c <= 126);
18+
}

ft_isprint.o

656 Bytes
Binary file not shown.

ft_itoa.c

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_itoa.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:54:05 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:54:05 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "libft.h"
14+
#include <stdio.h>
15+
16+
int count_digits(long n)
17+
{
18+
int counter;
19+
20+
if (n == 0)
21+
return (1);
22+
counter = 0;
23+
while (n != 0)
24+
{
25+
n /= 10;
26+
counter++;
27+
}
28+
return (counter);
29+
}
30+
31+
char *ft_itoa(int n)
32+
{
33+
char *res;
34+
int len;
35+
int pos;
36+
long num;
37+
38+
num = n;
39+
pos = num >= 0;
40+
len = count_digits(num) + (!pos ? 1 : 0);
41+
num *= pos ? 1 : -1;
42+
if (!(res = malloc(sizeof(char) * (len + 1))))
43+
return (NULL);
44+
res[len] = '\0';
45+
while (len >= 0)
46+
{
47+
res[len - 1] = num % 10 + 48;
48+
num /= 10;
49+
len--;
50+
}
51+
if (!pos)
52+
res[0] = '-';
53+
return (res);
54+
}

ft_itoa.o

1.09 KB
Binary file not shown.

ft_lstadd_back.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_lstadd_back.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:54:08 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:54:08 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "libft.h"
14+
15+
void ft_lstadd_back(t_list **lst, t_list *new)
16+
{
17+
t_list *tmp;
18+
19+
if (!(*lst))
20+
{
21+
*lst = new;
22+
return ;
23+
}
24+
tmp = ft_lstlast(*lst);
25+
tmp->next = new;
26+
}

ft_lstadd_back.o

728 Bytes
Binary file not shown.

ft_lstadd_front.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_lstadd_front.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:54:11 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:54:11 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "libft.h"
14+
15+
void ft_lstadd_front(t_list **lst, t_list *new)
16+
{
17+
if (!lst || !new)
18+
return ;
19+
new->next = *lst;
20+
*lst = new;
21+
}

ft_lstadd_front.o

684 Bytes
Binary file not shown.

ft_lstclear.c

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_lstclear.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:54:13 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:54:14 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "libft.h"
14+
15+
void ft_lstclear(t_list **lst, void (*del)(void *))
16+
{
17+
t_list *tmp;
18+
19+
while (*lst)
20+
{
21+
tmp = *lst;
22+
tmp = tmp->next;
23+
del((*lst)->content);
24+
free(*lst);
25+
*lst = tmp;
26+
}
27+
}

ft_lstclear.o

748 Bytes
Binary file not shown.

ft_lstdelone.c

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_lstdelone.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: zskeeter <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2021/04/25 13:54:16 by zskeeter #+# #+# */
9+
/* Updated: 2021/04/25 13:54:16 by zskeeter ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "libft.h"
14+
15+
void ft_lstdelone(t_list *lst, void (*del)(void *))
16+
{
17+
del(lst->content);
18+
free(lst);
19+
}

ft_lstdelone.o

688 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)