-
Notifications
You must be signed in to change notification settings - Fork 1
/
inverted_search.h
77 lines (66 loc) · 1.66 KB
/
inverted_search.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef INVERTED_SEARCH_H
#define INVERTED_SEARCH_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
#include <errno.h>
//defining macros
#define FAILURE -1
#define SUCCESS 0
#define FNAME_SIZE 15
#define WORD_SIZE 10
#define FILE_EMPTY -2
#define FILE_NOTAVAILABLE -3
#define REPEATATION -4
//Structure for file list
typedef char data_t;
typedef struct file_node
{
data_t file_name[FNAME_SIZE];
struct file_node *link;
}Flist;
//Structure for link table
typedef struct linkTable_node
{
int word_count;
data_t file_name[FNAME_SIZE];
struct linkTable_node *table_link;
}Ltable;
//structure to store word count
typedef struct word_node
{
int file_count;
data_t word[WORD_SIZE];
Ltable *Tlink;
struct word_node *link;
}Wlist;
int to_create_list_of_files(Flist **f_head, char *name);
void create_database(Flist *f_head, Wlist *head[]);
// read contents of a file
Wlist * read_datafile( Wlist *head[], char *filename);
// create word_list
int insert_at_last(Wlist **head, data_t *data);
// update linktable
int update_link_table(Wlist **head);
// update
int update_word_count(Wlist ** head, char * file_name);
// print_word_count
int print_word_count(Wlist *head);
//searching a word
void search_database( Wlist *head, char *word);
//display
void display_database( Wlist *head[] );
//save_databse
void save_database( Wlist *head[]);
//
void write_databasefile(Wlist *head, FILE* databasefile);
//update
void update_database( Wlist *head[], Flist **f_head);
int isFileEmpty(char *filename);
void file_validation_n_file_list(Flist **f_head, char *argv[]);
#endif