Added root words in the result.
#include <stdio.h>
#include <netinet/in.h>
/*
* idx2index - Part of the flow to convert a StarDict index to a dictd index.
* Author: LluĂs Batlle
* In order to convert a StarDict idx file to a dictd index file, pass:
* ./idx2index < file.idx | LC_ALL=POSIX sort > file.index
* */
static int get_raw_int()
{
int i;
fread(&i, sizeof(int) , 1, stdin);
i = ntohl(i); /* Network to Host order */
return i;
}
static int get_raw_word(char * word)
{
int c;
int count = 0;
do
{
c = getchar();
if (c == EOF)
break;
word[count] = (char) c;
++count;
} while (c != 0);
return count;
}
int main()
{
char word[256];
do
{
int offset, length;
int res;
char c_offset[20], c_length[20];
res = get_raw_word(word);
if (res == 0)
break;
offset = get_raw_int();
num_to_ia5(c_offset, offset);
length = get_raw_int();
num_to_ia5(c_length, length);
printf("%s\t%s\t%s\n", word, c_offset, c_length);
} while(1);
return 0;
}