X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Fkdump.c;h=d86396e2306c0c88813d6ff127df9c329b3d97d2;hp=93344e623ef7366a50d4e4678329cbad27fc56c3;hb=e2e073b5c947e996304ed7d577497af5e9a879ee;hpb=fc7107844c9ec8ea23e680ca4f3231923db4e9c5 diff --git a/index/kdump.c b/index/kdump.c index 93344e6..d86396e 100644 --- a/index/kdump.c +++ b/index/kdump.c @@ -1,50 +1,55 @@ -/* - * Copyright (C) 1994-1995, Index Data I/S - * All rights reserved. - * Sebastian Hammer, Adam Dickmeiss - * - * $Log: kdump.c,v $ - * Revision 1.7 1995-10-10 12:24:38 adam - * Temporary sort files are compressed. - * - * Revision 1.6 1995/09/29 14:01:42 adam - * Bug fixes. - * - * Revision 1.5 1995/09/11 13:09:35 adam - * More work on relevance feedback. - * - * Revision 1.4 1995/09/08 14:52:27 adam - * Minor changes. Dictionary is lower case now. - * - * Revision 1.3 1995/09/06 16:11:17 adam - * Option: only one word key per file. - * - * Revision 1.2 1995/09/04 12:33:42 adam - * Various cleanup. YAZ util used instead. - * - * Revision 1.1 1995/09/04 09:10:36 adam - * More work on index add/del/update. - * Merge sort implemented. - * Initial work on z39 server. - * - */ +/* This file is part of the Zebra server. + Copyright (C) Index Data + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#if HAVE_CONFIG_H +#include +#endif #include +#include #include +#include +#ifdef WIN32 +#include +#endif +#if HAVE_UNISTD_H #include +#endif #include -#include +#include #include "index.h" char *prog; +int main(int argc, char **argv) +{ + exit(0); +} +#if 0 +/* old kdumper.. must be updated to use new codec .. */ int key_file_decode (FILE *f) { int c, d; c = getc (f); - switch (c & 192) + switch (c & 192) { case 0: d = c; @@ -61,6 +66,9 @@ int key_file_decode (FILE *f) d = (d << 8) + (getc (f) & 0xff); d = (d << 8) + (getc (f) & 0xff); break; + default: + d = 0; + assert (0); } return d; } @@ -96,6 +104,7 @@ static int read_one (FILE *inf, char *name, char *key, struct it_key *prevk) return 1; } + int main (int argc, char **argv) { int ret; @@ -103,14 +112,16 @@ int main (int argc, char **argv) char *key_fname = NULL; char key_string[IT_MAX_WORD]; char key_info[256]; + ZebraMaps zm; FILE *inf; + Res res = NULL; struct it_key prevk; prevk.sysno = 0; prevk.seqno = 0; prog = *argv; - while ((ret = options ("v:", argv, argc, &arg)) != -2) + while ((ret = options ("c:v:", argv, argc, &arg)) != -2) { if (ret == 0) { @@ -118,39 +129,78 @@ int main (int argc, char **argv) } else if (ret == 'v') { - log_init (log_mask_str(arg), prog, NULL); + yaz_log_init (yaz_log_mask_str(arg), prog, NULL); } + else if (ret == 'c') + { + if (!(res = res_open (arg, 0, 0))) + { + yaz_log(YLOG_FATAL, "Failed to open resource file %s", arg); + exit (1); + } + } else { - logf (LOG_FATAL, "Unknown option '-%s'", arg); + yaz_log (YLOG_FATAL, "Unknown option '-%s'", arg); exit (1); } } if (!key_fname) { - fprintf (stderr, "kdump [-v log] file\n"); + fprintf (stderr, "kdump [-c config] [-v log] file\n"); exit (1); } + if (!res) + res = res_open ("zebra.cfg", 0, 0); + zm = zebra_maps_open (res, 0); if (!(inf = fopen (key_fname, "r"))) { - logf (LOG_FATAL|LOG_ERRNO, "fopen %s", key_fname); + yaz_log (YLOG_FATAL|YLOG_ERRNO, "fopen %s", key_fname); exit (1); } + printf ("t rg op sysno seqno txt\n"); while (read_one (inf, key_string, key_info, &prevk)) { struct it_key k; int op; + char keybuf[IT_MAX_WORD+1]; + char *to = keybuf; + const char *from = key_string; + int usedb_type = from[0]; + int reg_type = from[1]; op = key_info[0]; memcpy (&k, 1+key_info, sizeof(k)); - printf ("%7d op=%d s=%-5d %s\n", k.sysno, op, k.seqno, - key_string); + + from += 2; + while (*from) + { + const char *res = zebra_maps_output (zm, reg_type, &from); + if (!res) + *to++ = *from++; + else + while (*res) + *to++ = *res++; + } + *to = '\0'; + printf ("%c %3d %c %7d %5d %s\n", reg_type, usedb_type, op ? 'i':'d', + k.sysno, k.seqno, keybuf); } + zebra_maps_close (zm); if (fclose (inf)) { - logf (LOG_FATAL|LOG_ERRNO, "fclose %s", key_fname); + yaz_log (YLOG_FATAL|YLOG_ERRNO, "fclose %s", key_fname); exit (1); } - exit (0); } +#endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +