int list_recursive(t_dlist *list, t_dlist *first, char ***pointed_square, int size, int tmp_lin, int tmp_col) { int result; int lin; int col; char **square; square = *pointed_square; (void)first; lin = 0; col = 0; result = (is_right(&square, &lin, &col, size, list)); print_it(list->content); ft_putnbr(result); /*if (result == 1 && list-> next != NULL) { tmp_lin = lin; tmp_col = col; list = list -> next; list_recursive (list, first, square, size, tmp_lin, tmp_col); }*/ ft_putstr("salut"); if (result == 0 && list->prev != NULL) { list = list -> prev; malloc_square(size); ft_putchar('M'); result = is_right (&square, &tmp_lin +1, &tmp_col + 1, size, list); print_it(list->content); ft_putnbr(result); } if (result == 1 && list-> next != NULL) { ft_putstr("post_M"); tmp_lin = lin; tmp_col = col; list = list -> next; list_recursive (list, first, &square, size, tmp_lin, tmp_col); } if (result == 0 && list->prev == NULL) { ft_putstr("yolo"); return (0); } if (result == 1 && list->next == NULL) { ft_putnbr(8); return (1); } return (0); }
int place_in_square (t_dlist *list, int size, t_dlist *first) { char **square; int result; square = malloc_square(size); result = list_recursive(list, first, &square, size, 0 , 0); if (result == 0) { ft_putchar('v'); list = first; place_in_square(list, size + 1, first); } return (0); }
int main(int argc, char **argv) { struct disk_image *di; jfs_t *jfs; if (argc != 2) { usage(); } /* mount the disk image file so we can access it*/ di = mount_disk_image(argv[1]); jfs = init_jfs(di); list_recursive(jfs); unmount_disk_image(di); exit(0); }
int main(int argc, char* argv[]) { // initialize list firstDirItem = (DirQueueItem*)malloc(sizeof(DirQueueItem)); firstDirItem->directoryEntry = 0; firstDirItem->next = 0; char filename[1024] = "BSA.img"; if(argc != 2) { printf("Usage: %s filename\n", argv[0]); printf("I will pick file '%s' for you.\n", filename); }else{ strncpy(filename, argv[1], 1023); } handle = open(filename, O_RDONLY | O_BINARY); if (handle == -1){ printf("Can't open file! errno: %d\n", errno); exit(1); } bootsector = (BOOTSECTOR*)malloc(sizeof(char)* 512); unsigned int bytesRead; if ((bytesRead = read(handle, bootsector, 512)) != 512) { printf("Could not read 512 Bytes (read %d)! errno: %d\n", bytesRead, errno); exit(1); } printVolumeInformation(bootsector); unsigned int firstFATStartPos = bootsector->BPB.reservedsectors * bootsector->BPB.sectorsize; unsigned int FATSize = bootsector->BPB.FATsectors * bootsector->BPB.sectorsize; FAT = (char*)malloc(sizeof(char) * FATSize); printf("First FAT starting at byte %d, length %d\n", firstFATStartPos, FATSize); unsigned int newPos; newPos = lseek(handle, firstFATStartPos, SEEK_SET); if((bytesRead = read(handle, FAT, FATSize)) != FATSize) { printf("Could not read %d Bytes(read %d)! errno: %d\n", FATSize, bytesRead, errno); exit(1); } unsigned int rootDirectoryStartPos = firstFATStartPos + (bootsector->BPB.numberofFATs * FATSize); unsigned int rootDirectoryStartCluster = bootsector->BPB.reservedsectors + bootsector->BPB.FATsectors * bootsector->BPB.numberofFATs; printf("Root directory starting at cluster %d / byte %d\n", rootDirectoryStartCluster, rootDirectoryStartPos); newPos = lseek(handle, rootDirectoryStartPos, SEEK_SET); printf("\n"); // list root directory and add subdirectories to global queue listDirectory(rootDirectoryStartPos); printf("\n"); // recursively list all directories inside the global queue list_recursive(); return 0; }