Exemplo n.º 1
0
void links(char * path1, char * path2) {

	int path1_len = str_len(path1);
	path1[path1_len - 1] = '\0';

	int path2_len, i, index_file_name, quant_chars;
	char * directory_path;
	char * name;
	iNode * path1_inode = current;
	path1_inode = parser_path(path1, path1_inode);

	if (path1_inode == NULL) {
		printf("Wrong name or path\n");
	}

	// Search for the first / from right to left, to get the path and the
	//filename.
	path2_len = str_len(path2);
	for (i = path2_len; i >= 0; i--) {
		if (path2[i] == '/') {
			index_file_name = i;
			break;
		}
	}
	//if I find one
	if (i >= 0) {
		quant_chars = path2_len - (path2_len - index_file_name) + 1;
		directory_path = malloc(quant_chars);
		name = malloc(path2_len - quant_chars);
		memcpy(directory_path, path2, quant_chars);
		memcpy(name, path2 + quant_chars, path2_len - quant_chars);
		name[path2_len - quant_chars] = '\0';
		directory_path[quant_chars - 1] = '\0';

		iNode * path2_inode = current;
		path2_inode = parser_path(directory_path, path2_inode);

		iNode * link_node = insert_file(name, 777, path2_inode);
		copy_link_inode(path1_inode, link_node);
	} else {

		/*printf("ENTRO");*/
		iNode * path2_inode = current;
		iNode * link_node = insert_file(path2, 2, path2_inode);

		copy_link_inode(path1_inode, link_node);
		/*printf("ID:%d\n",link_node->identifier);*/
		fs_insert_inode(link_node);
	}

	return;
}
Exemplo n.º 2
0
int add_files(const struct sockaddr_in *peer_addr, const char *pck_data, int data_len) {
	int i, j;
	char tmp[1024];
	unsigned char md5[MD5_DIGEST_LENGTH];
	char op;

	j = 0;
	for (i = 0; i < data_len; i ++) {
		if (pck_data[i] != '+' && pck_data[i] != '-') {
			fprintf(stderr, "add_files error - bad packet format\n");
			return -1;
		}
		op = pck_data[i];
		memcpy(md5, pck_data + i + 1, MD5_DIGEST_LENGTH);
		
		for (i += MD5_DIGEST_LENGTH + 1 ; i < data_len; i ++) {
			if (pck_data[i] != '\n') {
				tmp[j] = pck_data[i];
				j ++;
			} else {
				tmp[j] = 0;
				j = 0;
				if (op == '+') {
					insert_file(tmp, md5, peer_addr->sin_addr.s_addr, peer_addr->sin_port);	
				} else {
					remove_file(peer_addr->sin_addr.s_addr, peer_addr->sin_port, tmp, md5);
				}

				break;
			}
		}
	}

	return 0;
}
void
new_mail_widget::create_actions()
{
  m_action_send_msg = new QAction(FT_MAKE_ICON(FT_ICON16_SEND),
				  tr("Send mail"), this);
  connect(m_action_send_msg, SIGNAL(activated()), this, SLOT(send()));

  m_action_attach_file = new QAction(FT_MAKE_ICON(FT_ICON16_ATTACH),
				     tr("Attach file"), this);
  connect(m_action_attach_file, SIGNAL(activated()), this, SLOT(attach_files()));

  m_action_insert_file = new QAction(FT_MAKE_ICON(FT_ICON16_OPENFILE),
				     tr("Insert text file"), this);
  connect(m_action_insert_file, SIGNAL(activated()), this, SLOT(insert_file()));

  m_action_edit_note = new QAction(FT_MAKE_ICON(FT_ICON16_EDIT_NOTE),
				   tr("Edit note"), this);
  connect(m_action_edit_note, SIGNAL(activated()), this, SLOT(edit_note()));

  m_action_add_header = new QAction(FT_MAKE_ICON(ICON16_HEADER),
				   tr("Add header field"), this);
  connect(m_action_add_header, SIGNAL(activated()), this, SLOT(add_field_editor()));

  m_action_open_notepad = new QAction(FT_MAKE_ICON(ICON16_NOTEPAD),
				   tr("Open global notepad"), this);
  connect(m_action_open_notepad, SIGNAL(activated()), this, SLOT(open_global_notepad()));

}
Exemplo n.º 4
0
int
insert_file(const char * filename, class Properties& p){
  FILE * f = fopen(filename, "r");
  int res = insert_file(f, p);
  if(f) fclose(f);
  return res;
}
Exemplo n.º 5
0
FileStore::FileStore()
{
	//run command to return /n delimited list of files in the current directory
	FILE* pipe = popen(config->find_cmd.c_str(), "r");

	if(!pipe)
		return;

	char *line = NULL;
	size_t size = 0;
	size_t root_path_length = config->cwd_path.length() + 1;

	while(!feof(pipe))
	{
		if(getline(&line, &size, pipe) != -1)
		{
			std::string path = std::string(line);
			
			//pop the ending newline
			path.pop_back();

			//remove root working directory
			path = path.substr(root_path_length, std::string::npos);

			//create a new File object, and save it in the vector
			insert_file(new File(path));
		}
	}

	pclose(pipe);
}
Exemplo n.º 6
0
int do_creat(char * filename, int mode) {

	int i;
	iNode * ret;
	if ((ret = insert_file(filename, mode, current)) == NULL) {
		return -1;
	}
	int fd = insert_fd(ret->iNode_number);
	return fd;

}
Exemplo n.º 7
0
/****************************************************************************************************************************************
*	FUNCTION NAME : main.c
*
*	DESCRIPTION : main function for implementing bst
*
*	RETURN VALUE : SUCCESS
*
**************************************************************************************************************************************/
int main(int argc, char *argv[])
{
	if(NULL == argv[1])
	{
		printf("please enter input file name\n");
		exit(FAILURE);
	}
	if(NULL == argv[2])
	{
		printf("please enter output file name\n");
		exit(FAILURE);
	}

	FILE *fp1; //file pointer for input file
	FILE *fp2; //file pointer for output file

	file_open(&fp1, argv[1], "r");//opening input file in read mode
	file_open(&fp2, argv[2], "w");//opening output file in write mode

	char input[MAX]; //for storing input file names
	node *root = NULL; //root node of tree
	int count = 0; //name count
	int duplicates = 0;

	while(1)
	{
		memset(input, 0, MAX * sizeof(char));//initializing input
		/*reading from the file*/
		fgets(input, (MAX-1)*sizeof(char), fp1);
		if(feof(fp1))
		{
			break;
		}
		insert_bst(&root, input, &duplicates);
		count++;
	}

	printf("\n\n**********File contents in level order***********\n\n");
	fprintf(fp2, "Total names present in the input file is %d\n", count);
	fprintf(fp2, "Total number of duplicate names present in the input file is %d\n\n", duplicates);
	fprintf(fp2, "\n\n**********File contents in level order***********\n\n");
	insert_file(&root, &fp2);

	file_close(&fp1); //closing input file
	file_close(&fp2); //closing output file
	free_bst(&root);

	return SUCCESS;
}
Exemplo n.º 8
0
void cp_file(char * filename, iNode * origin, iNode * path_inode)
{
	iNode * ret, * aux;
	char * buff;
	int fd;
	aux = current;
	if ( (ret = insert_file(filename, 777, path_inode)) == NULL)
		return ;
	insert_fd(ret->iNode_number);
	current = origin;
	fd = do_open(filename, 1, 2);
	buff = malloc(getsize(fd));
	read(fd, buff, -1);
	//printf("\nhasta ahora todo va bien. filename:%s. buffer:%s", filename, buff);
	//while(1);
	current = path_inode;
	fd = do_open(filename, 1, 777);
	write(fd, buff, str_len(buff));
	current = aux;
}
Exemplo n.º 9
0
/*
 * Insert diversion number DIVNUM into the current output file.  The
 * diversion is NOT placed on the expansion obstack, because it must not
 * be rescanned.  When the file is closed, it is deleted by the system.
 */
void
insert_diversion (int divnum)
{
  FILE *div;

  if (divnum < 0 || divnum >= ndiversion)
    return;

  div  = divtab[divnum];
  if (div == NULL || div == output)
    return;

  if (output != NULL)
    {
      rewind (div);
      insert_file (div);
      output_current_line = -1;
    }
  fclose (div);
  divtab[divnum] = NULL;
}
Exemplo n.º 10
0
BOOL CSoliDire::add_file()
{
	CFileDialog dlgAdd(TRUE, (LPCTSTR)"*.*|*.*||", NULL, OFN_OVERWRITEPROMPT, (LPCTSTR)"*.*|*.*||", NULL);   

	UINT iRet = dlgAdd.DoModal(),
		 nCount = 0;

	if (iRet == IDOK)
	{
		POSITION pos = dlgAdd.GetStartPosition();
		while (pos)
		{
			insert_file(dlgAdd.GetNextPathName(pos));
			nCount++;
		}
		CString msg;
		printf("%d file(s) sucessfully added.\n", nCount);
		return TRUE;
	}
	return FALSE;

}
bool implicit_report(bip_context* c)
{
    /* Create report file */
    FILE* report = fopen("reports/implicit.tex", "w");
    if(report == NULL) {
        return false;
    }

    /* Write preamble */
    bool success = insert_file("latex/header.tex", report);
    if(!success) {
        return false;
    }
    fprintf(report, "\n");

    /* Write header */
    fprintf(report, "\\section{%s}\n\n", "Implicit Enumeration");
    fprintf(report, "\\noindent{\\huge %s.} \\\\[0.4cm]\n",
            "Binary Integer Programming");
    fprintf(report, "{\\LARGE %s.}\\\\[0.4cm]\n", "Operation Research");
    fprintf(report, "\\HRule \\\\[0.5cm]\n");

    /* Write description */
    fprintf(report, "\\indent ");
    success = insert_file("latex/preamble.tex", report);
    if(!success) {
        return false;
    }

    /* Write first section */
    fprintf(report, "\\\\[0.5cm]\n\\noindent{\\Large Details:}\n");
    fprintf(report, "\\begin{compactitem}\n");
    fprintf(report, "\\item %s : \\textsc{%s}. \n",
            "Executed on", get_current_time());
    fprintf(report, "\\item %s : \\textsc{%lf %s}. \n",
            "Execution time", c->execution_time,
            "seconds");
    fprintf(report, "\\item %s : \\textsc{%i %s}. \n",
            "Memory required", c->memory_required,
            "bytes");
    fprintf(report, "\\end{compactitem}\n");
    fprintf(report, "\n");

    /* TOC */
    fprintf(report, "\\newpage\n");
    fprintf(report, "\\tableofcontents\n");
    fprintf(report, "\\newpage\n");
    fprintf(report, "\n");

    /* Model */
    fprintf(report, "\\section{%s}\n", "Model");
    fprintf(report, "\n");
    imp_model(report, c);
    fprintf(report, "\\end{adjustwidth}\n");
    fprintf(report, "\\newpage\n");
    fprintf(report, "\n");

    /* Write execution */
    fprintf(report, "\\section{%s}\n", "Resolution");
    success = copy_streams(c->report_buffer, report);
    if(!success) {
        return false;
    }

    /* End document */
    fprintf(report, "\\end{document}\n");
    fprintf(report, "\n");

    /* Save & swap buffers */
    int success_file = fflush(report);
    if(success_file == EOF) {
        return false;
    }
    success_file = fclose(c->report_buffer);
    if(success_file == EOF) {
        return false;
    }
    c->report_buffer = report;

    return true;
}
Exemplo n.º 12
0
static void
insert_diversion_helper (m4_diversion *diversion)
{
  /* Effectively undivert only if an output stream is active.  */
  if (output_diversion)
    {
      if (diversion->size)
        {
          if (!output_diversion->u.file)
            {
              /* Transferring diversion metadata is faster than
                 copying contents.  */
              assert (!output_diversion->used && output_diversion != &div0
                      && !output_file);
              output_diversion->u.buffer = diversion->u.buffer;
              output_diversion->size = diversion->size;
              output_cursor = diversion->u.buffer + diversion->used;
              output_unused = diversion->size - diversion->used;
              diversion->u.buffer = NULL;
            }
          else
            {
              /* Avoid double-charging the total in-memory size when
                 transferring from one in-memory diversion to
                 another.  */
              total_buffer_size -= diversion->size;
              output_text (diversion->u.buffer, diversion->used);
            }
        }
      else if (!output_diversion->u.file)
        {
          /* Transferring diversion metadata is faster than copying
             contents.  */
          assert (!output_diversion->used && output_diversion != &div0
                  && !output_file);
          output_diversion->u.file = m4_tmprename (diversion->divnum,
                                                   output_diversion->divnum);
          output_diversion->used = 1;
          output_file = output_diversion->u.file;
          diversion->u.file = NULL;
          diversion->size = 1;
        }
      else
        {
          if (!diversion->u.file)
            diversion->u.file = m4_tmpopen (diversion->divnum, true);
          insert_file (diversion->u.file);
        }

      output_current_line = -1;
    }

  /* Return all space used by the diversion.  */
  if (diversion->size)
    {
      if (!output_diversion)
        total_buffer_size -= diversion->size;
      free (diversion->u.buffer);
      diversion->size = 0;
    }
  else
    {
      if (diversion->u.file)
        {
          FILE *file = diversion->u.file;
          diversion->u.file = NULL;
          if (m4_tmpclose (file, diversion->divnum) != 0)
            m4_error (0, errno,
                      _("cannot clean temporary file for diversion"));
        }
      if (m4_tmpremove (diversion->divnum) != 0)
        M4ERROR ((0, errno, "cannot clean temporary file for diversion"));
    }
  diversion->used = 0;
  gl_oset_remove (diversion_table, diversion);
  diversion->u.next = free_list;
  free_list = diversion;
}
Exemplo n.º 13
0
/***********************************************************************************************************************************************
*	FUNCTION NAME : main.c
*
*	DESCRIPTION : contains main function swhich call other functions for implementing the given problem statement
*
*	RETURN VALUE : SUCCESS
*
**************************************************************************************************************************************************/
int main(int argc, char *argv[])
{
	/*error handling for command line arguments*/
	if(NULL == argv[1])
	{
		printf("Please provide first input file name\n");
		exit(FAILURE);
	}

	if(NULL == argv[2])
	{
		printf("Please provide second input file name\n");
		exit(FAILURE);
	}

	if(NULL == argv[3])
	{
		printf("Please provide output file name\n");
		exit(FAILURE);
	}

	FILE *fp1; //file pointer for first input file
	FILE *fp2; //file pointer for second input file
	FILE *fp3; //file pointer for output file

	int index; //array index

	char string[MAX];//for storing strings
	memset(string,0,MAX*sizeof(char));//initializing input to null

	char *arr[MAX]; //array for storing names
	/*initializing array of pointers to null*/
	for (index=0; index<MAX-1; index++)
	{
		arr[index] = NULL;
	}

	file_open(&fp1, argv[1], "r");//opening first input file in read only mode
	file_open(&fp2, argv[2], "r");//opening second input file in read only mode
	file_open(&fp3,argv[3], "w");//opening output file in write only mode

	index = 0;
	/*reading from first input file & storing it in array*/
	while(1)
	{
		fgets(string, (MAX-1)*sizeof(char), fp1); //reading from the first input file
		/*error handling for end of file*/
		if(feof(fp1))
		{
			break;
		}
		insert_array(arr, string, index);
		++index;
	}

	/*reading from second input file and storing it in array*/
	while(1)
	{
		fgets(string, (MAX-1)*sizeof(char), fp2); //reading from the second input file
		/*error handling for end of file*/
		if(feof(fp2))
		{
			break;
		}
		insert_array(arr, string, index);
		++index;
	}

	printf("\n");
	printf("***************array before sorting*************************\n");
	display_array(arr, index);
	printf("\n\n");

	
	quicksort(arr, 0, index-1);//sorting the array
	printf("*******************array after sorting****************************\n");
	display_array(arr, index);
	printf("\n\n");


	insert_file(arr, index, &fp3);//read from the ds and store it in output file

	file_close(&fp1); //closing first input file
	file_close(&fp2); //closing second input file
	file_close(&fp3); //closing output file

	free_array(arr, index); //free the link list

	return SUCCESS;
}
Exemplo n.º 14
0
int main(int argc, char *argv[])
{
  char filename[STRING_LENGTH];
  char *include_path;

  /* Command line parameters */
  if (argc < 2) {
    include_path = (char *) malloc(sizeof(char)*2);
    strcpy(include_path, ".");
  }
  else {
    include_path = (char *) malloc(sizeof(char)*strlen(argv[1]));
    strcpy(include_path, argv[1]);
  }

  /* User code at top of file */
  sprintf(filename, "%s/%s", include_path, "user_code_top.metaflex");
  insert_file(filename);

  /* Definitions */
  sprintf(filename, "%s/%s", include_path, "roman_numbers.metaflex");
  insert_file(filename);

  /* Separator */
  printf("\n%%%%\n");

  /* Rules */

  /* - Wordlist rules */
  sprintf(filename, "%s/%s", include_path, "article.wordlist");
  rules_from_file(filename, "ARTICLE");
  sprintf(filename, "%s/%s", include_path, "be.wordlist");
  rules_from_file(filename, "BE");
  sprintf(filename, "%s/%s", include_path, "character.wordlist");
  rules_from_file(filename, "CHARACTER");
  sprintf(filename, "%s/%s", include_path, "first_person.wordlist");
  rules_from_file(filename, "FIRST_PERSON");
  sprintf(filename, "%s/%s", include_path, "first_person_possessive.wordlist");
  rules_from_file(filename, "FIRST_PERSON_POSSESSIVE");
  sprintf(filename, "%s/%s", include_path, "first_person_reflexive.wordlist");
  rules_from_file(filename, "FIRST_PERSON_REFLEXIVE");
  sprintf(filename, "%s/%s", include_path, "negative_adjective.wordlist");
  rules_from_file(filename, "NEGATIVE_ADJECTIVE");
  sprintf(filename, "%s/%s", include_path, "negative_comparative.wordlist");
  rules_from_file(filename, "NEGATIVE_COMPARATIVE");
  sprintf(filename, "%s/%s", include_path, "negative_noun.wordlist");
  rules_from_file(filename, "NEGATIVE_NOUN");
  sprintf(filename, "%s/%s", include_path, "neutral_adjective.wordlist");
  rules_from_file(filename, "NEUTRAL_ADJECTIVE");
  sprintf(filename, "%s/%s", include_path, "neutral_noun.wordlist");
  rules_from_file(filename, "NEUTRAL_NOUN");
  sprintf(filename, "%s/%s", include_path, "nothing.wordlist");
  rules_from_file(filename, "NOTHING");
  sprintf(filename, "%s/%s", include_path, "positive_adjective.wordlist");
  rules_from_file(filename, "POSITIVE_ADJECTIVE");
  sprintf(filename, "%s/%s", include_path, "positive_comparative.wordlist");
  rules_from_file(filename, "POSITIVE_COMPARATIVE");
  sprintf(filename, "%s/%s", include_path, "positive_noun.wordlist");
  rules_from_file(filename, "POSITIVE_NOUN");
  sprintf(filename, "%s/%s", include_path, "second_person.wordlist");
  rules_from_file(filename, "SECOND_PERSON");
  sprintf(filename, "%s/%s", include_path, "second_person_possessive.wordlist");
  rules_from_file(filename, "SECOND_PERSON_POSSESSIVE");
  sprintf(filename, "%s/%s", include_path, "second_person_reflexive.wordlist");
  rules_from_file(filename, "SECOND_PERSON_REFLEXIVE");
  sprintf(filename, "%s/%s", include_path, "third_person_possessive.wordlist");
  rules_from_file(filename, "THIRD_PERSON_POSSESSIVE");

  /* - Single word rules */
  printf("\n /* single word rules */\n");
  rule_for_word("and",                                   "AND");
  rule_for_word("as",                                    "AS");
  rule_for_word("enter",                                 "ENTER");
  rule_for_word("exeunt",                                "EXEUNT");
  rule_for_word("exit",                                  "EXIT");
  rule_for_word("heart",                                 "HEART");
  rule_for_word("if not",                                "IF_NOT");
  rule_for_word("if so",                                 "IF_SO");
  rule_for_word("less",                                  "LESS");
  rule_for_word("let us",                                "LET_US");
  rule_for_word("listen to",                             "LISTEN_TO");
  rule_for_word("mind",                                  "MIND");
  rule_for_word("more",                                  "MORE");
  rule_for_word("not",                                   "NOT");
  rule_for_word("open",                                  "OPEN");
  rule_for_word("proceed to",                            "PROCEED_TO");
  rule_for_word("recall",                                "RECALL");
  rule_for_word("remember",                              "REMEMBER");
  rule_for_word("return to",                             "RETURN_TO");
  rule_for_word("speak",                                 "SPEAK");
  rule_for_word("than",                                  "THAN");
  rule_for_word("the cube of",                           "THE_CUBE_OF");
  rule_for_word("the difference between",                "THE_DIFFERENCE_BETWEEN");
  rule_for_word("the factorial of",                      "THE_FACTORIAL_OF");
  rule_for_word("the product of",                        "THE_PRODUCT_OF");
  rule_for_word("the quotient between",                  "THE_QUOTIENT_BETWEEN");
  rule_for_word("the remainder of the quotient between", "THE_REMAINDER_OF_THE_QUOTIENT_BETWEEN");
  rule_for_word("the square of",                         "THE_SQUARE_OF");
  rule_for_word("the square root of",                    "THE_SQUARE_ROOT_OF");
  rule_for_word("the sum of",                            "THE_SUM_OF");
  rule_for_word("twice",                                 "TWICE");
  rule_for_word("we must",                               "WE_MUST");
  rule_for_word("we shall",                              "WE_SHALL");

  /* - Other rules */
  sprintf(filename, "%s/%s", include_path, "terminals.metaflex");
  printf("\n /* rules for terminals from file %s */", filename);
  insert_file(filename);

  /* Separator */
  printf("\n%%%%\n");

  /* User code */
  sprintf(filename, "%s/%s", include_path, "user_code_bottom.metaflex");
  insert_file(filename);

  /* We did it, no problemas */
  free(include_path);
  return 0;
}
Exemplo n.º 15
0
void mv(char * filename, char * path)
{
	int i, name_length, type;
	filename[str_len(filename) - 1] = 0;
	iNode * path_inode = current;
	path_inode = parser_path(path, path_inode);
	iNode * filename_inode = current;
	filename_inode = parser_path(filename, filename_inode);

	if(filename_inode->gid < currentUsr.group)
	{
		printf("\nCan not move '%s'. Permission denied.", filename);
		return ;
	}

	if(filename_inode == NULL)
	{
		printf("\nCan not move '%s'. File doesn't exist.", filename);
		return ;
	}

	if(path_inode == NULL)
	{
		name_length = str_len(path);
		for(i = 0; i < name_length; i++)
			if(path[i] == '/')
			{
				printf("\nCan not move '%s' to '%s'. Directory doesn't exist.", filename, path);
				return;
			}
		rename_file(filename_inode->iNode_number, path);
		return ;
	}

	int init_block = current->data.direct_blocks[0];
	directoryEntry * dr = (directoryEntry*)calloc(64 * 96, 1);
	read_disk(0, init_block, dr, (BLOCK_SIZE * 12), 0);
	for(i = 1; i < 96; i++){
		if( strcmp(filename, dr[i].name) == 1){
			type = dr[i].type;
			break;
		}
	}

	if(type == DIRECTORY)
	{
		insert_directory_entry(filename_inode, path_inode, filename);

		int inode_number = filename_inode->iNode_number;
		init_block = current->data.direct_blocks[0];
		directoryEntry * dr = (directoryEntry*)calloc(sizeof(directoryEntry),96);
		read_disk(0,init_block,dr,BLOCK_SIZE*12,0);
		iNode * parent = fs_get_inode(dr[1].inode);
		int father_init_block = current->data.direct_blocks[0];
		directoryEntry * father_dr = (directoryEntry*)calloc(sizeof(directoryEntry),96);
		read_disk(0,father_init_block,father_dr,BLOCK_SIZE*12,0);

		for ( i = 2; i < 96; i++){
			if ( father_dr[i].inode == inode_number){
				dr[i].type = 0;
				dr[i].inode = 0;
				dr[i].lenght = 0;
				strcopy(dr[i].name,"\0",1 );
				break;
			}
		}
		write_disk(0,init_block,dr,BLOCK_SIZE*12,0);
	}
	else if( type == FILE)
	{
		insert_file(filename, 777, path_inode);
		rmDir(filename);
	}

	return ;
}
Exemplo n.º 16
0
int main()
{
	printf("main\n");
	node * root = create_Tree();
	char fname[30];
	char * word = (char *)malloc(sizeof(char)*MAXLENGTH);
	int i;
	char k[3];
	do
	{
		printf("\n1. Check a file for spelling errors.\n2. Word lookup.\n3. Add a word to dictionary.\n4. Exit.\nEnter your choice: ");
		scanf("%d",&i);
		if (i==1)
		{
			printf("Enter the name of the file you wish to run spell check on : ");
			scanf("%s", fname);
			spell_Check(fname, root);
		}
		else if (i==2)
		{
			printf("Enter the word you wish to look up : ");
			scanf("%s",word);
			if (search(root,word))
			{
				printf("The word is correctly spelled.\n");
			}
			else
			{
				printf("The word is misspelt.\n");
				printf("Word correction suggestions:\n");
				fix(word, root);
				printf("Would you like to add your word to the dictionary? Type y/n: ");
				scanf("%s", k);
				if (k[0] == 'y')
				{
					insert(root,word);
					printf("Word added\n");
				}
					
			}
		}
		
		else if (i==3)
		{
			printf("Enter the word to be added\n");
			char str[100];
			scanf("%s",str);
			if(search(root,str) == 0)
			{
				insert(root,str);
				insert_file(str);
				printf("Word added\n");
			}
			else
				printf("Already exists in dictionary\n");
		}
		
		if (i > 4 || i < 1)
			printf("Invalid choice. Enter again.\n");
	}while (i != 4);
	deleteTree(root);
	return 0;
}