-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
37e795f
commit 2658d05
Showing
297 changed files
with
16,710 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
compressed.data | ||
*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
## | ||
## EPITECH PROJECT, 2018 | ||
## makefile | ||
## File description: | ||
## makefile | ||
## | ||
|
||
SRC_ALL = src/option_h.c \ | ||
src/file.c \ | ||
src/lib/my_strcmp.c \ | ||
src/lib/my_putstr.c \ | ||
src/lib/my_strlen.c \ | ||
src/lib/itos_base.c \ | ||
src/lib/list_p1.c \ | ||
src/lib/my_getnbr.c \ | ||
src/lib/my_revstr.c \ | ||
src/lib/my_strncpy.c \ | ||
src/lib/my_strncat.c \ | ||
src/lib/read_file.c \ | ||
src/lib/my_strcat.c \ | ||
src/lib/my_strcpy.c \ | ||
src/lib/my_itos.c | ||
|
||
SRC_ANT = src/antman/main.c \ | ||
src/antman/txt/txt.c \ | ||
src/antman/txt/tools.c \ | ||
src/antman/ppm/ppm.c \ | ||
src/antman/ppm/utils.c | ||
|
||
SRC_GIA = src/giantman/main.c \ | ||
src/giantman/txt/txt.c \ | ||
src/giantman/txt/tools.c\ | ||
src/giantman/ppm/ppm.c | ||
|
||
CFLAGS = -Iinclude#-W -Wall -Wextra | ||
|
||
CC = gcc -no-pie -g | ||
|
||
OBJ_ANT = $(SRC_ANT:.c=.o) | ||
|
||
OBJ_GIA = $(SRC_GIA:.c=.o) | ||
|
||
OBJ_ALL = $(SRC_ALL:.c=.o) | ||
|
||
NAME_ANT = antman | ||
|
||
NAME_GIA = giantman | ||
|
||
all: $(NAME_ANT) | ||
|
||
$(NAME_ANT): $(OBJ_ANT) $(OBJ_GIA) $(OBJ_ALL) | ||
$(CC) -o antman/$(NAME_ANT) $(OBJ_ANT) $(OBJ_ALL) | ||
$(CC) -o giantman/$(NAME_GIA) $(OBJ_GIA) $(OBJ_ALL) | ||
|
||
clean: | ||
rm -f $(OBJ_ANT) | ||
rm -f $(OBJ_GIA) | ||
rm -f $(OBJ_ALL) | ||
rm -f *.o | ||
|
||
fclean: clean | ||
rm -f $(NAME_ANT) | ||
rm -f $(NAME_GIA) | ||
|
||
re: fclean all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Antman {Epitech} | ||
|
||
**Attention au -42.** Servez vous de ce repo pour vous orienter si vous avez des difficultés, *tricher ne vous apportera rien.* | ||
|
||
Je rappel également que les codes présents ici n'ont pas été corrigés suite à leur création, **les erreurs que j'ai pu faire sont toujours dedans**, à vous de faire attention ! | ||
|
||
## Note | ||
|
||
| MyEpitech | Norme | | ||
|--|--| | ||
| 13% | 0 fautes | | ||
|
||
Le pourcentage ne correspond pas à la valeur du projet, les tests étant nouveaux et pas très bien terminés. | ||
|
||
## Quelques Astuces | ||
|
||
Vous trouverez l'algorithme dans le fichier **Review Antman**. |
Binary file not shown.
Empty file.
Binary file not shown.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
** EPITECH PROJECT, 2021 | ||
** B-CPE-110-BDX-1-1-antman-arthur.decaen | ||
** File description: | ||
** antman | ||
*/ | ||
|
||
#ifndef ANTMAN_H_ | ||
#define ANTMAN_H_ | ||
|
||
typedef struct list_element | ||
{ | ||
char *elem; | ||
int value; | ||
struct list_element *next; | ||
} list_element_t, *list_t; | ||
|
||
int check_h(int argc, char **argv); | ||
int ant_h(void); | ||
int check_file(char *filepath); | ||
int index_function(char elem); | ||
|
||
char *get_content(char *path); | ||
int len_2darray(char **array); | ||
void html_compress(char *filepath); | ||
|
||
void lzw_compress(char *txt); | ||
char *strfromchar(char letter); | ||
void print_bin(list_t result, list_t dict); | ||
int in_list(char *txt, list_t liste); | ||
char *clonestr(char *txt); | ||
int size_file(char const *filepath); | ||
|
||
void compress(char *file); | ||
|
||
list_t new_list(void); | ||
list_t push_back_list(list_t li, char *value); | ||
list_t init_list(char *txt); | ||
list_t push_back_list_int(list_t li, int value); | ||
list_t clear_list(list_t li, int flag); | ||
list_t pop_front_list(list_t li, int flag); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
** EPITECH PROJECT, 2021 | ||
** antman | ||
** File description: | ||
** common | ||
*/ | ||
|
||
#ifndef COMMON_H_ | ||
#define COMMON_H_ | ||
|
||
char *get_content(char *path); | ||
char *itos_base(int n, int base); | ||
|
||
#endif |
44 changes: 44 additions & 0 deletions
44
B1 - Elementary Programming in C/Antman/include/giantman.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
** EPITECH PROJECT, 2021 | ||
** B-CPE-110-BDX-1-1-antman-arthur.decaen | ||
** File description: | ||
** giantman | ||
*/ | ||
|
||
#ifndef GIANTMAN_H_ | ||
#define GIANTMAN_H_ | ||
|
||
typedef struct list_element | ||
{ | ||
char *elem; | ||
int value; | ||
struct list_element *next; | ||
} list_element_t, *list_t; | ||
|
||
int check_h(int argc, char **argv); | ||
int giant_h(void); | ||
int check_file(char *filepath); | ||
int index_function(char elem); | ||
void html_compress(char *filepath); | ||
|
||
list_t new_list(void); | ||
list_t push_back_list(list_t li, char *value); | ||
list_t init_list(char *txt); | ||
list_t push_back_list_int(list_t li, int value); | ||
list_t clear_list(list_t li, int flag); | ||
list_t pop_front_list(list_t li, int flag); | ||
|
||
void txt_function(char *file); | ||
char *clonestr(char *txt); | ||
char *strfromchar(char letter); | ||
int size_file(char const *filepath); | ||
int in_list(char *txt, list_t liste); | ||
|
||
list_t get_all_number(char *txt, char *filepath); | ||
int get(list_element_t **liste); | ||
char *in_list_int(int index, list_t liste); | ||
|
||
// -----------------decompress----------------- | ||
void decompress_ppm(char *file); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
** EPITECH PROJECT, 2021 | ||
** B-CPE-110-BDX-1-1-antman-arthur.decaen | ||
** File description: | ||
** lib | ||
*/ | ||
|
||
#ifndef LIB_H_ | ||
#define LIB_H_ | ||
|
||
int my_strcmp(char const *s1, char const *s2); | ||
int my_strlen(char const *str); | ||
void my_putstr(char const *str); | ||
int my_get_nbr(char *str); | ||
char *itos_base(int n, int base); | ||
char *my_strncat(char *dest, const char *src, int n); | ||
char *my_strncpy(char *dest, char const *src, int n); | ||
char *load_file(char const *filepath); | ||
char *my_strcat(char *dest, char const *src); | ||
char *my_strcpy(char *dest, char const *src); | ||
char *my_itos(int value, int base); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
** EPITECH PROJECT, 2021 | ||
** B-CPE-110-BDX-1-1-antman-arthur.decaen | ||
** File description: | ||
** main | ||
*/ | ||
|
||
#include "lib.h" | ||
#include "antman.h" | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
void (*funct[3])(char *file) = {lzw_compress, lzw_compress, compress}; | ||
int index; | ||
|
||
if (check_h(argc, argv)) | ||
return ant_h(); | ||
if (check_file(argv[1]) || argc != 3) | ||
return 84; | ||
if ((index = index_function(argv[2][0])) == -1) | ||
return 84; | ||
(*funct[index])(argv[1]); | ||
return 0; | ||
} |
91 changes: 91 additions & 0 deletions
91
B1 - Elementary Programming in C/Antman/src/antman/ppm/ppm.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
** EPITECH PROJECT, 2021 | ||
** B-CPE-110-BDX-1-1-antman-arthur.decaen | ||
** File description: | ||
** ppm | ||
*/ | ||
|
||
#include <fcntl.h> | ||
#include <sys/stat.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include "common.h" | ||
#include "lib.h" | ||
|
||
void print_text(char **); | ||
|
||
unsigned char getnbr(int *n, char *str) | ||
{ | ||
int nbr = 0; | ||
int count = 0; | ||
|
||
while (*str < 58 && *str > 47) { | ||
nbr += (*str - 48); | ||
nbr *= 10; | ||
count++; | ||
str++; | ||
} | ||
*n = count + 1; | ||
return (unsigned char)(nbr / 10); | ||
} | ||
|
||
int getnbr_i(int *n, char *str) | ||
{ | ||
int nbr = 0; | ||
int count = 0; | ||
|
||
while (*str < 58 && *str > 47) { | ||
nbr += (*str - 48); | ||
nbr *= 10; | ||
count++; | ||
str++; | ||
} | ||
*n = count + 1; | ||
return (nbr / 10); | ||
} | ||
|
||
int get_line_nbr(char *path) | ||
{ | ||
int line = 0; | ||
char *ppm = load_file(path); | ||
|
||
for (int i = 0; ppm[i] != 0; i++) { | ||
if (ppm[i] == 10) | ||
line++; | ||
} | ||
return line; | ||
} | ||
|
||
void print_dims(char **str) | ||
{ | ||
int n; | ||
int dim; | ||
int len; | ||
|
||
for (int i = 0; i < 2; i++) { | ||
dim = getnbr_i(&n, str[0]); | ||
write(1, &dim, 2); | ||
str[0] += n; | ||
} | ||
} | ||
|
||
void compress(char *file) | ||
{ | ||
int line = get_line_nbr(file); | ||
unsigned char *data = malloc(sizeof(unsigned char) * line); | ||
char *ppm = load_file(file); | ||
char *tmp = ppm; | ||
int n = 0; | ||
int count = 0; | ||
|
||
print_text(&ppm); | ||
print_dims(&ppm); | ||
for (int i = 0; i < line - 3; i++) { | ||
data[i] = getnbr(&n, ppm); | ||
ppm += n; | ||
} | ||
write(1, data, line - 3); | ||
free(data); | ||
free(tmp); | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
B1 - Elementary Programming in C/Antman/src/antman/ppm/utils.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
** EPITECH PROJECT, 2021 | ||
** antman | ||
** File description: | ||
** utils | ||
*/ | ||
|
||
#include <unistd.h> | ||
|
||
void print_text(char **file) | ||
{ | ||
int count = 0; | ||
|
||
file[0] += 3; | ||
while (file[0][count] != '\n') | ||
count++; | ||
write(1, &count, 1); | ||
write(1, file[0], count++); | ||
file[0] += count; | ||
} |
Oops, something went wrong.