author | viric@llimona |
Sat, 08 Sep 2007 09:12:50 +0200 | |
changeset 28 | 75b6d5659a19 |
parent 8 | 09ec33061ff3 |
permissions | -rw-r--r-- |
0 | 1 |
#include <stdio.h> |
2 |
#include <netinet/in.h> |
|
3 |
||
4 |
/* |
|
5 |
* idx2index - Part of the flow to convert a StarDict index to a dictd index. |
|
6 |
* Author: LluĂs Batlle |
|
7 |
* In order to convert a StarDict idx file to a dictd index file, pass: |
|
8 |
* ./idx2index < file.idx | LC_ALL=POSIX sort > file.index |
|
9 |
* */ |
|
10 |
||
8
09ec33061ff3
Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
0
diff
changeset
|
11 |
static int get_raw_int() |
0 | 12 |
{ |
13 |
int i; |
|
14 |
fread(&i, sizeof(int) , 1, stdin); |
|
15 |
i = ntohl(i); /* Network to Host order */ |
|
16 |
return i; |
|
17 |
} |
|
18 |
||
8
09ec33061ff3
Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
0
diff
changeset
|
19 |
static int get_raw_word(char * word) |
0 | 20 |
{ |
21 |
int c; |
|
22 |
int count = 0; |
|
23 |
||
24 |
do |
|
25 |
{ |
|
26 |
c = getchar(); |
|
27 |
if (c == EOF) |
|
28 |
break; |
|
29 |
word[count] = (char) c; |
|
30 |
++count; |
|
31 |
} while (c != 0); |
|
32 |
return count; |
|
33 |
} |
|
34 |
||
35 |
int main() |
|
36 |
{ |
|
37 |
char word[256]; |
|
38 |
||
39 |
do |
|
40 |
{ |
|
41 |
int offset, length; |
|
42 |
int res; |
|
43 |
char c_offset[20], c_length[20]; |
|
44 |
||
8
09ec33061ff3
Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
0
diff
changeset
|
45 |
res = get_raw_word(word); |
0 | 46 |
if (res == 0) |
47 |
break; |
|
8
09ec33061ff3
Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
0
diff
changeset
|
48 |
offset = get_raw_int(); |
0 | 49 |
num_to_ia5(c_offset, offset); |
8
09ec33061ff3
Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
0
diff
changeset
|
50 |
length = get_raw_int(); |
0 | 51 |
num_to_ia5(c_length, length); |
52 |
printf("%s\t%s\t%s\n", word, c_offset, c_length); |
|
53 |
} while(1); |
|
54 |
return 0; |
|
55 |
} |