X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Fkdump.c;h=0e2fc2d25b0fd1b54c613abfa181a65d9cb6237c;hp=cd094bc85ff6f68b15fd8b096a25a56b3c6d28af;hb=2b1851bd5565e3d21f9cf9a37661a584c063b75f;hpb=c5ae7c0234530d9c3c907383583cd156ed45628d diff --git a/index/kdump.c b/index/kdump.c index cd094bc..0e2fc2d 100644 --- a/index/kdump.c +++ b/index/kdump.c @@ -1,10 +1,45 @@ /* - * Copyright (C) 1994-1996, Index Data I/S + * Copyright (C) 1994-1999, Index Data * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: kdump.c,v $ - * Revision 1.10 1996-06-04 14:56:12 quinn + * Revision 1.20 2002-04-04 14:14:13 adam + * Multiple registers (alpha early) + * + * Revision 1.19 2000/12/05 10:01:44 adam + * Fixed bug regarding user-defined attribute sets. + * + * Revision 1.18 1999/09/07 07:19:21 adam + * Work on character mapping. Implemented replace rules. + * + * Revision 1.17 1999/02/02 14:50:55 adam + * Updated WIN32 code specific sections. Changed header. + * + * Revision 1.16 1998/05/20 10:12:17 adam + * Implemented automatic EXPLAIN database maintenance. + * Modified Zebra to work with ASN.1 compiled version of YAZ. + * + * Revision 1.15 1998/03/05 08:45:12 adam + * New result set model and modular ranking system. Moved towards + * descent server API. System information stored as "SGML" records. + * + * Revision 1.14 1997/10/27 14:33:04 adam + * Moved towards generic character mapping depending on "structure" + * field in abstract syntax file. Fixed a few memory leaks. Fixed + * bug with negative integers when doing searches with relational + * operators. + * + * Revision 1.13 1997/09/09 13:38:07 adam + * Partial port to WIN95/NT. + * + * Revision 1.12 1997/09/05 09:52:32 adam + * Extra argument added to function chr_read_maptab (tab path). + * + * Revision 1.11 1996/10/29 14:06:49 adam + * Include zebrautl.h instead of alexutil.h. + * + * Revision 1.10 1996/06/04 14:56:12 quinn * Fix * * Revision 1.9 1996/06/04 14:18:53 quinn @@ -38,11 +73,15 @@ * */ #include +#include #include +#ifdef WIN32 +#include +#else #include +#endif #include -#include #include #include "index.h" @@ -113,15 +152,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; - chrmaptab *map = 0; prevk.sysno = 0; prevk.seqno = 0; prog = *argv; - while ((ret = options ("m:v:", argv, argc, &arg)) != -2) + while ((ret = options ("c:v:", argv, argc, &arg)) != -2) { if (ret == 0) { @@ -129,14 +169,14 @@ 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 == 'm') + else if (ret == 'c') { - if (!(map = chr_read_maptab(arg))) - { - logf(LOG_FATAL, "Failed to open maptab"); - exit(1); + if (!(res = res_open (arg, 0))) + { + logf(LOG_FATAL, "Failed to open resource file %s", arg); + exit (1); } } else @@ -147,39 +187,46 @@ int main (int argc, char **argv) } if (!key_fname) { - fprintf (stderr, "kdump [-m maptab -v log] file\n"); + fprintf (stderr, "kdump [-c config] [-v log] file\n"); exit (1); } + if (!res) + res = res_open ("zebra.cfg", 0); + zm = zebra_maps_open (res); if (!(inf = fopen (key_fname, "r"))) { logf (LOG_FATAL|LOG_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)); - if (map) - { - char *to = keybuf, *from = key_string; - while (*from) - { - char *res = (char*)map->output[(unsigned char) *(from++)]; + 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'; + *to++ = *res++; } - else - strcpy(keybuf, key_string); - printf ("%7d op=%d s=%-5d %s\n", k.sysno, op, k.seqno, - keybuf); + *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);