projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Using yaz/test.h. Test for zebra without config
[idzebra-moved-to-github.git]
/
util
/
zebramap.c
diff --git
a/util/zebramap.c
b/util/zebramap.c
index
991d16b
..
9c03d0b
100644
(file)
--- a/
util/zebramap.c
+++ b/
util/zebramap.c
@@
-1,4
+1,4
@@
-/* $Id: zebramap.c,v 1.41 2005-06-14 12:42:49 adam Exp $
+/* $Id: zebramap.c,v 1.44 2006-03-13 17:40:28 mike Exp $
Copyright (C) 1995-2005
Index Data ApS
Copyright (C) 1995-2005
Index Data ApS
@@
-77,7
+77,8
@@
void zebra_maps_close (ZebraMaps zms)
xfree (zms);
}
xfree (zms);
}
-static void zebra_map_read (ZebraMaps zms, const char *name)
+/* Returns 0 if all is well, -1 on fatal error */
+static int zebra_map_read (ZebraMaps zms, const char *name, int fail_fatal)
{
FILE *f;
char line[512];
{
FILE *f;
char line[512];
@@
-88,8
+89,9
@@
static void zebra_map_read (ZebraMaps zms, const char *name)
if (!(f = yaz_fopen(zms->tabpath, name, "r", zms->tabroot)))
{
if (!(f = yaz_fopen(zms->tabpath, name, "r", zms->tabroot)))
{
- yaz_log(YLOG_WARN|YLOG_ERRNO, "%s", name);
- return ;
+ int level = fail_fatal ? YLOG_FATAL : YLOG_WARN;
+ yaz_log(level|YLOG_ERRNO, "%s", name);
+ return -1;
}
while ((argc = readconf_line(f, &lineno, line, 512, argv, 10)))
{
}
while ((argc = readconf_line(f, &lineno, line, 512, argv, 10)))
{
@@
-146,13
+148,15
@@
static void zebra_map_read (ZebraMaps zms, const char *name)
for (zp = zms->map_list; zp; zp = zp->next)
zms->lookup_array[zp->reg_id] = zp;
for (zp = zms->map_list; zp; zp = zp->next)
zms->lookup_array[zp->reg_id] = zp;
+
+ return 0;
}
static void zms_map_handle (void *p, const char *name, const char *value)
{
ZebraMaps zms = (ZebraMaps) p;
}
static void zms_map_handle (void *p, const char *name, const char *value)
{
ZebraMaps zms = (ZebraMaps) p;
- zebra_map_read (zms, value);
+ (void) zebra_map_read (zms, value, 0);
}
ZebraMaps zebra_maps_open (Res res, const char *base)
}
ZebraMaps zebra_maps_open (Res res, const char *base)
@@
-180,7
+184,8
@@
ZebraMaps zebra_maps_open (Res res, const char *base)
for (i = 0; i<256; i++)
zms->lookup_array[i] = 0;
if (!res || !res_trav (res, "index", zms, zms_map_handle))
for (i = 0; i<256; i++)
zms->lookup_array[i] = 0;
if (!res || !res_trav (res, "index", zms, zms_map_handle))
- zebra_map_read (zms, "default.idx");
+ if (zebra_map_read (zms, "default.idx", 1) < 0)
+ return 0;
zms->wrbuf_1 = wrbuf_alloc();
zms->wrbuf_1 = wrbuf_alloc();
@@
-189,6
+194,7
@@
ZebraMaps zebra_maps_open (Res res, const char *base)
struct zebra_map *zebra_map_get (ZebraMaps zms, unsigned reg_id)
{
struct zebra_map *zebra_map_get (ZebraMaps zms, unsigned reg_id)
{
+ assert(reg_id >= 0 && reg_id <= 255);
return zms->lookup_array[reg_id];
}
return zms->lookup_array[reg_id];
}
@@
-215,7
+221,7
@@
chrmaptab zebra_charmap_get (ZebraMaps zms, unsigned reg_id)
if (!zm->maptab_name || !yaz_matchstr (zm->maptab_name, "@"))
return NULL;
if (!(zm->maptab = chrmaptab_create (zms->tabpath,
if (!zm->maptab_name || !yaz_matchstr (zm->maptab_name, "@"))
return NULL;
if (!(zm->maptab = chrmaptab_create (zms->tabpath,
- zm->maptab_name, 0,
+ zm->maptab_name,
zms->tabroot)))
yaz_log(YLOG_WARN, "Failed to read character table %s",
zm->maptab_name);
zms->tabroot)))
yaz_log(YLOG_WARN, "Failed to read character table %s",
zm->maptab_name);