Skip to content

Commit

Permalink
Merge pull request #1 from Haliris/init_branch
Browse files Browse the repository at this point in the history
Init PR, adds libft to repo, tests workflows
  • Loading branch information
Tsunghao-C authored Aug 15, 2024
2 parents 2e5abc3 + 558c404 commit 7bcbd1d
Show file tree
Hide file tree
Showing 56 changed files with 1,997 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jteissie <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/08/14 18:14:24 by jteissie #+# #+# #
# Updated: 2024/08/14 18:16:09 by jteissie ### ########.fr #
# #
# **************************************************************************** #

NAME = cub3d
CC = cc
CFLAGS = -Wall -Werror -Wextra -g3

SRCDIR = srcs
OBJDIR = obj
CFILES = main.c

INCS = -I ./include \
-I ./libft

vpath %.c ./ srcs/

OBJS = $(addprefix $(OBJDIR)/, $(CFILES:.c=.o))

all: $(OBJDIR) $(NAME)

$(OBJDIR)/%.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS) $(INCS) -c $< -o $@

$(OBJDIR):
mkdir -p $(OBJDIR)

$(NAME): $(OBJS)
make -C ./libft all
$(CC) $(CFLAGS) $(INCS) -o $(NAME) $(OBJS) -L ./libft/ -lft $(LDFLAGS)
@echo "> Cub3d build done!"

clean:
@echo "> Cleaning object files..."
make -C ./libft/ clean
@rm -rf $(OBJDIR)

fclean: clean
@echo "> Removing cub3d..."
rm -f ./libft/libft.a
rm -f $(NAME)

re: fclean all

.PHONY: all clean fclean re
15 changes: 15 additions & 0 deletions include/cub3d.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/14 18:13:07 by jteissie #+# #+# */
/* Updated: 2024/08/14 18:13:26 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef CUB3D_H
# define CUB3D_H
#endif
17 changes: 17 additions & 0 deletions libft/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**/*.out
**/*.a
**/*.o
**/.vscode
**/.gch
**/main
**/*.swp
srcs/libftTester/
./libtest/
srcs/libft.h
srcs/libft.h.gch
srcs/libft.so
srcs/Makefile
srcs/libft.a
libft-war-machine/*
test_dump.c
test_main.c
94 changes: 94 additions & 0 deletions libft/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: bthomas <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/03/24 16:14:13 by jteissie #+# #+# #
# Updated: 2024/07/29 11:40:50 by bthomas ### ########.fr #
# #
# **************************************************************************** #

CC = cc

CCFLAGS = -Wall -Wextra -Werror -g3

NAME = libft.a

SRC = ft_atoi.c \
ft_bzero.c \
ft_calloc.c \
ft_isalnum.c \
ft_isalpha.c \
ft_isascii.c \
ft_isdigit.c \
ft_isprint.c \
ft_itoa.c \
ft_memchr.c \
ft_memcpy.c \
ft_memcmp.c \
ft_memmove.c \
ft_memset.c \
ft_putchar_fd.c \
ft_putnbr_fd.c \
ft_putendl_fd.c \
ft_putstr_fd.c \
ft_split.c \
ft_strchr.c \
ft_strdup.c \
ft_striteri.c \
ft_strjoin.c \
ft_strlcat.c \
ft_strlcpy.c \
ft_strlen.c \
ft_strmapi.c \
ft_strncmp.c \
ft_strcmp.c \
ft_strnstr.c \
ft_strrchr.c \
ft_strtrim.c \
ft_substr.c \
ft_tolower.c \
ft_toupper.c \
ft_strjoin3.c \
ft_strreplacejoin.c \
ft_strarrjoin.c \
ft_printf/ft_printf.c \
ft_printf/format_triage.c \
ft_printf/write_utils.c

BONUS = ft_lstnew_bonus.c \
ft_lstadd_front_bonus.c \
ft_lstsize_bonus.c \
ft_lstlast_bonus.c \
ft_lstadd_back_bonus.c \
ft_lstdelone_bonus.c \
ft_lstclear_bonus.c \
ft_lstiter_bonus.c \
ft_lstmap_bonus.c

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

BONUS_OBJS = $(BONUS:.c=.o)

all : $(NAME)

$(NAME) : $(OBJS)
ar rc $(NAME) $(OBJS)

%.o: %.c
$(CC) $(CCFLAGS) -c $< -I ./ -o $@

clean :
rm -f $(OBJS) $(BONUS_OBJS)

fclean : clean
rm -f $(NAME)

bonus : $(BONUS_OBJS)
ar rc $(NAME) $(BONUS_OBJS)

re : fclean all

.PHONY : all clean fclean re bonus
38 changes: 38 additions & 0 deletions libft/ft_atoi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/22 19:28:31 by jteissie #+# #+# */
/* Updated: 2024/03/23 16:31:12 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_atoi(const char *nptr)
{
int i;
int result;
int minus;

i = 0;
result = 0;
minus = 0;
while (nptr[i] == ' ' || (nptr[i] >= 9 && nptr[i] <= 13))
i++;
if (nptr[i] == '-' || nptr[i] == '+')
{
if (nptr[i] == '-')
minus = 1;
i++;
}
while (nptr[i] >= '0' && nptr[i] <= '9')
{
result = result * 10 + (nptr[i] - '0');
i++;
}
if (minus)
result *= -1;
return (result);
}
27 changes: 27 additions & 0 deletions libft/ft_bzero.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:41:46 by jteissie #+# #+# */
/* Updated: 2024/05/15 15:00:35 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

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

i = 0;
str = s;
while (i < n)
{
str[i] = '\0';
i++;
}
}
28 changes: 28 additions & 0 deletions libft/ft_calloc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 17:05:28 by jteissie #+# #+# */
/* Updated: 2024/05/22 15:40:09 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void *ft_calloc(size_t nmemb, size_t size)
{
void *ptr;
size_t total_size;

total_size = size * nmemb;
if (total_size < size && total_size != 0)
return (NULL);
ptr = malloc(total_size);
if (!ptr)
return (NULL);
ft_memset(ptr, 0, total_size);
return (ptr);
}
20 changes: 20 additions & 0 deletions libft/ft_isalnum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:31:49 by jteissie #+# #+# */
/* Updated: 2024/05/22 14:57:58 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isalnum(int c)
{
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
return (1);
if (c >= '0' && c <= '9')
return (1);
return (0);
}
18 changes: 18 additions & 0 deletions libft/ft_isalpha.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:42:26 by jteissie #+# #+# */
/* Updated: 2024/05/22 14:58:03 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isalpha(int c)
{
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
return (1);
return (0);
}
18 changes: 18 additions & 0 deletions libft/ft_isascii.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isascii.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 17:06:25 by jteissie #+# #+# */
/* Updated: 2024/05/22 14:58:10 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isascii(int c)
{
if (c > 127 || c < 0)
return (0);
return (1);
}
18 changes: 18 additions & 0 deletions libft/ft_isdigit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isdigit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:33:38 by jteissie #+# #+# */
/* Updated: 2024/05/22 14:58:16 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isdigit(int c)
{
if (c >= '0' && c <= '9')
return (1);
return (0);
}
18 changes: 18 additions & 0 deletions libft/ft_isprint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isprint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:43:06 by jteissie #+# #+# */
/* Updated: 2024/03/24 18:13:36 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

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

0 comments on commit 7bcbd1d

Please sign in to comment.