# 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
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
-/* $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
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");
-/* $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
#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
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;
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;
}
/*
-/* $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
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++);
}
}
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;
}
-/* $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
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)
{
}
}
-static void logRecord (ZebraHandle zh)
+static void logRecord(ZebraHandle zh)
{
check_log_limit(zh);
++zh->records_processed;
}
-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);
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)
{
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
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);
}
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;
}
*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;
}
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 == '\'')
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;
}
}
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;
}
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);
}
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);
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);
{
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;
}
{
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;
}
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;
}
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;
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);
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;
}
if (rinfo)
{
assert(*rinfo == sizeof(*sysno));
- memcpy (sysno, rinfo+1, sizeof(*sysno));
+ memcpy(sysno, rinfo+1, sizeof(*sysno));
}
}
}
/* 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");
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,
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);
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,
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],
/* 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)
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);
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;
}
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);
}
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]);
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);
}
{
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);
}
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);
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;
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;
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)
{
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
}
if (!i)
return;
- extract_add_string (p, buf, i);
+ extract_add_string(p, buf, i);
}
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);
}
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,
-/* $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
#include <idzebra/util.h>
#include <idzebra/flock.h>
#include <sortidx.h>
-
+#include <index_types.h>
#if HAVE_SYS_TIMES_H
#include <sys/times.h>
#endif
char *server_path_prefix;
data1_handle dh;
+ zebra_index_types_t index_types;
ZebraMaps zebra_maps;
ZebraRankClass rank_classes;
RecTypes recTypes;
-/* $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
#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;
}
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);
}
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;
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;
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];
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;
{
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 */
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;
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;
}
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;
}
-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 &&
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;
}
}
}
-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];
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;
}
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)
{
*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);
{ /* 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 */
/* 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
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
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;
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);
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);
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;
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;
}
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))
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;
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);
}
}
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;
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
{
break;
}
}
- xfree (isams_i);
+ xfree(isams_i);
return 0;
}
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;
#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];
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;
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);
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 "
-/* $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
#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 */
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 */
*/
/* 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)
{
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++] = '/';
}
/* 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);
printf("%*sIdx: [%s]", (level + 1) * 4, "",
tl->structure);
printf("%s %s", tl->index_name, tl->source);
- printf (" XData:\"");
+ printf(" XData:\"");
for (i = 0; i<wrd_tl.term_len && i < 40; i++)
- fputc (wrd_tl.term_buf[i], stdout);
- fputc ('"', stdout);
+ fputc(wrd_tl.term_buf[i], stdout);
+ fputc('"', stdout);
if (wrd_tl.term_len > 40)
- printf (" ...");
- fputc ('\n', stdout);
+ printf(" ...");
+ fputc('\n', stdout);
}
else
{
{
printf("%*s tag=", (level + 1) * 4, "");
for (i = 0; i<wrd->term_len && i < 40; i++)
- fputc (wrd->term_buf[i], stdout);
+ fputc(wrd->term_buf[i], stdout);
if (i == 40)
- printf (" ..");
+ printf(" ..");
printf("\n");
}
else
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);
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';
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]))
{
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;
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++;
}
}
-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)
{
printf("%*sIdx: [%s]", (level + 1) * 4, "",
tlist->structure);
printf("%s %s", tlist->index_name, tlist->source);
- printf (" XData:\"");
+ printf(" XData:\"");
for (i = 0; i<wrd->term_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
{
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);
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;
</root>
*/
-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];
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,
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");
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 &&
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;
&& 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;
}
}
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;
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");
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));
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)))
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)))
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;
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;
}
}
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;
}
}
-/* $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
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;
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 {
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)
{
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
{
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)
{
(*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;
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;
}
{
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");
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)
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)
{
-/* $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
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;
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);
-/* $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
break;
}
}
- rset_close (rfd);
+ rset_close(rfd);
*count = rset->hits_count;
}
}
}
}
- rset_close (rfd);
+ rset_close(rfd);
}
struct scan2_info_entry {
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 */
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;
}
*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();
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);
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);
else
termset_name = termset_value_string;
- limit_set = resultSetRef (zh, termset_name);
+ limit_set = resultSetRef(zh, termset_name);
if (!limit_set)
{
{
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]);
-/* $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
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);
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;
*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);
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]);
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, '(');
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)
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]);
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);
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:
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:
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:
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:
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:
*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++)
{
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]);
*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++)
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;
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";
*/
- 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]);
-/* $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
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,
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);
}
}
}
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)
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;
}
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;
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)
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)
{
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);
}
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
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);
{
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;
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
#if 0
dump_file_dict(dict);
#endif
- dict_close (dict);
+ dict_close(dict);
return ZEBRA_OK;
}
-/* $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
{
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
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);
}
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] != '/')
{
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,
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,
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;
}
-/* $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
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)
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)
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);
-/* $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
static void filter_cb(void *cd, const char *name)
{
- puts (name);
+ puts(name);
}
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;
#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 <dir> ...\n"
+ fprintf(stderr, "%s [options] command <dir> ...\n"
"Commands:\n"
" update <dir> Update index with files below <dir>.\n"
" If <dir> is empty filenames are read from stdin.\n"
" -f <n> Display information for the first <n> 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);
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"))
{
{
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
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':
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')
#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')
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;
}
-/* $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
#include <yaz/charneg.h>
#include <idzebra/api.h>
-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;
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;
}
{
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)
{
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; i<no_terms; i++)
{
zebra_result_set_term_info(zh, r->setname, 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;
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:
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:
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)
{
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;
(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) {
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;
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)
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:
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;
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)
{
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";
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);
}
}
}
}
- 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");
}
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;
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);
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
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)
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);
{
char pidstr[30];
- sprintf (pidstr, "%ld", (long) getpid ());
- write (fd, pidstr, strlen(pidstr));
+ sprintf(pidstr, "%ld", (long) getpid());
+ write(fd, pidstr, strlen(pidstr));
}
}
#endif
{
char pidfname[4096];
zebra_pidfname(sob->handle, pidfname);
- unlink (pidfname);
+ unlink(pidfname);
}
#endif
if (sob->handle)
}
}
-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:
-/* $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
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);
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);
zint runNumber;
zint staticrank;
} RecordAttr;
-RecordAttr *rec_init_attr (ZebraExplainInfo zei, Record rec);
+RecordAttr *rec_init_attr(ZebraExplainInfo zei, Record rec);
YAZ_END_CDECL