This commit is contained in:
Camille Chauvet 2023-01-05 19:04:29 +01:00
parent 909bb442b6
commit 975e0c2ef5
89 changed files with 226 additions and 201 deletions

View File

@ -1,4 +1,4 @@
SRCS = draw.c main.c shape.c xpm.c SRCS = draw.c main.c map.c shape.c xpm.c
OBJ = ${SRCS:.c=.o} OBJ = ${SRCS:.c=.o}

View File

@ -6,19 +6,19 @@
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ # # By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# # # Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2023/01/04 20:00:03 by cchauvet ### ########.fr # # Updated: 2023/01/05 19:00:54 by cchauvet ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
CC = clang CC = clang
SRCS = ft_strcmp.c ft_strfjoin.c ft_strmerger.c SRCS = draw.c main.c map.c shape.c xpm.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)
NAME = extra.a NAME = extra.a
CFLAGS = -Wall -Werror -Wextra CFLAGS = -Wall -Werror -Wextra -g
%.o: %.c extra.h %.o: %.c extra.h
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) -c -o $@ $<

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 14:03:10 by cchauvet #+# #+# */ /* Created: 2023/01/04 14:03:10 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:59:10 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 18:59:25 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,5 +18,6 @@
char *ft_strfjoin(char *s1, char *s2); char *ft_strfjoin(char *s1, char *s2);
char *ft_strmerger(size_t arg_len, ...); char *ft_strmerger(size_t arg_len, ...);
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
int ft_strcmp(char *s1, char *s2); int ft_strcmp(char *s1, char *s2);
#endif #endif

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 19:20:47 by cchauvet #+# #+# */ /* Created: 2023/01/04 19:20:47 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:22:20 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 13:20:20 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,7 +14,10 @@
int ft_strcmp(char *s1, char *s2) int ft_strcmp(char *s1, char *s2)
{ {
while (*s1 == *s2 && *s1 != '\0') int i;
s1++;
return (*s1 - *s2); i = 0;
while (s1[i] == s2[i] && s1[i] != '\0')
i++;
return (s1[i] - s2[i]);
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tabrealloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/05 18:58:48 by cchauvet #+# #+# */
/* Updated: 2023/01/05 18:58:59 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size)
{
char **new;
size_t i;
new = malloc(new_size * sizeof(char *));
if (new == NULL)
return (NULL);
i = 0;
while (i < current_size)
{
new[i] = tab[i];
i++;
}
free(tab);
return (new);
}

View File

@ -6,7 +6,7 @@
# By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ # # By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2022/12/14 15:49:18 by cchauvet #+# #+# # # Created: 2022/12/14 15:49:18 by cchauvet #+# #+# #
# Updated: 2022/12/14 16:08:19 by cchauvet ### ########.fr # # Updated: 2023/01/05 17:44:06 by cchauvet ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -16,7 +16,7 @@ OBJS = ${SRCS:.c=.o}
NAME = get_next_line.a NAME = get_next_line.a
CFLAGS = -Wall -Werror -Wextra CFLAGS = -Wall -Werror -Wextra -g
CC = clang CC = clang

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/26 00:52:47 by cchauvet #+# #+# */ /* Created: 2022/10/26 00:52:47 by cchauvet #+# #+# */
/* Updated: 2022/11/14 15:37:48 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 13:07:10 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -36,7 +36,7 @@ char *ft_getline(int fd)
stash = NULL; stash = NULL;
buf = NULL; buf = NULL;
while (ft_strchr(stash, '\n') == -1) while (ft_strchri(stash, '\n') == -1)
{ {
buf = ft_getstash(fd); buf = ft_getstash(fd);
if (buf == NULL) if (buf == NULL)
@ -54,7 +54,7 @@ char *ft_getreturn(char *str)
if (str == NULL) if (str == NULL)
return (NULL); return (NULL);
i = ft_strchr(str, '\n') + 1; i = ft_strchri(str, '\n') + 1;
if (i == 0) if (i == 0)
i = ft_strlen(str); i = ft_strlen(str);
return (ft_strndup(str, i)); return (ft_strndup(str, i));
@ -67,7 +67,7 @@ char *ft_getextra(char *str)
if (str == NULL) if (str == NULL)
return (NULL); return (NULL);
i = ft_strchr(str, '\n') + 1; i = ft_strchri(str, '\n') + 1;
if (i == 0) if (i == 0)
return (NULL); return (NULL);
j = ft_strlen(str + i); j = ft_strlen(str + i);
@ -81,7 +81,7 @@ char *get_next_line(int fd)
char *buf2; char *buf2;
buf2 = stash; buf2 = stash;
if (ft_strchr(stash, '\n') == -1) if (ft_strchri(stash, '\n') == -1)
{ {
buf1 = ft_getline(fd); buf1 = ft_getline(fd);
buf2 = ft_strfjoin(stash, buf1); buf2 = ft_strfjoin(stash, buf1);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/14 15:38:06 by cchauvet #+# #+# */ /* Created: 2022/11/14 15:38:06 by cchauvet #+# #+# */
/* Updated: 2023/01/04 20:05:54 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 13:06:19 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,12 +17,11 @@
# ifndef BUFFER_SIZE # ifndef BUFFER_SIZE
# define BUFFER_SIZE 42 # define BUFFER_SIZE 42
# endif # endif
# include "../libft/libft.h"
void *ft_calloc(size_t nmemb, size_t size); void *ft_calloc(size_t nmemb, size_t size);
void *ft_realloc(void *ptr, size_t size); void *ft_realloc(void *ptr, size_t size);
char *ft_strfjoin(char *dst, char *src); char *ft_strfjoin(char *dst, char *src);
char *ft_strndup(char *src, size_t n); char *ft_strndup(char *src, size_t n);
size_t ft_strlen(char *str); ssize_t ft_strchri(char *str, char c);
ssize_t ft_strchr(char *str, char c);
char *get_next_line(int fd); char *get_next_line(int fd);
#endif #endif

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/26 00:55:44 by cchauvet #+# #+# */ /* Created: 2022/10/26 00:55:44 by cchauvet #+# #+# */
/* Updated: 2022/11/14 15:39:50 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 13:06:37 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -31,18 +31,6 @@ void *ft_calloc(size_t nmemb, size_t size)
return ((void *) tab); return ((void *) tab);
} }
size_t ft_strlen(char *str)
{
size_t i;
if (str == NULL)
return (0);
i = 0;
while (str[i] != '\0')
i++;
return (i);
}
char *ft_strfjoin(char *s1, char *s2) char *ft_strfjoin(char *s1, char *s2)
{ {
ssize_t i; ssize_t i;
@ -91,7 +79,7 @@ char *ft_strndup(char *src, size_t n)
return (out); return (out);
} }
ssize_t ft_strchr(char *str, char c) ssize_t ft_strchri(char *str, char c)
{ {
size_t i; size_t i;

Binary file not shown.

View File

@ -6,7 +6,7 @@
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ # # By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# # # Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2023/01/04 15:35:42 by cchauvet ### ########.fr # # Updated: 2023/01/05 17:44:37 by cchauvet ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -63,7 +63,7 @@ BOBJS = $(BSRCS:.c=.o)
NAME = libft.a NAME = libft.a
CFLAGS = -Wall -Werror -Wextra CFLAGS = -Wall -Werror -Wextra -g
%.o: %.c libft.h %.o: %.c libft.h
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) -c -o $@ $<

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,13 +6,13 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/29 22:23:35 by cchauvet #+# #+# */ /* Created: 2022/09/29 22:23:35 by cchauvet #+# #+# */
/* Updated: 2022/09/29 22:24:53 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 18:54:54 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"
void ft_putchar_fd(char c, int fd) void ft_putchar_fd(int fd, char c)
{ {
write(fd, &c, 1); write(fd, &c, 1);
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,15 +6,18 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 12:03:59 by cchauvet #+# #+# */ /* Created: 2022/09/26 12:03:59 by cchauvet #+# #+# */
/* Updated: 2022/09/27 09:02:11 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 17:46:12 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <stddef.h>
#include "libft.h"
size_t ft_strlen(const char *s) size_t ft_strlen(const char *s)
{ {
size_t length; size_t length;
if (s == NULL)
return (0);
length = 0; length = 0;
while (s[length]) while (s[length])
length++; length++;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */ /* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
/* Updated: 2023/01/04 15:20:30 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 18:55:10 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -46,7 +46,7 @@ char **ft_split(char const *s, char c);
char *ft_itoa(int n); char *ft_itoa(int n);
char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
void ft_striteri(char *s, void (*f)(unsigned int, char*)); void ft_striteri(char *s, void (*f)(unsigned int, char*));
void ft_putchar_fd(char c, int fd); void ft_putchar_fd(int fd, char c);
void ft_putstr_fd(char *s, int fd); void ft_putstr_fd(char *s, int fd);
void ft_putendl_fd(char *s, int fd); void ft_putendl_fd(char *s, int fd);
void ft_putnbr_fd(int n, int fd); void ft_putnbr_fd(int n, int fd);

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */ /* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
/* Updated: 2023/01/04 20:07:06 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 18:59:40 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,6 +19,7 @@
int ft_printf(const char *format, ...); int ft_printf(const char *format, ...);
char *get_next_line(int fd); char *get_next_line(int fd);
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
char *ft_strfjoin(char *s1, char *s2); char *ft_strfjoin(char *s1, char *s2);
char *ft_strmerger(size_t arg_len, ...); char *ft_strmerger(size_t arg_len, ...);
int ft_strcmp(char *s1, char *s2); int ft_strcmp(char *s1, char *s2);
@ -54,10 +55,10 @@ char **ft_split(char const *s, char c);
char *ft_itoa(int n); char *ft_itoa(int n);
char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
void ft_striteri(char *s, void (*f)(unsigned int, char*)); void ft_striteri(char *s, void (*f)(unsigned int, char*));
void ft_putchar_fd(char c, int fd); void ft_putchar_fd(int fd, char c);
void ft_putstr_fd(char *s, int fd); void ft_putstr_fd(int fd, char *s);
void ft_putendl_fd(char *s, int fd); void ft_putendl_fd(int fd, char *s);
void ft_putnbr_fd(int n, int fd); void ft_putnbr_fd(int fd, int n);
typedef struct s_list typedef struct s_list
{ {

View File

@ -6,22 +6,22 @@
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ # # By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# # # Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2023/01/04 15:36:08 by cchauvet ### ########.fr # # Updated: 2023/01/05 18:25:05 by cchauvet ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
CC = clang CC = clang
SRCS = ft_dprintul_base.c ft_isdigit.c ft_dprintul.c ft_dprintx.c ft_dprintflag.c ft_skipflag.c ft_vdprintf.c ft_dprintl_base.c ft_dprintX.c ft_dprintptr.c ft_strlen.c ft_putstr_fd.c ft_dprintarg.c ft_printf.c ft_putchar_fd.c ft_isarg.c SRCS = ft_dprintarg.c ft_dprintflag.c ft_dprintl_base.c ft_dprintptr.c ft_dprintstrtab.c ft_dprintul_base.c ft_dprintul.c ft_dprintx.c ft_dprintX.c ft_isarg.c ft_isdigit.c ft_printf.c ft_putchar_fd.c ft_putstr_fd.c ft_skipflag.c ft_strlen.c ft_vdprintf.c
OBJS = ${SRCS:.c=.o} OBJS = ${SRCS:.c=.o}
NAME = ft_printf.a NAME = ft_printf.a
CFLAG = -Wall -Werror -Wextra CFLAG = -Wall -Werror -Wextra -g
%.o: %.c %.o: %.c
${CC} ${CFLAGS} -c -o $@ $< ${CC} ${CFLAG} -c -o $@ $<
all: ${NAME} all: ${NAME}

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/23 18:08:31 by cchauvet #+# #+# */ /* Created: 2022/10/23 18:08:31 by cchauvet #+# #+# */
/* Updated: 2022/10/23 18:54:41 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 17:37:12 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -24,6 +24,8 @@ int ft_dprintarg(int fd, int arg, va_list args)
return (ft_dprintul(fd, va_arg(args, unsigned int))); return (ft_dprintul(fd, va_arg(args, unsigned int)));
if (arg == 'c') if (arg == 'c')
return (ft_putchar_fd(fd, va_arg(args, int))); return (ft_putchar_fd(fd, va_arg(args, int)));
if (arg == 'S')
return (ft_dprintstrtab(fd, va_arg(args, char **)));
if (arg == 's') if (arg == 's')
return (ft_putstr_fd(fd, va_arg(args, char *))); return (ft_putstr_fd(fd, va_arg(args, char *)));
if (arg == '%') if (arg == '%')

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dprintstrtab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/05 17:26:55 by cchauvet #+# #+# */
/* Updated: 2023/01/05 18:52:56 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_dprintstrtab(int fd, char **tab)
{
size_t index;
int i;
i = 0;
index = 0;
while (tab[index] != NULL)
{
i += ft_putstr_fd(fd, tab[index]) + 1;
ft_putchar_fd(fd, '\n');
index++;
}
return (i);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/11 22:37:41 by cchauvet #+# #+# */ /* Created: 2022/10/11 22:37:41 by cchauvet #+# #+# */
/* Updated: 2022/10/12 16:09:22 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 18:26:24 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,7 +18,7 @@ int ft_isarg(int c)
if (c == '\0') if (c == '\0')
return (1); return (1);
flags = "cspdiuxX%"; flags = "cspdiuxX%S";
while (*flags) while (*flags)
{ {
if (*flags == c) if (*flags == c)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */ /* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
/* Updated: 2022/11/07 19:41:50 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 17:36:39 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -29,6 +29,7 @@ int ft_dprintx(int fd, unsigned int n);
int ft_dprint_upperx(int fd, unsigned int n); int ft_dprint_upperx(int fd, unsigned int n);
int ft_dprintflag(int fd, const char *flag, va_list va); int ft_dprintflag(int fd, const char *flag, va_list va);
int ft_dprintarg(int fd, int c, va_list va); int ft_dprintarg(int fd, int c, va_list va);
int ft_dprintstrtab(int fd, char **tab);
int ft_printf(const char *format, ...); int ft_printf(const char *format, ...);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

24
main.c
View File

@ -6,13 +6,25 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/12 17:20:17 by cchauvet #+# #+# */ /* Created: 2022/12/12 17:20:17 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:47:28 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 18:18:07 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "solong.h" #include "solong.h"
int main(void) int main(int ac, char **av)
{
char **map;
if (ac)
{
map = ft_readfile(av[1]);
ft_printf("%S", map);
}
return (0);
}
int maiin(void)
{ {
void *window_manager; void *window_manager;
void *window; void *window;
@ -22,16 +34,18 @@ int main(void)
window = mlx_new_window(window_manager, 500, 500, "Hello world!"); window = mlx_new_window(window_manager, 500, 500, "Hello world!");
shape.x = 10; shape.x = 10;
shape.y = 10; shape.y = 10;
shape.size = 100; shape.size = 25;
shape.color = ft_strdup("purple"); shape.color = ft_strdup("yellow");
shape.bcolor = ft_strdup("black"); shape.bcolor = ft_strdup("black");
shape.shape = ft_strdup("square"); shape.shape = ft_strdup("square");
printf("%d", ft_strcmp(shape.shape, "square"));
ft_xpm_gen_file(shape); ft_xpm_gen_file(shape);
free(shape.color); free(shape.color);
free(shape.bcolor); free(shape.bcolor);
free(shape.shape); free(shape.shape);
mlx_loop(window_manager); // mlx_loop(window_manager);
mlx_destroy_window(window_manager, window); mlx_destroy_window(window_manager, window);
mlx_destroy_display(window_manager); mlx_destroy_display(window_manager);
free(window_manager); free(window_manager);
return (1);
} }

BIN
main.o

Binary file not shown.

36
map.c Normal file
View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/05 13:51:49 by cchauvet #+# #+# */
/* Updated: 2023/01/05 19:00:31 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "solong.h"
char **ft_readfile(char *path)
{
char **map;
int fd;
ssize_t nb_line;
fd = open(path, O_RDONLY);
nb_line = 1;
map = malloc(sizeof(char *) * 2);
if (map == NULL)
return (NULL);
map[0] = get_next_line(fd);
while (map[nb_line - 1] != NULL)
{
map[nb_line] = get_next_line(fd);
map = ft_tabrealloc(map, nb_line + 1, nb_line + 2);
if (map == NULL)
return (NULL);
nb_line++;
}
return (map);
}

BIN
map.o Normal file

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 16:20:03 by cchauvet #+# #+# */ /* Created: 2023/01/04 16:20:03 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:48:18 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 17:40:19 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -34,5 +34,5 @@ char *ft_gen_xpm_file(t_shape);
char *ft_square(char c, size_t x_len, size_t y_len); char *ft_square(char c, size_t x_len, size_t y_len);
char *ft_triangle(char c, char b, size_t x_len, size_t y_len); char *ft_triangle(char c, char b, size_t x_len, size_t y_len);
char *ft_xpm_gen_file(t_shape shape); char *ft_xpm_gen_file(t_shape shape);
char **ft_readfile(char *path);
#endif #endif

16
test.c
View File

@ -1,16 +0,0 @@
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(int ac, char **av)
{
int fd;
if (ac)
{
fd = open(av[1], O_RDONLY);
printf("%d", fd);
close(fd);
}
return (0);
}

View File

@ -1,105 +0,0 @@
/* XPM */
static char * XFACE[] = {"
100 100 1 1",
"a c purple",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa"};

42
xpm.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 13:53:03 by cchauvet #+# #+# */ /* Created: 2023/01/04 13:53:03 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:48:36 by cchauvet ### ########.fr */ /* Updated: 2023/01/05 13:47:30 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,6 +17,7 @@ static char *name_generator(t_shape shape)
char *out; char *out;
char *size; char *size;
char *color; char *color;
char *temp;
color = ft_strdup(shape.color); color = ft_strdup(shape.color);
if (color == NULL) if (color == NULL)
@ -24,7 +25,10 @@ static char *name_generator(t_shape shape)
size = ft_itoa(shape.size); size = ft_itoa(shape.size);
if (size == NULL) if (size == NULL)
return (NULL); return (NULL);
out = ft_strmerger(8, shape.shape, "_", color, "_", size, "x", size, ".xpm"); temp = ft_strmerger(5, XPM_PATH, shape.shape, "_", color, "_");
if (temp == NULL)
return (NULL);
out = ft_strmerger(5, temp, size, "x", size, ".xpm");
return (out); return (out);
} }
@ -39,7 +43,7 @@ static char *ft_map_gen(t_shape shape)
char *ft_gen_xpm_content(t_shape shape) char *ft_gen_xpm_content(t_shape shape)
{ {
char *xpm_content; char *content;
char *temp; char *temp;
char *size; char *size;
char *map; char *map;
@ -50,44 +54,46 @@ char *ft_gen_xpm_content(t_shape shape)
temp = ft_strdup("/* XPM */\nstatic char * XFACE[] = {" "\"\n"); temp = ft_strdup("/* XPM */\nstatic char * XFACE[] = {" "\"\n");
if (temp == NULL) if (temp == NULL)
return (NULL); return (NULL);
xpm_content = ft_strmerger(5, temp, size, " ", size, " 2 1\",\n\""); content = ft_strmerger(5, temp, size, " ", size, " 2 1\",\n\"");
free(temp); free(temp);
if (xpm_content == NULL) if (content == NULL)
return (NULL); return (NULL);
map = ft_map_gen(shape); map = ft_map_gen(shape);
if (map == NULL) if (map == NULL)
return (NULL); return (NULL);
temp = ft_strmerger(5, xpm_content, "a c ", shape.color, "\",\n", map); temp = ft_strmerger(4, content, "a c ", shape.color, "\",\n\"");
if (temp == NULL) if (temp == NULL)
return (NULL); return (NULL);
free(xpm_content); free(content);
xpm_content = ft_strmerger(2, temp, "\"b c ", shape.bcolor, "\",\n};"); content = ft_strmerger(6, temp, "b c ", shape.bcolor, "\",\n", map, "};");
free(temp); free(temp);
return (xpm_content); return (content);
} }
char *ft_xpm_gen_file(t_shape shape) char *ft_xpm_gen_file(t_shape shape)
{ {
char *file_content; char *file_content;
char *name; char *path;
int fd; int fd;
file_content = ft_gen_xpm_content(shape); file_content = ft_gen_xpm_content(shape);
if (file_content == NULL) if (file_content == NULL)
return (NULL); return (NULL);
name = name_generator(shape); path = name_generator(shape);
if (name == NULL) if (path == NULL)
{
free(file_content);
return (NULL); return (NULL);
name = ft_strfjoin(XPM_PATH, name); }
if (name == NULL) fd = open(path, O_RDONLY);
return (NULL);
fd = open(name, O_RDONLY);
if (fd == -1) if (fd == -1)
{ {
close(fd); close(fd);
fd = open(name, O_WRONLY | O_CREAT, 0644); fd = open(path, O_WRONLY | O_CREAT, 0644);
if (fd == -1)
return (NULL);
write(fd, file_content, ft_strlen(file_content)); write(fd, file_content, ft_strlen(file_content));
close(fd); close(fd);
} }
return (name); return (path);
} }

BIN
xpm.o

Binary file not shown.