2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.21 2002-04-04 20:50:37 adam
8 * Multi register works with record paths and data1 profile path
10 * Revision 1.20 2002/04/04 14:14:13 adam
11 * Multiple registers (alpha early)
13 * Revision 1.19 2000/12/05 10:01:44 adam
14 * Fixed bug regarding user-defined attribute sets.
16 * Revision 1.18 1999/09/07 07:19:21 adam
17 * Work on character mapping. Implemented replace rules.
19 * Revision 1.17 1999/02/02 14:50:55 adam
20 * Updated WIN32 code specific sections. Changed header.
22 * Revision 1.16 1998/05/20 10:12:17 adam
23 * Implemented automatic EXPLAIN database maintenance.
24 * Modified Zebra to work with ASN.1 compiled version of YAZ.
26 * Revision 1.15 1998/03/05 08:45:12 adam
27 * New result set model and modular ranking system. Moved towards
28 * descent server API. System information stored as "SGML" records.
30 * Revision 1.14 1997/10/27 14:33:04 adam
31 * Moved towards generic character mapping depending on "structure"
32 * field in abstract syntax file. Fixed a few memory leaks. Fixed
33 * bug with negative integers when doing searches with relational
36 * Revision 1.13 1997/09/09 13:38:07 adam
37 * Partial port to WIN95/NT.
39 * Revision 1.12 1997/09/05 09:52:32 adam
40 * Extra argument added to function chr_read_maptab (tab path).
42 * Revision 1.11 1996/10/29 14:06:49 adam
43 * Include zebrautl.h instead of alexutil.h.
45 * Revision 1.10 1996/06/04 14:56:12 quinn
48 * Revision 1.9 1996/06/04 14:18:53 quinn
51 * Revision 1.8 1996/06/04 10:18:59 adam
52 * Minor changes - removed include of ctype.h.
54 * Revision 1.7 1995/10/10 12:24:38 adam
55 * Temporary sort files are compressed.
57 * Revision 1.6 1995/09/29 14:01:42 adam
60 * Revision 1.5 1995/09/11 13:09:35 adam
61 * More work on relevance feedback.
63 * Revision 1.4 1995/09/08 14:52:27 adam
64 * Minor changes. Dictionary is lower case now.
66 * Revision 1.3 1995/09/06 16:11:17 adam
67 * Option: only one word key per file.
69 * Revision 1.2 1995/09/04 12:33:42 adam
70 * Various cleanup. YAZ util used instead.
72 * Revision 1.1 1995/09/04 09:10:36 adam
73 * More work on index add/del/update.
74 * Merge sort implemented.
75 * Initial work on z39 server.
94 int key_file_decode (FILE *f)
105 d = ((c&63) << 8) + (getc (f) & 0xff);
108 d = ((c&63) << 8) + (getc (f) & 0xff);
109 d = (d << 8) + (getc (f) & 0xff);
112 d = ((c&63) << 8) + (getc (f) & 0xff);
113 d = (d << 8) + (getc (f) & 0xff);
114 d = (d << 8) + (getc (f) & 0xff);
121 static int read_one (FILE *inf, char *name, char *key, struct it_key *prevk)
128 if ((c=getc(inf)) == EOF)
134 c = key_file_decode (inf);
137 itkey.sysno = c + prevk->sysno;
140 prevk->sysno = itkey.sysno;
143 c = key_file_decode (inf);
144 itkey.seqno = c + prevk->seqno;
145 prevk->seqno = itkey.seqno;
147 memcpy (key+1, &itkey, sizeof(itkey));
151 int main (int argc, char **argv)
155 char *key_fname = NULL;
156 char key_string[IT_MAX_WORD];
167 while ((ret = options ("c:v:", argv, argc, &arg)) != -2)
175 yaz_log_init (yaz_log_mask_str(arg), prog, NULL);
179 if (!(res = res_open (arg, 0)))
181 logf(LOG_FATAL, "Failed to open resource file %s", arg);
187 logf (LOG_FATAL, "Unknown option '-%s'", arg);
193 fprintf (stderr, "kdump [-c config] [-v log] file\n");
197 res = res_open ("zebra.cfg", 0);
198 zm = zebra_maps_open (res, 0);
199 if (!(inf = fopen (key_fname, "r")))
201 logf (LOG_FATAL|LOG_ERRNO, "fopen %s", key_fname);
204 printf ("t rg op sysno seqno txt\n");
205 while (read_one (inf, key_string, key_info, &prevk))
209 char keybuf[IT_MAX_WORD+1];
211 const char *from = key_string;
212 int usedb_type = from[0];
213 int reg_type = from[1];
216 memcpy (&k, 1+key_info, sizeof(k));
221 const char *res = zebra_maps_output (zm, reg_type, &from);
229 printf ("%c %3d %c %7d %5d %s\n", reg_type, usedb_type, op ? 'i':'d',
230 k.sysno, k.seqno, keybuf);
232 zebra_maps_close (zm);
235 logf (LOG_FATAL|LOG_ERRNO, "fclose %s", key_fname);