parsing_input v0 (Not working yet)

This commit is contained in:
Manzovince
2019-04-15 21:34:30 +02:00
parent 10901ad1a6
commit 95b96fc25f
4 changed files with 59 additions and 31 deletions

View File

@@ -6,7 +6,7 @@
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */ /* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
/* Updated: 2019/04/15 20:19:55 by vmanzoni ### ########.fr */ /* Updated: 2019/04/15 20:49:33 by vmanzoni ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -127,13 +127,13 @@ int add_to_list(char **square, t_fillist **list)
return (1); return (1);
} }
/*
int main(int ac, char **av) int main(int ac, char **av)
{ {
static t_fillist *list = NULL; // avant d'appeller add_to_list il faut declarer un pointeur static vers la structure static t_fillist *list = NULL; // avant d'appeller add_to_list il faut declarer un pointeur static vers la structure
int i; int i;
if (ac > 4) if (ac > 1)
{ {
add_to_list(++av, &list); // l'appel de la fonction se fait avec un carre valide de 4*4 et l'adresse du pointeur vers la liste add_to_list(++av, &list); // l'appel de la fonction se fait avec un carre valide de 4*4 et l'adresse du pointeur vers la liste
if (ac == 9) if (ac == 9)
@@ -149,3 +149,4 @@ int main(int ac, char **av)
return (0); return (0);
} }
*/

View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */ /* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */ /* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
/* Updated: 2019/04/15 16:23:18 by hulamy ### ########.fr */ /* Updated: 2019/04/15 20:53:57 by vmanzoni ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -22,22 +22,6 @@
# define BUFF_SIZE 1024 # define BUFF_SIZE 1024
/*
** DELETE BEFORE EVALUATION
*/
void print_test(char *test);
/*
** FUNCTIONS
*/
char *read_file(char *file);
void print_error(char *s);
int check_file_errors(char *file);
int check_tetri_errors(char *tetri);
int check_tetri_errors2(char *tetri);
/* /*
** STRUCTURE ** STRUCTURE
*/ */
@@ -52,6 +36,17 @@ typedef struct s_fillist
struct s_fillist *next; struct s_fillist *next;
} t_fillist; } t_fillist;
/*
** FUNCTIONS
*/
void print_test(char *test); //DELETE BEFORE EVALUATION
char *read_file(char *file);
void print_error(char *s);
void parse_input(char *input);
int check_file_errors(char *file);
int check_tetri_errors(char *tetri);
int check_tetri_errors2(char *tetri);
int add_to_list(char **square, t_fillist **list); int add_to_list(char **square, t_fillist **list);
#endif #endif

5
main.c
View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */ /* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
/* Updated: 2019/04/15 14:41:44 by vmanzoni ### ########.fr */ /* Updated: 2019/04/15 20:54:24 by vmanzoni ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -22,13 +22,14 @@ int main(int argc, char **argv)
print_error("Error: Could not read file.\n"); print_error("Error: Could not read file.\n");
if (check_file_errors(input)) if (check_file_errors(input))
print_error("Error: Invalid file.\n"); print_error("Error: Invalid file.\n");
parse_input(input);
/* /*
Transform input to tetriminos Transform input to tetriminos
Backtracking for smallest square Backtracking for smallest square
Transform tetriminos with letters Transform tetriminos with letters
Print result Print result
*/ */
print_test(input); //print_test(input);
} }
else else
print_error("Usage: Please submit a file.\n"); print_error("Usage: Please submit a file.\n");

View File

@@ -6,30 +6,61 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */ /* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
/* Updated: 2019/04/15 20:14:43 by vmanzoni ### ########.fr */ /* Updated: 2019/04/15 21:33:52 by vmanzoni ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "fillit.h" #include "fillit.h"
/* /*
** Function that parse a file and return each tetrimino ** Function that parse a file and put each tetrimino in a linked list
*/ */
/*
void parse_input(char *input) void parse_input(char *input)
{ {
char *tetri; //static t_fillist *list = NULL;
char **square;
int i; int i;
int j;
int k;
i = 0; i = 0;
while (input[i]) while (input[i])
{ {
tetri[i] = input[i]; j = 0;
if (i != 0 && i%19 == 0) while (j < 4)
{ {
k = 0;
i+2; while (k < 4)
square[j][k++] = input[i++];
j++;
} }
printf("print:\n%s\n", *square);
//add_to_list(square, &list);
while (input[i] == '\n')
i++;
}
}
/*
void parse_input(char *input)
{
//static t_fillist *list = NULL;
char square[19];
int i;
int j;
i = 0;
while (input[i])
{
j = 0;
while (j < 19)
square[j++] = input[i++];
square[19] = '\0';
printf("PRINT:\n%s\n", square);
//add_to_list(square, &list);
while (input[i] == '\n')
i++;
} }
} }
*/ */