Skip to content

Commit

Permalink
sandsalamand copy
Browse files Browse the repository at this point in the history
  • Loading branch information
sandsalamand committed Aug 9, 2018
0 parents commit 32231f5
Show file tree
Hide file tree
Showing 65 changed files with 2,074 additions and 0 deletions.
103 changes: 103 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: sgrindhe <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/07/09 10:37:50 by sgrindhe #+# #+# #
# Updated: 2018/08/08 01:21:31 by sgrindhe ### ########.fr #
# #
# **************************************************************************** #

FLAG = -Wall -Wextra -Werror

NAME = libft.a

SRC = ft_atoi.c \
ft_bzero.c \
ft_isalnum.c \
ft_isalpha.c \
ft_isascii.c \
ft_isdigit.c \
ft_isprint.c \
ft_itoa.c \
ft_memalloc.c \
ft_memccpy.c \
ft_memchr.c \
ft_memcmp.c \
ft_memcpy.c \
ft_memdel.c \
ft_memmove.c \
ft_memset.c \
ft_putchar.c \
ft_putchar_fd.c \
ft_putendl.c \
ft_putendl_fd.c \
ft_putnbr.c \
ft_putnbr_fd.c \
ft_putstr.c \
ft_putstr_fd.c \
ft_strcat.c \
ft_strchr.c \
ft_strclr.c \
ft_strcmp.c \
ft_strcpy.c \
ft_strdel.c \
ft_strdup.c \
ft_strequ.c \
ft_striter.c \
ft_striteri.c \
ft_strjoin.c \
ft_strlcat.c \
ft_strlen.c \
ft_strmap.c \
ft_strmapi.c \
ft_strncat.c \
ft_strncmp.c \
ft_strncpy.c \
ft_strnequ.c \
ft_strnew.c \
ft_strnstr.c \
ft_strrchr.c \
ft_strsplit.c \
ft_strstr.c \
ft_strsub.c \
ft_strtrim.c \
ft_tolower.c \
ft_toupper.c \
ft_lstadd.c \
ft_lstdel.c \
ft_lstdelone.c \
ft_lstiter.c \
ft_lstnew.c \
ft_lstmap.c \
ft_2d_int_array.c \
ft_2d_char_array.c \
ft_map_2d_int_array.c \
ft_map_2d_char_array.c \

OBJ = $(SRC:.c=.o)

all: $(NAME)

$(NAME): $(OBJ)
@ar rc $(NAME) $(OBJ)
@echo "$(NAME) created"
@ranlib $(NAME)
@echo "$(NAME) indexed"

%.o: %.c
@gcc $(FLAG) -c $< -o $@

clean:
@rm -f $(OBJ)
@echo "OBJ deleted"

fclean: clean
@rm -f $(NAME)
@echo "$(NAME) deleted"

re: fclean all

.PHONY: all, clean, fclean, re
1 change: 1 addition & 0 deletions author
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sgrindhe
35 changes: 35 additions & 0 deletions ft_2d_char_array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_2d_char_array.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/08/06 23:37:00 by sgrindhe #+# #+# */
/* Updated: 2018/08/08 21:45:27 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

char **ft_2d_char_array(unsigned int width, unsigned int height)
{
unsigned int i;
char **result;

if (width == 0 || height == 0)
return (NULL);
result = malloc(sizeof(char*) * (width + 1));
result[width] = NULL;
if (!result)
return (NULL);
i = 0;
while (i < height)
{
result[i] = (char*)malloc(sizeof(char) * (height + 1));
if (!result[i])
return (NULL);
result[i++][height] = '\0';
}
return (result);
}
36 changes: 36 additions & 0 deletions ft_2d_int_array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_2d_int_array.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/08/07 23:07:22 by sgrindhe #+# #+# */
/* Updated: 2018/08/08 21:45:51 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

t_2d_int_array *ft_2d_int_array(unsigned int width, unsigned int height)
{
unsigned int i;
int **temp_array;
t_2d_int_array *s_result;

if (width == 0 || height == 0)
return (NULL);
temp_array = malloc(sizeof(int*) * width);
if (!temp_array)
return (NULL);
i = 0;
while (i < height)
{
temp_array[i++] = (int*)malloc(sizeof(int) * height);
}
s_result = malloc((sizeof(int*) * width) * (sizeof(int) * height));
s_result->two_dim_array = temp_array;
s_result->width = width;
s_result->height = height;
return (s_result);
}
50 changes: 50 additions & 0 deletions ft_atoi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/07/29 23:39:12 by sgrindhe #+# #+# */
/* Updated: 2018/08/05 00:26:37 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

static int trim_array(const char *str)
{
int i;

i = 0;
while ((str[i] >= 9 && str[i] <= 13) || str[i] == 32)
i++;
return (i);
}

int ft_atoi(const char *str)
{
long long num;
int i;
int bool_negative;

num = 0;
bool_negative = 0;
i = trim_array(str) - 1;
if (str[i + 1] == '-')
{
i++;
bool_negative = 1;
}
else if (str[i + 1] == '+')
i++;
while (str[++i])
{
if (str[i] < '0' || str[i] > '9')
return (bool_negative == 1 ? -num : num);
num += str[i] - '0';
if (str[i + 1] >= '0' && str[i + 1] <= '9')
num *= 10;
}
return (bool_negative == 1 ? (int)-num : (int)num);
}
27 changes: 27 additions & 0 deletions ft_bzero.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/07/17 04:14:41 by sgrindhe #+# #+# */
/* Updated: 2018/08/05 00:33:33 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_bzero(void *s, size_t n)
{
char *str;
size_t i;

str = (char*)s;
i = 0;
while (i < n)
{
str[i] = 0;
i++;
}
}
25 changes: 25 additions & 0 deletions ft_isalnum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/07/12 03:50:48 by sgrindhe #+# #+# */
/* Updated: 2018/08/05 00:33:45 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

int ft_isalnum(int c)
{
if (ft_isalpha(c) != 0 || ft_isdigit(c) != 0)
{
return (1);
}
else
{
return (0);
}
}
23 changes: 23 additions & 0 deletions ft_isalpha.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/07/12 02:22:26 by sgrindhe #+# #+# */
/* Updated: 2018/07/21 15:20:51 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isalpha(int c)
{
if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122))
{
return (c);
}
else
{
return (0);
}
}
23 changes: 23 additions & 0 deletions ft_isascii.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isascii.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/07/12 02:09:49 by sgrindhe #+# #+# */
/* Updated: 2018/07/12 02:13:49 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isascii(int c)
{
if (c >= 0 && c <= 127)
{
return (1);
}
else
{
return (0);
}
}
23 changes: 23 additions & 0 deletions ft_isdigit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isdigit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/07/12 01:58:17 by sgrindhe #+# #+# */
/* Updated: 2018/07/12 02:14:11 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isdigit(int c)
{
if (c >= 48 && c <= 57)
{
return (1);
}
else
{
return (0);
}
}
23 changes: 23 additions & 0 deletions ft_isprint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isprint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/07/12 02:19:10 by sgrindhe #+# #+# */
/* Updated: 2018/07/12 02:20:09 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isprint(int c)
{
if (c >= 32 && c <= 126)
{
return (1);
}
else
{
return (0);
}
}
Loading

0 comments on commit 32231f5

Please sign in to comment.