#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main(){

	printf("Starting the testing program.");
	ftruncate(0, 0);
	/*
	**
	**
	**
	**
	**
int ftruncate(int fd, off_t length){ / *
	struct open_file *open_file0 = new_open_file();
	struct open_file *open_file1 = new_open_file();
	struct open_file *open_file2 = new_open_file();
	struct open_file *open_file3 = new_open_file();
	struct open_file *open_file4 = new_open_file();
	struct open_file *open_file5 = new_open_file();
	struct open_file *open_file6 = new_open_file();
	struct open_file *open_file7 = new_open_file();
	open_file0->fd = 0;
	open_file1->fd = 1;
	open_file2->fd = 2;
	open_file3->fd = 3;
	open_file4->fd = 4;
	open_file5->fd = 5;
	open_file6->fd = 6;
	open_file7->fd = 7;
	print_open_files();
	del_open_file(open_file4);
	print_open_files();
	del_open_file(open_file0);
	print_open_files();
	del_open_file(open_file7);
	print_open_files();
	/ *
	struct stat filestat;
	if((fd=o_open_2("test_output", O_RDONLY))<0) error("test could not open");
	if(fstat(fd, &filestat)==-1) error("test bad fstat file.");
	/ *
	open_file->fd = fd; 
	open_file->inode = (long) filestat.st_ino;
	open_file->block_count = (int) filestat.st_blocks; 
	open_file->file_size = (int) filestat.st_size; 
	open_file->digest = malloc(SIZEOF_MD5* sizeof(uint8) *
			(open_file->block_count + 1));
	fprintf(stderr, "inode: %016lx | fd: %08x | block_count: %08x | file_size: %08x | bc*bs = %08x\n\n",
			open_file->inode, open_file->fd, open_file->block_count,
			open_file->file_size,
			open_file->block_count * BLOCKSIZE );
	generate_md5_for_open_file(open_file);
	open_file->parity = malloc(BLOCKSIZE * sizeof(uint8));
	generate_parity(open_file, -1);
	print_hex(open_file->digest, open_file->block_count*SIZEOF_MD5, "digest");
	print_hex(open_file->parity, BLOCKSIZE, "parity");
	* /
	return fd * ((int) length);
}
	int fd = open("test_output", O_APPEND);
	if(fd<0){
		fprintf(stderr, "An error occured: NULL returned");
		return 1;
	}
	if(close(fd) != 0){
		fprintf(stderr, "close --- non zero");
		return 1;
	}

	int fd2 = open("test_output2", O_CREAT, S_IRWXU | S_IRWXG);
	if(fd2<0){
		fprintf(stderr, "An error occured: NULL returned 2");
		return 1;
	}
	if(close(fd2) != 0){
		fprintf(stderr, "close --- non zero 2");
		return 1;
	}
	return 0;
	*/
	return 0;

}




