files cleaned (WORKING)
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -5,3 +5,7 @@ objs/
|
||||
a\.out\.dSYM/
|
||||
|
||||
a\.out
|
||||
|
||||
*.swo
|
||||
|
||||
*.swp
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.test_mask.c.swp
BIN
.test_mask.c.swp
Binary file not shown.
@@ -6,13 +6,13 @@
|
||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
|
||||
/* Updated: 2019/04/22 15:12:47 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/22 15:58:39 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "fillit.h"
|
||||
#include <stdio.h>
|
||||
#include "libft/includes/libft.h"
|
||||
//#include "libft/includes/libft.h"
|
||||
|
||||
/*
|
||||
** this function prints a 16 bites short
|
||||
@@ -24,8 +24,8 @@ void print_bits(short line)
|
||||
|
||||
mask = 1 << 27;
|
||||
while (mask >>= 1)
|
||||
(line & mask) ? ft_putnbr(1) : ft_putnbr(0);
|
||||
ft_putchar('\n');
|
||||
(line & mask) ? write(1, "1", 1) : write(1, "0", 1);
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -33,17 +33,19 @@ void print_bits(short line)
|
||||
** then it fills it and its reverse into the list
|
||||
*/
|
||||
|
||||
int fill_list(char *line, t_fillist *list)
|
||||
int fill_list(char line[], t_fillist *list)
|
||||
{
|
||||
short tmp;
|
||||
int test;
|
||||
int i;
|
||||
|
||||
while (*line)
|
||||
i = 0;
|
||||
while (line[i])
|
||||
{
|
||||
list->tetribit <<= 1;
|
||||
if (*line == '\n')
|
||||
line++;
|
||||
if (*(line++) == '#')
|
||||
if (line[i] == '\n')
|
||||
i++;
|
||||
if (line[i++] == '#')
|
||||
list->tetribit |= 1;
|
||||
}
|
||||
tmp = list->tetribit;
|
||||
@@ -128,7 +130,7 @@ void test(unsigned int map[])
|
||||
mask = (mask >> 1) | (((1 << (i % 32)) & map[j]) << (31 - (i % 32)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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
|
||||
@@ -150,3 +152,4 @@ int main(int ac, char **av)
|
||||
|
||||
return (0);
|
||||
}
|
||||
*/
|
||||
|
||||
7
fillit.h
7
fillit.h
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/19 14:52:10 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/04/22 15:57:43 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
#include <stdio.h> // for debug printf
|
||||
#include <stdbool.h> // to use bool type
|
||||
|
||||
# define BUFF_SIZE 1024
|
||||
#include "libft/includes/libft.h"
|
||||
|
||||
//# define BUFF_SIZE 1024
|
||||
|
||||
/*
|
||||
** STRUCTURE
|
||||
@@ -45,5 +47,6 @@ 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 fill_list(char *line, t_fillist *list);
|
||||
|
||||
#endif
|
||||
|
||||
2
main.c
2
main.c
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/16 16:41:28 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/22 15:50:16 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@@ -6,28 +6,12 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/18 16:09:24 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/19 12:53:40 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/04/22 17:06:51 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "fillit.h"
|
||||
|
||||
/*
|
||||
** !!! DELETE PRINT_BITS BEFORE EVAL !!!
|
||||
*/
|
||||
|
||||
void print_bits(short octet)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 1 << 16;
|
||||
while (i >>= 1)
|
||||
(octet & i) ? write(1, "1", 1) : write(1, "0", 1);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Function that parse a file and put each tetrimino in a linked list
|
||||
*/
|
||||
@@ -56,25 +40,9 @@ char **create_square(char *tetri)
|
||||
return (square);
|
||||
}
|
||||
|
||||
short create_tetribit(char *tetri)
|
||||
{
|
||||
short tetribit;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
tetribit = 0;
|
||||
while (tetri[i])
|
||||
{
|
||||
if (tetri[i] != '\n') // Pour comparer avec le tetri en char
|
||||
printf("%c", tetri[i]);
|
||||
if (tetri[i] == '#')
|
||||
tetribit = tetribit | 1;
|
||||
else
|
||||
tetribit <<= 1;
|
||||
i++;
|
||||
}
|
||||
return (tetribit);
|
||||
}
|
||||
/*
|
||||
** Function that parse a file and put each tetrimino in a linked list
|
||||
*/
|
||||
|
||||
void parse_input(char *input)
|
||||
{
|
||||
@@ -82,24 +50,18 @@ void parse_input(char *input)
|
||||
char tetri[20];
|
||||
int i;
|
||||
int j;
|
||||
short test; //DELETE BEFORE EVAL
|
||||
|
||||
i = 0;
|
||||
printf("input: %s\n", input);
|
||||
printf("end\n");
|
||||
while (input[i])
|
||||
{
|
||||
j = 0;
|
||||
while (j < 19)
|
||||
tetri[j++] = input[i++];
|
||||
tetri[19] = '\0';
|
||||
printf("%s\n", tetri);
|
||||
if (check_tetri_errors(tetri))
|
||||
print_error("Error: Tetrimino not valid.");
|
||||
test = create_tetribit(tetri);
|
||||
printf("\n");
|
||||
print_bits(test);
|
||||
//test = create_square(tetri);
|
||||
//add_to_list(test, &list);
|
||||
add_to_list(tetri, &list);
|
||||
while (input[i] == '\n')
|
||||
i++;
|
||||
}
|
||||
@@ -107,6 +69,7 @@ void parse_input(char *input)
|
||||
** ce qui suit sert juste a afficher le contenu de tous les tetraminos de la liste chainee
|
||||
** pour debug, a effacer au rendu
|
||||
*/
|
||||
/*
|
||||
while (list && (i = -1))
|
||||
{
|
||||
while (++i < list->size[1])
|
||||
@@ -114,4 +77,5 @@ void parse_input(char *input)
|
||||
printf("\n");
|
||||
list = list->next;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user