diff options
Diffstat (limited to 'tools/rdf2binary.c')
-rw-r--r-- | tools/rdf2binary.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tools/rdf2binary.c b/tools/rdf2binary.c index c1c7d1b727..70ca495262 100644 --- a/tools/rdf2binary.c +++ b/tools/rdf2binary.c | |||
@@ -46,15 +46,14 @@ long long_to_big_endian (void* value) | |||
46 | 46 | ||
47 | int main() | 47 | int main() |
48 | { | 48 | { |
49 | FILE *in; | 49 | FILE *in, *idx_out, *desc_out; |
50 | int idx_out, desc_out; | ||
51 | struct word w; | 50 | struct word w; |
52 | char buf[10000]; | 51 | char buf[10000]; |
53 | long cur_offset = 0; | 52 | long cur_offset = 0; |
54 | 53 | ||
55 | in = fopen("dict.preparsed", "r"); | 54 | in = fopen("dict.preparsed", "r"); |
56 | idx_out = open("dict.index", O_WRONLY | O_CREAT); | 55 | idx_out = fopen("dict.index", "wb"); |
57 | desc_out = open("dict.desc", O_WRONLY | O_CREAT); | 56 | desc_out = fopen("dict.desc", "wb"); |
58 | 57 | ||
59 | if (in == NULL || idx_out < 0 || desc_out < 0) | 58 | if (in == NULL || idx_out < 0 || desc_out < 0) |
60 | { | 59 | { |
@@ -79,20 +78,20 @@ int main() | |||
79 | /* We will null-terminate the words */ | 78 | /* We will null-terminate the words */ |
80 | strncpy(w.word, word, WORDLEN - 1); | 79 | strncpy(w.word, word, WORDLEN - 1); |
81 | w.offset = long_to_big_endian(&cur_offset); | 80 | w.offset = long_to_big_endian(&cur_offset); |
82 | write(idx_out, &w, sizeof(struct word)); | 81 | fwrite(&w, sizeof(struct word), 1, idx_out); |
83 | 82 | ||
84 | while (1) | 83 | while (1) |
85 | { | 84 | { |
86 | int len = strlen(desc); | 85 | int len = strlen(desc); |
87 | cur_offset += len; | 86 | cur_offset += len; |
88 | write(desc_out, desc, len); | 87 | fwrite(desc, len, 1, desc_out); |
89 | 88 | ||
90 | desc = strtok(NULL, "\t"); | 89 | desc = strtok(NULL, "\t"); |
91 | if (desc == NULL) | 90 | if (desc == NULL) |
92 | break ; | 91 | break ; |
93 | 92 | ||
94 | cur_offset++; | 93 | cur_offset++; |
95 | write(desc_out, "\n", 1); | 94 | fwrite("\n", 1, 1, desc_out); |
96 | 95 | ||
97 | } | 96 | } |
98 | } | 97 | } |