
#ifndef TRUE
#define FALSE 0
#define TRUE (!FALSE)
#endif
#define BFSZ 600
#define HASH_WORDS 5000
#define NPOINT 4
typedef struct {int widx; int point[NPOINT]; int len; } WREC; 
typedef struct Dict {char *word; int upto; WREC wrec; struct Dict *next;} DICT;
typedef struct Glist {char *word; int idx; struct Glist *next;} GLIST;
typedef struct Vlist {int gid; int num; int score; struct Vlist *next;} VLIST;
typedef struct Wcache {DICT *dict; VLIST *list; struct Wcache *next;} WCACHE; 
typedef struct Point {short group; int item; char score;} POINT;

typedef struct Wlist {DICT *dict; int score; struct Wlist *next;} WLIST;
#define U_HASH 1000
#define HASH_CACHE 5000

/*---------------------------------------------------------*/
void fts_init(char *rt);
void fts_close(void);
DICT *fts_word_add(char *word, WREC *wrec, int upto);
DICT *fts_word_find(char *word);
DICT *fts_word_find_add(char *word);
int fts_word_update(DICT *w);
VLIST *fts_read(DICT *w);
int fts_group_add(char *word, int idx);
void fts_stats(int *nwords, int *nuni);

int fts_read_words(void);
int fts_word_append(char *word, WREC *wrec);
void fts_read_groups(void);
int fts_group_find(char *word);
void fts_append_group(char *group, int idx);
void fts_uni_add(char *word);
int fts_add(char *group, int num, char *article);
int fts_fix_word( char *s);
void fts_uni_cache(char *group, int num);
void fts_cache_add(DICT *dict, int score, int gid, int num);
void fts_cache_addv(WCACHE *list,DICT *dict, int score, int gid, int num);
void fts_cache_write(void);
void fts_cache_write_one(DICT *dict, VLIST *list);
void fts_open(void);
void fts_word_open(void);
void fts_append(int gid, int num, int score);
void fts_search(char *wordlist);
void fts_expire(void);
int fts_hash(char *s, int max);
char *fts_dir(char *s);
/*---------------------------------------------------------*/
/*--EXTRA STUFF -------------------------------------------*/
char *ncpy(char *dst, char *src, int len);
int lib_flength(char *fname);
void *mem_malloc(size_t t);
void mem_free(void *m, char *file, int line);
char *mystrdup(const char *str);


/*---------------------------------------------------------*/
#define filemsg printf
#define emsg printf



