From 98e21f950e6d0babe88a6a1ccb03b90f0b3a6b1a Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 4 Apr 2002 20:50:36 +0000 Subject: [PATCH] Multi register works with record paths and data1 profile path --- bfile/mfile.c | 7 ++- include/charmap.h | 7 ++- include/direntz.h | 6 +- include/zebramap.h | 7 ++- index/dir.c | 34 +++++++++-- index/extract.c | 19 +++++- index/index.h | 4 +- index/kdump.c | 7 ++- index/main.c | 15 +++-- index/retrieve.c | 22 ++++++- index/trav.c | 169 ++++++++------------------------------------------- index/zebraapi.c | 78 +++++++++++++----------- index/zserver.c | 12 ++-- recctrl/regxread.c | 9 ++- test/gils/zebra.cfg | 5 +- util/charmap.c | 7 ++- util/dirent.c | 34 +++-------- util/res.c | 4 +- util/zebramap.c | 17 ++++-- 19 files changed, 211 insertions(+), 252 deletions(-) diff --git a/bfile/mfile.c b/bfile/mfile.c index 794d529..d00e78e 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: mfile.c,v $ - * Revision 1.42 2002-04-04 14:14:13 adam + * Revision 1.43 2002-04-04 20:50:36 adam + * Multi register works with record paths and data1 profile path + * + * Revision 1.42 2002/04/04 14:14:13 adam * Multiple registers (alpha early) * * Revision 1.41 2000/11/29 14:24:01 adam @@ -182,7 +185,7 @@ static int scan_areadef(MFile_area ma, const char *ad, const char *base) ad++; if (!*ad) break; - if (!zebra_is_abspath(ad) && base) + if (!yaz_is_abspath(ad) && base) { strcpy (dirname, base); i = strlen(dirname); diff --git a/include/charmap.h b/include/charmap.h index 23661a5..326f0d4 100644 --- a/include/charmap.h +++ b/include/charmap.h @@ -36,7 +36,10 @@ * OF THIS SOFTWARE. * * $Log: charmap.h,v $ - * Revision 1.6 1999-11-30 13:48:03 adam + * Revision 1.7 2002-04-04 20:50:36 adam + * Multi register works with record paths and data1 profile path + * + * Revision 1.6 1999/11/30 13:48:03 adam * Improved installation. Updated for inclusion of YAZ header files. * * Revision 1.5 1999/09/07 07:19:21 adam @@ -73,7 +76,7 @@ typedef struct chr_t_entry chr_t_entry; typedef struct chrmaptab_info *chrmaptab; YAZ_EXPORT chrmaptab chrmaptab_create(const char *tabpath, const char *name, - int map_only); + int map_only, const char *tabroot); YAZ_EXPORT void chrmaptab_destroy (chrmaptab tab); YAZ_EXPORT const char **chr_map_input(chrmaptab t, const char **from, int len); diff --git a/include/direntz.h b/include/direntz.h index 7e8ba5b..fcca6f7 100644 --- a/include/direntz.h +++ b/include/direntz.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: direntz.h,v $ - * Revision 1.5 2002-04-04 14:14:13 adam + * Revision 1.6 2002-04-04 20:50:36 adam + * Multi register works with record paths and data1 profile path + * + * Revision 1.5 2002/04/04 14:14:13 adam * Multiple registers (alpha early) * * Revision 1.4 1999/05/26 07:49:13 adam @@ -51,4 +54,3 @@ void closedir (DIR *dd); #include #endif -int zebra_is_abspath (const char *p); diff --git a/include/zebramap.h b/include/zebramap.h index 21fd34a..9cf43fa 100644 --- a/include/zebramap.h +++ b/include/zebramap.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebramap.h,v $ - * Revision 1.12 2001-11-14 22:06:27 adam + * Revision 1.13 2002-04-04 20:50:36 adam + * Multi register works with record paths and data1 profile path + * + * Revision 1.12 2001/11/14 22:06:27 adam * Rank-weight may be controlled via query. * * Revision 1.11 2001/01/22 10:42:56 adam @@ -59,7 +62,7 @@ extern "C" { #endif typedef struct zebra_maps *ZebraMaps; -ZebraMaps zebra_maps_open (Res res); +ZebraMaps zebra_maps_open (Res res, const char *base); void zebra_maps_close (ZebraMaps zm); diff --git a/index/dir.c b/index/dir.c index 35c64f1..fecb46e 100644 --- a/index/dir.c +++ b/index/dir.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dir.c,v $ - * Revision 1.21 1999-05-26 07:49:13 adam + * Revision 1.22 2002-04-04 20:50:36 adam + * Multi register works with record paths and data1 profile path + * + * Revision 1.21 1999/05/26 07:49:13 adam * C++ compilation. * * Revision 1.20 1999/02/02 14:50:50 adam @@ -84,18 +87,28 @@ #include "index.h" -struct dir_entry *dir_open (const char *rep) +struct dir_entry *dir_open (const char *rep, const char *base) { DIR *dir; - char path[256]; + char path[1024]; + char full_rep[1024]; size_t pathpos; struct dirent *dent; size_t entry_max = 500; size_t idx = 0; struct dir_entry *entry; - logf (LOG_DEBUG, "dir_open %s", rep); - if (!(dir = opendir(rep))) + if (base && !yaz_is_abspath(rep)) + { + strcpy (full_rep, base); + strcat (full_rep, "/"); + } + else + *full_rep = '\0'; + strcat (full_rep, rep); + + logf (LOG_LOG, "dir_open %s", full_rep); + if (!(dir = opendir(full_rep))) { logf (LOG_WARN|LOG_ERRNO, "opendir %s", rep); if (errno != ENOENT && errno != EACCES) @@ -124,7 +137,16 @@ struct dir_entry *dir_open (const char *rep) entry = entry_n; } strcpy (path + pathpos, dent->d_name); - stat (path, &finfo); + + if (base && !yaz_is_abspath (path)) + { + strcpy (full_rep, base); + strcat (full_rep, "/"); + strcat (full_rep, path); + stat (full_rep, &finfo); + } + else + stat (path, &finfo); switch (finfo.st_mode & S_IFMT) { case S_IFREG: diff --git a/index/extract.c b/index/extract.c index 2f4bf84..040aff0 100644 --- a/index/extract.c +++ b/index/extract.c @@ -3,7 +3,7 @@ * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Id: extract.c,v 1.114 2002-04-04 14:14:13 adam Exp $ + * $Id: extract.c,v 1.115 2002-04-04 20:50:36 adam Exp $ */ #include #include @@ -15,6 +15,7 @@ #include #include "index.h" +#include #include #if _FILE_OFFSET_BITS == 64 @@ -814,9 +815,21 @@ int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname, fd = -1; else { - if ((fd = open (fname, O_BINARY|O_RDONLY)) == -1) + char full_rep[1024]; + + if (zh->path_reg && !yaz_is_abspath (fname)) + { + strcpy (full_rep, zh->path_reg); + strcat (full_rep, "/"); + strcat (full_rep, fname); + } + else + strcpy (full_rep, fname); + + + if ((fd = open (full_rep, O_BINARY|O_RDONLY)) == -1) { - logf (LOG_WARN|LOG_ERRNO, "open %s", fname); + logf (LOG_WARN|LOG_ERRNO, "open %s", full_rep); return 0; } } diff --git a/index/index.h b/index/index.h index 21969e8..7e72df1 100644 --- a/index/index.h +++ b/index/index.h @@ -2,7 +2,7 @@ * Copyright (C) 1995-2002, Index Data * All rights reserved. * Sebastian Hammer, Adam Dickmeiss, Heikki Levanto - * $Id: index.h,v 1.75 2002-04-04 14:14:13 adam Exp $ + * $Id: index.h,v 1.76 2002-04-04 20:50:37 adam Exp $ */ #ifndef INDEX_H @@ -78,7 +78,7 @@ void dirs_add (struct dirs_info *p, const char *src, int sysno, time_t mtime); void dirs_del (struct dirs_info *p, const char *src); void dirs_free (struct dirs_info **pp); -struct dir_entry *dir_open (const char *rep); +struct dir_entry *dir_open (const char *rep, const char *base); void dir_sort (struct dir_entry *e); void dir_free (struct dir_entry **e_p); diff --git a/index/kdump.c b/index/kdump.c index 0e2fc2d..3157512 100644 --- a/index/kdump.c +++ b/index/kdump.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kdump.c,v $ - * Revision 1.20 2002-04-04 14:14:13 adam + * Revision 1.21 2002-04-04 20:50:37 adam + * Multi register works with record paths and data1 profile path + * + * Revision 1.20 2002/04/04 14:14:13 adam * Multiple registers (alpha early) * * Revision 1.19 2000/12/05 10:01:44 adam @@ -192,7 +195,7 @@ int main (int argc, char **argv) } if (!res) res = res_open ("zebra.cfg", 0); - zm = zebra_maps_open (res); + zm = zebra_maps_open (res, 0); if (!(inf = fopen (key_fname, "r"))) { logf (LOG_FATAL|LOG_ERRNO, "fopen %s", key_fname); diff --git a/index/main.c b/index/main.c index 1b91efc..5231053 100644 --- a/index/main.c +++ b/index/main.c @@ -2,7 +2,7 @@ * Copyright (C) 1994-2002, Index Data * All rights reserved. * - * $Id: main.c,v 1.83 2002-04-04 14:14:13 adam Exp $ + * $Id: main.c,v 1.84 2002-04-04 20:50:37 adam Exp $ */ #include #include @@ -96,13 +96,20 @@ int main (int argc, char **argv) ZEBRAVER, ZEBRADATE); #endif zs = zebra_start (configName ? configName : "zebra.cfg"); - + if (!zs) + exit (1); zh = zebra_open (zs); } if (rGroupDef.databaseName) - zebra_select_database (zh, rGroupDef.databaseName); + { + if (zebra_select_database (zh, rGroupDef.databaseName)) + exit (1); + } else - zebra_select_database (zh, "Default"); + { + if (zebra_select_database (zh, "Default")) + exit (1); + } if (!strcmp (arg, "update")) cmd = 'u'; diff --git a/index/retrieve.c b/index/retrieve.c index 9b8baae..b8cd854 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: retrieve.c,v $ - * Revision 1.15 2002-04-04 14:14:13 adam + * Revision 1.16 2002-04-04 20:50:37 adam + * Multi register works with record paths and data1 profile path + * + * Revision 1.15 2002/04/04 14:14:13 adam * Multiple registers (alpha early) * * Revision 1.14 2001/01/22 11:41:41 adam @@ -65,6 +68,7 @@ #endif #include "index.h" +#include int zebra_record_ext_read (void *fh, char *buf, size_t count) { @@ -170,10 +174,22 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, } else { - if ((fc.fd = open (fname, O_BINARY|O_RDONLY)) == -1) + char full_rep[1024]; + + if (zh->path_reg && !yaz_is_abspath (fname)) + { + strcpy (full_rep, zh->path_reg); + strcat (full_rep, "/"); + strcat (full_rep, fname); + } + else + strcpy (full_rep, fname); + + + if ((fc.fd = open (full_rep, O_BINARY|O_RDONLY)) == -1) { logf (LOG_WARN|LOG_ERRNO, "Retrieve fail; missing file: %s", - fname); + full_rep); rec_rm (&rec); return 14; } diff --git a/index/trav.c b/index/trav.c index 3cd2001..c4768fe 100644 --- a/index/trav.c +++ b/index/trav.c @@ -1,143 +1,8 @@ /* - * Copyright (C) 1994-1999, Index Data + * Copyright (C) 1994-2002, Index Data * All rights reserved. - * Sebastian Hammer, Adam Dickmeiss - * - * $Log: trav.c,v $ - * Revision 1.38 2002-04-04 14:14:13 adam - * Multiple registers (alpha early) - * - * Revision 1.37 2002/02/20 17:30:01 adam - * Work on new API. Locking system re-implemented - * - * Revision 1.36 1999/05/15 14:36:38 adam - * Updated dictionary. Implemented "compression" of dictionary. - * - * Revision 1.35 1999/02/02 14:51:09 adam - * Updated WIN32 code specific sections. Changed header. - * - * Revision 1.34 1998/06/08 14:43:14 adam - * Added suport for EXPLAIN Proxy servers - added settings databasePath - * and explainDatabase to facilitate this. Increased maximum number - * of databases and attributes in one register. - * - * Revision 1.33 1998/01/12 15:04:08 adam - * The test option (-s) only uses read-lock (and not write lock). - * - * Revision 1.32 1997/09/25 14:56:51 adam - * Windows NT interface code to the stat call. - * - * Revision 1.31 1997/09/17 12:19:17 adam - * Zebra version corresponds to YAZ version 1.4. - * Changed Zebra server so that it doesn't depend on global common_resource. - * - * Revision 1.30 1997/09/09 13:38:09 adam - * Partial port to WIN95/NT. - * - * Revision 1.29 1997/02/12 20:39:47 adam - * Implemented options -f that limits the log to the first - * records. - * Changed some log messages also. - * - * Revision 1.28 1996/11/01 08:58:44 adam - * Interface to isamc system now includes update and delete. - * - * Revision 1.27 1996/10/29 14:06:56 adam - * Include zebrautl.h instead of alexutil.h. - * - * Revision 1.26 1996/06/04 10:19:01 adam - * Minor changes - removed include of ctype.h. - * - * Revision 1.25 1996/05/01 13:46:37 adam - * First work on multiple records in one file. - * New option, -offset, to the "unread" command in the filter module. - * - * Revision 1.24 1996/04/26 10:00:23 adam - * Added option -V to zebraidx to display version information. - * Removed stupid warnings from file update. - * - * Revision 1.23 1996/04/12 07:02:25 adam - * File update of single files. - * - * Revision 1.22 1996/04/09 06:50:50 adam - * Bug fix: bad reference in function fileUpdateR. - * - * Revision 1.21 1996/03/22 15:34:18 quinn - * Fixed bad reference - * - * Revision 1.20 1996/03/21 14:50:10 adam - * File update uses modify-time instead of change-time. - * - * Revision 1.19 1996/03/20 16:16:55 quinn - * Added diagnostic output - * - * Revision 1.18 1996/03/19 12:43:27 adam - * Bug fix: File update traversal didn't handle trailing slashes correctly. - * Bug fix: Update of sub directory groups wasn't handled correctly. - * - * Revision 1.17 1996/02/12 18:45:17 adam - * Changed naming of some functions. - * - * Revision 1.16 1996/02/05 12:30:02 adam - * Logging reduced a bit. - * The remaining running time is estimated during register merge. - * - * Revision 1.15 1995/12/07 17:38:48 adam - * Work locking mechanisms for concurrent updates/commit. - * - * Revision 1.14 1995/12/06 12:41:26 adam - * New command 'stat' for the index program. - * Filenames can be read from stdin by specifying '-'. - * Bug fix/enhancement of the transformation from terms to regular - * expressons in the search engine. - * - * Revision 1.13 1995/11/28 09:09:46 adam - * Zebra config renamed. - * Use setting 'recordId' to identify record now. - * Bug fix in recindex.c: rec_release_blocks was invokeded even - * though the blocks were already released. - * File traversal properly deletes records when needed. - * - * Revision 1.12 1995/11/24 11:31:37 adam - * Commands add & del read filenames from stdin if source directory is - * empty. - * Match criteria supports 'constant' strings. - * - * Revision 1.11 1995/11/22 17:19:19 adam - * Record management uses the bfile system. - * - * Revision 1.10 1995/11/21 15:01:16 adam - * New general match criteria implemented. - * New feature: document groups. - * - * Revision 1.9 1995/11/21 09:20:32 adam - * Yet more work on record match. - * - * Revision 1.8 1995/11/20 16:59:46 adam - * New update method: the 'old' keys are saved for each records. - * - * Revision 1.7 1995/11/20 11:56:28 adam - * Work on new traversal. - * - * Revision 1.6 1995/11/17 15:54:42 adam - * Started work on virtual directory structure. - * - * Revision 1.5 1995/10/17 18:02:09 adam - * New feature: databases. Implemented as prefix to words in dictionary. - * - * Revision 1.4 1995/09/28 09:19:46 adam - * xfree/xmalloc used everywhere. - * Extract/retrieve method seems to work for text records. - * - * Revision 1.3 1995/09/06 16:11:18 adam - * Option: only one word key per file. - * - * Revision 1.2 1995/09/04 12:33:43 adam - * Various cleanup. YAZ util used instead. - * - * Revision 1.1 1995/09/01 14:06:36 adam - * Split of work into more files. * + * $Id: trav.c,v 1.39 2002-04-04 20:50:37 adam Exp $ */ @@ -173,7 +38,7 @@ static void repositoryExtractR (ZebraHandle zh, int deleteFlag, char *rep, int i; size_t rep_len = strlen (rep); - e = dir_open (rep); + e = dir_open (rep, zh->path_reg); if (!e) return; logf (LOG_LOG, "dir %s", rep); @@ -248,7 +113,7 @@ static void fileUpdateR (ZebraHandle zh, size_t src_len = strlen (src); sprintf (tmppath, "%s%s", base, src); - e_src = dir_open (tmppath); + e_src = dir_open (tmppath, zh->path_reg); logf (LOG_LOG, "dir %s", tmppath); #if 0 @@ -441,10 +306,20 @@ static void fileUpdate (ZebraHandle zh, int src_len; assert (path); + + if (zh->path_reg && !yaz_is_abspath(path)) + { + strcpy (src, zh->path_reg); + strcat (src, "/"); + } + else + *src = '\0'; + strcat (src, path); + stat (src, &sbuf); + strcpy (src, path); src_len = strlen (src); - stat (src, &sbuf); if (S_ISREG(sbuf.st_mode)) { struct dirs_entry *e_dst; @@ -492,9 +367,19 @@ static void repositoryExtract (ZebraHandle zh, char src[1024]; assert (path); - strcpy (src, path); + if (zh->path_reg && !yaz_is_abspath(path)) + { + strcpy (src, zh->path_reg); + strcat (src, "/"); + } + else + *src = '\0'; + strcat (src, path); stat (src, &sbuf); + + strcpy (src, path); + if (S_ISREG(sbuf.st_mode)) fileExtract (zh, NULL, src, rGroup, deleteFlag); else if (S_ISDIR(sbuf.st_mode)) @@ -510,7 +395,7 @@ static void repositoryExtractG (ZebraHandle zh, { char src[1024]; - while (scanf ("%s", src) == 1) + while (scanf ("%1020s", src) == 1) repositoryExtract (zh, deleteFlag, rGroup, src); } else diff --git a/index/zebraapi.c b/index/zebraapi.c index a84c4c1..13b913e 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2002, Index Data * All rights reserved. * - * $Id: zebraapi.c,v 1.51 2002-04-04 14:14:13 adam Exp $ + * $Id: zebraapi.c,v 1.52 2002-04-04 20:50:37 adam Exp $ */ #include @@ -35,7 +35,6 @@ static void zebra_chdir (ZebraService zh) #endif } - static void zebra_flush_reg (ZebraHandle zh) { zebraExplain_flush (zh->reg->zei, 1, zh); @@ -44,7 +43,6 @@ static void zebra_flush_reg (ZebraHandle zh) zebra_index_merge (zh); } - static struct zebra_register *zebra_register_open (ZebraService zs, const char *name, int rw, int useshadow, @@ -59,7 +57,8 @@ ZebraHandle zebra_open (ZebraService zs) { ZebraHandle zh; - assert (zs); + if (!zs) + return 0; zh = (ZebraHandle) xmalloc (sizeof(*zh)); yaz_log (LOG_LOG, "zebra_open zs=%p returns %p", zs, zh); @@ -96,36 +95,40 @@ ZebraHandle zebra_open (ZebraService zs) ZebraService zebra_start (const char *configName) { - ZebraService zh = xmalloc (sizeof(*zh)); + Res res; yaz_log (LOG_LOG, "zebra_start %s", configName); - zh->configName = xstrdup(configName); - zh->sessions = 0; - - if (!(zh->global_res = res_open (zh->configName, 0))) - { - logf (LOG_WARN, "Failed to read resources `%s'", zh->configName); - } + if (!(res = res_open (configName, 0))) + yaz_log (LOG_WARN, "Cannot read resources `%s'", configName); else { - logf (LOG_LOG, "Read resources `%s'", zh->configName); - } - zebra_chdir (zh); + ZebraService zh = xmalloc (sizeof(*zh)); - zebra_mutex_cond_init (&zh->session_lock); - if (!res_get (zh->global_res, "passwd")) - zh->passwd_db = NULL; - else - { - zh->passwd_db = passwd_db_open (); - if (!zh->passwd_db) - logf (LOG_WARN|LOG_ERRNO, "passwd_db_open failed"); - else - passwd_db_file (zh->passwd_db, res_get (zh->global_res, "passwd")); + yaz_log (LOG_LOG, "Read resources `%s'", configName); + + zh->global_res = res; + zh->configName = xstrdup(configName); + zh->sessions = 0; + + zebra_chdir (zh); + + zebra_mutex_cond_init (&zh->session_lock); + if (!res_get (zh->global_res, "passwd")) + zh->passwd_db = NULL; + else + { + zh->passwd_db = passwd_db_open (); + if (!zh->passwd_db) + logf (LOG_WARN|LOG_ERRNO, "passwd_db_open failed"); + else + passwd_db_file (zh->passwd_db, + res_get (zh->global_res, "passwd")); + } + zh->path_root = res_get (zh->global_res, "root"); + return zh; } - zh->path_root = res_get (zh->global_res, "root"); - return zh; + return 0; } static @@ -162,10 +165,11 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name, if (useshadow) bf_cache (reg->bfs, res_get (res, "shadow")); data1_set_tabpath (reg->dh, res_get(res, "profilePath")); + data1_set_tabroot (reg->dh, reg_path); reg->recTypes = recTypes_init (reg->dh); recTypes_default_handlers (reg->recTypes); - reg->zebra_maps = zebra_maps_open (res); + reg->zebra_maps = zebra_maps_open (res, reg_path); reg->rank_classes = NULL; reg->key_buf = 0; @@ -400,21 +404,22 @@ static Res zebra_open_res (ZebraHandle zh) { Res res = 0; char fname[512]; - if (*zh->reg_name == 0) - { - res = zh->service->global_res; - yaz_log (LOG_LOG, "local res = global res"); - } - else if (zh->path_reg) + if (zh->path_reg) { sprintf (fname, "%.200s/zebra.cfg", zh->path_reg); - yaz_log (LOG_LOG, "res_open(%s)", fname); res = res_open (fname, zh->service->global_res); if (!res) - return 0; + res = zh->service->global_res; + } + else if (*zh->reg_name == 0) + { + res = zh->service->global_res; } else + { + yaz_log (LOG_WARN, "no register root specified"); return 0; /* no path for register - fail! */ + } return res; } @@ -635,7 +640,6 @@ void zebra_search_rpn (ZebraHandle zh, ODR decode, ODR stream, zebra_end_read (zh); - logf(LOG_APP,"SEARCH:%d:",zh->hits); *hits = zh->hits; } diff --git a/index/zserver.c b/index/zserver.c index 9f0572c..4930473 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2000, Index Data * All rights reserved. * - * $Id: zserver.c,v 1.85 2002-04-04 14:14:13 adam Exp $ + * $Id: zserver.c,v 1.86 2002-04-04 20:50:37 adam Exp $ */ #include @@ -62,7 +62,7 @@ bend_initresult *bend_init (bend_initrequest *q) sob = statserv_getcontrol (); if (!(zh = zebra_open (sob->handle))) { - logf (LOG_FATAL, "Failed to open Zebra `%s'", sob->configname); + yaz_log (LOG_FATAL, "Failed to open config `%s'", sob->configname); r->errcode = 1; return r; } @@ -233,8 +233,12 @@ static int bend_scan (void *handle, bend_scan_rr *r) ZebraHandle zh = (ZebraHandle) handle; int is_partial, i; - zebra_select_databases (zh, r->num_bases, (const char **) r->basenames); - + if (zebra_select_databases (zh, r->num_bases, + (const char **) r->basenames)) + { + zebra_result (zh, &r->errcode, &r->errstring); + return 0; + } r->entries = (struct scan_entry *) odr_malloc (r->stream, sizeof(*r->entries) * r->num_entries); zebra_scan (zh, r->stream, r->term, diff --git a/recctrl/regxread.c b/recctrl/regxread.c index 6fdbd89..7b7b8be 100644 --- a/recctrl/regxread.c +++ b/recctrl/regxread.c @@ -3,7 +3,10 @@ * All rights reserved. * * $Log: regxread.c,v $ - * Revision 1.37 2001-05-29 08:51:59 adam + * Revision 1.38 2002-04-04 20:50:37 adam + * Multi register works with record paths and data1 profile path + * + * Revision 1.37 2001/05/29 08:51:59 adam * More fixes for character encodings. * * Revision 1.36 2001/05/22 21:02:26 adam @@ -753,13 +756,13 @@ int readFileSpec (struct lexSpec *spec) if (spec->tcl_interp) { sprintf (fname, "%s.tflt", spec->name); - spec_inf = yaz_path_fopen (data1_get_tabpath(spec->dh), fname, "r"); + spec_inf = data1_path_fopen (spec->dh, fname, "r"); } #endif if (!spec_inf) { sprintf (fname, "%s.flt", spec->name); - spec_inf = yaz_path_fopen (data1_get_tabpath(spec->dh), fname, "r"); + spec_inf = data1_path_fopen (spec->dh, fname, "r"); } if (!spec_inf) { diff --git a/test/gils/zebra.cfg b/test/gils/zebra.cfg index 09d35b3..351b926 100644 --- a/test/gils/zebra.cfg +++ b/test/gils/zebra.cfg @@ -1,5 +1,5 @@ # Simple Zebra configuration file -# $Id: zebra.cfg,v 1.11 2000-12-01 17:59:08 adam Exp $ +# $Id: zebra.cfg,v 1.12 2002-04-04 20:50:37 adam Exp $ # # Where the schema files, attribute files, etc are located. profilePath: .:../../tab:../../../yaz/tab @@ -12,5 +12,6 @@ attset: explain.att recordtype: grs.sgml storekeys: 1 -storedata: 1 +#storedata: 1 +recordId: file #recordId: (bib1,identifier-standard) diff --git a/util/charmap.c b/util/charmap.c index fdbf0bf..e6ea960 100644 --- a/util/charmap.c +++ b/util/charmap.c @@ -3,7 +3,7 @@ * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Id: charmap.c,v 1.19 2002-02-18 11:47:23 adam Exp $ + * $Id: charmap.c,v 1.20 2002-04-04 20:50:37 adam Exp $ * */ @@ -357,7 +357,8 @@ static int scan_string(char *s, return 0; } -chrmaptab chrmaptab_create(const char *tabpath, const char *name, int map_only) +chrmaptab chrmaptab_create(const char *tabpath, const char *name, int map_only, + const char *tabroot) { FILE *f; char line[512], *argv[50]; @@ -368,7 +369,7 @@ chrmaptab chrmaptab_create(const char *tabpath, const char *name, int map_only) NMEM nmem; logf (LOG_DEBUG, "maptab %s open", name); - if (!(f = yaz_path_fopen(tabpath, name, "r"))) + if (!(f = yaz_path_fopen_base(tabpath, name, "r", tabroot))) { logf(LOG_WARN|LOG_ERRNO, "%s", name); return 0; diff --git a/util/dirent.c b/util/dirent.c index 232021d..d0e7ef4 100644 --- a/util/dirent.c +++ b/util/dirent.c @@ -1,32 +1,24 @@ /* - * Copyright (C) 1997-1999, Index Data + * Copyright (C) 1997-2002, Index Data * All rights reserved. - * Sebastian Hammer, Adam Dickmeiss * - * $Log: dirent.c,v $ - * Revision 1.4 2002-04-04 14:14:14 adam - * Multiple registers (alpha early) - * - * Revision 1.3 1999/02/02 14:51:38 adam - * Updated WIN32 code specific sections. Changed header. - * - * Revision 1.2 1997/09/17 12:19:24 adam - * Zebra version corresponds to YAZ version 1.4. - * Changed Zebra server so that it doesn't depend on global common_resource. - * - * + * $Id: dirent.c,v 1.5 2002-04-04 20:50:37 adam Exp $ * * This utility implements a opendir/readdir/close on Windows. */ -#ifdef WIN32 +#include #include +#ifdef WIN32 #include +#endif #include #include #include +#ifdef WIN32 + struct DIR { HANDLE handle; WIN32_FIND_DATA find_data; @@ -69,15 +61,3 @@ void closedir(DIR *dd) #endif -int zebra_is_abspath (const char *p) -{ - if (*p == '/') - return 1; -#ifdef WIN32 - if (*p == '\\') - return 1; - if (*p && p[1] == ':' && isalpha(*p)) - return 1; -#endif - return 0; -} diff --git a/util/res.c b/util/res.c index a65e506..f9e6689 100644 --- a/util/res.c +++ b/util/res.c @@ -3,7 +3,7 @@ * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Id: res.c,v 1.29 2002-04-04 14:14:14 adam Exp $ + * $Id: res.c,v 1.30 2002-04-04 20:50:37 adam Exp $ */ #include #include @@ -165,7 +165,7 @@ Res res_open (const char *name, Res def_res) if (access (name, R_OK)) #endif { - logf (LOG_LOG|LOG_ERRNO, "Cannot access resource file `%s'", name); + logf (LOG_WARN|LOG_ERRNO, "Cannot access resource file `%s'", name); return 0; } r = (Res) xmalloc (sizeof(*r)); diff --git a/util/zebramap.c b/util/zebramap.c index 42c57e6..71c715a 100644 --- a/util/zebramap.c +++ b/util/zebramap.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebramap.c,v $ - * Revision 1.23 2001-11-15 08:41:24 adam + * Revision 1.24 2002-04-04 20:50:37 adam + * Multi register works with record paths and data1 profile path + * + * Revision 1.23 2001/11/15 08:41:24 adam * Fix for weight (bug introduced by previous commit). * * Revision 1.22 2001/11/14 22:06:27 adam @@ -121,6 +124,7 @@ struct zebra_map { struct zebra_maps { char *tabpath; + char *tabroot; NMEM nmem; struct zebra_map *map_list; char temp_map_str[2]; @@ -153,7 +157,7 @@ static void zebra_map_read (ZebraMaps zms, const char *name) int lineno = 0; struct zebra_map **zm = 0, *zp; - if (!(f = yaz_path_fopen(zms->tabpath, name, "r"))) + if (!(f = yaz_path_fopen_base(zms->tabpath, name, "r", zms->tabroot))) { logf(LOG_WARN|LOG_ERRNO, "%s", name); return ; @@ -276,7 +280,7 @@ static void zms_map_handle (void *p, const char *name, const char *value) zebra_map_read (zms, value); } -ZebraMaps zebra_maps_open (Res res) +ZebraMaps zebra_maps_open (Res res, const char *base) { ZebraMaps zms = (ZebraMaps) xmalloc (sizeof(*zms)); int i; @@ -284,6 +288,9 @@ ZebraMaps zebra_maps_open (Res res) zms->nmem = nmem_create (); zms->tabpath = nmem_strdup (zms->nmem, res_get_def (res, "profilePath", ".")); + zms->tabroot = 0; + if (base) + zms->tabroot = nmem_strdup (zms->nmem, base); zms->map_list = NULL; zms->temp_map_str[0] = '\0'; @@ -301,6 +308,7 @@ ZebraMaps zebra_maps_open (Res res) zms->wrbuf_1 = wrbuf_alloc(); zms->wrbuf_2 = wrbuf_alloc(); + return zms; } @@ -332,7 +340,8 @@ 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, - zm->maptab_name, 0))) + zm->maptab_name, 0, + zms->tabroot))) logf(LOG_WARN, "Failed to read character table %s", zm->maptab_name); else -- 1.7.10.4