Skip to content

Commit

Permalink
files added
Browse files Browse the repository at this point in the history
  • Loading branch information
agras committed Apr 8, 2024
1 parent 31a16b3 commit f3d243b
Show file tree
Hide file tree
Showing 61 changed files with 2,371 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
57 changes: 57 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: agras <agras@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/03/01 10:20:34 by agras #+# #+# #
# Updated: 2022/04/12 21:33:47 by agras ### ########.fr #
# #
# **************************************************************************** #

INCLUDES_CLIENT = -I includes/server/ -I libft/includes/

INCLUDES_SERVER = -I includes/client/ -I libft/includes/

SERVER_SRCS = src/server/server.c\
src/server/bit_management.c

CLIENT_SRCS = src/client/client.c

SERVER_OBJS = $(SERVER_SRCS:.c=.o)

CLIENT_OBJS = $(CLIENT_SRCS:.c=.o)

CC = gcc
RM = rm -f
CFLAGS = -Wall -Wextra -Werror
#CFLAGS =


all: lib server client

server: $(SERVER_OBJS)
$(CC) $(CFLAGS) $(SERVER_OBJS) ${INCLUDES_SERVER} -L./libft -lft -o server

client: $(CLIENT_OBJS)
$(CC) $(CFLAGS) $(CLIENT_OBJS) ${INCLUDES_CLIENT} -L./libft -lft -o client

lib:
@ make --no-print-directory -sC ./libft

clean:
$(RM) $(SERVER_OBJS)
$(RM) $(CLIENT_OBJS)
make clean -C libft

fclean:
$(RM) $(SERVER_OBJS)
$(RM) server
$(RM) $(CLIENT_OBJS)
$(RM) client
make fclean -C libft

re: fclean all

.PHONY: all clean fclean re
25 changes: 25 additions & 0 deletions includes/client/client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* client.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: agras <agras@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/12 22:05:50 by agras #+# #+# */
/* Updated: 2022/04/12 19:19:24 by agras ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef CLIENT_H
# define CLIENT_H

# include <sys/types.h>
# include <signal.h>
# include <unistd.h>
# include <stdlib.h>
# include <string.h>
# include <stdio.h>

# include "../../libft/includes/libft.h"

#endif
29 changes: 29 additions & 0 deletions includes/server/server.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* server.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: agras <agras@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/12 21:59:44 by agras #+# #+# */
/* Updated: 2022/04/12 21:32:06 by agras ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef SERVER_H
# define SERVER_H

# include <sys/types.h>
# include <unistd.h>
# include <stdlib.h>
# include <stdio.h>
# include <signal.h>
# include <string.h>

# include "../../libft/includes/libft.h"

void set_bit(char *byte, int shift);
void clear_bit(char *byte, int shift);
void print_byte_bin(unsigned char byte);

#endif
99 changes: 99 additions & 0 deletions libft/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: agras <agras@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/11/01 01:48:03 by agras #+# #+# #
# Updated: 2022/02/09 17:01:24 by agras ### ########.fr #
# #
# **************************************************************************** #

NAME = libft.a
SRCS = ${IS}ft_isalpha.c\
${IS}ft_isdigit.c\
${IS}ft_isalnum.c\
${IS}ft_isascii.c\
${IS}ft_isprint.c\
${MEM}ft_memset.c\
${MEM}ft_bzero.c\
${MEM}ft_memcpy.c\
${MEM}ft_memcmp.c\
${MEM}ft_memmove.c\
${MEM}ft_memchr.c\
${MEM}ft_calloc.c\
${STR}ft_strlen.c\
${STR}ft_substr.c\
${STR}ft_strjoin.c\
${STR}ft_strlcpy.c\
${STR}ft_strlcat.c\
${STR}ft_toupper.c\
${STR}ft_tolower.c\
${STR}ft_strchr.c\
${STR}ft_strrchr.c\
${STR}ft_strncmp.c\
${STR}ft_strnstr.c\
${STR}ft_strdup.c\
${STR}ft_strtrim.c\
${STR}ft_strmapi.c\
${STR}ft_striteri.c\
${STR}ft_cstr.c\
${STR}ft_split.c\
${STR}ft_strcmp.c\
${STR}strcmp_occurence.c\
${STR}ft_strcat_malloc.c\
${PRINT}ft_putstr_fd.c\
${PRINT}ft_putnbr_fd.c\
${PRINT}ft_putendl_fd.c\
${PRINT}ft_putchar_fd.c\
${PRINT}ft_print_2d_tab_char.c\
${CONV}ft_itoa.c\
${CONV}ft_atoi.c\
${LST}ft_lstsize.c\
${LST}ft_lstnew.c\
${LST}ft_lstmap.c\
${LST}ft_lstlast.c\
${LST}ft_lstiter.c\
${LST}ft_lstdelone.c\
${LST}ft_lstclear.c\
${LST}ft_lstadd_front.c\
${LST}ft_lstadd_back.c\
${GNL}get_next_line_utils.c\
${GNL}get_next_line.c\
${FREE}free_2d_tab.c

GNL = src/gnl/
IS = src/is/
CONV = src/conv/
MEM = src/mem/
PRINT = src/print/
LST = src/lst/
STR = src/str/
FREE = src/free/

INCLUDES = -I includes
OBJS = ${SRCS:.c=.o}
CC = gcc
CFLAGS = -Wall -Wextra -Werror
RM = rm -f

.c.o:
${CC} ${CFLAGS} ${INCLUDES} -c $< -o ${<:.c=.o}

${NAME}: ${OBJS}
ar rcs ${NAME} ${OBJS}

# bonus: ${OBJS} ${OBJSB}
# ar rcs ${NAME} ${OBJSB}

all: ${NAME}

clean:
${RM} ${OBJS}

fclean: clean
${RM} ${NAME}

re: fclean all

105 changes: 105 additions & 0 deletions libft/includes/libft.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libft.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: agras <agras@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/24 14:20:16 by agras #+# #+# */
/* Updated: 2022/02/09 16:44:02 by agras ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef LIBFT_H
# define LIBFT_H
# include <stddef.h>
# include <stdlib.h>
# include <unistd.h>

# include "../src/gnl/get_next_line.h"

// ----------- STRUCTS

typedef struct s_list
{
void *content;
struct s_list *next;
} t_list;

// ------------ PROTOTYPES

// IS

int ft_isalpha(int c);
int ft_isdigit(int c);
int ft_isalnum(int c);
int ft_isascii(int c);
int ft_isprint(int c);

// MEM

void *ft_memset(void *s, int c, size_t n);
void *ft_memcpy(void *dest, const void *src, size_t n);
int ft_memcmp(const void *s1, const void *s2, size_t n);
void *ft_memmove(void *dest, const void *src, size_t n);
void *ft_memchr(const void *s, int c, size_t n);
void *ft_calloc(size_t nmemb, size_t size);
void ft_bzero(void *s, size_t n);

// STR

size_t ft_strlen(const char *s);
char *ft_substr(char const *s, unsigned int start, size_t len);
char *ft_strjoin(char const *s1, char const *s2);
size_t ft_strlcpy(char *dst, const char *src, size_t size);
size_t ft_strlcat(char *dst, const char *src, size_t size);
char *ft_strchr(const char *s, int c);
char *ft_strrchr(const char *s, int c);
int ft_strncmp(const char *s1, const char *s2, size_t n);
char *ft_strnstr(const char *big, const char *little, size_t len);
int ft_toupper(int c);
int ft_tolower(int c);
char *ft_strdup(const char *s);
char *ft_strtrim(char const *s1, char const *set);
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
void ft_striteri(char *s, void (*f)(unsigned int, char*));
char **ft_split(char const *s, char c);
char *ft_cstr(char *str, char c);
int ft_strcmp(const char *s1, const char *s2);
int strcmp_occurence(const char *s1, const char *s2);
char *ft_strcat_malloc(const char *dst, const char *src);

// PRINT

void ft_putstr_fd(char *s, int fd);
void ft_putnbr_fd(int n, int fd);
void ft_putendl_fd(char *s, int fd);
void ft_putchar_fd(char c, int fd);
void ft_print_2d_tab_char(char **tab);

// CONV

int ft_atoi(const char *nptr);
char *ft_itoa(int n);

// LST

void ft_lstadd_back(t_list **lst, t_list *new);
void ft_lstadd_front(t_list **lst, t_list *new);
void ft_lstclear(t_list **lst, void (*del)(void*));
void ft_lstdelone(t_list *lst, void (*del)(void*));
void ft_lstiter(t_list *lst, void (*f)(void *));
t_list *ft_lstlast(t_list *lst);
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
t_list *ft_lstnew(void *content);
int ft_lstsize(t_list *lst);

// GNL

char *get_next_line(int fd, int mod);

// FREE

void free_2d_tab(void **tab);

#endif
Loading

0 comments on commit f3d243b

Please sign in to comment.