2 * Copyright (C) 1994-1996, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.9 1996-06-04 14:18:53 quinn
10 * Revision 1.8 1996/06/04 10:18:59 adam
11 * Minor changes - removed include of ctype.h.
13 * Revision 1.7 1995/10/10 12:24:38 adam
14 * Temporary sort files are compressed.
16 * Revision 1.6 1995/09/29 14:01:42 adam
19 * Revision 1.5 1995/09/11 13:09:35 adam
20 * More work on relevance feedback.
22 * Revision 1.4 1995/09/08 14:52:27 adam
23 * Minor changes. Dictionary is lower case now.
25 * Revision 1.3 1995/09/06 16:11:17 adam
26 * Option: only one word key per file.
28 * Revision 1.2 1995/09/04 12:33:42 adam
29 * Various cleanup. YAZ util used instead.
31 * Revision 1.1 1995/09/04 09:10:36 adam
32 * More work on index add/del/update.
33 * Merge sort implemented.
34 * Initial work on z39 server.
49 int key_file_decode (FILE *f)
60 d = ((c&63) << 8) + (getc (f) & 0xff);
63 d = ((c&63) << 8) + (getc (f) & 0xff);
64 d = (d << 8) + (getc (f) & 0xff);
67 d = ((c&63) << 8) + (getc (f) & 0xff);
68 d = (d << 8) + (getc (f) & 0xff);
69 d = (d << 8) + (getc (f) & 0xff);
76 static int read_one (FILE *inf, char *name, char *key, struct it_key *prevk)
83 if ((c=getc(inf)) == EOF)
89 c = key_file_decode (inf);
92 itkey.sysno = c + prevk->sysno;
95 prevk->sysno = itkey.sysno;
98 c = key_file_decode (inf);
99 itkey.seqno = c + prevk->seqno;
100 prevk->seqno = itkey.seqno;
102 memcpy (key+1, &itkey, sizeof(itkey));
106 int main (int argc, char **argv)
110 char *key_fname = NULL;
111 char key_string[IT_MAX_WORD];
121 while ((ret = options ("v:", argv, argc, &arg)) != -2)
129 log_init (log_mask_str(arg), prog, NULL);
133 if (!(map = chr_read_maptab(arg)))
135 logf(LOG_FATAL, "Failed to open maptab");
141 logf (LOG_FATAL, "Unknown option '-%s'", arg);
147 fprintf (stderr, "kdump [-m maptab -v log] file\n");
150 if (!(inf = fopen (key_fname, "r")))
152 logf (LOG_FATAL|LOG_ERRNO, "fopen %s", key_fname);
155 while (read_one (inf, key_string, key_info, &prevk))
159 char keybuf[IT_MAX_WORD+1];
162 memcpy (&k, 1+key_info, sizeof(k));
165 char *to = keybuf, *from = key_string;
169 char *res = (char*)map->output[(unsigned char) *from];
176 strcpy(keybuf, key_string);
177 printf ("%7d op=%d s=%-5d %s\n", k.sysno, op, k.seqno,
182 logf (LOG_FATAL|LOG_ERRNO, "fclose %s", key_fname);