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