From: Adam Dickmeiss Date: Mon, 29 Oct 2007 09:25:40 +0000 (+0000) Subject: WS changes for function calls. X-Git-Tag: ZEBRA.2.0.20~96 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=d82c0efad7971d102220a8824e1ea674db5b7fe2;p=idzebra-moved-to-github.git WS changes for function calls. --- diff --git a/examples/gils/zebra.cfg b/examples/gils/zebra.cfg index 4cb52d4..2e0034f 100644 --- a/examples/gils/zebra.cfg +++ b/examples/gils/zebra.cfg @@ -1,5 +1,5 @@ # Simple Zebra configuration file -# $Id: zebra.cfg,v 1.15 2006-12-18 23:40:06 adam Exp $ +# $Id: zebra.cfg,v 1.16 2007-10-29 09:25:40 adam Exp $ # # Where the schema files, attribute files, etc are located. profilePath: .:../../tab @@ -13,10 +13,11 @@ recordtype: grs.sgml isam: c # Flags for the non-authenticated user. w=write (allows ES Updates) -perm.anonymous: rw +perm.anonymous: r +passwd: mypasswd #rank: zvrank -recordId: (bib-1,title) +##recordId: (bib-1,title) storedata: 1 diff --git a/index/check_res.c b/index/check_res.c index b3b2b26..d079022 100644 --- a/index/check_res.c +++ b/index/check_res.c @@ -1,4 +1,4 @@ -/* $Id: check_res.c,v 1.6 2007-05-16 08:46:19 adam Exp $ +/* $Id: check_res.c,v 1.7 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -63,6 +63,7 @@ int zebra_check_res(Res res) res_add(v, "threads", ""); res_add(v, "trunclimit", ""); res_add(v, "truncmax", ""); + res_add(v, "indextypes", ""); res_add(v, "database", "p"); res_add(v, "explainDatabase", "p"); res_add(v, "fileVerboseLimit", "p"); diff --git a/index/dir.c b/index/dir.c index bddc4d5..3dfe2bd 100644 --- a/index/dir.c +++ b/index/dir.c @@ -1,4 +1,4 @@ -/* $Id: dir.c,v 1.35 2007-01-15 15:10:16 adam Exp $ +/* $Id: dir.c,v 1.36 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "index.h" -int zebra_file_stat (const char *file_name, struct stat *buf, +int zebra_file_stat(const char *file_name, struct stat *buf, int follow_links) { #ifndef WIN32 @@ -45,7 +45,7 @@ int zebra_file_stat (const char *file_name, struct stat *buf, return stat(file_name, buf); } -struct dir_entry *dir_open (const char *rep, const char *base, +struct dir_entry *dir_open(const char *rep, const char *base, int follow_links) { DIR *dir; @@ -59,99 +59,99 @@ struct dir_entry *dir_open (const char *rep, const char *base, if (base && !yaz_is_abspath(rep)) { - strcpy (full_rep, base); - strcat (full_rep, "/"); + strcpy(full_rep, base); + strcat(full_rep, "/"); } else *full_rep = '\0'; - strcat (full_rep, rep); + strcat(full_rep, rep); - yaz_log (YLOG_DEBUG, "dir_open %s", full_rep); + yaz_log(YLOG_DEBUG, "dir_open %s", full_rep); if (!(dir = opendir(full_rep))) { - yaz_log (YLOG_WARN|YLOG_ERRNO, "opendir %s", rep); + yaz_log(YLOG_WARN|YLOG_ERRNO, "opendir %s", rep); return NULL; } - entry = (struct dir_entry *) xmalloc (sizeof(*entry) * entry_max); - strcpy (path, rep); + entry = (struct dir_entry *) xmalloc(sizeof(*entry) * entry_max); + strcpy(path, rep); pathpos = strlen(path); if (!pathpos || path[pathpos-1] != '/') path[pathpos++] = '/'; - while ( (dent = readdir (dir)) ) + while ( (dent = readdir(dir)) ) { struct stat finfo; - if (strcmp (dent->d_name, ".") == 0 || - strcmp (dent->d_name, "..") == 0) + if (strcmp(dent->d_name, ".") == 0 || + strcmp(dent->d_name, "..") == 0) continue; if (idx == entry_max-1) { struct dir_entry *entry_n; entry_n = (struct dir_entry *) - xmalloc (sizeof(*entry) * (entry_max += 1000)); - memcpy (entry_n, entry, idx * sizeof(*entry)); - xfree (entry); + xmalloc(sizeof(*entry) * (entry_max += 1000)); + memcpy(entry_n, entry, idx * sizeof(*entry)); + xfree(entry); entry = entry_n; } - strcpy (path + pathpos, dent->d_name); + strcpy(path + pathpos, dent->d_name); - if (base && !yaz_is_abspath (path)) + if (base && !yaz_is_abspath(path)) { - strcpy (full_rep, base); - strcat (full_rep, "/"); - strcat (full_rep, path); - zebra_file_stat (full_rep, &finfo, follow_links); + strcpy(full_rep, base); + strcat(full_rep, "/"); + strcat(full_rep, path); + zebra_file_stat(full_rep, &finfo, follow_links); } else - zebra_file_stat (path, &finfo, follow_links); + zebra_file_stat(path, &finfo, follow_links); switch (finfo.st_mode & S_IFMT) { case S_IFREG: entry[idx].kind = dirs_file; entry[idx].mtime = finfo.st_mtime; - entry[idx].name = (char *) xmalloc (strlen(dent->d_name)+1); - strcpy (entry[idx].name, dent->d_name); + entry[idx].name = (char *) xmalloc(strlen(dent->d_name)+1); + strcpy(entry[idx].name, dent->d_name); idx++; break; case S_IFDIR: entry[idx].kind = dirs_dir; entry[idx].mtime = finfo.st_mtime; - entry[idx].name = (char *) xmalloc (strlen(dent->d_name)+2); - strcpy (entry[idx].name, dent->d_name); - strcat (entry[idx].name, "/"); + entry[idx].name = (char *) xmalloc(strlen(dent->d_name)+2); + strcpy(entry[idx].name, dent->d_name); + strcat(entry[idx].name, "/"); idx++; break; } } entry[idx].name = NULL; - closedir (dir); - yaz_log (YLOG_DEBUG, "dir_close"); + closedir(dir); + yaz_log(YLOG_DEBUG, "dir_close"); return entry; } -static int dir_cmp (const void *p1, const void *p2) +static int dir_cmp(const void *p1, const void *p2) { - return strcmp (((struct dir_entry *) p1)->name, - ((struct dir_entry *) p2)->name); + return strcmp(((struct dir_entry *) p1)->name, + ((struct dir_entry *) p2)->name); } -void dir_sort (struct dir_entry *e) +void dir_sort(struct dir_entry *e) { size_t nmemb = 0; while (e[nmemb].name) nmemb++; - qsort (e, nmemb, sizeof(*e), dir_cmp); + qsort(e, nmemb, sizeof(*e), dir_cmp); } -void dir_free (struct dir_entry **e_p) +void dir_free(struct dir_entry **e_p) { size_t i = 0; struct dir_entry *e = *e_p; - assert (e); + assert(e); while (e[i].name) - xfree (e[i++].name); - xfree (e); + xfree(e[i++].name); + xfree(e); *e_p = NULL; } /* diff --git a/index/dirs.c b/index/dirs.c index 54424d8..6c2f73b 100644 --- a/index/dirs.c +++ b/index/dirs.c @@ -1,4 +1,4 @@ -/* $Id: dirs.c,v 1.27 2007-01-15 15:10:16 adam Exp $ +/* $Id: dirs.c,v 1.28 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -45,98 +45,98 @@ struct dirs_info { int nextpath_deleted; }; -static int dirs_client_proc (char *name, const char *info, int pos, +static int dirs_client_proc(char *name, const char *info, int pos, void *client) { struct dirs_info *ci = (struct dirs_info *) client; struct dirs_entry *entry; - if (memcmp (name, ci->prefix, ci->prelen)) + if (memcmp(name, ci->prefix, ci->prelen)) return 1; if (ci->no_cur < 0) { ci->no_cur = 0; return 0; } - assert (ci->no_cur < ci->no_max); + assert(ci->no_cur < ci->no_max); entry = ci->entries + ci->no_cur; if (info[0] == sizeof(entry->sysno)+sizeof(entry->mtime)) { - strcpy (entry->path, name + ci->prelen); + strcpy(entry->path, name + ci->prelen); entry->kind = dirs_file; - memcpy (&entry->sysno, info+1, sizeof(entry->sysno)); - memcpy (&entry->mtime, info+1+sizeof(entry->sysno), + memcpy(&entry->sysno, info+1, sizeof(entry->sysno)); + memcpy(&entry->mtime, info+1+sizeof(entry->sysno), sizeof(entry->mtime)); ci->no_cur++; } else if (info[0] == sizeof(entry->mtime)) { - strcpy (entry->path, name + ci->prelen); + strcpy(entry->path, name + ci->prelen); entry->kind = dirs_dir; - memcpy (&entry->mtime, info+1, sizeof(entry->mtime)); + memcpy(&entry->mtime, info+1, sizeof(entry->mtime)); ci->no_cur++; } return 0; } -struct dirs_info *dirs_open (Dict dict, const char *rep, int rw) +struct dirs_info *dirs_open(Dict dict, const char *rep, int rw) { struct dirs_info *p; int before = 0, after; - yaz_log (YLOG_DEBUG, "dirs_open %s", rep); - p = (struct dirs_info *) xmalloc (sizeof (*p)); + yaz_log(YLOG_DEBUG, "dirs_open %s", rep); + p = (struct dirs_info *) xmalloc(sizeof(*p)); p->dict = dict; p->rw = rw; - strcpy (p->prefix, rep); + strcpy(p->prefix, rep); p->prelen = strlen(p->prefix); - strcpy (p->nextpath, rep); + strcpy(p->nextpath, rep); p->nextpath_deleted = 0; p->no_read = p->no_cur = 0; after = p->no_max = 100; p->entries = (struct dirs_entry *) - xmalloc (sizeof(*p->entries) * (p->no_max)); - yaz_log (YLOG_DEBUG, "dirs_open first scan"); - dict_scan (p->dict, p->nextpath, &before, &after, p, dirs_client_proc); + xmalloc(sizeof(*p->entries) * (p->no_max)); + yaz_log(YLOG_DEBUG, "dirs_open first scan"); + dict_scan(p->dict, p->nextpath, &before, &after, p, dirs_client_proc); return p; } -struct dirs_info *dirs_fopen (Dict dict, const char *path, int rw) +struct dirs_info *dirs_fopen(Dict dict, const char *path, int rw) { struct dirs_info *p; struct dirs_entry *entry; char *info; - p = (struct dirs_info *) xmalloc (sizeof(*p)); + p = (struct dirs_info *) xmalloc(sizeof(*p)); p->dict = dict; p->rw = rw; *p->prefix = '\0'; - p->entries = (struct dirs_entry *) xmalloc (sizeof(*p->entries)); + p->entries = (struct dirs_entry *) xmalloc(sizeof(*p->entries)); p->no_read = 0; p->no_cur = 0; p->no_max = 2; entry = p->entries; - info = dict_lookup (dict, path); + info = dict_lookup(dict, path); if (info && info[0] == sizeof(entry->sysno)+sizeof(entry->mtime)) { - strcpy (entry->path, path); + strcpy(entry->path, path); entry->kind = dirs_file; - memcpy (&entry->sysno, info+1, sizeof(entry->sysno)); - memcpy (&entry->mtime, info+1+sizeof(entry->sysno), + memcpy(&entry->sysno, info+1, sizeof(entry->sysno)); + memcpy(&entry->mtime, info+1+sizeof(entry->sysno), sizeof(entry->mtime)); p->no_cur++; } return p; } -struct dirs_entry *dirs_read (struct dirs_info *p) +struct dirs_entry *dirs_read(struct dirs_info *p) { int before = 0, after = p->no_max+1; if (p->no_read < p->no_cur) { - yaz_log (YLOG_DEBUG, "dirs_read %d. returns %s", p->no_read, + yaz_log(YLOG_DEBUG, "dirs_read %d. returns %s", p->no_read, (p->entries + p->no_read)->path); return p->last_entry = p->entries + (p->no_read++); } @@ -154,71 +154,71 @@ struct dirs_entry *dirs_read (struct dirs_info *p) } p->no_read = 1; p->nextpath_deleted = 0; - yaz_log (YLOG_DEBUG, "dirs_read rescan %s", p->nextpath); - dict_scan (p->dict, p->nextpath, &before, &after, p, dirs_client_proc); + yaz_log(YLOG_DEBUG, "dirs_read rescan %s", p->nextpath); + dict_scan(p->dict, p->nextpath, &before, &after, p, dirs_client_proc); if (p->no_read <= p->no_cur) return p->last_entry = p->entries; return p->last_entry = NULL; } -struct dirs_entry *dirs_last (struct dirs_info *p) +struct dirs_entry *dirs_last(struct dirs_info *p) { return p->last_entry; } -void dirs_mkdir (struct dirs_info *p, const char *src, time_t mtime) +void dirs_mkdir(struct dirs_info *p, const char *src, time_t mtime) { char path[DIRS_MAX_PATH]; - sprintf (path, "%s%s", p->prefix, src); - yaz_log (YLOG_DEBUG, "dirs_mkdir %s", path); + sprintf(path, "%s%s", p->prefix, src); + yaz_log(YLOG_DEBUG, "dirs_mkdir %s", path); if (p->rw) - dict_insert (p->dict, path, sizeof(mtime), &mtime); + dict_insert(p->dict, path, sizeof(mtime), &mtime); } -void dirs_rmdir (struct dirs_info *p, const char *src) +void dirs_rmdir(struct dirs_info *p, const char *src) { char path[DIRS_MAX_PATH]; - sprintf (path, "%s%s", p->prefix, src); - yaz_log (YLOG_DEBUG, "dirs_rmdir %s", path); + sprintf(path, "%s%s", p->prefix, src); + yaz_log(YLOG_DEBUG, "dirs_rmdir %s", path); if (p->rw) - dict_delete (p->dict, path); + dict_delete(p->dict, path); } -void dirs_add (struct dirs_info *p, const char *src, zint sysno, time_t mtime) +void dirs_add(struct dirs_info *p, const char *src, zint sysno, time_t mtime) { char path[DIRS_MAX_PATH]; char info[16]; - sprintf (path, "%s%s", p->prefix, src); - yaz_log (YLOG_DEBUG, "dirs_add %s", path); - memcpy (info, &sysno, sizeof(sysno)); - memcpy (info+sizeof(sysno), &mtime, sizeof(mtime)); + sprintf(path, "%s%s", p->prefix, src); + yaz_log(YLOG_DEBUG, "dirs_add %s", path); + memcpy(info, &sysno, sizeof(sysno)); + memcpy(info+sizeof(sysno), &mtime, sizeof(mtime)); if (p->rw) - dict_insert (p->dict, path, sizeof(sysno)+sizeof(mtime), info); + dict_insert(p->dict, path, sizeof(sysno)+sizeof(mtime), info); } -void dirs_del (struct dirs_info *p, const char *src) +void dirs_del(struct dirs_info *p, const char *src) { char path[DIRS_MAX_PATH]; - sprintf (path, "%s%s", p->prefix, src); - yaz_log (YLOG_DEBUG, "dirs_del %s", path); + sprintf(path, "%s%s", p->prefix, src); + yaz_log(YLOG_DEBUG, "dirs_del %s", path); if (p->rw) { if (!strcmp(path, p->nextpath)) p->nextpath_deleted = 1; - dict_delete (p->dict, path); + dict_delete(p->dict, path); } } -void dirs_free (struct dirs_info **pp) +void dirs_free(struct dirs_info **pp) { struct dirs_info *p = *pp; - xfree (p->entries); - xfree (p); + xfree(p->entries); + xfree(p); *pp = NULL; } diff --git a/index/extract.c b/index/extract.c index cec5575..24e5b9e 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.262 2007-08-31 07:02:24 adam Exp $ +/* $Id: extract.c,v 1.263 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -66,8 +66,8 @@ static void extract_flush_record_keys(ZebraHandle zh, zint sysno, zint staticrank); static void extract_flush_sort_keys(ZebraHandle zh, zint sysno, int cmd, zebra_rec_keys_t skp); -static void extract_schema_add (struct recExtractCtrl *p, Odr_oid *oid); -static void extract_token_add (RecWord *p); +static void extract_schema_add(struct recExtractCtrl *p, Odr_oid *oid); +static void extract_token_add(RecWord *p); static void check_log_limit(ZebraHandle zh) { @@ -78,7 +78,7 @@ static void check_log_limit(ZebraHandle zh) } } -static void logRecord (ZebraHandle zh) +static void logRecord(ZebraHandle zh) { check_log_limit(zh); ++zh->records_processed; @@ -105,7 +105,7 @@ static void init_extractCtrl(ZebraHandle zh, struct recExtractCtrl *ctrl) } -static void extract_add_index_string (RecWord *p, +static void extract_add_index_string(RecWord *p, zinfo_index_category_t cat, const char *str, int length); @@ -141,7 +141,7 @@ static void snippet_add_complete_field(RecWord *p, int ord) const char *last = 0; if (remain > 0) - map = zebra_maps_input (zh->reg->zebra_maps, p->index_type, &b, remain, 1); + map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 1); while (remain > 0 && i < IT_MAX_WORD) { @@ -185,7 +185,7 @@ static void snippet_add_complete_field(RecWord *p, int ord) remain = p->term_len - (b - p->term_buf); if (remain > 0) { - map = zebra_maps_input (zh->reg->zebra_maps, p->index_type, &b, + map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 0); } else @@ -285,8 +285,8 @@ static void snippet_token_add(RecWord *p) int ch = zebraExplain_lookup_attr_str( zei, zinfo_index_category_index, p->index_type, p->index_name); - if (zebra_maps_is_complete (h->zh->reg->zebra_maps, p->index_type)) - snippet_add_complete_field (p, ch); + if(zebra_maps_is_complete (h->zh->reg->zebra_maps, p->index_type)) + snippet_add_complete_field(p, ch); else snippet_add_incomplete_field(p, ch); } @@ -426,11 +426,11 @@ static char *get_match_from_spec(ZebraHandle zh, attname_str[i] = '\0'; } - searchRecordKey (zh, reckeys, attname_str, ws, 32); + searchRecordKey(zh, reckeys, attname_str, ws, 32); if (*s != ')') { - yaz_log (YLOG_WARN, "Missing ) in match criteria %s in group %s", + yaz_log(YLOG_WARN, "Missing ) in match criteria %s in group %s", spec, zh->m_group ? zh->m_group : "none"); return NULL; } @@ -444,12 +444,12 @@ static char *get_match_from_spec(ZebraHandle zh, *dst++ = ' '; first = 0; } - strcpy (dst, ws[i]); + strcpy(dst, ws[i]); dst += strlen(ws[i]); } if (first) { - yaz_log (YLOG_WARN, "Record didn't contain match" + yaz_log(YLOG_WARN, "Record didn't contain match" " fields in (%s,%s)", attset_str, attname_str); return NULL; } @@ -466,25 +466,25 @@ static char *get_match_from_spec(ZebraHandle zh, spec_len = s1 - s; if (spec_len > sizeof(special)-1) spec_len = sizeof(special)-1; - memcpy (special, s, spec_len); + memcpy(special, s, spec_len); special[spec_len] = '\0'; s = s1; - if (!strcmp (special, "group")) + if (!strcmp(special, "group")) spec_src = zh->m_group; - else if (!strcmp (special, "database")) + else if (!strcmp(special, "database")) spec_src = zh->basenames[0]; - else if (!strcmp (special, "filename")) { + else if (!strcmp(special, "filename")) { spec_src = fname; } - else if (!strcmp (special, "type")) + else if (!strcmp(special, "type")) spec_src = zh->m_record_type; else spec_src = NULL; if (spec_src) { - strcpy (dst, spec_src); - dst += strlen (spec_src); + strcpy(dst, spec_src); + dst += strlen(spec_src); } } else if (*s == '\"' || *s == '\'') @@ -501,12 +501,12 @@ static char *get_match_from_spec(ZebraHandle zh, if (*s) s++; tmpString[i] = '\0'; - strcpy (dst, tmpString); - dst += strlen (tmpString); + strcpy(dst, tmpString); + dst += strlen(tmpString); } else { - yaz_log (YLOG_WARN, "Syntax error in match criteria %s in group %s", + yaz_log(YLOG_WARN, "Syntax error in match criteria %s in group %s", spec, zh->m_group ? zh->m_group : "none"); return NULL; } @@ -514,7 +514,7 @@ static char *get_match_from_spec(ZebraHandle zh, } if (dst == dstBuf) { - yaz_log (YLOG_WARN, "No match criteria for record %s in group %s", + yaz_log(YLOG_WARN, "No match criteria for record %s in group %s", fname, zh->m_group ? zh->m_group : "none"); return NULL; } @@ -535,7 +535,7 @@ static void all_matches_add(struct recExtractCtrl *ctrl) word.index_name = "_ALLRECORDS"; word.index_type = 'w'; word.seqno = 1; - extract_add_index_string (&word, zinfo_index_category_alwaysmatches, + extract_add_index_string(&word, zinfo_index_category_alwaysmatches, "", 0); } @@ -570,7 +570,7 @@ ZEBRA_RES zebra_extract_file(ZebraHandle zh, zint *sysno, const char *fname, if (!zh->m_group || !*zh->m_group) *gprefix = '\0'; else - sprintf (gprefix, "%s.", zh->m_group); + sprintf(gprefix, "%s.", zh->m_group); yaz_log(log_level_extract, "zebra_extract_file %s", fname); @@ -581,34 +581,34 @@ ZEBRA_RES zebra_extract_file(ZebraHandle zh, zint *sysno, const char *fname, break; else if (fname[i] == '.') { - strcpy (ext, fname+i+1); + strcpy(ext, fname+i+1); break; } /* determine file type - depending on extension */ original_record_type = zh->m_record_type; if (!zh->m_record_type) { - sprintf (ext_res, "%srecordType.%s", gprefix, ext); - zh->m_record_type = res_get (zh->res, ext_res); + sprintf(ext_res, "%srecordType.%s", gprefix, ext); + zh->m_record_type = res_get(zh->res, ext_res); } if (!zh->m_record_type) { check_log_limit(zh); if (zh->records_processed + zh->records_skipped < zh->m_file_verbose_limit) - yaz_log (YLOG_LOG, "? %s", fname); + yaz_log(YLOG_LOG, "? %s", fname); zh->records_skipped++; return 0; } /* determine match criteria */ if (!zh->m_record_id) { - sprintf (ext_res, "%srecordId.%s", gprefix, ext); - zh->m_record_id = res_get (zh->res, ext_res); + sprintf(ext_res, "%srecordId.%s", gprefix, ext); + zh->m_record_id = res_get(zh->res, ext_res); } if (!(recType = - recType_byName (zh->reg->recTypes, zh->res, zh->m_record_type, + recType_byName(zh->reg->recTypes, zh->res, zh->m_record_type, &recTypeClientData))) { yaz_log(YLOG_WARN, "No such record type: %s", zh->m_record_type); @@ -631,18 +631,18 @@ ZEBRA_RES zebra_extract_file(ZebraHandle zh, zint *sysno, const char *fname, { char full_rep[1024]; - if (zh->path_reg && !yaz_is_abspath (fname)) + if (zh->path_reg && !yaz_is_abspath(fname)) { - strcpy (full_rep, zh->path_reg); - strcat (full_rep, "/"); - strcat (full_rep, fname); + strcpy(full_rep, zh->path_reg); + strcat(full_rep, "/"); + strcat(full_rep, fname); } else - strcpy (full_rep, fname); + strcpy(full_rep, fname); - if ((fd = open (full_rep, O_BINARY|O_RDONLY)) == -1) + if ((fd = open(full_rep, O_BINARY|O_RDONLY)) == -1) { - yaz_log (YLOG_WARN|YLOG_ERRNO, "open %s", full_rep); + yaz_log(YLOG_WARN|YLOG_ERRNO, "open %s", full_rep); zh->m_record_type = original_record_type; return ZEBRA_FAIL; } @@ -689,26 +689,26 @@ ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh, { yaz_log(log_level_extract, "Record type explicitly specified: %s", recordType); - recType = recType_byName (zh->reg->recTypes, zh->res, recordType, + recType = recType_byName(zh->reg->recTypes, zh->res, recordType, &clientData); } else { if (!(zh->m_record_type)) { - yaz_log (YLOG_WARN, "No such record type defined"); + yaz_log(YLOG_WARN, "No such record type defined"); return ZEBRA_FAIL; } yaz_log(log_level_extract, "Get record type from rgroup: %s", zh->m_record_type); - recType = recType_byName (zh->reg->recTypes, zh->res, + recType = recType_byName(zh->reg->recTypes, zh->res, zh->m_record_type, &clientData); recordType = zh->m_record_type; } if (!recType) { - yaz_log (YLOG_WARN, "No such record type: %s", recordType); + yaz_log(YLOG_WARN, "No such record type: %s", recordType); return ZEBRA_FAIL; } @@ -809,9 +809,9 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, zebra_rec_keys_reset(zh->reg->keys); zebra_rec_keys_reset(zh->reg->sortKeys); - if (zebraExplain_curDatabase (zh->reg->zei, zh->basenames[0])) + if (zebraExplain_curDatabase(zh->reg->zei, zh->basenames[0])) { - if (zebraExplain_newDatabase (zh->reg->zei, zh->basenames[0], + if (zebraExplain_newDatabase(zh->reg->zei, zh->basenames[0], zh->m_explain_database)) return ZEBRA_FAIL; } @@ -853,15 +853,15 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, return ZEBRA_FAIL; case RECCTRL_EXTRACT_ERROR_GENERIC: /* error occured during extraction ... */ - yaz_log (YLOG_WARN, "extract error: generic"); + yaz_log(YLOG_WARN, "extract error: generic"); return ZEBRA_FAIL; case RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER: /* error occured during extraction ... */ - yaz_log (YLOG_WARN, "extract error: no such filter"); + yaz_log(YLOG_WARN, "extract error: no such filter"); return ZEBRA_FAIL; case RECCTRL_EXTRACT_SKIP: if (show_progress) - yaz_log (YLOG_LOG, "skip %s %s " ZINT_FORMAT, + yaz_log(YLOG_LOG, "skip %s %s " ZINT_FORMAT, recordType, pr_fname, (zint) start_offset); *more = 1; @@ -873,7 +873,7 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, case RECCTRL_EXTRACT_OK: break; default: - yaz_log (YLOG_WARN, "extract error: unknown error: %d", r); + yaz_log(YLOG_WARN, "extract error: unknown error: %d", r); return ZEBRA_FAIL; } end_offset = stream->endf(stream, 0); @@ -901,7 +901,7 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, zh->m_record_id); if (!matchStr) { - yaz_log (YLOG_LOG, "error %s %s " ZINT_FORMAT, recordType, + yaz_log(YLOG_LOG, "error %s %s " ZINT_FORMAT, recordType, pr_fname, (zint) start_offset); return ZEBRA_FAIL; } @@ -923,7 +923,7 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, if (rinfo) { assert(*rinfo == sizeof(*sysno)); - memcpy (sysno, rinfo+1, sizeof(*sysno)); + memcpy(sysno, rinfo+1, sizeof(*sysno)); } } } @@ -940,26 +940,26 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, /* new record */ if (action == action_delete) { - yaz_log (YLOG_LOG, "delete %s %s " ZINT_FORMAT, recordType, + yaz_log(YLOG_LOG, "delete %s %s " ZINT_FORMAT, recordType, pr_fname, (zint) start_offset); - yaz_log (YLOG_WARN, "cannot delete record above (seems new)"); + yaz_log(YLOG_WARN, "cannot delete record above (seems new)"); return ZEBRA_FAIL; } else if (action == action_replace) { - yaz_log (YLOG_LOG, "update %s %s " ZINT_FORMAT, recordType, + yaz_log(YLOG_LOG, "update %s %s " ZINT_FORMAT, recordType, pr_fname, (zint) start_offset); - yaz_log (YLOG_WARN, "cannot update record above (seems new)"); + yaz_log(YLOG_WARN, "cannot update record above (seems new)"); return ZEBRA_FAIL; } if (show_progress) - yaz_log (YLOG_LOG, "add %s %s " ZINT_FORMAT, recordType, pr_fname, + yaz_log(YLOG_LOG, "add %s %s " ZINT_FORMAT, recordType, pr_fname, (zint) start_offset); - rec = rec_new (zh->reg->records); + rec = rec_new(zh->reg->records); *sysno = rec->sysno; - recordAttr = rec_init_attr (zh->reg->zei, rec); + recordAttr = rec_init_attr(zh->reg->zei, rec); if (extractCtrl.staticrank < 0) { yaz_log(YLOG_WARN, "Negative staticrank for record. Set to 0"); @@ -992,19 +992,19 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, zebra_rec_keys_t sortKeys = zebra_rec_keys_open(); if (action == action_insert) { - yaz_log (YLOG_LOG, "skipped %s %s " ZINT_FORMAT, + yaz_log(YLOG_LOG, "skipped %s %s " ZINT_FORMAT, recordType, pr_fname, (zint) start_offset); logRecord(zh); return ZEBRA_FAIL; } - rec = rec_get (zh->reg->records, *sysno); - assert (rec); + rec = rec_get(zh->reg->records, *sysno); + assert(rec); - recordAttr = rec_init_attr (zh->reg->zei, rec); + recordAttr = rec_init_attr(zh->reg->zei, rec); /* decrease total size */ - zebraExplain_recordBytesIncrement (zh->reg->zei, + zebraExplain_recordBytesIncrement(zh->reg->zei, - recordAttr->recordSize); zebra_rec_keys_set_buf(delkeys, @@ -1046,7 +1046,7 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, int db_ord = zebraExplain_get_database_ord(zh->reg->zei); dict_delete_ord(zh->reg->matchDict, db_ord, matchStr); } - rec_del (zh->reg->records, &rec); + rec_del(zh->reg->records, &rec); } zebra_rec_keys_close(delkeys); zebra_rec_keys_close(sortKeys); @@ -1076,17 +1076,17 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, zebra_rec_keys_close(sortKeys); } /* update file type */ - xfree (rec->info[recInfo_fileType]); + xfree(rec->info[recInfo_fileType]); rec->info[recInfo_fileType] = - rec_strdup (recordType, &rec->size[recInfo_fileType]); + rec_strdup(recordType, &rec->size[recInfo_fileType]); /* update filename */ - xfree (rec->info[recInfo_filename]); + xfree(rec->info[recInfo_filename]); rec->info[recInfo_filename] = - rec_strdup (fname, &rec->size[recInfo_filename]); + rec_strdup(fname, &rec->size[recInfo_filename]); /* update delete keys */ - xfree (rec->info[recInfo_delKeys]); + xfree(rec->info[recInfo_delKeys]); if (!zebra_rec_keys_empty(zh->reg->keys) && zh->m_store_keys == 1) { zebra_rec_keys_get_buf(zh->reg->keys, @@ -1099,7 +1099,7 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, rec->size[recInfo_delKeys] = 0; } /* update sort keys */ - xfree (rec->info[recInfo_sortKeys]); + xfree(rec->info[recInfo_sortKeys]); zebra_rec_keys_get_buf(zh->reg->sortKeys, &rec->info[recInfo_sortKeys], @@ -1114,10 +1114,10 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, /* set run-number for this record */ recordAttr->runNumber = - zebraExplain_runNumberIncrement (zh->reg->zei, 0); + zebraExplain_runNumberIncrement(zh->reg->zei, 0); /* update store data */ - xfree (rec->info[recInfo_storeData]); + xfree(rec->info[recInfo_storeData]); /* update store data */ if (zh->store_data_buf) @@ -1133,7 +1133,7 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, rec->size[recInfo_storeData] = recordAttr->recordSize; rec->info[recInfo_storeData] = (char *) - xmalloc (recordAttr->recordSize); + xmalloc(recordAttr->recordSize); stream->seekf(stream, start_offset); stream->readf(stream, rec->info[recInfo_storeData], recordAttr->recordSize); @@ -1145,15 +1145,15 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, rec->size[recInfo_storeData] = 0; } /* update database name */ - xfree (rec->info[recInfo_databaseName]); + xfree(rec->info[recInfo_databaseName]); rec->info[recInfo_databaseName] = - rec_strdup (zh->basenames[0], &rec->size[recInfo_databaseName]); + rec_strdup(zh->basenames[0], &rec->size[recInfo_databaseName]); /* update offset */ recordAttr->recordOffset = start_offset; /* commit this record */ - rec_put (zh->reg->records, &rec); + rec_put(zh->reg->records, &rec); logRecord(zh); return ZEBRA_OK; } @@ -1163,13 +1163,13 @@ ZEBRA_RES zebra_extract_explain(void *handle, Record rec, data1_node *n) ZebraHandle zh = (ZebraHandle) handle; struct recExtractCtrl extractCtrl; - if (zebraExplain_curDatabase (zh->reg->zei, + if (zebraExplain_curDatabase(zh->reg->zei, rec->info[recInfo_databaseName])) { abort(); - if (zebraExplain_newDatabase (zh->reg->zei, + if (zebraExplain_newDatabase(zh->reg->zei, rec->info[recInfo_databaseName], 0)) - abort (); + abort(); } zebra_rec_keys_reset(zh->reg->keys); @@ -1230,12 +1230,12 @@ ZEBRA_RES zebra_extract_explain(void *handle, Record rec, data1_node *n) } extract_flush_sort_keys(zh, rec->sysno, 1, zh->reg->sortKeys); - xfree (rec->info[recInfo_delKeys]); + xfree(rec->info[recInfo_delKeys]); zebra_rec_keys_get_buf(zh->reg->keys, &rec->info[recInfo_delKeys], &rec->size[recInfo_delKeys]); - xfree (rec->info[recInfo_sortKeys]); + xfree(rec->info[recInfo_sortKeys]); zebra_rec_keys_get_buf(zh->reg->sortKeys, &rec->info[recInfo_sortKeys], &rec->size[recInfo_sortKeys]); @@ -1369,8 +1369,8 @@ void extract_flush_record_keys2(ZebraHandle zh, zint sysno, if (!zh->reg->key_block) { int mem = 1024*1024 * atoi( res_get_def( zh->res, "memmax", "8")); - const char *key_tmp_dir = res_get_def (zh->res, "keyTmpDir", "."); - int use_threads = atoi(res_get_def (zh->res, "threads", "1")); + const char *key_tmp_dir = res_get_def(zh->res, "keyTmpDir", "."); + int use_threads = atoi(res_get_def(zh->res, "threads", "1")); zh->reg->key_block = key_block_create(mem, key_tmp_dir, use_threads); } @@ -1378,14 +1378,14 @@ void extract_flush_record_keys2(ZebraHandle zh, zint sysno, { extract_rec_keys_adjust(zh, 1, ins_keys); if (!del_keys) - zebraExplain_recordCountIncrement (zei, 1); + zebraExplain_recordCountIncrement(zei, 1); zebra_rec_keys_rewind(ins_keys); } if (del_keys) { extract_rec_keys_adjust(zh, 0, del_keys); if (!ins_keys) - zebraExplain_recordCountIncrement (zei, -1); + zebraExplain_recordCountIncrement(zei, -1); zebra_rec_keys_rewind(del_keys); } @@ -1449,11 +1449,11 @@ void extract_flush_record_keys(ZebraHandle zh, zint sysno, int cmd, if (!zh->reg->key_block) { int mem = 1024*1024 * atoi( res_get_def( zh->res, "memmax", "8")); - const char *key_tmp_dir = res_get_def (zh->res, "keyTmpDir", "."); - int use_threads = atoi(res_get_def (zh->res, "threads", "1")); + const char *key_tmp_dir = res_get_def(zh->res, "keyTmpDir", "."); + int use_threads = atoi(res_get_def(zh->res, "threads", "1")); zh->reg->key_block = key_block_create(mem, key_tmp_dir, use_threads); } - zebraExplain_recordCountIncrement (zei, cmd ? 1 : -1); + zebraExplain_recordCountIncrement(zei, cmd ? 1 : -1); #if 0 yaz_log(YLOG_LOG, "sysno=" ZINT_FORMAT " cmd=%d", sysno, cmd); @@ -1596,7 +1596,7 @@ static void extract_add_staticrank_string(RecWord *p, static void extract_add_string(RecWord *p, const char *string, int length) { ZebraHandle zh = p->extractCtrl->handle; - assert (length > 0); + assert(length > 0); if (!p->index_name) return; @@ -1679,12 +1679,12 @@ static void extract_add_incomplete_field(RecWord *p) p->seqno++; } } - extract_add_string (p, buf, i); + extract_add_string(p, buf, i); p->seqno++; } } -static void extract_add_complete_field (RecWord *p) +static void extract_add_complete_field(RecWord *p) { ZebraHandle zh = p->extractCtrl->handle; const char *b = p->term_buf; @@ -1693,7 +1693,7 @@ static void extract_add_complete_field (RecWord *p) int i = 0, remain = p->term_len; if (remain > 0) - map = zebra_maps_input (zh->reg->zebra_maps, p->index_type, &b, remain, 1); + map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 1); while (remain > 0 && i < IT_MAX_WORD) { @@ -1732,7 +1732,7 @@ static void extract_add_complete_field (RecWord *p) remain = p->term_len - (b - p->term_buf); if (remain > 0) { - map = zebra_maps_input (zh->reg->zebra_maps, p->index_type, &b, + map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 0); } else @@ -1741,7 +1741,7 @@ static void extract_add_complete_field (RecWord *p) } if (!i) return; - extract_add_string (p, buf, i); + extract_add_string(p, buf, i); } static void extract_token_add(RecWord *p) @@ -1762,8 +1762,8 @@ static void extract_token_add(RecWord *p) p->term_buf = wrbuf_buf(wrbuf); p->term_len = wrbuf_len(wrbuf); } - if (zebra_maps_is_complete (zh->reg->zebra_maps, p->index_type)) - extract_add_complete_field (p); + if (zebra_maps_is_complete(zh->reg->zebra_maps, p->index_type)) + extract_add_complete_field(p); else extract_add_incomplete_field(p); } @@ -1796,7 +1796,7 @@ static void extract_set_store_data_prepare(struct recExtractCtrl *p) static void extract_schema_add(struct recExtractCtrl *p, Odr_oid *oid) { ZebraHandle zh = (ZebraHandle) p->handle; - zebraExplain_addSchema (zh->reg->zei, oid); + zebraExplain_addSchema(zh->reg->zei, oid); } void extract_flush_sort_keys(ZebraHandle zh, zint sysno, diff --git a/index/index.h b/index/index.h index 8478bde..b9d8432 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.200 2007-08-21 13:27:04 adam Exp $ +/* $Id: index.h,v 1.201 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include - +#include #if HAVE_SYS_TIMES_H #include #endif @@ -144,6 +144,7 @@ struct zebra_register { char *server_path_prefix; data1_handle dh; + zebra_index_types_t index_types; ZebraMaps zebra_maps; ZebraRankClass rank_classes; RecTypes recTypes; diff --git a/index/kinput.c b/index/kinput.c index 5fe9733..57dab07 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -1,4 +1,4 @@ -/* $Id: kinput.c,v 1.83 2007-02-06 09:32:50 adam Exp $ +/* $Id: kinput.c,v 1.84 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -63,28 +63,28 @@ static void pkey(const char *b, int mode) #endif -void getFnameTmp (Res res, char *fname, int no) +void getFnameTmp(Res res, char *fname, int no) { const char *pre; - pre = res_get_def (res, "keyTmpDir", "."); - sprintf (fname, "%s/key%d.tmp", pre, no); + pre = res_get_def(res, "keyTmpDir", "."); + sprintf(fname, "%s/key%d.tmp", pre, no); } -void extract_get_fname_tmp (ZebraHandle zh, char *fname, int no) +void extract_get_fname_tmp(ZebraHandle zh, char *fname, int no) { const char *pre; - pre = res_get_def (zh->res, "keyTmpDir", "."); - sprintf (fname, "%s/key%d.tmp", pre, no); + pre = res_get_def(zh->res, "keyTmpDir", "."); + sprintf(fname, "%s/key%d.tmp", pre, no); } -void key_file_chunk_read (struct key_file *f) +void key_file_chunk_read(struct key_file *f) { int nr = 0, r = 0, fd; char fname[1024]; - getFnameTmp (f->res, fname, f->no); - fd = open (fname, O_BINARY|O_RDONLY); + getFnameTmp(f->res, fname, f->no); + fd = open(fname, O_BINARY|O_RDONLY); f->buf_ptr = 0; f->buf_size = 0; @@ -95,14 +95,14 @@ void key_file_chunk_read (struct key_file *f) } if (!f->length) { - if ((f->length = lseek (fd, 0L, SEEK_END)) == (off_t) -1) + if ((f->length = lseek(fd, 0L, SEEK_END)) == (off_t) -1) { yaz_log(YLOG_WARN|YLOG_ERRNO, "cannot seek %s", fname); - close (fd); + close(fd); return ; } } - if (lseek (fd, f->offset, SEEK_SET) == -1) + if (lseek(fd, f->offset, SEEK_SET) == -1) { yaz_log(YLOG_WARN|YLOG_ERRNO, "cannot seek %s", fname); close(fd); @@ -110,7 +110,7 @@ void key_file_chunk_read (struct key_file *f) } while (f->chunk - nr > 0) { - r = read (fd, f->buf + nr, f->chunk - nr); + r = read(fd, f->buf + nr, f->chunk - nr); if (r <= 0) break; nr += r; @@ -118,28 +118,28 @@ void key_file_chunk_read (struct key_file *f) if (r == -1) { yaz_log(YLOG_WARN|YLOG_ERRNO, "read of %s", fname); - close (fd); + close(fd); return; } f->buf_size = nr; if (f->readHandler) (*f->readHandler)(f, f->readInfo); - close (fd); + close(fd); } -void key_file_destroy (struct key_file *f) +void key_file_destroy(struct key_file *f) { iscz1_stop(f->decode_handle); - xfree (f->buf); - xfree (f->prev_name); - xfree (f); + xfree(f->buf); + xfree(f->prev_name); + xfree(f); } -struct key_file *key_file_init (int no, int chunk, Res res) +struct key_file *key_file_init(int no, int chunk, Res res) { struct key_file *f; - f = (struct key_file *) xmalloc (sizeof(*f)); + f = (struct key_file *) xmalloc(sizeof(*f)); f->res = res; f->decode_handle = iscz1_start(); f->no = no; @@ -147,28 +147,28 @@ struct key_file *key_file_init (int no, int chunk, Res res) f->offset = 0; f->length = 0; f->readHandler = NULL; - f->buf = (unsigned char *) xmalloc (f->chunk); - f->prev_name = (char *) xmalloc (INP_NAME_MAX); + f->buf = (unsigned char *) xmalloc(f->chunk); + f->prev_name = (char *) xmalloc(INP_NAME_MAX); *f->prev_name = '\0'; - key_file_chunk_read (f); + key_file_chunk_read(f); return f; } -int key_file_getc (struct key_file *f) +int key_file_getc(struct key_file *f) { if (f->buf_ptr < f->buf_size) return f->buf[(f->buf_ptr)++]; if (f->buf_size < f->chunk) return EOF; f->offset += f->buf_size; - key_file_chunk_read (f); + key_file_chunk_read(f); if (f->buf_ptr < f->buf_size) return f->buf[(f->buf_ptr)++]; else return EOF; } -int key_file_read (struct key_file *f, char *key) +int key_file_read(struct key_file *f, char *key) { int i, c; char srcbuf[128]; @@ -176,11 +176,11 @@ int key_file_read (struct key_file *f, char *key) char *dst; int j; - c = key_file_getc (f); + c = key_file_getc(f); if (c == 0) { - strcpy (key, f->prev_name); - i = 1+strlen (key); + strcpy(key, f->prev_name); + i = 1+strlen(key); } else if (c == EOF) return 0; @@ -188,9 +188,9 @@ int key_file_read (struct key_file *f, char *key) { i = 0; key[i++] = c; - while ((key[i++] = key_file_getc (f))) + while ((key[i++] = key_file_getc(f))) ; - strcpy (f->prev_name, key); + strcpy(f->prev_name, key); iscz1_reset(f->decode_handle); } c = key_file_getc(f); /* length + insert/delete combined */ @@ -235,7 +235,7 @@ struct heap_info { static struct heap_info *key_heap_malloc(void) { /* malloc and clear it */ struct heap_info *hi; - hi = (struct heap_info *) xmalloc (sizeof(*hi)); + hi = (struct heap_info *) xmalloc(sizeof(*hi)); hi->info.file = 0; hi->info.buf = 0; hi->heapnum = 0; @@ -260,14 +260,14 @@ struct heap_info *key_heap_init_file(ZebraHandle zh, hi = key_heap_malloc(); hi->zh = zh; hi->info.file = (struct key_file **) - xmalloc (sizeof(*hi->info.file) * (1+nkeys)); - hi->info.buf = (char **) xmalloc (sizeof(*hi->info.buf) * (1+nkeys)); - hi->ptr = (int *) xmalloc (sizeof(*hi->ptr) * (1+nkeys)); + xmalloc(sizeof(*hi->info.file) * (1+nkeys)); + hi->info.buf = (char **) xmalloc(sizeof(*hi->info.buf) * (1+nkeys)); + hi->ptr = (int *) xmalloc(sizeof(*hi->ptr) * (1+nkeys)); hi->cmp = cmp; for (i = 0; i<= nkeys; i++) { hi->ptr[i] = i; - hi->info.buf[i] = (char *) xmalloc (INP_NAME_MAX); + hi->info.buf[i] = (char *) xmalloc(INP_NAME_MAX); } return hi; } @@ -282,20 +282,20 @@ struct heap_info *key_heap_init_raw(ZebraHandle zh, return hi; } -void key_heap_destroy (struct heap_info *hi, int nkeys) +void key_heap_destroy(struct heap_info *hi, int nkeys) { int i; if (!hi->raw_reading) for (i = 0; i<=nkeys; i++) - xfree (hi->info.buf[i]); + xfree(hi->info.buf[i]); - xfree (hi->info.buf); - xfree (hi->ptr); - xfree (hi->info.file); - xfree (hi); + xfree(hi->info.buf); + xfree(hi->ptr); + xfree(hi->info.file); + xfree(hi); } -static void key_heap_swap (struct heap_info *hi, int i1, int i2) +static void key_heap_swap(struct heap_info *hi, int i1, int i2) { int swap; @@ -305,13 +305,13 @@ static void key_heap_swap (struct heap_info *hi, int i1, int i2) } -static void key_heap_delete (struct heap_info *hi) +static void key_heap_delete(struct heap_info *hi) { int cur = 1, child = 2; - assert (hi->heapnum > 0); + assert(hi->heapnum > 0); - key_heap_swap (hi, 1, hi->heapnum); + key_heap_swap(hi, 1, hi->heapnum); hi->heapnum--; while (child <= hi->heapnum) { if (child < hi->heapnum && @@ -321,7 +321,7 @@ static void key_heap_delete (struct heap_info *hi) if ((*hi->cmp)(&hi->info.buf[hi->ptr[cur]], &hi->info.buf[hi->ptr[child]]) > 0) { - key_heap_swap (hi, cur, child); + key_heap_swap(hi, cur, child); cur = child; child = 2*cur; } @@ -330,26 +330,26 @@ static void key_heap_delete (struct heap_info *hi) } } -static void key_heap_insert (struct heap_info *hi, const char *buf, int nbytes, +static void key_heap_insert(struct heap_info *hi, const char *buf, int nbytes, struct key_file *kf) { int cur, parent; cur = ++(hi->heapnum); - memcpy (hi->info.buf[hi->ptr[cur]], buf, nbytes); + memcpy(hi->info.buf[hi->ptr[cur]], buf, nbytes); hi->info.file[hi->ptr[cur]] = kf; parent = cur/2; while (parent && (*hi->cmp)(&hi->info.buf[hi->ptr[parent]], &hi->info.buf[hi->ptr[cur]]) > 0) { - key_heap_swap (hi, cur, parent); + key_heap_swap(hi, cur, parent); cur = parent; parent = cur/2; } } -static int heap_read_one (struct heap_info *hi, char *name, char *key) +static int heap_read_one(struct heap_info *hi, char *name, char *key) { int n, r; char rbuf[INP_NAME_MAX]; @@ -358,13 +358,13 @@ static int heap_read_one (struct heap_info *hi, char *name, char *key) if (!hi->heapnum) return 0; n = hi->ptr[1]; - strcpy (name, hi->info.buf[n]); + strcpy(name, hi->info.buf[n]); kf = hi->info.file[n]; r = strlen(name); - memcpy (key, hi->info.buf[n] + r+1, KEY_SIZE); - key_heap_delete (hi); - if ((r = key_file_read (kf, rbuf))) - key_heap_insert (hi, rbuf, r, kf); + memcpy(key, hi->info.buf[n] + r+1, KEY_SIZE); + key_heap_delete(hi); + if ((r = key_file_read(kf, rbuf))) + key_heap_insert(hi, rbuf, r, kf); hi->no_iterations++; return 1; } @@ -410,7 +410,7 @@ struct heap_cread_info { int look_level; }; -static int heap_cread_item (void *vp, char **dst, int *insertMode); +static int heap_cread_item(void *vp, char **dst, int *insertMode); int heap_cread_item2(void *vp, char **dst, int *insertMode) { @@ -429,7 +429,7 @@ int heap_cread_item2(void *vp, char **dst, int *insertMode) *insertMode = 0; p->look_level++; } - memcpy (*dst, p->key_1, p->sz_1); + memcpy(*dst, p->key_1, p->sz_1); #if 0 yaz_log(YLOG_LOG, "DUP level=%d", p->look_level); pkey(*dst, *insertMode); @@ -452,7 +452,7 @@ int heap_cread_item2(void *vp, char **dst, int *insertMode) { /* lookahead in 2 . Now in 1. */ p->sz_1 = p->sz_2; p->mode_1 = p->mode_2; - memcpy (p->key_1, p->key_2, p->sz_2); + memcpy(p->key_1, p->key_2, p->sz_2); } if (p->mode_1) level = 1; /* insert */ @@ -485,7 +485,7 @@ int heap_cread_item2(void *vp, char **dst, int *insertMode) /* all the same. new round .. */ p->sz_1 = p->sz_2; p->mode_1 = p->mode_2; - memcpy (p->key_1, p->key_2, p->sz_1); + memcpy(p->key_1, p->key_2, p->sz_1); if (p->mode_1) level = 1; /* insert */ else @@ -504,7 +504,7 @@ int heap_cread_item2(void *vp, char **dst, int *insertMode) level++; } p->look_level = level; - memcpy (*dst, p->key_1, p->sz_1); + memcpy(*dst, p->key_1, p->sz_1); #if 0 pkey(*dst, *insertMode); #endif @@ -512,7 +512,7 @@ int heap_cread_item2(void *vp, char **dst, int *insertMode) return 1; } -int heap_cread_item (void *vp, char **dst, int *insertMode) +int heap_cread_item(void *vp, char **dst, int *insertMode) { struct heap_cread_info *p = (struct heap_cread_info *) vp; struct heap_info *hi = p->hi; @@ -520,7 +520,7 @@ int heap_cread_item (void *vp, char **dst, int *insertMode) if (p->first_in_list) { *insertMode = p->key[0]; - memcpy (*dst, p->key+1, sizeof(struct it_key)); + memcpy(*dst, p->key+1, sizeof(struct it_key)); #if PR_KEY_LOW zebra_log_dict_entry(hi->zh, p->cur_name); pkey(*dst, *insertMode); @@ -529,16 +529,16 @@ int heap_cread_item (void *vp, char **dst, int *insertMode) p->first_in_list = 0; return 1; } - strcpy (p->prev_name, p->cur_name); - if (!(p->more = heap_read_one (hi, p->cur_name, p->key))) + strcpy(p->prev_name, p->cur_name); + if (!(p->more = heap_read_one(hi, p->cur_name, p->key))) return 0; - if (*p->cur_name && strcmp (p->cur_name, p->prev_name)) + if (*p->cur_name && strcmp(p->cur_name, p->prev_name)) { p->first_in_list = 1; return 0; } *insertMode = p->key[0]; - memcpy (*dst, p->key+1, sizeof(struct it_key)); + memcpy(*dst, p->key+1, sizeof(struct it_key)); #if PR_KEY_LOW zebra_log_dict_entry(hi->zh, p->cur_name); pkey(*dst, *insertMode); @@ -547,9 +547,9 @@ int heap_cread_item (void *vp, char **dst, int *insertMode) return 1; } -int heap_inpc (struct heap_cread_info *hci, struct heap_info *hi) +int heap_inpc(struct heap_cread_info *hci, struct heap_info *hi) { - ISAMC_I *isamc_i = (ISAMC_I *) xmalloc (sizeof(*isamc_i)); + ISAMC_I *isamc_i = (ISAMC_I *) xmalloc(sizeof(*isamc_i)); isamc_i->clientData = hci; isamc_i->read_item = heap_cread_item2; @@ -560,39 +560,39 @@ int heap_inpc (struct heap_cread_info *hci, struct heap_info *hi) ISAM_P isamc_p, isamc_p2; char *dict_info; - strcpy (this_name, hci->cur_name); - assert (hci->cur_name[0]); + strcpy(this_name, hci->cur_name); + assert(hci->cur_name[0]); hi->no_diffs++; - if ((dict_info = dict_lookup (hi->reg->dict, hci->cur_name))) + if ((dict_info = dict_lookup(hi->reg->dict, hci->cur_name))) { - memcpy (&isamc_p, dict_info+1, sizeof(ISAM_P)); + memcpy(&isamc_p, dict_info+1, sizeof(ISAM_P)); isamc_p2 = isamc_p; - isamc_merge (hi->reg->isamc, &isamc_p2, isamc_i); + isamc_merge(hi->reg->isamc, &isamc_p2, isamc_i); if (!isamc_p2) { hi->no_deletions++; - if (!dict_delete (hi->reg->dict, this_name)) + if (!dict_delete(hi->reg->dict, this_name)) abort(); } else { hi->no_updates++; if (isamc_p2 != isamc_p) - dict_insert (hi->reg->dict, this_name, + dict_insert(hi->reg->dict, this_name, sizeof(ISAM_P), &isamc_p2); } } else { isamc_p = 0; - isamc_merge (hi->reg->isamc, &isamc_p, isamc_i); + isamc_merge(hi->reg->isamc, &isamc_p, isamc_i); hi->no_insertions++; if (isamc_p) - dict_insert (hi->reg->dict, this_name, + dict_insert(hi->reg->dict, this_name, sizeof(ISAM_P), &isamc_p); } } - xfree (isamc_i); + xfree(isamc_i); return 0; } @@ -605,8 +605,8 @@ int heap_inp0(struct heap_cread_info *hci, struct heap_info *hi) char *dst = mybuf; int mode; - strcpy (this_name, hci->cur_name); - assert (hci->cur_name[0]); + strcpy(this_name, hci->cur_name); + assert(hci->cur_name[0]); hi->no_diffs++; while (heap_cread_item2(hci, &dst, &mode)) @@ -618,7 +618,7 @@ int heap_inp0(struct heap_cread_info *hci, struct heap_info *hi) int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi) { - ISAMC_I *isamc_i = (ISAMC_I *) xmalloc (sizeof(*isamc_i)); + ISAMC_I *isamc_i = (ISAMC_I *) xmalloc(sizeof(*isamc_i)); isamc_i->clientData = hci; isamc_i->read_item = heap_cread_item2; @@ -629,40 +629,40 @@ int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi) ISAM_P isamc_p, isamc_p2; char *dict_info; - strcpy (this_name, hci->cur_name); - assert (hci->cur_name[0]); + strcpy(this_name, hci->cur_name); + assert(hci->cur_name[0]); hi->no_diffs++; #if 0 assert(hi->zh); zebra_log_dict_entry(hi->zh, hci->cur_name); #endif - if ((dict_info = dict_lookup (hi->reg->dict, hci->cur_name))) + if ((dict_info = dict_lookup(hi->reg->dict, hci->cur_name))) { - memcpy (&isamc_p, dict_info+1, sizeof(ISAM_P)); + memcpy(&isamc_p, dict_info+1, sizeof(ISAM_P)); isamc_p2 = isamc_p; - isamb_merge (hi->reg->isamb, &isamc_p2, isamc_i); + isamb_merge(hi->reg->isamb, &isamc_p2, isamc_i); if (!isamc_p2) { hi->no_deletions++; - if (!dict_delete (hi->reg->dict, this_name)) + if (!dict_delete(hi->reg->dict, this_name)) abort(); } else { hi->no_updates++; if (isamc_p2 != isamc_p) - dict_insert (hi->reg->dict, this_name, + dict_insert(hi->reg->dict, this_name, sizeof(ISAM_P), &isamc_p2); } } else { isamc_p = 0; - isamb_merge (hi->reg->isamb, &isamc_p, isamc_i); + isamb_merge(hi->reg->isamb, &isamc_p, isamc_i); hi->no_insertions++; if (isamc_p) - dict_insert (hi->reg->dict, this_name, + dict_insert(hi->reg->dict, this_name, sizeof(ISAM_P), &isamc_p); } } @@ -670,9 +670,9 @@ int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi) return 0; } -int heap_inps (struct heap_cread_info *hci, struct heap_info *hi) +int heap_inps(struct heap_cread_info *hci, struct heap_info *hi) { - ISAMS_I isams_i = (ISAMS_I) xmalloc (sizeof(*isams_i)); + ISAMS_I isams_i = (ISAMS_I) xmalloc(sizeof(*isams_i)); isams_i->clientData = hci; isams_i->read_item = heap_cread_item; @@ -683,14 +683,14 @@ int heap_inps (struct heap_cread_info *hci, struct heap_info *hi) ISAM_P isams_p; char *dict_info; - strcpy (this_name, hci->cur_name); - assert (hci->cur_name[0]); + strcpy(this_name, hci->cur_name); + assert(hci->cur_name[0]); hi->no_diffs++; - if (!(dict_info = dict_lookup (hi->reg->dict, hci->cur_name))) + if (!(dict_info = dict_lookup(hi->reg->dict, hci->cur_name))) { - isams_p = isams_merge (hi->reg->isams, isams_i); + isams_p = isams_merge(hi->reg->isams, isams_i); hi->no_insertions++; - dict_insert (hi->reg->dict, this_name, sizeof(ISAM_P), &isams_p); + dict_insert(hi->reg->dict, this_name, sizeof(ISAM_P), &isams_p); } else { @@ -698,7 +698,7 @@ int heap_inps (struct heap_cread_info *hci, struct heap_info *hi) break; } } - xfree (isams_i); + xfree(isams_i); return 0; } @@ -709,7 +709,7 @@ struct progressInfo { off_t totalOffset; }; -void progressFunc (struct key_file *keyp, void *info) +void progressFunc(struct key_file *keyp, void *info) { struct progressInfo *p = (struct progressInfo *) info; time_t now, remaining; @@ -737,7 +737,7 @@ void progressFunc (struct key_file *keyp, void *info) #define R_OK 4 #endif -void zebra_index_merge (ZebraHandle zh) +void zebra_index_merge(ZebraHandle zh) { struct key_file **kf = 0; char rbuf[1024]; @@ -755,22 +755,22 @@ void zebra_index_merge (ZebraHandle zh) nkeys = 0; while (1) { - extract_get_fname_tmp (zh, fname, nkeys+1); - if (access (fname, R_OK) == -1) + extract_get_fname_tmp (zh, fname, nkeys+1); + if (access(fname, R_OK) == -1) break; nkeys++; } if (!nkeys) return ; } - kf = (struct key_file **) xmalloc ((1+nkeys) * sizeof(*kf)); + kf = (struct key_file **) xmalloc((1+nkeys) * sizeof(*kf)); progressInfo.totalBytes = 0; progressInfo.totalOffset = 0; - time (&progressInfo.startTime); - time (&progressInfo.lastTime); + time(&progressInfo.startTime); + time(&progressInfo.lastTime); for (i = 1; i<=nkeys; i++) { - kf[i] = key_file_init (i, 8192, zh->res); + kf[i] = key_file_init(i, 8192, zh->res); kf[i]->readHandler = progressFunc; kf[i]->readInfo = &progressInfo; progressInfo.totalBytes += kf[i]->length; @@ -780,21 +780,21 @@ void zebra_index_merge (ZebraHandle zh) hi->reg = zh->reg; for (i = 1; i<=nkeys; i++) - if ((r = key_file_read (kf[i], rbuf))) - key_heap_insert (hi, rbuf, r, kf[i]); + if ((r = key_file_read(kf[i], rbuf))) + key_heap_insert(hi, rbuf, r, kf[i]); if (1) { struct heap_cread_info hci; - hci.key = (char *) xmalloc (KEY_SIZE); - hci.key_1 = (char *) xmalloc (KEY_SIZE); - hci.key_2 = (char *) xmalloc (KEY_SIZE); + hci.key = (char *) xmalloc(KEY_SIZE); + hci.key_1 = (char *) xmalloc(KEY_SIZE); + hci.key_2 = (char *) xmalloc(KEY_SIZE); hci.ret = -1; hci.first_in_list = 1; hci.hi = hi; hci.look_level = 0; - hci.more = heap_read_one (hi, hci.cur_name, hci.key); + hci.more = heap_read_one(hi, hci.cur_name, hci.key); if (zh->reg->isams) heap_inps(&hci, hi); @@ -803,19 +803,19 @@ void zebra_index_merge (ZebraHandle zh) if (zh->reg->isamb) heap_inpb(&hci, hi); - xfree (hci.key); - xfree (hci.key_1); - xfree (hci.key_2); + xfree(hci.key); + xfree(hci.key_1); + xfree(hci.key_2); } for (i = 1; i<=nkeys; i++) { - extract_get_fname_tmp (zh, rbuf, i); - unlink (rbuf); + extract_get_fname_tmp (zh, rbuf, i); + unlink(rbuf); } for (i = 1; i<=nkeys; i++) - key_file_destroy (kf[i]); - xfree (kf); + key_file_destroy(kf[i]); + xfree(kf); if (hi->no_iterations) { /* do not log if nothing happened */ yaz_log(YLOG_LOG, "Iterations: isam/dict " diff --git a/index/recgrs.c b/index/recgrs.c index c62d1a9..10abf8c 100644 --- a/index/recgrs.c +++ b/index/recgrs.c @@ -1,4 +1,4 @@ -/* $Id: recgrs.c,v 1.19 2007-05-08 12:50:04 adam Exp $ +/* $Id: recgrs.c,v 1.20 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -396,7 +396,7 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) #endif char *pexpr = xmalloc(strlen(tagpath)+5); - sprintf (pexpr, "/%s\n", tagpath); + sprintf(pexpr, "/%s\n", tagpath); for (xpe = abs->xp_elements; xpe; xpe = xpe->next) xpe->match_state = -1; /* don't know if it matches yet */ @@ -418,7 +418,7 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) xpe1->match_state = ok; #endif } - assert (ok == 0 || ok == 1); + assert(ok == 0 || ok == 1); if (ok) { #ifdef ENHANCED_XELM /* we have to check the perdicates up to the root node */ @@ -476,7 +476,7 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) */ /* add xpath index for an attribute */ -static void index_xpath_attr (char *tag_path, char *name, char *value, +static void index_xpath_attr(char *tag_path, char *name, char *value, char *structure, struct recExtractCtrl *p, RecWord *wrd) { @@ -514,7 +514,7 @@ static void mk_tag_path_full(char *tag_path_full, size_t max, data1_node *n) size_t tlen = strlen(nn->u.tag.tag); if (tlen + flen > (max - 2)) break; - memcpy (tag_path_full + flen, nn->u.tag.tag, tlen); + memcpy(tag_path_full + flen, nn->u.tag.tag, tlen); flen += tlen; tag_path_full[flen++] = '/'; } @@ -564,7 +564,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, /* need to copy recword because it may be changed */ RecWord wrd_tl; wrd->index_type = *tl->structure; - memcpy (&wrd_tl, wrd, sizeof(*wrd)); + memcpy(&wrd_tl, wrd, sizeof(*wrd)); if (tl->source) sp_parse(sp, n, &wrd_tl, tl->source); @@ -576,13 +576,13 @@ static void index_xpath(struct source_parser *sp, data1_node *n, printf("%*sIdx: [%s]", (level + 1) * 4, "", tl->structure); printf("%s %s", tl->index_name, tl->source); - printf (" XData:\""); + printf(" XData:\""); for (i = 0; i 40) - printf (" ..."); - fputc ('\n', stdout); + printf(" ..."); + fputc('\n', stdout); } else { @@ -615,9 +615,9 @@ static void index_xpath(struct source_parser *sp, data1_node *n, { printf("%*s tag=", (level + 1) * 4, ""); for (i = 0; iterm_len && i < 40; i++) - fputc (wrd->term_buf[i], stdout); + fputc(wrd->term_buf[i], stdout); if (i == 40) - printf (" .."); + printf(" .."); printf("\n"); } else @@ -638,7 +638,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, char attr_tag_path_full[1024]; /* this could be cached as well */ - sprintf (attr_tag_path_full, "@%s/%s", + sprintf(attr_tag_path_full, "@%s/%s", xp->name, tag_path_full); tll[i] = xpath_termlist_by_tagpath(attr_tag_path_full,n); @@ -659,9 +659,9 @@ static void index_xpath(struct source_parser *sp, data1_node *n, strlen(xp->name) + strlen(xp->value) < sizeof(comb)-2) { /* attribute value exact */ - strcpy (comb, xp->name); - strcat (comb, "="); - strcat (comb, xp->value); + strcpy(comb, xp->name); + strcat(comb, "="); + strcat(comb, xp->value); wrd->index_name = ZEBRA_XPATH_ATTR_NAME; wrd->index_type = '0'; @@ -681,7 +681,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, char attr_tag_path_full[1024]; int xpdone = 0; - sprintf (attr_tag_path_full, "@%s/%s", + sprintf(attr_tag_path_full, "@%s/%s", xp->name, tag_path_full); if ((tl = tll[i])) { @@ -691,7 +691,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, if (!tl->index_name) { /* add xpath index for the attribute */ - index_xpath_attr (attr_tag_path_full, xp->name, + index_xpath_attr(attr_tag_path_full, xp->name, xp->value, tl->structure, p, wrd); xpdone = 1; @@ -713,7 +713,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, the attribute as "w" */ if (!xpdone && !termlist_only) { - index_xpath_attr (attr_tag_path_full, xp->name, + index_xpath_attr(attr_tag_path_full, xp->name, xp->value, "w", p, wrd); } i++; @@ -723,7 +723,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, } } -static void index_termlist (struct source_parser *sp, data1_node *par, +static void index_termlist(struct source_parser *sp, data1_node *par, data1_node *n, struct recExtractCtrl *p, int level, RecWord *wrd) { @@ -759,13 +759,13 @@ static void index_termlist (struct source_parser *sp, data1_node *par, printf("%*sIdx: [%s]", (level + 1) * 4, "", tlist->structure); printf("%s %s", tlist->index_name, tlist->source); - printf (" XData:\""); + printf(" XData:\""); for (i = 0; iterm_len && i < 40; i++) - fputc (wrd->term_buf[i], stdout); - fputc ('"', stdout); + fputc(wrd->term_buf[i], stdout); + fputc('"', stdout); if (wrd->term_len > 40) - printf (" ..."); - fputc ('\n', stdout); + printf(" ..."); + fputc('\n', stdout); } else { @@ -915,13 +915,13 @@ static int grs_extract_sub(void *clientData, struct recExtractCtrl *p, data1_concat_text(p->dh, mem, n); /* ensure our data1 tree is UTF-8 */ - data1_iconv (p->dh, mem, n, "UTF-8", data1_get_encoding(p->dh, n)); + data1_iconv(p->dh, mem, n, "UTF-8", data1_get_encoding(p->dh, n)); - data1_remove_idzebra_subtree (p->dh, n); + data1_remove_idzebra_subtree(p->dh, n); #if 0 - data1_pr_tree (p->dh, n, stdout); + data1_pr_tree(p->dh, n, stdout); #endif (*p->init)(p, &wrd); @@ -936,7 +936,7 @@ int zebra_grs_extract(void *clientData, struct recExtractCtrl *p, data1_node *(*grs_read)(struct grs_read_info *)) { int ret; - NMEM mem = nmem_create (); + NMEM mem = nmem_create(); ret = grs_extract_sub(clientData, p, mem, grs_read); nmem_destroy(mem); return ret; @@ -1031,7 +1031,7 @@ static int process_comp(data1_handle dh, data1_node *n, Z_RecordComposition *c, */ -static void zebra_xml_metadata (struct recRetrieveCtrl *p, data1_node *top, +static void zebra_xml_metadata(struct recRetrieveCtrl *p, data1_node *top, NMEM mem) { const char *idzebra_ns[3]; @@ -1043,29 +1043,29 @@ static void zebra_xml_metadata (struct recRetrieveCtrl *p, data1_node *top, idzebra_ns[1] = "http://www.indexdata.dk/zebra/"; idzebra_ns[2] = 0; - data1_mk_text (p->dh, mem, i2, top); + data1_mk_text(p->dh, mem, i2, top); - n = data1_mk_tag (p->dh, mem, "idzebra", idzebra_ns, top); + n = data1_mk_tag(p->dh, mem, "idzebra", idzebra_ns, top); - data1_mk_text (p->dh, mem, "\n", top); + data1_mk_text(p->dh, mem, "\n", top); - data1_mk_text (p->dh, mem, i4, n); + data1_mk_text(p->dh, mem, i4, n); - data1_mk_tag_data_int (p->dh, n, "size", p->recordSize, mem); + data1_mk_tag_data_int(p->dh, n, "size", p->recordSize, mem); if (p->score != -1) { - data1_mk_text (p->dh, mem, i4, n); - data1_mk_tag_data_int (p->dh, n, "score", p->score, mem); + data1_mk_text(p->dh, mem, i4, n); + data1_mk_tag_data_int(p->dh, n, "score", p->score, mem); } - data1_mk_text (p->dh, mem, i4, n); - data1_mk_tag_data_zint (p->dh, n, "localnumber", p->localno, mem); + data1_mk_text(p->dh, mem, i4, n); + data1_mk_tag_data_zint(p->dh, n, "localnumber", p->localno, mem); if (p->fname) { - data1_mk_text (p->dh, mem, i4, n); + data1_mk_text(p->dh, mem, i4, n); data1_mk_tag_data_text(p->dh, n, "filename", p->fname, mem); } - data1_mk_text (p->dh, mem, i2, n); + data1_mk_text(p->dh, mem, i2, n); } int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, @@ -1094,17 +1094,17 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, if (!node) { p->diagnostic = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; - nmem_destroy (mem); + nmem_destroy(mem); return 0; } data1_concat_text(p->dh, mem, node); - data1_remove_idzebra_subtree (p->dh, node); + data1_remove_idzebra_subtree(p->dh, node); #if 0 - data1_pr_tree (p->dh, node, stdout); + data1_pr_tree(p->dh, node, stdout); #endif - top = data1_get_root_tag (p->dh, node); + top = data1_get_root_tag(p->dh, node); yaz_log(YLOG_DEBUG, "grs_retrieve: size"); tagname = data1_systag_lookup(node->u.root.absyn, "size", "size"); @@ -1148,10 +1148,10 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, assert(p->input_format); if (!oid_oidcmp(p->input_format, yaz_oid_recsyn_xml)) - zebra_xml_metadata (p, top, mem); + zebra_xml_metadata(p, top, mem); #if 0 - data1_pr_tree (p->dh, node, stdout); + data1_pr_tree(p->dh, node, stdout); #endif if (p->comp && p->comp->which == Z_RecordComp_complex && p->comp->u.complex->generic && @@ -1175,7 +1175,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, if (!(node = data1_map_record(p->dh, onode, map, mem))) { p->diagnostic = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; - nmem_destroy (mem); + nmem_destroy(mem); return 0; } break; @@ -1185,7 +1185,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, && oid_oidcmp(requested_schema, node->u.root.absyn->oid)) { p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; - nmem_destroy (mem); + nmem_destroy(mem); return 0; } } @@ -1204,7 +1204,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, if (!(node = data1_map_record(p->dh, onode, map, mem))) { p->diagnostic = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; - nmem_destroy (mem); + nmem_destroy(mem); return 0; } break; @@ -1238,7 +1238,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, selected = 1; #if 0 - data1_pr_tree (p->dh, node, stdout); + data1_pr_tree(p->dh, node, stdout); #endif yaz_log(YLOG_DEBUG, "grs_retrieve: transfer syntax mapping"); @@ -1248,10 +1248,10 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, if (!oid_oidcmp(p->input_format, yaz_oid_recsyn_xml)) { #if 0 - data1_pr_tree (p->dh, node, stdout); + data1_pr_tree(p->dh, node, stdout); #endif /* default output encoding for XML is UTF-8 */ - data1_iconv (p->dh, mem, node, + data1_iconv(p->dh, mem, node, p->encoding ? p->encoding : "UTF-8", data1_get_encoding(p->dh, node)); @@ -1260,14 +1260,14 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else { - char *new_buf = (char*) odr_malloc (p->odr, p->rec_len); - memcpy (new_buf, p->rec_buf, p->rec_len); + char *new_buf = (char*) odr_malloc(p->odr, p->rec_len); + memcpy(new_buf, p->rec_buf, p->rec_len); p->rec_buf = new_buf; } } else if (!oid_oidcmp(p->input_format, yaz_oid_recsyn_grs_1)) { - data1_iconv (p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); + data1_iconv(p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); dummy = 0; if (!(p->rec_buf = data1_nodetogr(p->dh, node, selected, p->odr, &dummy))) @@ -1278,7 +1278,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, else if (!oid_oidcmp(p->input_format, yaz_oid_recsyn_explain)) { /* ensure our data1 tree is UTF-8 */ - data1_iconv (p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); + data1_iconv(p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); if (!(p->rec_buf = data1_nodetoexplain(p->dh, node, selected, p->odr))) @@ -1289,7 +1289,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, else if (!oid_oidcmp(p->input_format, yaz_oid_recsyn_summary)) { /* ensure our data1 tree is UTF-8 */ - data1_iconv (p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); + data1_iconv(p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); if (!(p->rec_buf = data1_nodetosummary(p->dh, node, selected, p->odr))) p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; @@ -1299,30 +1299,30 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, else if (!oid_oidcmp(p->input_format, yaz_oid_recsyn_sutrs)) { if (p->encoding) - data1_iconv (p->dh, mem, node, p->encoding, + data1_iconv(p->dh, mem, node, p->encoding, data1_get_encoding(p->dh, node)); if (!(p->rec_buf = data1_nodetobuf(p->dh, node, selected, &p->rec_len))) p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else { - char *new_buf = (char*) odr_malloc (p->odr, p->rec_len); - memcpy (new_buf, p->rec_buf, p->rec_len); + char *new_buf = (char*) odr_malloc(p->odr, p->rec_len); + memcpy(new_buf, p->rec_buf, p->rec_len); p->rec_buf = new_buf; } } else if (!oid_oidcmp(p->input_format, yaz_oid_recsyn_soif)) { if (p->encoding) - data1_iconv (p->dh, mem, node, p->encoding, + data1_iconv(p->dh, mem, node, p->encoding, data1_get_encoding(p->dh, node)); if (!(p->rec_buf = data1_nodetosoif(p->dh, node, selected, &p->rec_len))) p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else { - char *new_buf = (char*) odr_malloc (p->odr, p->rec_len); - memcpy (new_buf, p->rec_buf, p->rec_len); + char *new_buf = (char*) odr_malloc(p->odr, p->rec_len); + memcpy(new_buf, p->rec_buf, p->rec_len); p->rec_buf = new_buf; } } @@ -1341,15 +1341,15 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, else { if (p->encoding) - data1_iconv (p->dh, mem, node, p->encoding, + data1_iconv(p->dh, mem, node, p->encoding, data1_get_encoding(p->dh, node)); if (!(p->rec_buf = data1_nodetomarc(p->dh, marctab, node, selected, &p->rec_len))) p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else { - char *new_buf = (char*) odr_malloc (p->odr, p->rec_len); - memcpy (new_buf, p->rec_buf, p->rec_len); + char *new_buf = (char*) odr_malloc(p->odr, p->rec_len); + memcpy(new_buf, p->rec_buf, p->rec_len); p->rec_buf = new_buf; } } diff --git a/index/rectext.c b/index/rectext.c index 6f3968d..8f5fba6 100644 --- a/index/rectext.c +++ b/index/rectext.c @@ -1,4 +1,4 @@ -/* $Id: rectext.c,v 1.6 2007-04-16 21:54:37 adam Exp $ +/* $Id: rectext.c,v 1.7 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -33,7 +33,7 @@ struct filter_info { char *sep; }; -static void *filter_init (Res res, RecType recType) +static void *filter_init(Res res, RecType recType) { struct filter_info *tinfo = (struct filter_info *) xmalloc(sizeof(*tinfo)); tinfo->sep = 0; @@ -50,11 +50,11 @@ static ZEBRA_RES filter_config(void *clientData, Res res, const char *args) return ZEBRA_OK; } -static void filter_destroy (void *clientData) +static void filter_destroy(void *clientData) { struct filter_info *tinfo = clientData; - xfree (tinfo->sep); - xfree (tinfo); + xfree(tinfo->sep); + xfree(tinfo); } struct buf_info { @@ -64,18 +64,18 @@ struct buf_info { int max; }; -static struct buf_info *buf_open (struct recExtractCtrl *p) +static struct buf_info *buf_open(struct recExtractCtrl *p) { - struct buf_info *fi = (struct buf_info *) xmalloc (sizeof(*fi)); + struct buf_info *fi = (struct buf_info *) xmalloc(sizeof(*fi)); fi->p = p; - fi->buf = (char *) xmalloc (4096); + fi->buf = (char *) xmalloc(4096); fi->offset = 1; fi->max = 1; return fi; } -static int buf_getchar (struct filter_info *tinfo, struct buf_info *fi, char *dst) +static int buf_getchar(struct filter_info *tinfo, struct buf_info *fi, char *dst) { if (fi->offset >= fi->max) { @@ -97,19 +97,19 @@ static int buf_getchar (struct filter_info *tinfo, struct buf_info *fi, char *ds return 1; } -static void buf_close (struct buf_info *fi) +static void buf_close(struct buf_info *fi) { - xfree (fi->buf); - xfree (fi); + xfree(fi->buf); + xfree(fi); } -static int filter_extract (void *clientData, struct recExtractCtrl *p) +static int filter_extract(void *clientData, struct recExtractCtrl *p) { struct filter_info *tinfo = clientData; char w[512]; RecWord recWord; int r; - struct buf_info *fi = buf_open (p); + struct buf_info *fi = buf_open(p); int no_read = 0; #if 0 @@ -121,11 +121,11 @@ static int filter_extract (void *clientData, struct recExtractCtrl *p) { int i = 0; - r = buf_getchar (tinfo, fi, w); + r = buf_getchar(tinfo, fi, w); while (r > 0 && i < 511 && w[i] != '\n' && w[i] != '\r') { i++; - r = buf_getchar (tinfo, fi, w + i); + r = buf_getchar(tinfo, fi, w + i); } if (i) { @@ -135,13 +135,13 @@ static int filter_extract (void *clientData, struct recExtractCtrl *p) (*p->tokenAdd)(&recWord); } } while (r > 0); - buf_close (fi); + buf_close(fi); if (no_read == 0) return RECCTRL_EXTRACT_EOF; return RECCTRL_EXTRACT_OK; } -static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) +static int filter_retrieve(void *clientData, struct recRetrieveCtrl *p) { int r, filter_ptr = 0; static char *filter_buf = NULL; @@ -177,11 +177,11 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) char *nb; filter_size = 2*filter_size + 8192; - nb = (char *) xmalloc (filter_size); + nb = (char *) xmalloc(filter_size); if (filter_buf) { - memcpy (nb, filter_buf, filter_ptr); - xfree (filter_buf); + memcpy(nb, filter_buf, filter_ptr); + xfree(filter_buf); } filter_buf = nb; } @@ -189,15 +189,15 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) { if (p->score >= 0) { - sprintf (filter_buf, "Rank: %d\n", p->score); + sprintf(filter_buf, "Rank: %d\n", p->score); filter_ptr = strlen(filter_buf); } - sprintf (filter_buf + filter_ptr, "Local Number: " ZINT_FORMAT "\n", + sprintf(filter_buf + filter_ptr, "Local Number: " ZINT_FORMAT "\n", p->localno); filter_ptr = strlen(filter_buf); if (p->fname) { - sprintf (filter_buf + filter_ptr, "Filename: %s\n", p->fname); + sprintf(filter_buf + filter_ptr, "Filename: %s\n", p->fname); filter_ptr = strlen(filter_buf); } strcpy(filter_buf+filter_ptr++, "\n"); @@ -212,9 +212,9 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) filter_buf[filter_ptr] = '\0'; if (elementSetName) { - if (!strcmp (elementSetName, "B")) + if (!strcmp(elementSetName, "B")) no_lines = 4; - if (!strcmp (elementSetName, "M")) + if (!strcmp(elementSetName, "M")) no_lines = 20; } if (no_lines) @@ -222,7 +222,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) char *p = filter_buf; int i = 0; - while (++i <= no_lines && (p = strchr (p, '\n'))) + while (++i <= no_lines && (p = strchr(p, '\n'))) p++; if (p) { diff --git a/index/retrieve.c b/index/retrieve.c index 8957c3c..ebea719 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1,4 +1,4 @@ -/* $Id: retrieve.c,v 1.72 2007-08-21 13:27:04 adam Exp $ +/* $Id: retrieve.c,v 1.73 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -62,8 +62,8 @@ static int zebra_create_record_stream(ZebraHandle zh, else strcpy(full_rep, (*rec)->info[recInfo_filename]); - if ((fd = open (full_rep, O_BINARY|O_RDONLY)) == -1){ - yaz_log (YLOG_WARN|YLOG_ERRNO, "Retrieve fail; missing file: %s", + if ((fd = open(full_rep, O_BINARY|O_RDONLY)) == -1){ + yaz_log(YLOG_WARN|YLOG_ERRNO, "Retrieve fail; missing file: %s", full_rep); rec_free(rec); return YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; @@ -740,8 +740,8 @@ int zebra_record_fetch(ZebraHandle zh, const char *setname, file_type = rec->info[recInfo_fileType]; fname = rec->info[recInfo_filename]; basename = rec->info[recInfo_databaseName]; - *basenamep = (char *) odr_malloc (odr, strlen(basename)+1); - strcpy (*basenamep, basename); + *basenamep = (char *) odr_malloc(odr, strlen(basename)+1); + strcpy(*basenamep, basename); yaz_log(YLOG_DEBUG, "retrieve localno=" ZINT_FORMAT " score=%d", sysno, score); diff --git a/index/rpnscan.c b/index/rpnscan.c index d484132..5fd6b38 100644 --- a/index/rpnscan.c +++ b/index/rpnscan.c @@ -1,4 +1,4 @@ -/* $Id: rpnscan.c,v 1.13 2007-09-18 18:57:29 adam Exp $ +/* $Id: rpnscan.c,v 1.14 2007-10-29 09:25:40 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -102,7 +102,7 @@ static void count_set(ZebraHandle zh, RSET rset, zint *count) break; } } - rset_close (rfd); + rset_close(rfd); *count = rset->hits_count; } @@ -140,7 +140,7 @@ static void get_first_snippet_from_rset(ZebraHandle zh, } } } - rset_close (rfd); + rset_close(rfd); } struct scan2_info_entry { @@ -160,7 +160,7 @@ static int scan_handle2(char *name, const char *info, int pos, void *client) return 0; len_prefix = strlen(scan_info->prefix); - if (memcmp (name, scan_info->prefix, len_prefix)) + if (memcmp(name, scan_info->prefix, len_prefix)) return 1; /* skip special terms such as first-in-field specials */ @@ -170,8 +170,8 @@ static int scan_handle2(char *name, const char *info, int pos, void *client) wrbuf_rewind(scan_info->term); wrbuf_puts(scan_info->term, name+len_prefix); - assert (*info == sizeof(ISAM_P)); - memcpy (&scan_info->isam_p, info+1, sizeof(ISAM_P)); + assert(*info == sizeof(ISAM_P)); + memcpy(&scan_info->isam_p, info+1, sizeof(ISAM_P)); return 0; } @@ -297,7 +297,7 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, *num_entries = 0; return ZEBRA_OK; } - rpn_char_map_prepare (zh->reg, index_type, &rcmi); + rpn_char_map_prepare(zh->reg, index_type, &rcmi); for (i = 0; i < ord_no; i++) ar[i].term = wrbuf_alloc(); @@ -307,7 +307,7 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, char termz[IT_MAX_WORD+20]; int prefix_len = 0; - prefix_len = key_SU_encode (ords[i], termz); + prefix_len = key_SU_encode(ords[i], termz); termz[prefix_len] = 0; strcpy(ar[i].prefix, termz); @@ -377,7 +377,7 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, char termz[IT_MAX_WORD+20]; int prefix_len = 0; - prefix_len = key_SU_encode (ords[i], termz); + prefix_len = key_SU_encode(ords[i], termz); termz[prefix_len] = 0; strcpy(ar[i].prefix, termz); @@ -504,7 +504,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, else termset_name = termset_value_string; - limit_set = resultSetRef (zh, termset_name); + limit_set = resultSetRef(zh, termset_name); if (!limit_set) { @@ -536,7 +536,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, { int ord; - if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no])) + if (zebraExplain_curDatabase(zh->reg->zei, basenames[base_no])) { zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE, basenames[base_no]); diff --git a/index/rpnsearch.c b/index/rpnsearch.c index 269810b..88a411f 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -1,4 +1,4 @@ -/* $Id: rpnsearch.c,v 1.14 2007-05-14 14:05:21 adam Exp $ +/* $Id: rpnsearch.c,v 1.15 2007-10-29 09:25:41 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -134,9 +134,9 @@ static int add_isam_p(const char *name, const char *info, char term_tmp[IT_MAX_WORD]; int ord = 0; const char *index_name; - int len = key_SU_decode (&ord, (const unsigned char *) name); + int len = key_SU_decode(&ord, (const unsigned char *) name); - zebra_term_untrans (p->zh, p->reg_type, term_tmp, name+len); + zebra_term_untrans (p->zh, p->reg_type, term_tmp, name+len); yaz_log(log_level_rpn, "grep: %d %c %s", ord, name[len], term_tmp); zebraExplain_lookup_ord(p->zh->reg->zei, ord, 0 /* index_type */, &db, &index_name); @@ -739,8 +739,8 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, wrbuf_putc(term_dict, ')'); break; case 5: - if (!term_100 (zh->reg->zebra_maps, reg_type, - term_sub, term_component, space_split, term_dst)) + if (!term_100(zh->reg->zebra_maps, reg_type, + term_sub, term_component, space_split, term_dst)) { wrbuf_destroy(term_component); return 0; @@ -964,7 +964,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, *ol = ord_list_create(stream); - rpn_char_map_prepare (zh->reg, reg_type, &rcmi); + rpn_char_map_prepare(zh->reg, reg_type, &rcmi); attr_init_APT(&truncation, zapt, 5); truncation_value = attr_find(&truncation, NULL); yaz_log(log_level_rpn, "truncation value %d", truncation_value); @@ -981,7 +981,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, termp = *term_sub; /* start of term for each database */ - if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no])) + if (zebraExplain_curDatabase(zh->reg->zei, basenames[base_no])) { zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE, basenames[base_no]); @@ -998,7 +998,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, bases_ok++; *ol = ord_list_append(stream, *ol, ord); - ord_len = key_SU_encode (ord, ord_buf); + ord_len = key_SU_encode(ord, ord_buf); wrbuf_putc(term_dict, '('); @@ -1290,7 +1290,7 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh, int i; for (i = 0; i < *num_result_sets; i++) rset_delete((*result_sets)[i]); - grep_info_delete (&grep_info); + grep_info_delete(&grep_info); return res; } if ((*result_sets)[*num_result_sets] == 0) @@ -1358,7 +1358,7 @@ static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh, char *val; ISAM_P isam_p; - if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no])) + if (zebraExplain_curDatabase(zh->reg->zei, basenames[base_no])) { zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE, basenames[base_no]); @@ -1369,7 +1369,7 @@ static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh, attributeSet, &ord) != ZEBRA_OK) continue; - ord_len = key_SU_encode (ord, ord_buf); + ord_len = key_SU_encode(ord, ord_buf); memcpy(term_dict, ord_buf, ord_len); strcpy(term_dict+ord_len, FIRST_IN_FIELD_STR); val = dict_lookup(zh->reg->dict, term_dict); @@ -1623,7 +1623,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, wrbuf_destroy(term_num); return 0; } - term_value = atoi (wrbuf_cstr(term_num)); + term_value = atoi(wrbuf_cstr(term_num)); gen_regular_rel(term_dict, term_value-1, 1); break; case 2: @@ -1634,7 +1634,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, wrbuf_destroy(term_num); return 0; } - term_value = atoi (wrbuf_cstr(term_num)); + term_value = atoi(wrbuf_cstr(term_num)); gen_regular_rel(term_dict, term_value, 1); break; case 4: @@ -1645,7 +1645,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, wrbuf_destroy(term_num); return 0; } - term_value = atoi (wrbuf_cstr(term_num)); + term_value = atoi(wrbuf_cstr(term_num)); gen_regular_rel(term_dict, term_value, 0); break; case 5: @@ -1656,7 +1656,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, wrbuf_destroy(term_num); return 0; } - term_value = atoi (wrbuf_cstr(term_num)); + term_value = atoi(wrbuf_cstr(term_num)); gen_regular_rel(term_dict, term_value+1, 0); break; case -1: @@ -1668,7 +1668,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, wrbuf_destroy(term_num); return 0; } - term_value = atoi (wrbuf_cstr(term_num)); + term_value = atoi(wrbuf_cstr(term_num)); wrbuf_printf(term_dict, "(0*%d)", term_value); break; case 103: @@ -1712,7 +1712,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, *ol = ord_list_create(stream); - rpn_char_map_prepare (zh->reg, reg_type, &rcmi); + rpn_char_map_prepare(zh->reg, reg_type, &rcmi); for (base_no = 0; base_no < num_bases; base_no++) { @@ -1723,7 +1723,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, termp = *term_sub; - if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no])) + if (zebraExplain_curDatabase(zh->reg->zei, basenames[base_no])) { zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE, basenames[base_no]); @@ -1739,7 +1739,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, *ol = ord_list_append(stream, *ol, ord); - ord_len = key_SU_encode (ord, ord_buf); + ord_len = key_SU_encode(ord, ord_buf); wrbuf_putc(term_dict, '('); for (i = 0; i < ord_len; i++) @@ -1924,7 +1924,7 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, if (zapt->term->which != Z_Term_general) i = 0; else - i = atoi_n ((char *) zapt->term->u.general->buf, + i = atoi_n((char *) zapt->term->u.general->buf, zapt->term->u.general->len); if (i >= sort_sequence->num_specs) i = 0; @@ -2005,7 +2005,7 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream, char ord_buf[32]; RSET rset; WRBUF term_dict = wrbuf_alloc(); - int ord_len = key_SU_encode (ord, ord_buf); + int ord_len = key_SU_encode(ord, ord_buf); int term_type = Z_Term_characterString; const char *flags = "void"; @@ -2079,14 +2079,14 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh, */ - dict_grep_cmap (zh->reg->dict, 0, 0); + dict_grep_cmap(zh->reg->dict, 0, 0); for (base_no = 0; base_no < num_bases; base_no++) { int level = xpath_len; int first_path = 1; - if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no])) + if (zebraExplain_curDatabase(zh->reg->zei, basenames[base_no])) { zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE, basenames[base_no]); diff --git a/index/update_file.c b/index/update_file.c index 5663957..5a50d04 100644 --- a/index/update_file.c +++ b/index/update_file.c @@ -1,4 +1,4 @@ -/* $Id: update_file.c,v 1.5 2007-01-15 15:10:17 adam Exp $ +/* $Id: update_file.c,v 1.6 2007-10-29 09:25:41 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -51,15 +51,15 @@ static void dump_file_dict(Dict dict) char term[1000]; strcpy(term, "0"); - dict_scan (dict, term, &before, &after, 0, dump_file_dict_func); + dict_scan(dict, term, &before, &after, 0, dump_file_dict_func); } #endif -static int repComp (const char *a, const char *b, size_t len) +static int repComp(const char *a, const char *b, size_t len) { if (!len) return 0; - return memcmp (a, b, len); + return memcmp(a, b, len); } static void fileDelete_r(ZebraHandle zh, @@ -67,27 +67,27 @@ static void fileDelete_r(ZebraHandle zh, const char *base, char *src) { char tmppath[1024]; - size_t src_len = strlen (src); + size_t src_len = strlen(src); - while (dst && !repComp (dst->path, src, src_len+1)) + while (dst && !repComp(dst->path, src, src_len+1)) { switch (dst->kind) { case dirs_file: - sprintf (tmppath, "%s%s", base, dst->path); - zebra_extract_file (zh, &dst->sysno, tmppath, 1); + sprintf(tmppath, "%s%s", base, dst->path); + zebra_extract_file(zh, &dst->sysno, tmppath, 1); - strcpy (tmppath, dst->path); - dst = dirs_read (di); - dirs_del (di, tmppath); + strcpy(tmppath, dst->path); + dst = dirs_read(di); + dirs_del(di, tmppath); break; case dirs_dir: - strcpy (tmppath, dst->path); - dst = dirs_read (di); - dirs_rmdir (di, tmppath); + strcpy(tmppath, dst->path); + dst = dirs_read(di); + dirs_rmdir(di, tmppath); break; default: - dst = dirs_read (di); + dst = dirs_read(di); } } } @@ -100,16 +100,16 @@ static void file_update_r(ZebraHandle zh, struct dir_entry *e_src; int i_src = 0; static char tmppath[1024]; - size_t src_len = strlen (src); + size_t src_len = strlen(src); - sprintf (tmppath, "%s%s", base, src); - e_src = dir_open (tmppath, zh->path_reg, zh->m_follow_links); + sprintf(tmppath, "%s%s", base, src); + e_src = dir_open(tmppath, zh->path_reg, zh->m_follow_links); yaz_log(YLOG_LOG, "dir %s", tmppath); #if 0 - if (!dst || repComp (dst->path, src, src_len)) + if (!dst || repComp(dst->path, src, src_len)) #else - if (!dst || strcmp (dst->path, src)) + if (!dst || strcmp(dst->path, src)) #endif { if (!e_src) @@ -120,13 +120,13 @@ static void file_update_r(ZebraHandle zh, src[src_len] = '/'; src[++src_len] = '\0'; } - dirs_mkdir (di, src, 0); - if (dst && repComp (dst->path, src, src_len)) + dirs_mkdir(di, src, 0); + if (dst && repComp(dst->path, src, src_len)) dst = NULL; } else if (!e_src) { - strcpy (src, dst->path); + strcpy(src, dst->path); fileDelete_r(zh, di, dst, base, src); return; } @@ -137,21 +137,21 @@ static void file_update_r(ZebraHandle zh, src[src_len] = '/'; src[++src_len] = '\0'; } - dst = dirs_read (di); + dst = dirs_read(di); } - dir_sort (e_src); + dir_sort(e_src); while (1) { int sd; - if (dst && !repComp (dst->path, src, src_len)) + if (dst && !repComp(dst->path, src, src_len)) { if (e_src[i_src].name) { yaz_log(YLOG_DEBUG, "dst=%s src=%s", dst->path + src_len, e_src[i_src].name); - sd = strcmp (dst->path + src_len, e_src[i_src].name); + sd = strcmp(dst->path + src_len, e_src[i_src].name); } else sd = -1; @@ -164,72 +164,72 @@ static void file_update_r(ZebraHandle zh, if (sd == 0) { - strcpy (src + src_len, e_src[i_src].name); - sprintf (tmppath, "%s%s", base, src); + strcpy(src + src_len, e_src[i_src].name); + sprintf(tmppath, "%s%s", base, src); - switch (e_src[i_src].kind) + switch(e_src[i_src].kind) { case dirs_file: if (e_src[i_src].mtime > dst->mtime) { - if (zebra_extract_file (zh, &dst->sysno, tmppath, 0) == ZEBRA_OK) + if (zebra_extract_file(zh, &dst->sysno, tmppath, 0) == ZEBRA_OK) { - dirs_add (di, src, dst->sysno, e_src[i_src].mtime); + dirs_add(di, src, dst->sysno, e_src[i_src].mtime); } - yaz_log(YLOG_DEBUG, "old: %s", ctime (&dst->mtime)); - yaz_log(YLOG_DEBUG, "new: %s", ctime (&e_src[i_src].mtime)); + yaz_log(YLOG_DEBUG, "old: %s", ctime(&dst->mtime)); + yaz_log(YLOG_DEBUG, "new: %s", ctime(&e_src[i_src].mtime)); } - dst = dirs_read (di); + dst = dirs_read(di); break; case dirs_dir: file_update_r(zh, di, dst, base, src, level+1); - dst = dirs_last (di); + dst = dirs_last(di); yaz_log(YLOG_DEBUG, "last is %s", dst ? dst->path : "null"); break; default: - dst = dirs_read (di); + dst = dirs_read(di); } i_src++; } else if (sd > 0) { zint sysno = 0; - strcpy (src + src_len, e_src[i_src].name); - sprintf (tmppath, "%s%s", base, src); + strcpy(src + src_len, e_src[i_src].name); + sprintf(tmppath, "%s%s", base, src); switch (e_src[i_src].kind) { case dirs_file: - if (zebra_extract_file (zh, &sysno, tmppath, 0) == ZEBRA_OK) - dirs_add (di, src, sysno, e_src[i_src].mtime); + if (zebra_extract_file(zh, &sysno, tmppath, 0) == ZEBRA_OK) + dirs_add(di, src, sysno, e_src[i_src].mtime); break; case dirs_dir: file_update_r(zh, di, dst, base, src, level+1); if (dst) - dst = dirs_last (di); + dst = dirs_last(di); break; } i_src++; } else /* sd < 0 */ { - strcpy (src, dst->path); - sprintf (tmppath, "%s%s", base, dst->path); + strcpy(src, dst->path); + sprintf(tmppath, "%s%s", base, dst->path); switch (dst->kind) { case dirs_file: - zebra_extract_file (zh, &dst->sysno, tmppath, 1); - dirs_del (di, dst->path); - dst = dirs_read (di); + zebra_extract_file(zh, &dst->sysno, tmppath, 1); + dirs_del(di, dst->path); + dst = dirs_read(di); break; case dirs_dir: fileDelete_r(zh, di, dst, base, src); - dst = dirs_last (di); + dst = dirs_last(di); } } } - dir_free (&e_src); + dir_free(&e_src); } static void file_update_top(ZebraHandle zh, Dict dict, const char *path) @@ -240,20 +240,20 @@ static void file_update_top(ZebraHandle zh, Dict dict, const char *path) char dst[1024]; int src_len, ret; - assert (path); + assert(path); if (zh->path_reg && !yaz_is_abspath(path)) { - strcpy (src, zh->path_reg); - strcat (src, "/"); + strcpy(src, zh->path_reg); + strcat(src, "/"); } else *src = '\0'; - strcat (src, path); - ret = zebra_file_stat (src, &sbuf, zh->m_follow_links); + strcat(src, path); + ret = zebra_file_stat(src, &sbuf, zh->m_follow_links); - strcpy (src, path); - src_len = strlen (src); + strcpy(src, path); + src_len = strlen(src); if (ret == -1) { @@ -262,20 +262,20 @@ static void file_update_top(ZebraHandle zh, Dict dict, const char *path) else if (S_ISREG(sbuf.st_mode)) { struct dirs_entry *e_dst; - di = dirs_fopen (dict, src, zh->m_flag_rw); + di = dirs_fopen(dict, src, zh->m_flag_rw); e_dst = dirs_read(di); if (e_dst) { if (sbuf.st_mtime > e_dst->mtime) - if (zebra_extract_file (zh, &e_dst->sysno, src, 0) == ZEBRA_OK) - dirs_add (di, src, e_dst->sysno, sbuf.st_mtime); + if (zebra_extract_file(zh, &e_dst->sysno, src, 0) == ZEBRA_OK) + dirs_add(di, src, e_dst->sysno, sbuf.st_mtime); } else { zint sysno = 0; - if (zebra_extract_file (zh, &sysno, src, 0) == ZEBRA_OK) - dirs_add (di, src, sysno, sbuf.st_mtime); + if (zebra_extract_file(zh, &sysno, src, 0) == ZEBRA_OK) + dirs_add(di, src, sysno, sbuf.st_mtime); } dirs_free(&di); } @@ -286,9 +286,9 @@ static void file_update_top(ZebraHandle zh, Dict dict, const char *path) src[src_len] = '/'; src[++src_len] = '\0'; } - di = dirs_open (dict, src, zh->m_flag_rw); + di = dirs_open(dict, src, zh->m_flag_rw); *dst = '\0'; - file_update_r(zh, di, dirs_read (di), src, dst, 0); + file_update_r(zh, di, dirs_read(di), src, dst, 0); dirs_free (&di); } else @@ -304,7 +304,7 @@ static ZEBRA_RES zebra_open_fmatch(ZebraHandle zh, Dict *dictp) ord = zebraExplain_get_database_ord(zh->reg->zei); sprintf(fmatch_fname, FMATCH_DICT, ord); - if (!(*dictp = dict_open_res (zh->reg->bfs, fmatch_fname, 50, + if (!(*dictp = dict_open_res(zh->reg->bfs, fmatch_fname, 50, zh->m_flag_rw, 0, zh->res))) { yaz_log(YLOG_FATAL, "dict_open fail of %s", fmatch_fname); @@ -330,7 +330,7 @@ ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path) { Dict dict; - if (zebraExplain_curDatabase (zh->reg->zei, zh->basenames[0])) + if (zebraExplain_curDatabase(zh->reg->zei, zh->basenames[0])) { if (zebraExplain_newDatabase(zh->reg->zei, zh->basenames[0], 0)) return ZEBRA_FAIL; @@ -341,7 +341,7 @@ ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path) if (!strcmp(path, "") || !strcmp(path, "-")) { char src[1024]; - while (scanf ("%s", src) == 1) + while (scanf("%s", src) == 1) file_update_top(zh, dict, src); } else @@ -349,7 +349,7 @@ ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path) #if 0 dump_file_dict(dict); #endif - dict_close (dict); + dict_close(dict); return ZEBRA_OK; } diff --git a/index/update_path.c b/index/update_path.c index f2a9cea..93d6b7f 100644 --- a/index/update_path.c +++ b/index/update_path.c @@ -1,4 +1,4 @@ -/* $Id: update_path.c,v 1.3 2007-01-15 15:10:17 adam Exp $ +/* $Id: update_path.c,v 1.4 2007-10-29 09:25:41 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -42,12 +42,12 @@ static void repositoryExtractR(ZebraHandle zh, int deleteFlag, char *rep, { struct dir_entry *e; int i; - size_t rep_len = strlen (rep); + size_t rep_len = strlen(rep); - e = dir_open (rep, zh->path_reg, zh->m_follow_links); + e = dir_open(rep, zh->path_reg, zh->m_follow_links); if (!e) return; - yaz_log (YLOG_LOG, "dir %s", rep); + yaz_log(YLOG_LOG, "dir %s", rep); if (rep[rep_len-1] != '/') rep[rep_len] = '/'; else @@ -56,21 +56,21 @@ static void repositoryExtractR(ZebraHandle zh, int deleteFlag, char *rep, for (i=0; e[i].name; i++) { char *ecp; - strcpy (rep +rep_len+1, e[i].name); - if ((ecp = strrchr (e[i].name, '/'))) + strcpy(rep +rep_len+1, e[i].name); + if ((ecp = strrchr(e[i].name, '/'))) *ecp = '\0'; switch (e[i].kind) { case dirs_file: - zebra_extract_file (zh, NULL, rep, deleteFlag); + zebra_extract_file(zh, NULL, rep, deleteFlag); break; case dirs_dir: - repositoryExtractR (zh, deleteFlag, rep, level+1); + repositoryExtractR(zh, deleteFlag, rep, level+1); break; } } - dir_free (&e); + dir_free(&e); } @@ -82,15 +82,15 @@ void repositoryShow(ZebraHandle zh, const char *path) Dict dict; struct dirs_info *di; - if (!(dict = dict_open_res (zh->reg->bfs, FMATCH_DICT, 50, 0, 0, zh->res))) + if (!(dict = dict_open_res(zh->reg->bfs, FMATCH_DICT, 50, 0, 0, zh->res))) { - yaz_log (YLOG_FATAL, "dict_open fail of %s", FMATCH_DICT); + yaz_log(YLOG_FATAL, "dict_open fail of %s", FMATCH_DICT); return; } strncpy(src, path, sizeof(src)-1); src[sizeof(src)-1]='\0'; - src_len = strlen (src); + src_len = strlen(src); if (src_len && src[src_len-1] != '/') { @@ -98,12 +98,12 @@ void repositoryShow(ZebraHandle zh, const char *path) src[++src_len] = '\0'; } - di = dirs_open (dict, src, zh->m_flag_rw); + di = dirs_open(dict, src, zh->m_flag_rw); - while ( (dst = dirs_read (di)) ) - yaz_log (YLOG_LOG, "%s", dst->path); - dirs_free (&di); - dict_close (dict); + while ((dst = dirs_read(di))) + yaz_log(YLOG_LOG, "%s", dst->path); + dirs_free(&di); + dict_close(dict); } static void repositoryExtract(ZebraHandle zh, @@ -117,24 +117,24 @@ static void repositoryExtract(ZebraHandle zh, if (zh->path_reg && !yaz_is_abspath(path)) { - strcpy (src, zh->path_reg); - strcat (src, "/"); + strcpy(src, zh->path_reg); + strcat(src, "/"); } else *src = '\0'; - strcat (src, path); - ret = zebra_file_stat (src, &sbuf, zh->m_follow_links); + strcat(src, path); + ret = zebra_file_stat(src, &sbuf, zh->m_follow_links); - strcpy (src, path); + strcpy(src, path); if (ret == -1) - yaz_log (YLOG_WARN|YLOG_ERRNO, "Cannot access path %s", src); + yaz_log(YLOG_WARN|YLOG_ERRNO, "Cannot access path %s", src); else if (S_ISREG(sbuf.st_mode)) - zebra_extract_file (zh, NULL, src, deleteFlag); + zebra_extract_file(zh, NULL, src, deleteFlag); else if (S_ISDIR(sbuf.st_mode)) - repositoryExtractR (zh, deleteFlag, src, 0); + repositoryExtractR(zh, deleteFlag, src, 0); else - yaz_log (YLOG_WARN, "Skipping path %s", src); + yaz_log(YLOG_WARN, "Skipping path %s", src); } static void repositoryExtractG(ZebraHandle zh, const char *path, @@ -153,14 +153,14 @@ static void repositoryExtractG(ZebraHandle zh, const char *path, ZEBRA_RES zebra_update_from_path(ZebraHandle zh, const char *path) { - assert (path); + assert(path); repositoryExtractG(zh, path, 0); return ZEBRA_OK; } ZEBRA_RES zebra_delete_from_path(ZebraHandle zh, const char *path) { - assert (path); + assert(path); repositoryExtractG(zh, path, 1); return ZEBRA_OK; } diff --git a/index/zebraapi.c b/index/zebraapi.c index b8f3936..f648db9 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.259 2007-08-28 21:40:57 adam Exp $ +/* $Id: zebraapi.c,v 1.260 2007-10-29 09:25:41 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -381,6 +381,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, data1_set_tabroot (reg->dh, reg_path); reg->recTypes = recTypes_init (zs->record_classes, reg->dh); + reg->index_types = 0; reg->zebra_maps = zebra_maps_open(res, reg_path, profilePath); if (!reg->zebra_maps) @@ -419,7 +420,30 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, if (!strcmp (recordCompression, "bzip2")) record_compression = REC_COMPRESS_BZIP2; - if (1) + { + const char *index_types_fname = res_get(res, "indextypes"); + if (index_types_fname) + { + char tmp_full_name[1024]; + + if (!yaz_filepath_resolve(index_types_fname, + profilePath, + reg_path, + tmp_full_name)) + { + yaz_log(YLOG_WARN, "Could not find %s", index_types_fname); + ret = ZEBRA_FAIL; + } + else + { + reg->index_types = zebra_index_types_create( + tmp_full_name); + yaz_log(YLOG_LOG, "zebra_index_types_create returned %p", + reg->index_types); + } + } + + } { const char *index_fname = res_get_def(res, "index", "default.idx"); if (index_fname && *index_fname) @@ -580,6 +604,7 @@ static void zebra_register_close(ZebraService zs, struct zebra_register *reg) recTypes_destroy (reg->recTypes); zebra_maps_close (reg->zebra_maps); + zebra_index_types_destroy(reg->index_types); zebraRankDestroy (reg); bfs_destroy (reg->bfs); data1_destroy (reg->dh); diff --git a/index/zebraidx.c b/index/zebraidx.c index b3e8c23..a1378a2 100644 --- a/index/zebraidx.c +++ b/index/zebraidx.c @@ -1,4 +1,4 @@ -/* $Id: zebraidx.c,v 1.8 2007-10-23 12:39:48 adam Exp $ +/* $Id: zebraidx.c,v 1.9 2007-10-29 09:25:41 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -43,7 +43,7 @@ char *prog; static void filter_cb(void *cd, const char *name) { - puts (name); + puts(name); } static void show_filters(ZebraService zs) @@ -51,7 +51,7 @@ static void show_filters(ZebraService zs) zebra_filter_info(zs, 0, filter_cb); } -int main (int argc, char **argv) +int main(int argc, char **argv) { int ret; int cmd = 0; @@ -73,12 +73,12 @@ int main (int argc, char **argv) #ifdef WIN32 #else sprintf(nbuf, "%.40s(%ld)", *argv, (long) getpid()); - yaz_log_init_prefix (nbuf); + yaz_log_init_prefix(nbuf); #endif prog = *argv; if (argc < 2) { - fprintf (stderr, "%s [options] command ...\n" + fprintf(stderr, "%s [options] command ...\n" "Commands:\n" " update Update index with files below .\n" " If is empty filenames are read from stdin.\n" @@ -101,7 +101,7 @@ int main (int argc, char **argv) " -f Display information for the first records.\n" " -V Show version.\n", *argv ); - exit (1); + exit(1); } res_set(default_res, "profilePath", DEFAULT_PROFILE_PATH); res_set(default_res, "modulePath", DEFAULT_MODULE_PATH); @@ -117,34 +117,34 @@ int main (int argc, char **argv) zs = zebra_start_res(config, default_res, res); if (!zs) { - yaz_log (YLOG_FATAL, "Cannot read config %s", config); - exit (1); + yaz_log(YLOG_FATAL, "Cannot read config %s", config); + exit(1); } - zh = zebra_open (zs, 0); - zebra_shadow_enable (zh, enable_commit); + zh = zebra_open(zs, 0); + zebra_shadow_enable(zh, enable_commit); } if (database && - zebra_select_database (zh, database) == ZEBRA_FAIL) + zebra_select_database(zh, database) == ZEBRA_FAIL) { yaz_log(YLOG_FATAL, "Could not select database %s " "errCode=%d", database, zebra_errCode(zh) ); - exit (1); + exit(1); } - if (!strcmp (arg, "update")) + if (!strcmp(arg, "update")) cmd = 'u'; - else if (!strcmp (arg, "update1")) + else if (!strcmp(arg, "update1")) cmd = 'U'; - else if (!strcmp (arg, "update2")) + else if (!strcmp(arg, "update2")) cmd = 'm'; - else if (!strcmp (arg, "dump")) + else if (!strcmp(arg, "dump")) cmd = 's'; - else if (!strcmp (arg, "del") || !strcmp(arg, "delete")) + else if (!strcmp(arg, "del") || !strcmp(arg, "delete")) cmd = 'd'; - else if (!strcmp (arg, "init")) + else if (!strcmp(arg, "init")) { - zebra_init (zh); + zebra_init(zh); } else if (!strcmp(arg, "drop")) { @@ -154,34 +154,34 @@ int main (int argc, char **argv) { cmd = 'C'; } - else if (!strcmp (arg, "commit")) + else if (!strcmp(arg, "commit")) { - zebra_commit (zh); + zebra_commit(zh); } - else if (!strcmp (arg, "clean")) + else if (!strcmp(arg, "clean")) { - zebra_clean (zh); + zebra_clean(zh); } - else if (!strcmp (arg, "stat") || !strcmp (arg, "status")) + else if (!strcmp(arg, "stat") || !strcmp(arg, "status")) { - zebra_register_statistics (zh,0); + zebra_register_statistics(zh, 0); } - else if (!strcmp (arg, "dumpdict")) + else if (!strcmp(arg, "dumpdict")) { - zebra_register_statistics (zh,1); + zebra_register_statistics(zh, 1); } - else if (!strcmp (arg, "compact")) + else if (!strcmp(arg, "compact")) { - zebra_compact (zh); + zebra_compact(zh); } - else if (!strcmp (arg, "filters")) + else if (!strcmp(arg, "filters")) { show_filters(zs); } else { - yaz_log (YLOG_FATAL, "unknown command: %s", arg); - exit (1); + yaz_log(YLOG_FATAL, "unknown command: %s", arg); + exit(1); } } else @@ -190,19 +190,19 @@ int main (int argc, char **argv) if (!trans_started) { trans_started=1; - if (zebra_begin_trans (zh, 1) != ZEBRA_OK) + if (zebra_begin_trans(zh, 1) != ZEBRA_OK) exit(1); } switch (cmd) { case 'u': - res = zebra_repository_update (zh, arg); + res = zebra_repository_update(zh, arg); break; case 'd': - res = zebra_repository_delete (zh, arg); + res = zebra_repository_delete(zh, arg); break; case 's': - res = zebra_repository_show (zh, arg); + res = zebra_repository_show(zh, arg); nsections = 0; break; case 'C': @@ -221,15 +221,15 @@ int main (int argc, char **argv) zebra_errString(zh), add ? add : ""); if (trans_started) - if (zebra_end_trans (zh) != ZEBRA_OK) - yaz_log (YLOG_WARN, "zebra_end_trans failed"); + if (zebra_end_trans(zh) != ZEBRA_OK) + yaz_log(YLOG_WARN, "zebra_end_trans failed"); - zebra_close (zh); - zebra_stop (zs); + zebra_close(zh); + zebra_stop(zs); exit(1); } - log_event_end (NULL, NULL); + log_event_end(NULL, NULL); } } else if (ret == 'V') @@ -250,9 +250,9 @@ int main (int argc, char **argv) #endif } else if (ret == 'v') - yaz_log_init_level (yaz_log_mask_str(arg)); + yaz_log_init_level(yaz_log_mask_str(arg)); else if (ret == 'l') - yaz_log_init_file (arg); + yaz_log_init_file(arg); else if (ret == 'm') res_set(res, "memMax", arg); else if (ret == 'd') @@ -272,19 +272,19 @@ int main (int argc, char **argv) else if (ret == 'L') res_set(res, "followLinks", "0"); else - yaz_log (YLOG_WARN, "unknown option '-%s'", arg); + yaz_log(YLOG_WARN, "unknown option '-%s'", arg); } /* while arg */ if (trans_started) - if (zebra_end_trans (zh) != ZEBRA_OK) - yaz_log (YLOG_WARN, "zebra_end_trans failed"); + if (zebra_end_trans(zh) != ZEBRA_OK) + yaz_log(YLOG_WARN, "zebra_end_trans failed"); - zebra_close (zh); - zebra_stop (zs); + zebra_close(zh); + zebra_stop(zs); res_close(res); res_close(default_res); - exit (0); + exit(0); return 0; } diff --git a/index/zebrasrv.c b/index/zebrasrv.c index 9629d41..c024465 100644 --- a/index/zebrasrv.c +++ b/index/zebrasrv.c @@ -1,4 +1,4 @@ -/* $Id: zebrasrv.c,v 1.20 2007-10-25 07:43:13 adam Exp $ +/* $Id: zebrasrv.c,v 1.21 2007-10-29 09:25:41 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -45,18 +45,18 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -static int bend_sort (void *handle, bend_sort_rr *rr); -static int bend_delete (void *handle, bend_delete_rr *rr); -static int bend_esrequest (void *handle, bend_esrequest_rr *rr); -static int bend_segment (void *handle, bend_segment_rr *rr); -static int bend_search (void *handle, bend_search_rr *r); -static int bend_fetch (void *handle, bend_fetch_rr *r); -static int bend_scan (void *handle, bend_scan_rr *r); +static int bend_sort(void *handle, bend_sort_rr *rr); +static int bend_delete(void *handle, bend_delete_rr *rr); +static int bend_esrequest(void *handle, bend_esrequest_rr *rr); +static int bend_segment(void *handle, bend_segment_rr *rr); +static int bend_search(void *handle, bend_search_rr *r); +static int bend_fetch(void *handle, bend_fetch_rr *r); +static int bend_scan(void *handle, bend_scan_rr *r); -bend_initresult *bend_init (bend_initrequest *q) +bend_initresult *bend_init(bend_initrequest *q) { bend_initresult *r = (bend_initresult *) - odr_malloc (q->stream, sizeof(*r)); + odr_malloc(q->stream, sizeof(*r)); ZebraHandle zh; struct statserv_options_block *sob; char *user = NULL; @@ -78,12 +78,12 @@ bend_initresult *bend_init (bend_initrequest *q) q->implementation_name = "Zebra Information Server"; q->implementation_version = odr_strdup(q->stream, version_str); - yaz_log (YLOG_DEBUG, "bend_init"); + yaz_log(YLOG_DEBUG, "bend_init"); - sob = statserv_getcontrol (); - if (!(zh = zebra_open (sob->handle, 0))) + sob = statserv_getcontrol(); + if (!(zh = zebra_open(sob->handle, 0))) { - yaz_log (YLOG_WARN, "Failed to read config `%s'", sob->configname); + yaz_log(YLOG_WARN, "Failed to read config `%s'", sob->configname); r->errcode = YAZ_BIB1_PERMANENT_SYSTEM_ERROR; return r; } @@ -94,15 +94,15 @@ bend_initresult *bend_init (bend_initrequest *q) { if (q->auth->which == Z_IdAuthentication_open) { - char *openpass = xstrdup (q->auth->u.open); - char *cp = strchr (openpass, '/'); + char *openpass = xstrdup(q->auth->u.open); + char *cp = strchr(openpass, '/'); if (cp) { *cp = '\0'; - user = nmem_strdup (odr_getmem (q->stream), openpass); - passwd = nmem_strdup (odr_getmem (q->stream), cp+1); + user = nmem_strdup(odr_getmem(q->stream), openpass); + passwd = nmem_strdup(odr_getmem(q->stream), cp+1); } - xfree (openpass); + xfree(openpass); } else if (q->auth->which == Z_IdAuthentication_idPass) { @@ -189,26 +189,26 @@ static void search_terms(ZebraHandle zh, bend_search_rr *r) if (!no_terms) return; - r->search_info = odr_malloc (r->stream, sizeof(*r->search_info)); + r->search_info = odr_malloc(r->stream, sizeof(*r->search_info)); r->search_info->num_elements = 1; r->search_info->list = - odr_malloc (r->stream, sizeof(*r->search_info->list)); + odr_malloc(r->stream, sizeof(*r->search_info->list)); r->search_info->list[0] = - odr_malloc (r->stream, sizeof(**r->search_info->list)); + odr_malloc(r->stream, sizeof(**r->search_info->list)); r->search_info->list[0]->category = 0; r->search_info->list[0]->which = Z_OtherInfo_externallyDefinedInfo; - ext = odr_malloc (r->stream, sizeof(*ext)); + ext = odr_malloc(r->stream, sizeof(*ext)); r->search_info->list[0]->information.externallyDefinedInfo = ext; ext->direct_reference = odr_oiddup(r->stream, yaz_oid_userinfo_searchresult_1); ext->indirect_reference = 0; ext->descriptor = 0; ext->which = Z_External_searchResult1; - sr = odr_malloc (r->stream, sizeof(Z_SearchInfoReport)); + sr = odr_malloc(r->stream, sizeof(Z_SearchInfoReport)); ext->u.searchResult1 = sr; sr->num = no_terms; - sr->elements = odr_malloc (r->stream, sr->num * + sr->elements = odr_malloc(r->stream, sr->num * sizeof(*sr->elements)); for (i = 0; isetname, i, &count, &approx, outbuf, &len, &term_ref_id); - se = sr->elements[i] = odr_malloc (r->stream, sizeof(**sr->elements)); + se = sr->elements[i] = odr_malloc(r->stream, sizeof(**sr->elements)); se->subqueryId = term_ref_id ? odr_strdup(r->stream, term_ref_id) : 0; se->fullQuery = odr_intdup(r->stream, 0); se->subqueryExpression = - odr_malloc (r->stream, sizeof(Z_QueryExpression)); + odr_malloc(r->stream, sizeof(Z_QueryExpression)); se->subqueryExpression->which = Z_QueryExpression_term; se->subqueryExpression->u.term = - odr_malloc (r->stream, sizeof(Z_QueryExpressionTerm)); - term = odr_malloc (r->stream, sizeof(Z_Term)); + odr_malloc(r->stream, sizeof(Z_QueryExpressionTerm)); + term = odr_malloc(r->stream, sizeof(Z_Term)); se->subqueryExpression->u.term->queryTerm = term; switch (type) { case Z_Term_characterString: term->which = Z_Term_characterString; - term->u.characterString = odr_strdup (r->stream, outbuf); + term->u.characterString = odr_strdup(r->stream, outbuf); break; case Z_Term_general: term->which = Z_Term_general; - term->u.general = odr_malloc (r->stream, sizeof(*term->u.general)); + term->u.general = odr_malloc(r->stream, sizeof(*term->u.general)); term->u.general->size = term->u.general->len = len; - term->u.general->buf = odr_malloc (r->stream, len); - memcpy (term->u.general->buf, outbuf, len); + term->u.general->buf = odr_malloc(r->stream, len); + memcpy(term->u.general->buf, outbuf, len); break; default: term->which = Z_Term_general; @@ -279,15 +279,15 @@ int bend_search(void *handle, bend_search_rr *r) zint zhits = 0; ZEBRA_RES res; - res = zebra_select_databases (zh, r->num_bases, + res = zebra_select_databases(zh, r->num_bases, (const char **) r->basenames); if (res != ZEBRA_OK) { - zebra_result (zh, &r->errcode, &r->errstring); + zebra_result(zh, &r->errcode, &r->errstring); return 0; } zebra_set_break_handler(zh, break_handler, r->association); - yaz_log (YLOG_DEBUG, "ResultSet '%s'", r->setname); + yaz_log(YLOG_DEBUG, "ResultSet '%s'", r->setname); switch (r->query->which) { case Z_Query_type_1: case Z_Query_type_101: @@ -302,7 +302,7 @@ int bend_search(void *handle, bend_search_rr *r) if (zhits > 2147483646) zhits = 2147483647; r->hits = CAST_ZINT_TO_INT(zhits); - search_terms (zh, r); + search_terms(zh, r); } break; case Z_Query_type_2: @@ -326,12 +326,12 @@ int bend_fetch(void *handle, bend_fetch_rr *r) retrievalRecord.position = r->number; r->last_in_set = 0; - res = zebra_records_retrieve (zh, r->stream, r->setname, r->comp, + res = zebra_records_retrieve(zh, r->stream, r->setname, r->comp, r->request_format, 1, &retrievalRecord); if (res != ZEBRA_OK) { /* non-surrogate diagnostic */ - zebra_result (zh, &r->errcode, &r->errstring); + zebra_result(zh, &r->errcode, &r->errstring); } else if (retrievalRecord.errCode) { @@ -351,7 +351,7 @@ int bend_fetch(void *handle, bend_fetch_rr *r) return 0; } -static int bend_scan (void *handle, bend_scan_rr *r) +static int bend_scan(void *handle, bend_scan_rr *r) { ZebraScanEntry *entries; ZebraHandle zh = (ZebraHandle) handle; @@ -362,7 +362,7 @@ static int bend_scan (void *handle, bend_scan_rr *r) (const char **) r->basenames); if (res != ZEBRA_OK) { - zebra_result (zh, &r->errcode, &r->errstring); + zebra_result(zh, &r->errcode, &r->errstring); return 0; } if (r->step_size != 0 && *r->step_size != 0) { @@ -397,25 +397,25 @@ static int bend_scan (void *handle, bend_scan_rr *r) return 0; } -void bend_close (void *handle) +void bend_close(void *handle) { - zebra_close ((ZebraHandle) handle); + zebra_close((ZebraHandle) handle); xmalloc_trav("bend_close"); } -int bend_sort (void *handle, bend_sort_rr *rr) +int bend_sort(void *handle, bend_sort_rr *rr) { ZebraHandle zh = (ZebraHandle) handle; - if (zebra_sort (zh, rr->stream, + if (zebra_sort(zh, rr->stream, rr->num_input_setnames, (const char **) rr->input_setnames, rr->output_setname, rr->sort_sequence, &rr->sort_status) != ZEBRA_OK) - zebra_result (zh, &rr->errcode, &rr->errstring); + zebra_result(zh, &rr->errcode, &rr->errstring); return 0; } -int bend_delete (void *handle, bend_delete_rr *rr) +int bend_delete(void *handle, bend_delete_rr *rr) { ZebraHandle zh = (ZebraHandle) handle; @@ -425,7 +425,7 @@ int bend_delete (void *handle, bend_delete_rr *rr) return 0; } -static void es_admin_request (bend_esrequest_rr *rr, ZebraHandle zh, Z_AdminEsRequest *r) +static void es_admin_request(bend_esrequest_rr *rr, ZebraHandle zh, Z_AdminEsRequest *r) { ZEBRA_RES res = ZEBRA_OK; if (r->toKeep->databaseName) @@ -446,15 +446,15 @@ static void es_admin_request (bend_esrequest_rr *rr, ZebraHandle zh, Z_AdminEsRe break; case Z_ESAdminOriginPartToKeep_drop: yaz_log(YLOG_LOG, "adm-drop"); - res = zebra_drop_database (zh, r->toKeep->databaseName); + res = zebra_drop_database(zh, r->toKeep->databaseName); break; case Z_ESAdminOriginPartToKeep_create: yaz_log(YLOG_LOG, "adm-create %s", r->toKeep->databaseName); - res = zebra_create_database (zh, r->toKeep->databaseName); + res = zebra_create_database(zh, r->toKeep->databaseName); break; case Z_ESAdminOriginPartToKeep_import: yaz_log(YLOG_LOG, "adm-import"); - res = zebra_admin_import_begin (zh, r->toKeep->databaseName, + res = zebra_admin_import_begin(zh, r->toKeep->databaseName, r->toKeep->u.import->recordType); break; case Z_ESAdminOriginPartToKeep_refresh: @@ -488,34 +488,34 @@ static void es_admin_request (bend_esrequest_rr *rr, ZebraHandle zh, Z_AdminEsRe zebra_result(zh, &rr->errcode, &rr->errstring); } -static void es_admin (bend_esrequest_rr *rr, ZebraHandle zh, Z_Admin *r) +static void es_admin(bend_esrequest_rr *rr, ZebraHandle zh, Z_Admin *r) { switch (r->which) { case Z_Admin_esRequest: - es_admin_request (rr, zh, r->u.esRequest); + es_admin_request(rr, zh, r->u.esRequest); return; default: break; } - yaz_log (YLOG_WARN, "adm taskpackage (unhandled)"); + yaz_log(YLOG_WARN, "adm taskpackage (unhandled)"); rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED; rr->errstring = "adm-task package (unhandled)"; } -int bend_segment (void *handle, bend_segment_rr *rr) +int bend_segment(void *handle, bend_segment_rr *rr) { ZebraHandle zh = (ZebraHandle) handle; Z_Segment *segment = rr->segment; if (segment->num_segmentRecords) - zebra_admin_import_segment (zh, rr->segment); + zebra_admin_import_segment(zh, rr->segment); else - zebra_admin_import_end (zh); + zebra_admin_import_end(zh); return 0; } -int bend_esrequest (void *handle, bend_esrequest_rr *rr) +int bend_esrequest(void *handle, bend_esrequest_rr *rr) { ZebraHandle zh = (ZebraHandle) handle; @@ -526,7 +526,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) if (!rr->esr->taskSpecificParameters) { - yaz_log (YLOG_WARN, "No task specific parameters"); + yaz_log(YLOG_WARN, "No task specific parameters"); } else if (rr->esr->taskSpecificParameters->which == Z_External_ESAdmin) { @@ -535,53 +535,53 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) else if (rr->esr->taskSpecificParameters->which == Z_External_update) { Z_IUUpdate *up = rr->esr->taskSpecificParameters->u.update; - yaz_log (YLOG_LOG, "Received DB Update"); + yaz_log(YLOG_LOG, "Received DB Update"); if (up->which == Z_IUUpdate_esRequest) { Z_IUUpdateEsRequest *esRequest = up->u.esRequest; Z_IUOriginPartToKeep *toKeep = esRequest->toKeep; Z_IUSuppliedRecords *notToKeep = esRequest->notToKeep; - yaz_log (YLOG_LOG, "action"); + yaz_log(YLOG_LOG, "action"); if (toKeep->action) { switch (*toKeep->action) { case Z_IUOriginPartToKeep_recordInsert: - yaz_log (YLOG_LOG, "recordInsert"); + yaz_log(YLOG_LOG, "recordInsert"); break; case Z_IUOriginPartToKeep_recordReplace: - yaz_log (YLOG_LOG, "recordUpdate"); + yaz_log(YLOG_LOG, "recordUpdate"); break; case Z_IUOriginPartToKeep_recordDelete: - yaz_log (YLOG_LOG, "recordDelete"); + yaz_log(YLOG_LOG, "recordDelete"); break; case Z_IUOriginPartToKeep_elementUpdate: - yaz_log (YLOG_LOG, "elementUpdate"); + yaz_log(YLOG_LOG, "elementUpdate"); break; case Z_IUOriginPartToKeep_specialUpdate: - yaz_log (YLOG_LOG, "specialUpdate"); + yaz_log(YLOG_LOG, "specialUpdate"); break; case Z_ESAdminOriginPartToKeep_shutdown: - yaz_log (YLOG_LOG, "shutDown"); + yaz_log(YLOG_LOG, "shutDown"); break; case Z_ESAdminOriginPartToKeep_start: - yaz_log (YLOG_LOG, "start"); + yaz_log(YLOG_LOG, "start"); break; default: - yaz_log (YLOG_LOG, " unknown (%d)", *toKeep->action); + yaz_log(YLOG_LOG, " unknown (%d)", *toKeep->action); } } if (toKeep->databaseName) { - yaz_log (YLOG_LOG, "database: %s", toKeep->databaseName); + yaz_log(YLOG_LOG, "database: %s", toKeep->databaseName); if (zebra_select_database(zh, toKeep->databaseName)) return 0; } else { - yaz_log (YLOG_WARN, "no database supplied for ES Update"); + yaz_log(YLOG_WARN, "no database supplied for ES Update"); rr->errcode = YAZ_BIB1_ES_MISSING_MANDATORY_PARAMETER_FOR_SPECIFIED_FUNCTION_; rr->errstring = "database"; @@ -622,28 +622,28 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) rec->direct_reference, 0, oid_name_str); if (oid_name) - yaz_log (YLOG_LOG, "record %d type %s", i, + yaz_log(YLOG_LOG, "record %d type %s", i, oid_name); } switch (rec->which) { case Z_External_sutrs: if (rec->u.octet_aligned->len > 170) - yaz_log (YLOG_LOG, "%d bytes:\n%.168s ...", + yaz_log(YLOG_LOG, "%d bytes:\n%.168s ...", rec->u.sutrs->len, rec->u.sutrs->buf); else - yaz_log (YLOG_LOG, "%d bytes:\n%s", + yaz_log(YLOG_LOG, "%d bytes:\n%s", rec->u.sutrs->len, rec->u.sutrs->buf); break; case Z_External_octet: if (rec->u.octet_aligned->len > 170) - yaz_log (YLOG_LOG, "%d bytes:\n%.168s ...", + yaz_log(YLOG_LOG, "%d bytes:\n%.168s ...", rec->u.octet_aligned->len, rec->u.octet_aligned->buf); else - yaz_log (YLOG_LOG, "%d bytes\n%s", + yaz_log(YLOG_LOG, "%d bytes\n%s", rec->u.octet_aligned->len, rec->u.octet_aligned->buf); } @@ -701,7 +701,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) } } } - if (zebra_end_trans (zh) != ZEBRA_OK) + if (zebra_end_trans(zh) != ZEBRA_OK) { yaz_log(YLOG_WARN, "zebra_end_trans failed for" " extended service operation"); @@ -711,7 +711,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) } else { - yaz_log (YLOG_WARN, "Unknown Extended Service(%d)", + yaz_log(YLOG_WARN, "Unknown Extended Service(%d)", rr->esr->taskSpecificParameters->which); rr->errcode = YAZ_BIB1_ES_EXTENDED_SERVICE_TYPE_UNSUPP; @@ -719,7 +719,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) return 0; } -static void bend_start (struct statserv_options_block *sob) +static void bend_start(struct statserv_options_block *sob) { Res default_res = res_open(0, 0); @@ -731,8 +731,8 @@ static void bend_start (struct statserv_options_block *sob) res_close(default_res); if (!sob->handle) { - yaz_log (YLOG_FATAL, "Failed to read config `%s'", sob->configname); - exit (1); + yaz_log(YLOG_FATAL, "Failed to read config `%s'", sob->configname); + exit(1); } #ifdef WIN32 @@ -745,7 +745,7 @@ static void bend_start (struct statserv_options_block *sob) zebra_pidfname(sob->handle, pidfname); - fd = open (pidfname, O_EXCL|O_WRONLY|O_CREAT, 0666); + fd = open(pidfname, O_EXCL|O_WRONLY|O_CREAT, 0666); if (fd == -1) { if (errno != EEXIST) @@ -763,7 +763,7 @@ static void bend_start (struct statserv_options_block *sob) area.l_type = F_WRLCK; area.l_whence = SEEK_SET; area.l_len = area.l_start = 0L; - if (fcntl (fd, F_SETLK, &area) == -1) + if (fcntl(fd, F_SETLK, &area) == -1) { yaz_log(YLOG_ERRNO|YLOG_FATAL, "Zebra server already running"); exit(1); @@ -772,8 +772,8 @@ static void bend_start (struct statserv_options_block *sob) { char pidstr[30]; - sprintf (pidstr, "%ld", (long) getpid ()); - write (fd, pidstr, strlen(pidstr)); + sprintf(pidstr, "%ld", (long) getpid()); + write(fd, pidstr, strlen(pidstr)); } } #endif @@ -788,7 +788,7 @@ static void bend_stop(struct statserv_options_block *sob) { char pidfname[4096]; zebra_pidfname(sob->handle, pidfname); - unlink (pidfname); + unlink(pidfname); } #endif if (sob->handle) @@ -798,20 +798,20 @@ static void bend_stop(struct statserv_options_block *sob) } } -int main (int argc, char **argv) +int main(int argc, char **argv) { struct statserv_options_block *sob; - sob = statserv_getcontrol (); - strcpy (sob->configname, "zebra.cfg"); + sob = statserv_getcontrol(); + strcpy(sob->configname, "zebra.cfg"); sob->bend_start = bend_start; sob->bend_stop = bend_stop; #ifdef WIN32 - strcpy (sob->service_display_name, "Zebra Server"); + strcpy(sob->service_display_name, "Zebra Server"); #endif - statserv_setcontrol (sob); + statserv_setcontrol(sob); - return statserv_main (argc, argv, bend_init, bend_close); + return statserv_main(argc, argv, bend_init, bend_close); } /* * Local variables: diff --git a/index/zinfo.h b/index/zinfo.h index a3175b5..fd46688 100644 --- a/index/zinfo.h +++ b/index/zinfo.h @@ -1,4 +1,4 @@ -/* $Id: zinfo.h,v 1.38 2007-01-15 20:08:25 adam Exp $ +/* $Id: zinfo.h,v 1.39 2007-10-29 09:25:41 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -56,9 +56,9 @@ ZebraExplainInfo zebraExplain_open(Records records, data1_handle dh, void *updateHandle, ZebraExplainUpdateFunc *); -void zebraExplain_close (ZebraExplainInfo zei); -int zebraExplain_curDatabase (ZebraExplainInfo zei, const char *database); -int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, +void zebraExplain_close(ZebraExplainInfo zei); +int zebraExplain_curDatabase(ZebraExplainInfo zei, const char *database); +int zebraExplain_newDatabase(ZebraExplainInfo zei, const char *database, int explain_database); int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type, int set, int use); @@ -79,14 +79,14 @@ int zebraExplain_add_attr_str(ZebraExplainInfo zei, zinfo_index_category_t cat, int index_type, const char *str); -void zebraExplain_addSchema (ZebraExplainInfo zei, Odr_oid *oid); -void zebraExplain_recordCountIncrement (ZebraExplainInfo zei, int adjust_num); -void zebraExplain_recordBytesIncrement (ZebraExplainInfo zei, int adjust_num); -zint zebraExplain_runNumberIncrement (ZebraExplainInfo zei, int adjust_num); -void zebraExplain_loadAttsets (data1_handle dh, Res res); -void zebraExplain_flush (ZebraExplainInfo zei, void *updateHandle); - -int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord, +void zebraExplain_addSchema(ZebraExplainInfo zei, Odr_oid *oid); +void zebraExplain_recordCountIncrement(ZebraExplainInfo zei, int adjust_num); +void zebraExplain_recordBytesIncrement(ZebraExplainInfo zei, int adjust_num); +zint zebraExplain_runNumberIncrement(ZebraExplainInfo zei, int adjust_num); +void zebraExplain_loadAttsets(data1_handle dh, Res res); +void zebraExplain_flush(ZebraExplainInfo zei, void *updateHandle); + +int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord, int *index_type, const char **db, const char **string_index); @@ -108,7 +108,7 @@ typedef struct { zint runNumber; zint staticrank; } RecordAttr; -RecordAttr *rec_init_attr (ZebraExplainInfo zei, Record rec); +RecordAttr *rec_init_attr(ZebraExplainInfo zei, Record rec); YAZ_END_CDECL