1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2009 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
37 int main(int argc, char **argv)
43 /* old kdumper.. must be updated to use new codec .. */
44 int key_file_decode (FILE *f)
55 d = ((c&63) << 8) + (getc (f) & 0xff);
58 d = ((c&63) << 8) + (getc (f) & 0xff);
59 d = (d << 8) + (getc (f) & 0xff);
62 d = ((c&63) << 8) + (getc (f) & 0xff);
63 d = (d << 8) + (getc (f) & 0xff);
64 d = (d << 8) + (getc (f) & 0xff);
74 static int read_one (FILE *inf, char *name, char *key, struct it_key *prevk)
81 if ((c=getc(inf)) == EOF)
87 c = key_file_decode (inf);
90 itkey.sysno = c + prevk->sysno;
93 prevk->sysno = itkey.sysno;
96 c = key_file_decode (inf);
97 itkey.seqno = c + prevk->seqno;
98 prevk->seqno = itkey.seqno;
100 memcpy (key+1, &itkey, sizeof(itkey));
105 int main (int argc, char **argv)
109 char *key_fname = NULL;
110 char key_string[IT_MAX_WORD];
121 while ((ret = options ("c:v:", argv, argc, &arg)) != -2)
129 yaz_log_init (yaz_log_mask_str(arg), prog, NULL);
133 if (!(res = res_open (arg, 0, 0)))
135 yaz_log(YLOG_FATAL, "Failed to open resource file %s", arg);
141 yaz_log (YLOG_FATAL, "Unknown option '-%s'", arg);
147 fprintf (stderr, "kdump [-c config] [-v log] file\n");
151 res = res_open ("zebra.cfg", 0, 0);
152 zm = zebra_maps_open (res, 0);
153 if (!(inf = fopen (key_fname, "r")))
155 yaz_log (YLOG_FATAL|YLOG_ERRNO, "fopen %s", key_fname);
158 printf ("t rg op sysno seqno txt\n");
159 while (read_one (inf, key_string, key_info, &prevk))
163 char keybuf[IT_MAX_WORD+1];
165 const char *from = key_string;
166 int usedb_type = from[0];
167 int reg_type = from[1];
170 memcpy (&k, 1+key_info, sizeof(k));
175 const char *res = zebra_maps_output (zm, reg_type, &from);
183 printf ("%c %3d %c %7d %5d %s\n", reg_type, usedb_type, op ? 'i':'d',
184 k.sysno, k.seqno, keybuf);
186 zebra_maps_close (zm);
189 yaz_log (YLOG_FATAL|YLOG_ERRNO, "fclose %s", key_fname);
198 * c-file-style: "Stroustrup"
199 * indent-tabs-mode: nil
201 * vim: shiftwidth=4 tabstop=8 expandtab