-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwords.h
52 lines (43 loc) · 1.52 KB
/
words.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
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*-
*
* Copyright (c) 2008 Jeremy English <[email protected]>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* Created: 01-November-2008
*/
#ifndef __WORDS_H__
#define __WORDS_H__
#include <stdint.h>
#include <stdio.h>
#include "posting.h"
enum{
/* index words greater then this length will be excluded from the
index file. */
MAX_WORD_LEN = 50
};
typedef struct IndexWordData IndexWordData;
struct IndexWordData{
char word[MAX_WORD_LEN];
uint32_t num_docs;
uint32_t posting_offset;
};
typedef struct IndexWord IndexWord;
struct IndexWord {
IndexWordData data;
Posting *posting;
IndexWord *left; /* lesser */
IndexWord *right; /* greater */
};
extern IndexWord *new_index_word(char *word);
extern IndexWord *insert_word(IndexWord *treep, IndexWord *newp, uint32_t docid);
extern void print_word_tree(IndexWord *treep);
extern void write_index_file(IndexWord *treep, char *index_filename, char *posting_filename);
extern int get_index_recnum(FILE *fp, int recno, IndexWordData *wr);
#endif /*__WORDS_H__ */