-/* $Id: dicttest.c,v 1.27 2002-08-02 19:26:55 adam Exp $
+/* $Id: dicttest.c,v 1.28 2004-01-22 11:27:20 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
logf (LOG_FATAL, "no config and/or dictionary specified");
exit (1);
}
- my_resource = res_open (config, 0);
+ my_resource = res_open (config, 0, 0);
if (!my_resource)
{
logf (LOG_FATAL, "cannot open resource `%s'", config);
-/* $Id: res.h,v 1.12 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: res.h,v 1.13 2004-01-22 11:27:21 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
extern "C" {
#endif
-typedef struct res_struct *Res;
-
-Res res_open (const char *name, Res res_def);
-void res_close (Res r);
-char *res_get (Res r, const char *name);
-char *res_get_def (Res r, const char *name, char *def);
-int res_get_match (Res r, const char *name, const char *value, const char *s);
-void res_put (Res r, const char *name, const char *value);
-int res_trav (Res r, const char *prefix, void *p,
- void (*f)(void *p, const char *name, const char *value));
-int res_write (Res r);
+ typedef struct res_struct *Res;
+
+ Res res_open (const char *name, Res res_def, Res over_res);
+ void res_close (Res r);
+ const char *res_get (Res r, const char *name);
+ const char *res_get_def (Res r, const char *name, const char *def);
+ int res_get_match (Res r, const char *name, const char *value, const char *s);
+ void res_set (Res r, const char *name, const char *value);
+ int res_trav (Res r, const char *prefix, void *p,
+ void (*f)(void *p, const char *name, const char *value));
+ int res_write (Res r);
+ const char *res_get_prefix (Res r, const char *name, const char *prefix,
+ const char *def);
#ifdef __cplusplus
}
-/* $Id: rstemp.h,v 1.8 2002-08-02 19:26:55 adam Exp $
+/* $Id: rstemp.h,v 1.9 2004-01-22 11:27:21 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
{
int (*cmp)(const void *p1, const void *p2);
int key_size;
- char *temp_path;
+ const char *temp_path;
RSET_TERM rset_term;
} rset_temp_parms;
-/* $Id: zebraapi.h,v 1.11 2004-01-15 13:31:31 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: zebraapi.h,v 1.12 2004-01-22 11:27:21 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
#include <yaz/odr.h>
#include <yaz/oid.h>
#include <yaz/proto.h>
+#include <res.h>
#include <zebraver.h>
/* Fixme! Compare string (ignore case) */
YAZ_BEGIN_CDECL
-struct recordGroup {
- char *groupName;
- char *databaseName;
- char *path;
- char *recordId;
- char *recordType;
- int flagStoreData;
- int flagStoreKeys;
- int flagRw;
- int fileVerboseLimit;
- int databaseNamePath;
- int explainDatabase;
- int followLinks;
-};
-
typedef struct {
int processed;
int inserted;
/* Start Zebra using file 'configName' (usually zebra.cfg) */
/* There should be exactly one ZebraService */
-YAZ_EXPORT ZebraService zebra_start (const char *configName);
+YAZ_EXPORT ZebraService zebra_start (const char *configName,
+ Res def_res, Res over_res);
/* Close the whole Zebra */
YAZ_EXPORT int zebra_stop (ZebraService zs);
YAZ_EXPORT int zebra_admin_import_end (ZebraHandle zh);
int zebra_admin_exchange_record (ZebraHandle zh,
- const char *database,
const char *rec_buf,
size_t rec_len,
const char *recid_buf, size_t recid_len,
int zebra_init (ZebraHandle zh);
int zebra_compact (ZebraHandle zh);
-int zebra_repository_update (ZebraHandle zh);
-int zebra_repository_delete (ZebraHandle zh);
-int zebra_repository_show (ZebraHandle zh);
-int zebra_record_insert (ZebraHandle zh, const char *buf, int len, int *sysno);
-
-YAZ_EXPORT int zebra_set_group (ZebraHandle zh, struct recordGroup *rg);
-
+int zebra_repository_update (ZebraHandle zh, const char *path);
+int zebra_repository_delete (ZebraHandle zh, const char *path);
+int zebra_repository_show (ZebraHandle zh, const char *path);
+
+int zebra_add_record (ZebraHandle zh, const char *buf, int buf_size);
+
+int zebra_insert_record (ZebraHandle zh,
+ const char *recordType,
+ int *sysno, const char *match, const char *fname,
+ const char *buf, int buf_size);
+int zebra_update_record (ZebraHandle zh,
+ const char *recordType,
+ int* sysno, const char *match, const char *fname,
+ const char *buf, int buf_size,
+ int force_update);
+int zebra_delete_record (ZebraHandle zh,
+ const char *recordType,
+ int *sysno, const char *match, const char *fname,
+ const char *buf, int buf_size,
+ int force_update);
YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname,
int no, int *count,
-/* $Id: apitest.c,v 1.14 2003-06-18 11:46:33 adam Exp $
+/* $Id: apitest.c,v 1.15 2004-01-22 11:27:21 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
odr_input = odr_createmem (ODR_DECODE);
odr_output = odr_createmem (ODR_ENCODE);
- zs = zebra_start ("zebra.cfg");
+ zs = zebra_start ("zebra.cfg", 0, 0);
if (!zs)
{
printf ("zebra_start failed; missing zebra.cfg?\n");
-/* $Id: extract.c,v 1.146 2003-10-07 09:18:43 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: extract.c,v 1.147 2004-01-22 11:27:21 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
}
static char *fileMatchStr (ZebraHandle zh,
- struct recKeys *reckeys, struct recordGroup *rGroup,
+ struct recKeys *reckeys,
const char *fname, const char *spec)
{
static char dstBuf[2048]; /* static here ??? */
else
{
logf (LOG_WARN, "Missing ) in match criteria %s in group %s",
- spec, rGroup->groupName ? rGroup->groupName : "none");
+ spec, zh->m_group ? zh->m_group : "none");
return NULL;
}
s++;
s = s1;
if (!strcmp (special, "group"))
- spec_src = rGroup->groupName;
+ spec_src = zh->m_group;
else if (!strcmp (special, "database"))
- spec_src = rGroup->databaseName;
+ spec_src = zh->basenames[0];
else if (!strcmp (special, "filename")) {
spec_src = fname;
}
else if (!strcmp (special, "type"))
- spec_src = rGroup->recordType;
+ spec_src = zh->m_record_type;
else
spec_src = NULL;
if (spec_src)
else
{
logf (LOG_WARN, "Syntax error in match criteria %s in group %s",
- spec, rGroup->groupName ? rGroup->groupName : "none");
+ spec, zh->m_group ? zh->m_group : "none");
return NULL;
}
*dst++ = 1;
if (dst == dstBuf)
{
logf (LOG_WARN, "No match criteria for record %s in group %s",
- fname, rGroup->groupName ? rGroup->groupName : "none");
+ fname, zh->m_group ? zh->m_group : "none");
return NULL;
}
*dst = '\0';
struct recordGroup *rGroup;
};
-static int recordExtract (ZebraHandle zh,
- SYSNO *sysno, const char *fname,
- struct recordGroup *rGroup, int deleteFlag,
- struct file_read_info *fi,
- RecType recType, char *subType, void *clientData,
- int force_update)
+static int file_extract_record(ZebraHandle zh,
+ SYSNO *sysno, const char *fname,
+ int deleteFlag,
+ struct file_read_info *fi,
+ int force_update)
{
RecordAttr *recordAttr;
int r;
SYSNO sysnotmp;
Record rec;
off_t recordOffset = 0;
+ RecType recType;
+ void *clientData;
+ char subType[128];
+
+ if (!(recType =
+ recType_byName (zh->reg->recTypes, zh->m_record_type, subType,
+ &clientData)))
+ {
+ logf (LOG_WARN, "No such record type: %s", zh->m_record_type);
+ return 0;
+ }
+
+ /* announce database */
+ if (zebraExplain_curDatabase (zh->reg->zei, zh->basenames[0]))
+ {
+ if (zebraExplain_newDatabase (zh->reg->zei, zh->basenames[0],
+ zh->m_explain_database))
+ return 0;
+ }
if (fi->fd != -1)
{
extractCtrl.seqno[i] = 0;
}
extractCtrl.zebra_maps = zh->reg->zebra_maps;
- extractCtrl.flagShowRecords = !rGroup->flagRw;
+ extractCtrl.flagShowRecords = !zh->m_flag_rw;
- if (!rGroup->flagRw)
+ if (!zh->m_flag_rw)
printf ("File: %s " PRINTF_OFF_T "\n", fname, recordOffset);
- if (rGroup->flagRw)
+ if (zh->m_flag_rw)
{
char msg[512];
sprintf (msg, "%s:" PRINTF_OFF_T , fname, recordOffset);
else if (r == RECCTRL_EXTRACT_ERROR_GENERIC)
{
/* error occured during extraction ... */
- if (rGroup->flagRw &&
- zh->records_processed < rGroup->fileVerboseLimit)
+ if (zh->m_flag_rw &&
+ zh->records_processed < zh->m_file_verbose_limit)
{
- logf (LOG_WARN, "fail %s %s " PRINTF_OFF_T, rGroup->recordType,
+ logf (LOG_WARN, "fail %s %s " PRINTF_OFF_T, zh->m_record_type,
fname, recordOffset);
}
return 0;
else if (r == RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER)
{
/* error occured during extraction ... */
- if (rGroup->flagRw &&
- zh->records_processed < rGroup->fileVerboseLimit)
+ if (zh->m_flag_rw &&
+ zh->records_processed < zh->m_file_verbose_limit)
{
logf (LOG_WARN, "no filter for %s %s "
- PRINTF_OFF_T, rGroup->recordType,
+ PRINTF_OFF_T, zh->m_record_type,
fname, recordOffset);
}
return 0;
{
/* the extraction process returned no information - the record
is probably empty - unless flagShowRecords is in use */
- if (!rGroup->flagRw)
+ if (!zh->m_flag_rw)
return 1;
- logf (LOG_WARN, "empty %s %s " PRINTF_OFF_T, rGroup->recordType,
+ logf (LOG_WARN, "empty %s %s " PRINTF_OFF_T, zh->m_record_type,
fname, recordOffset);
return 1;
}
{
sysnotmp = 0;
sysno = &sysnotmp;
- if (rGroup->recordId && *rGroup->recordId)
+ if (zh->m_record_id && *zh->m_record_id)
{
char *rinfo;
- matchStr = fileMatchStr (zh, &zh->reg->keys, rGroup, fname,
- rGroup->recordId);
+ matchStr = fileMatchStr (zh, &zh->reg->keys, fname,
+ zh->m_record_id);
if (matchStr)
{
rinfo = dict_lookup (zh->reg->matchDict, matchStr);
/* new record */
if (deleteFlag)
{
- logf (LOG_LOG, "delete %s %s " PRINTF_OFF_T, rGroup->recordType,
+ logf (LOG_LOG, "delete %s %s " PRINTF_OFF_T, zh->m_record_type,
fname, recordOffset);
logf (LOG_WARN, "cannot delete record above (seems new)");
return 1;
}
- if (zh->records_processed < rGroup->fileVerboseLimit)
- logf (LOG_LOG, "add %s %s " PRINTF_OFF_T, rGroup->recordType,
+ if (zh->records_processed < zh->m_file_verbose_limit)
+ logf (LOG_LOG, "add %s %s " PRINTF_OFF_T, zh->m_record_type,
fname, recordOffset);
rec = rec_new (zh->reg->records);
{
yaz_log (LOG_LOG, "run number = %d", recordAttr->runNumber);
yaz_log (LOG_LOG, "skipped %s %s " PRINTF_OFF_T,
- rGroup->recordType, fname, recordOffset);
+ zh->m_record_type, fname, recordOffset);
extract_flushSortKeys (zh, *sysno, -1, &zh->reg->sortKeys);
rec_rm (&rec);
logRecord (zh);
if (!delkeys.buf_used)
{
logf (LOG_LOG, "delete %s %s " PRINTF_OFF_T,
- rGroup->recordType, fname, recordOffset);
+ zh->m_record_type, fname, recordOffset);
logf (LOG_WARN, "cannot delete file above, storeKeys false");
}
else
{
- if (zh->records_processed < rGroup->fileVerboseLimit)
+ if (zh->records_processed < zh->m_file_verbose_limit)
logf (LOG_LOG, "delete %s %s " PRINTF_OFF_T,
- rGroup->recordType, fname, recordOffset);
+ zh->m_record_type, fname, recordOffset);
zh->records_deleted++;
if (matchStr)
dict_delete (zh->reg->matchDict, matchStr);
if (!delkeys.buf_used)
{
logf (LOG_LOG, "update %s %s " PRINTF_OFF_T,
- rGroup->recordType, fname, recordOffset);
+ zh->m_record_type, fname, recordOffset);
logf (LOG_WARN, "cannot update file above, storeKeys false");
}
else
{
- if (zh->records_processed < rGroup->fileVerboseLimit)
+ if (zh->records_processed < zh->m_file_verbose_limit)
logf (LOG_LOG, "update %s %s " PRINTF_OFF_T,
- rGroup->recordType, fname, recordOffset);
+ zh->m_record_type, fname, recordOffset);
extract_flushSortKeys (zh, *sysno, 1, &zh->reg->sortKeys);
extract_flushRecordKeys (zh, *sysno, 1, &zh->reg->keys);
zh->records_updated++;
/* update file type */
xfree (rec->info[recInfo_fileType]);
rec->info[recInfo_fileType] =
- rec_strdup (rGroup->recordType, &rec->size[recInfo_fileType]);
+ rec_strdup (zh->m_record_type, &rec->size[recInfo_fileType]);
/* update filename */
xfree (rec->info[recInfo_filename]);
/* update delete keys */
xfree (rec->info[recInfo_delKeys]);
- if (zh->reg->keys.buf_used > 0 && rGroup->flagStoreKeys == 1)
+ if (zh->reg->keys.buf_used > 0 && zh->m_store_keys == 1)
{
rec->size[recInfo_delKeys] = zh->reg->keys.buf_used;
rec->info[recInfo_delKeys] = zh->reg->keys.buf;
/* update store data */
xfree (rec->info[recInfo_storeData]);
- if (rGroup->flagStoreData == 1)
+ if (zh->m_store_data)
{
rec->size[recInfo_storeData] = recordAttr->recordSize;
rec->info[recInfo_storeData] = (char *)
/* update database name */
xfree (rec->info[recInfo_databaseName]);
rec->info[recInfo_databaseName] =
- rec_strdup (rGroup->databaseName, &rec->size[recInfo_databaseName]);
+ rec_strdup (zh->basenames[0], &rec->size[recInfo_databaseName]);
/* update offset */
recordAttr->recordOffset = recordOffset;
}
int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname,
- const struct recordGroup *rGroupP, int deleteFlag)
+ int deleteFlag)
{
int r, i, fd;
char gprefix[128];
char ext[128];
char ext_res[128];
- char subType[128];
- RecType recType;
- struct recordGroup rGroupM;
- struct recordGroup *rGroup = &rGroupM;
struct file_read_info *fi;
- void *clientData;
- memcpy (rGroup, rGroupP, sizeof(*rGroupP));
-
- if (!rGroup->groupName || !*rGroup->groupName)
+ if (!zh->m_group || !*zh->m_group)
*gprefix = '\0';
else
- sprintf (gprefix, "%s.", rGroup->groupName);
-
+ sprintf (gprefix, "%s.", zh->m_group);
+
logf (LOG_DEBUG, "fileExtract %s", fname);
/* determine file extension */
break;
}
/* determine file type - depending on extension */
- if (!rGroup->recordType)
+ if (!zh->m_record_type)
{
sprintf (ext_res, "%srecordType.%s", gprefix, ext);
- if (!(rGroup->recordType = res_get (zh->res, ext_res)))
- {
- sprintf (ext_res, "%srecordType", gprefix);
- rGroup->recordType = res_get (zh->res, ext_res);
- }
+ zh->m_record_type = res_get (zh->res, ext_res);
}
- if (!rGroup->recordType)
+ if (!zh->m_record_type)
{
- if (zh->records_processed < rGroup->fileVerboseLimit)
+ if (zh->records_processed < zh->m_file_verbose_limit)
logf (LOG_LOG, "? %s", fname);
return 0;
}
- if (!*rGroup->recordType)
- return 0;
- if (!(recType =
- recType_byName (zh->reg->recTypes, rGroup->recordType, subType,
- &clientData)))
- {
- logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
- return 0;
- }
-
/* determine match criteria */
- if (!rGroup->recordId)
+ if (!zh->m_record_id)
{
sprintf (ext_res, "%srecordId.%s", gprefix, ext);
- rGroup->recordId = res_get (zh->res, ext_res);
- }
-
- /* determine database name */
- if (!rGroup->databaseName)
- {
- sprintf (ext_res, "%sdatabase.%s", gprefix, ext);
- if (!(rGroup->databaseName = res_get (zh->res, ext_res)))
- {
- sprintf (ext_res, "%sdatabase", gprefix);
- rGroup->databaseName = res_get (zh->res, ext_res);
- }
- }
- if (!rGroup->databaseName)
- rGroup->databaseName = "Default";
-
- /* determine if explain database */
-
- sprintf (ext_res, "%sexplainDatabase", gprefix);
- rGroup->explainDatabase =
- atoi (res_get_def (zh->res, ext_res, "0"));
-
- /* announce database */
- if (zebraExplain_curDatabase (zh->reg->zei, rGroup->databaseName))
- {
- if (zebraExplain_newDatabase (zh->reg->zei, rGroup->databaseName,
- rGroup->explainDatabase))
- return 0;
- }
-
- if (rGroup->flagStoreData == -1)
- {
- const char *sval;
- sprintf (ext_res, "%sstoreData.%s", gprefix, ext);
- if (!(sval = res_get (zh->res, ext_res)))
- {
- sprintf (ext_res, "%sstoreData", gprefix);
- sval = res_get (zh->res, ext_res);
- }
- if (sval)
- rGroup->flagStoreData = atoi (sval);
+ zh->m_record_id = res_get (zh->res, ext_res);
}
- if (rGroup->flagStoreData == -1)
- rGroup->flagStoreData = 0;
-
- if (rGroup->flagStoreKeys == -1)
- {
- const char *sval;
-
- sprintf (ext_res, "%sstoreKeys.%s", gprefix, ext);
- sval = res_get (zh->res, ext_res);
- if (!sval)
- {
- sprintf (ext_res, "%sstoreKeys", gprefix);
- sval = res_get (zh->res, ext_res);
- }
- if (!sval)
- sval = res_get (zh->res, "storeKeys");
- if (sval)
- rGroup->flagStoreKeys = atoi (sval);
- }
- if (rGroup->flagStoreKeys == -1)
- rGroup->flagStoreKeys = 0;
if (sysno && deleteFlag)
fd = -1;
do
{
file_begin (fi);
- r = recordExtract (zh, sysno, fname, rGroup, deleteFlag, fi,
- recType, subType, clientData, 1);
+ r = file_extract_record (zh, sysno, fname, deleteFlag, fi, 1);
} while (r && !sysno && fi->file_more);
file_read_stop (fi);
if (fd != -1)
close (fd);
return r;
}
-int extract_rec_in_mem (ZebraHandle zh, const char *recordType,
- const char *buf, size_t buf_size,
- const char *databaseName, int delete_flag,
- int test_mode, int *sysno,
- int store_keys, int store_data,
- const char *match_criteria)
-{
- struct recordGroup rGroup;
- rGroup.groupName = NULL;
- rGroup.databaseName = (char *)databaseName;
- rGroup.path = NULL;
- rGroup.recordId = NULL;
- rGroup.recordType = (char *)recordType;
- rGroup.flagStoreData = store_data;
- rGroup.flagStoreKeys = store_keys;
- rGroup.flagRw = 1;
- rGroup.databaseNamePath = 0;
- rGroup.explainDatabase = 0;
- rGroup.fileVerboseLimit = 100000;
- rGroup.followLinks = -1;
- return (bufferExtractRecord (zh,
- buf, buf_size,
- &rGroup,
- delete_flag,
- test_mode,
- recordType,
- sysno,
- match_criteria,
- "<no file>",
- 0,1));
-}
+
/*
If sysno is provided, then it's used to identify the reocord.
If not, and match_criteria is provided, then sysno is guessed
If not, and a record is provided, then sysno is got from there
*/
-int bufferExtractRecord (ZebraHandle zh,
- const char *buf, size_t buf_size,
- struct recordGroup *rGroup,
- int delete_flag,
- int test_mode,
- const char *recordType,
- int *sysno,
- const char *match_criteria,
- const char *fname,
- int force_update,
- int allow_update)
-
+int buffer_extract_record (ZebraHandle zh,
+ const char *buf, size_t buf_size,
+ int delete_flag,
+ int test_mode,
+ const char *recordType,
+ int *sysno,
+ const char *match_criteria,
+ const char *fname,
+ int force_update,
+ int allow_update)
{
RecordAttr *recordAttr;
struct recExtractCtrl extractCtrl;
Record rec;
long recordOffset = 0;
struct zebra_fetch_control fc;
+ const char *pr_fname = fname; /* filename to print .. */
+
+ if (!pr_fname)
+ pr_fname = "<no file>"; /* make it printable if file is omitted */
fc.fd = -1;
fc.record_int_buf = buf;
zh->reg->keys.prevSeqNo = 0;
zh->reg->sortKeys.buf_used = 0;
- /* announce database */
-
- if (!(rGroup->databaseName)) {
- logf (LOG_WARN, "Invalid record group, no database name given");
- return 0;
- }
-
- if (zebraExplain_curDatabase (zh->reg->zei, rGroup->databaseName))
+ if (zebraExplain_curDatabase (zh->reg->zei, zh->basenames[0]))
{
- if (zebraExplain_newDatabase (zh->reg->zei, rGroup->databaseName, 0))
+ if (zebraExplain_newDatabase (zh->reg->zei, zh->basenames[0],
+ zh->m_explain_database))
return 0;
}
- if (*recordType) {
+ if (recordType && *recordType) {
logf (LOG_DEBUG, "Record type explicitly specified: %s", recordType);
recType = recType_byName (zh->reg->recTypes, recordType, subType,
&clientData);
} else {
- if (!(rGroup->recordType)) {
+ if (!(zh->m_record_type)) {
logf (LOG_WARN, "No such record type defined");
return 0;
}
- logf (LOG_DEBUG, "Get record type from rgroup: %s",rGroup->recordType);
- recType = recType_byName (zh->reg->recTypes, rGroup->recordType, subType,
+ logf (LOG_DEBUG, "Get record type from rgroup: %s",zh->m_record_type);
+ recType = recType_byName (zh->reg->recTypes, zh->m_record_type, subType,
&clientData);
- recordType = rGroup->recordType;
+ recordType = zh->m_record_type;
}
if (!recType) {
- logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
+ logf (LOG_WARN, "No such record type: %s", zh->m_record_type);
return 0;
}
/* match criteria */
matchStr = NULL;
- if (! *sysno && match_criteria) {
+ if (! *sysno) {
char *rinfo;
- if (*match_criteria) {
+ if (match_criteria && *match_criteria) {
matchStr = (char *)match_criteria;
} else {
- if (rGroup->recordId && *rGroup->recordId) {
- matchStr = fileMatchStr (zh, &zh->reg->keys, rGroup, fname,
- rGroup->recordId);
+ if (zh->m_record_id && *zh->m_record_id) {
+ matchStr = fileMatchStr (zh, &zh->reg->keys, pr_fname,
+ zh->m_record_id);
}
}
if (matchStr) {
if (delete_flag)
{
logf (LOG_LOG, "delete %s %s %ld", recordType,
- fname, (long) recordOffset);
+ pr_fname, (long) recordOffset);
logf (LOG_WARN, "cannot delete record above (seems new)");
return 1;
}
- logf (LOG_LOG, "add %s %s %ld", recordType, fname,
+ logf (LOG_LOG, "add %s %s %ld", recordType, pr_fname,
(long) recordOffset);
rec = rec_new (zh->reg->records);
if (!allow_update) {
logf (LOG_LOG, "skipped %s %s %ld",
- recordType, fname, (long) recordOffset);
+ recordType, pr_fname, (long) recordOffset);
logRecord(zh);
return -1;
}
assert (rec);
recordAttr = rec_init_attr (zh->reg->zei, rec);
-
+
if (!force_update) {
- if (recordAttr->runNumber ==
- zebraExplain_runNumberIncrement (zh->reg->zei, 0))
+ if (recordAttr->runNumber ==
+ zebraExplain_runNumberIncrement (zh->reg->zei, 0))
{
- logf (LOG_LOG, "skipped %s %s %ld", recordType,
- fname, (long) recordOffset);
- extract_flushSortKeys (zh, *sysno, -1, &zh->reg->sortKeys);
- rec_rm (&rec);
- logRecord(zh);
- return 1;
+ logf (LOG_LOG, "skipped %s %s %ld", recordType,
+ pr_fname, (long) recordOffset);
+ extract_flushSortKeys (zh, *sysno, -1, &zh->reg->sortKeys);
+ rec_rm (&rec);
+ logRecord(zh);
+ return 0;
}
}
if (!delkeys.buf_used)
{
logf (LOG_LOG, "delete %s %s %ld", recordType,
- fname, (long) recordOffset);
+ pr_fname, (long) recordOffset);
logf (LOG_WARN, "cannot delete file above, storeKeys false");
}
else
{
logf (LOG_LOG, "delete %s %s %ld", recordType,
- fname, (long) recordOffset);
+ pr_fname, (long) recordOffset);
zh->records_deleted++;
if (matchStr)
dict_delete (zh->reg->matchDict, matchStr);
}
rec_rm (&rec);
logRecord(zh);
- return 1;
+ return 0;
}
else
{
if (!delkeys.buf_used)
{
logf (LOG_LOG, "update %s %s %ld", recordType,
- fname, (long) recordOffset);
+ pr_fname, (long) recordOffset);
logf (LOG_WARN, "cannot update file above, storeKeys false");
}
else
{
logf (LOG_LOG, "update %s %s %ld", recordType,
- fname, (long) recordOffset);
+ pr_fname, (long) recordOffset);
extract_flushSortKeys (zh, *sysno, 1, &zh->reg->sortKeys);
extract_flushRecordKeys (zh, *sysno, 1, &zh->reg->keys);
zh->records_updated++;
/* update delete keys */
xfree (rec->info[recInfo_delKeys]);
- if (zh->reg->keys.buf_used > 0 && rGroup->flagStoreKeys == 1)
+ if (zh->reg->keys.buf_used > 0 && zh->m_store_keys == 1)
{
rec->size[recInfo_delKeys] = zh->reg->keys.buf_used;
rec->info[recInfo_delKeys] = zh->reg->keys.buf;
/* update store data */
xfree (rec->info[recInfo_storeData]);
- if (rGroup->flagStoreData == 1)
+ if (zh->m_store_data)
{
rec->size[recInfo_storeData] = recordAttr->recordSize;
rec->info[recInfo_storeData] = (char *)
xmalloc (recordAttr->recordSize);
-#if 1
memcpy (rec->info[recInfo_storeData], buf, recordAttr->recordSize);
-#else
- if (lseek (fi->fd, recordOffset, SEEK_SET) < 0)
- {
- logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s",
- (long) recordOffset, fname);
- exit (1);
- }
- if (read (fi->fd, rec->info[recInfo_storeData], recordAttr->recordSize)
- < recordAttr->recordSize)
- {
- logf (LOG_ERRNO|LOG_FATAL, "read %d bytes of %s",
- recordAttr->recordSize, fname);
- exit (1);
- }
-#endif
}
else
{
/* update database name */
xfree (rec->info[recInfo_databaseName]);
rec->info[recInfo_databaseName] =
- rec_strdup (rGroup->databaseName, &rec->size[recInfo_databaseName]);
+ rec_strdup (zh->basenames[0], &rec->size[recInfo_databaseName]);
/* update offset */
recordAttr->recordOffset = recordOffset;
return 0;
}
-
-
int explain_extract (void *handle, Record rec, data1_node *n)
{
ZebraHandle zh = (ZebraHandle) handle;
-/* $Id: index.h,v 1.102 2003-06-23 15:35:25 adam Exp $
+/* $Id: index.h,v 1.103 2004-01-22 11:27:21 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
void dir_sort (struct dir_entry *e);
void dir_free (struct dir_entry **e_p);
-void repositoryUpdate (ZebraHandle zh);
-void repositoryAdd (ZebraHandle zh);
-void repositoryDelete (ZebraHandle zh);
-void repositoryShow (ZebraHandle zh);
+void repositoryUpdate (ZebraHandle zh, const char *path);
+void repositoryAdd (ZebraHandle zh, const char *path);
+void repositoryDelete (ZebraHandle zh, const char *path);
+void repositoryShow (ZebraHandle zh, const char *path);
int key_open (ZebraHandle zh, int mem);
int key_close (ZebraHandle zh);
struct zebra_register *regs;
Zebra_mutex_cond session_lock;
Passwd_db passwd_db;
- char *path_root;
+ const char *path_root;
};
struct zebra_service *service;
struct zebra_register *reg;
- char *admin_databaseName;
+ char *xadmin_databaseName;
char **basenames;
int num_basenames;
struct tms tms1;
struct tms tms2;
#endif
- struct recordGroup rGroup;
int shadow_enable;
int records_inserted;
yaz_iconv_t iconv_to_utf8;
yaz_iconv_t iconv_from_utf8;
+
+ int m_follow_links;
+ const char *m_group;
+ const char *m_record_id;
+ const char *m_record_type;
+ int m_store_data;
+ int m_store_keys;
+ int m_explain_database;
+ int m_flag_rw;
+ int m_file_verbose_limit;
};
struct rank_control {
void extract_get_fname_tmp (ZebraHandle zh, char *fname, int no);
void zebra_index_merge (ZebraHandle zh);
-int bufferExtractRecord (ZebraHandle zh,
- const char *buf, size_t buf_size,
- struct recordGroup *rGroup,
- int delete_flag,
- int test_mode,
- const char *recordType,
- int *sysno,
- const char *match_criteria,
- const char *fname,
- int force_update,
- int allow_update);
-
+int buffer_extract_record (ZebraHandle zh,
+ const char *buf, size_t buf_size,
+ int delete_flag,
+ int test_mode,
+ const char *recordType,
+ int *sysno,
+ const char *match_criteria,
+ const char *fname,
+ int force_update,
+ int allow_update);
+
+#if 0
int extract_rec_in_mem (ZebraHandle zh, const char *recordType,
const char *buf, size_t buf_size,
const char *databaseName, int delete_flag,
int test_mode, int *sysno,
int store_keys, int store_data,
const char *match_criteria);
+#endif
+
void extract_flushWriteKeys (ZebraHandle zh);
struct zebra_fetch_control {
int explain_extract (void *handle, Record rec, data1_node *n);
int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname,
- const struct recordGroup *rGroup, int deleteFlag);
+ int deleteFlag);
int zebra_begin_read (ZebraHandle zh);
int zebra_end_read (ZebraHandle zh);
-/* $Id: kdump.c,v 1.23 2003-05-24 22:35:11 adam Exp $
+/* $Id: kdump.c,v 1.24 2004-01-22 11:27:21 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
}
else if (ret == 'c')
{
- if (!(res = res_open (arg, 0)))
+ if (!(res = res_open (arg, 0, 0)))
{
logf(LOG_FATAL, "Failed to open resource file %s", arg);
exit (1);
exit (1);
}
if (!res)
- res = res_open ("zebra.cfg", 0);
+ res = res_open ("zebra.cfg", 0, 0);
zm = zebra_maps_open (res, 0);
if (!(inf = fopen (key_fname, "r")))
{
-/* $Id: lockutil.c,v 1.17 2002-08-02 19:26:55 adam Exp $
+/* $Id: lockutil.c,v 1.18 2004-01-22 11:27:21 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
void zebra_lock_prefix (Res res, char *path)
{
- char *lock_dir = res_get_def (res, "lockDir", "");
+ const char *lock_dir = res_get_def (res, "lockDir", "");
strcpy (path, lock_dir);
if (*path && path[strlen(path)-1] != '/')
-/* $Id: main.c,v 1.109 2004-01-15 14:22:22 adam Exp $
+/* $Id: main.c,v 1.110 2004-01-22 11:27:21 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
char *configName = 0;
int nsections = 0;
int disableCommit = 0;
- char *mem_max = 0;
+ char *database = "Default";
+ Res res = res_open(0, 0, 0);
int trans_started=0;
#if HAVE_SYS_TIMES_H
#ifndef WIN32
char nbuf[100];
#endif
- struct recordGroup rGroupDef;
ZebraService zs = 0;
ZebraHandle zh = 0;
times(&tms1);
gettimeofday(&start_time, 0);
#endif
-
- rGroupDef.groupName = NULL;
- rGroupDef.databaseName = NULL;
- rGroupDef.path = NULL;
- rGroupDef.recordId = NULL;
- rGroupDef.recordType = NULL;
- rGroupDef.flagStoreData = -1;
- rGroupDef.flagStoreKeys = -1;
- rGroupDef.flagRw = 1;
- rGroupDef.databaseNamePath = 0;
- rGroupDef.explainDatabase = 0;
- rGroupDef.fileVerboseLimit = 100000;
- rGroupDef.followLinks = -1;
-
prog = *argv;
if (argc < 2)
{
const char *config = configName ? configName : "zebra.cfg";
logf (LOG_LOG, "Zebra version %s %s",
ZEBRAVER, ZEBRADATE);
- zs = zebra_start (config);
+ zs = zebra_start (config, 0, res);
if (!zs)
{
yaz_log (LOG_FATAL, "Cannot read config %s", config);
zebra_shadow_enable (zh, 0);
}
- if (rGroupDef.databaseName)
- {
- if (zebra_select_database (zh, rGroupDef.databaseName))
- {
- logf(LOG_FATAL, "Could not select database %s errCode=%d",
- rGroupDef.databaseName, zebra_errCode(zh) );
- exit (1);
- }
- }
- else
- {
- if (zebra_select_database (zh, "Default"))
- {
- logf(LOG_FATAL, "Could not select database Default errCode=%d",
- zebra_errCode(zh) );
- exit (1);
- }
- }
- if (mem_max)
- zebra_set_resource(zh, "memmax",mem_max);
-
+ if (zebra_select_database (zh, database))
+ {
+ logf(LOG_FATAL, "Could not select database %s errCode=%d",
+ database, zebra_errCode(zh) );
+ exit (1);
+ }
if (!strcmp (arg, "update"))
cmd = 'u';
else if (!strcmp (arg, "update1"))
}
else
{
- rGroupDef.path = arg;
- zebra_set_group (zh, &rGroupDef);
if (!trans_started)
{
trans_started=1;
switch (cmd)
{
case 'u':
- zebra_repository_update (zh);
+ zebra_repository_update (zh, arg);
break;
case 'd':
- zebra_repository_delete (zh);
+ zebra_repository_delete (zh, arg);
break;
case 's':
- logf (LOG_LOG, "dumping %s", rGroupDef.path);
- zebra_repository_show (zh);
+ zebra_repository_show (zh, arg);
nsections = 0;
break;
case 'C':
- zebra_create_database(zh, rGroupDef.path);
+ zebra_create_database(zh, arg);
break;
case 'D':
- zebra_drop_database(zh, rGroupDef.path);
+ zebra_drop_database(zh, arg);
break;
default:
nsections = 0;
else if (ret == 'l')
yaz_log_init_file (arg);
else if (ret == 'm')
- mem_max = arg;
+ res_set(res, "memMax", arg);
else if (ret == 'd')
- rGroupDef.databaseName = arg;
+ database = arg;
else if (ret == 's')
- rGroupDef.flagRw = 0;
+ res_set(res, "openRW", "0");
else if (ret == 'g')
- rGroupDef.groupName = arg;
+ res_set(res, "group", arg);
else if (ret == 'f')
- rGroupDef.fileVerboseLimit = atoi(arg);
+ res_set(res, "verboseLimit", arg);
else if (ret == 'c')
configName = arg;
else if (ret == 't')
- rGroupDef.recordType = arg;
+ res_set(res, "recordType", arg);
else if (ret == 'n')
- disableCommit = 1;
+ res_set(res, "disableCommit", "1");
else if (ret == 'L')
- rGroupDef.followLinks = 0;
+ res_set(res, "followLinks", "0");
else
logf (LOG_WARN, "unknown option '-%s'", arg);
} /* while arg */
-/* $Id: trav.c,v 1.43 2003-10-20 19:26:05 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: trav.c,v 1.44 2004-01-22 11:27:21 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
}
static void repositoryExtractR (ZebraHandle zh, int deleteFlag, char *rep,
- struct recordGroup *rGroup,
int level)
{
struct dir_entry *e;
int i;
size_t rep_len = strlen (rep);
- e = dir_open (rep, zh->path_reg, rGroup->followLinks);
+ e = dir_open (rep, zh->path_reg, zh->m_follow_links);
if (!e)
return;
yaz_log (LOG_LOG, "dir %s", rep);
strcpy (rep +rep_len+1, e[i].name);
if ((ecp = strrchr (e[i].name, '/')))
*ecp = '\0';
- if (level == 0 && rGroup->databaseNamePath)
- rGroup->databaseName = e[i].name;
switch (e[i].kind)
{
case dirs_file:
- fileExtract (zh, NULL, rep, rGroup, deleteFlag);
+ fileExtract (zh, NULL, rep, deleteFlag);
break;
case dirs_dir:
- repositoryExtractR (zh, deleteFlag, rep, rGroup, level+1);
+ repositoryExtractR (zh, deleteFlag, rep, level+1);
break;
}
}
static void fileDeleteR (ZebraHandle zh,
struct dirs_info *di, struct dirs_entry *dst,
- const char *base, char *src,
- struct recordGroup *rGroup)
+ const char *base, char *src)
{
char tmppath[1024];
size_t src_len = strlen (src);
{
case dirs_file:
sprintf (tmppath, "%s%s", base, dst->path);
- fileExtract (zh, &dst->sysno, tmppath, rGroup, 1);
+ fileExtract (zh, &dst->sysno, tmppath, 1);
strcpy (tmppath, dst->path);
dst = dirs_read (di);
static void fileUpdateR (ZebraHandle zh,
struct dirs_info *di, struct dirs_entry *dst,
const char *base, char *src,
- struct recordGroup *rGroup,
int level)
{
struct dir_entry *e_src;
size_t src_len = strlen (src);
sprintf (tmppath, "%s%s", base, src);
- e_src = dir_open (tmppath, zh->path_reg, rGroup->followLinks);
+ e_src = dir_open (tmppath, zh->path_reg, zh->m_follow_links);
yaz_log (LOG_LOG, "dir %s", tmppath);
#if 0
else if (!e_src)
{
strcpy (src, dst->path);
- fileDeleteR (zh, di, dst, base, src, rGroup);
+ fileDeleteR (zh, di, dst, base, src);
return;
}
else
break;
yaz_log (LOG_DEBUG, "trav sd=%d", sd);
- if (level == 0 && rGroup->databaseNamePath)
- rGroup->databaseName = e_src[i_src].name;
if (sd == 0)
{
strcpy (src + src_len, e_src[i_src].name);
case dirs_file:
if (e_src[i_src].mtime > dst->mtime)
{
- if (fileExtract (zh, &dst->sysno, tmppath, rGroup, 0))
+ if (fileExtract (zh, &dst->sysno, tmppath, 0))
{
dirs_add (di, src, dst->sysno, e_src[i_src].mtime);
}
dst = dirs_read (di);
break;
case dirs_dir:
- fileUpdateR (zh, di, dst, base, src, rGroup, level+1);
+ fileUpdateR (zh, di, dst, base, src, level+1);
dst = dirs_last (di);
yaz_log (LOG_DEBUG, "last is %s", dst ? dst->path : "null");
break;
switch (e_src[i_src].kind)
{
case dirs_file:
- if (fileExtract (zh, &sysno, tmppath, rGroup, 0))
+ if (fileExtract (zh, &sysno, tmppath, 0))
dirs_add (di, src, sysno, e_src[i_src].mtime);
break;
case dirs_dir:
- fileUpdateR (zh, di, dst, base, src, rGroup, level+1);
+ fileUpdateR (zh, di, dst, base, src, level+1);
if (dst)
dst = dirs_last (di);
break;
switch (dst->kind)
{
case dirs_file:
- fileExtract (zh, &dst->sysno, tmppath, rGroup, 1);
+ fileExtract (zh, &dst->sysno, tmppath, 1);
dirs_del (di, dst->path);
dst = dirs_read (di);
break;
case dirs_dir:
- fileDeleteR (zh, di, dst, base, src, rGroup);
+ fileDeleteR (zh, di, dst, base, src);
dst = dirs_last (di);
}
}
dir_free (&e_src);
}
-static void groupRes (ZebraHandle zh, struct recordGroup *rGroup)
+void repositoryShow (ZebraHandle zh, const char *path)
{
- char resStr[256];
- char gPrefix[256];
-
- if (!rGroup->groupName || !*rGroup->groupName)
- *gPrefix = '\0';
- else
- sprintf (gPrefix, "%s.", rGroup->groupName);
-
- sprintf (resStr, "%srecordId", gPrefix);
- rGroup->recordId = res_get (zh->res, resStr);
- sprintf (resStr, "%sdatabasePath", gPrefix);
- rGroup->databaseNamePath =
- atoi (res_get_def (zh->res, resStr, "0"));
-
- rGroup->databaseNamePath =
- atoi (res_get_def (zh->res, resStr, "0"));
-
- if (rGroup->followLinks == -1)
- {
- sprintf (resStr, "%sfollowLinks", gPrefix);
- rGroup->followLinks =
- atoi (res_get_def (zh->res, resStr, "1"));
- }
-}
-
-void repositoryShow (ZebraHandle zh)
-
-{
- struct recordGroup *rGroup = &zh->rGroup;
char src[1024];
int src_len;
struct dirs_entry *dst;
Dict dict;
struct dirs_info *di;
-
+
if (!(dict = dict_open (zh->reg->bfs, FMATCH_DICT, 50, 0, 0)))
{
yaz_log (LOG_FATAL, "dict_open fail of %s", FMATCH_DICT);
return;
}
- assert (rGroup->path);
- strcpy (src, rGroup->path);
+ strncpy(src, path, sizeof(src)-1);
+ src[sizeof(src)-1]='\0';
src_len = strlen (src);
if (src_len && src[src_len-1] != '/')
src[++src_len] = '\0';
}
- di = dirs_open (dict, src, rGroup->flagRw);
+ di = dirs_open (dict, src, zh->m_flag_rw);
while ( (dst = dirs_read (di)) )
yaz_log (LOG_LOG, "%s", dst->path);
dict_close (dict);
}
-static void fileUpdate (ZebraHandle zh,
- Dict dict, struct recordGroup *rGroup,
- const char *path)
+static void fileUpdate (ZebraHandle zh, Dict dict, const char *path)
{
struct dirs_info *di;
struct stat sbuf;
else
*src = '\0';
strcat (src, path);
- ret = zebra_file_stat (src, &sbuf, rGroup->followLinks);
+ ret = zebra_file_stat (src, &sbuf, zh->m_follow_links);
strcpy (src, path);
src_len = strlen (src);
if (e_dst)
{
if (sbuf.st_mtime > e_dst->mtime)
- if (fileExtract (zh, &e_dst->sysno, src, rGroup, 0))
+ if (fileExtract (zh, &e_dst->sysno, src, 0))
dirs_add (di, src, e_dst->sysno, sbuf.st_mtime);
}
else
{
SYSNO sysno = 0;
- if (fileExtract (zh, &sysno, src, rGroup, 0))
+ if (fileExtract (zh, &sysno, src, 0))
dirs_add (di, src, sysno, sbuf.st_mtime);
}
dirs_free (&di);
src[src_len] = '/';
src[++src_len] = '\0';
}
- di = dirs_open (dict, src, rGroup->flagRw);
+ di = dirs_open (dict, src, zh->m_flag_rw);
*dst = '\0';
- fileUpdateR (zh, di, dirs_read (di), src, dst, rGroup, 0);
+ fileUpdateR (zh, di, dirs_read (di), src, dst, 0);
dirs_free (&di);
}
else
}
static void repositoryExtract (ZebraHandle zh,
- int deleteFlag, struct recordGroup *rGroup,
- const char *path)
+ int deleteFlag, const char *path)
{
struct stat sbuf;
char src[1024];
else
*src = '\0';
strcat (src, path);
- ret = zebra_file_stat (src, &sbuf, rGroup->followLinks);
+ ret = zebra_file_stat (src, &sbuf, zh->m_follow_links);
strcpy (src, path);
if (ret == -1)
yaz_log (LOG_WARN|LOG_ERRNO, "Cannot access path %s", src);
else if (S_ISREG(sbuf.st_mode))
- fileExtract (zh, NULL, src, rGroup, deleteFlag);
+ fileExtract (zh, NULL, src, deleteFlag);
else if (S_ISDIR(sbuf.st_mode))
- repositoryExtractR (zh, deleteFlag, src, rGroup, 0);
+ repositoryExtractR (zh, deleteFlag, src, 0);
else
yaz_log (LOG_WARN, "Skipping path %s", src);
}
-static void repositoryExtractG (ZebraHandle zh,
- int deleteFlag, struct recordGroup *rGroup)
+static void repositoryExtractG (ZebraHandle zh, const char *path,
+ int deleteFlag)
{
- if (*rGroup->path == '\0' || !strcmp(rGroup->path, "-"))
+ if (!strcmp(path, "") || !strcmp(path, "-"))
{
char src[1024];
-
+
while (scanf ("%1020s", src) == 1)
- repositoryExtract (zh, deleteFlag, rGroup, src);
+ repositoryExtract (zh, deleteFlag, src);
}
else
- repositoryExtract (zh, deleteFlag, rGroup, rGroup->path);
+ repositoryExtract (zh, deleteFlag, path);
}
-void repositoryUpdate (ZebraHandle zh)
+void repositoryUpdate (ZebraHandle zh, const char *path)
{
- struct recordGroup *rGroup = &zh->rGroup;
- groupRes (zh, rGroup);
- assert (rGroup->path);
- if (rGroup->recordId && !strcmp (rGroup->recordId, "file"))
+ assert (path);
+ if (zh->m_record_id && !strcmp (zh->m_record_id, "file"))
{
Dict dict;
if (!(dict = dict_open (zh->reg->bfs, FMATCH_DICT, 50,
- rGroup->flagRw, 0)))
+ zh->m_flag_rw, 0)))
{
yaz_log (LOG_FATAL, "dict_open fail of %s", FMATCH_DICT);
return ;
}
- if (*rGroup->path == '\0' || !strcmp(rGroup->path, "-"))
+ if (!strcmp(path, "") || !strcmp(path, "-"))
{
char src[1024];
while (scanf ("%s", src) == 1)
- fileUpdate (zh, dict, rGroup, src);
+ fileUpdate (zh, dict, src);
}
else
- fileUpdate (zh, dict, rGroup, rGroup->path);
+ fileUpdate (zh, dict, path);
dict_close (dict);
}
else
- repositoryExtractG (zh, 0, rGroup);
+ repositoryExtractG (zh, path, 0);
}
-void repositoryDelete (ZebraHandle zh)
+void repositoryDelete (ZebraHandle zh, const char *path)
{
- struct recordGroup *rGroup = &zh->rGroup;
- groupRes (zh, rGroup);
- assert (rGroup->path);
- repositoryExtractG (zh, 1, rGroup);
+ assert (path);
+ repositoryExtractG (zh, path, 1);
}
-/* $Id: zebraapi.c,v 1.115 2003-11-28 14:47:45 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: zebraapi.c,v 1.116 2004-01-22 11:27:21 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
zh->lock_normal = 0;
zh->lock_shadow = 0;
- zh->admin_databaseName = 0;
-
zh->shadow_enable = 1;
default_encoding = res_get_def(zs->global_res, "encoding", "ISO-8859-1");
return zh;
}
-ZebraService zebra_start (const char *configName)
+ZebraService zebra_start (const char *configName, Res def_res, Res over_res)
{
Res res;
yaz_log(LOG_API|LOG_LOG,"zebra_start %s",configName);
- if ((res = res_open (configName, 0)))
+ if ((res = res_open (configName, def_res, over_res)))
{
ZebraService zh = xmalloc (sizeof(*zh));
{
struct zebra_register *reg;
int record_compression = REC_COMPRESS_NONE;
- char *recordCompression = 0;
+ const char *recordCompression = 0;
+ const char *profilePath;
+ char cwd[1024];
ASSERTZS;
}
if (useshadow)
bf_cache (reg->bfs, res_get (res, "shadow"));
- data1_set_tabpath (reg->dh, res_get_def(res, "profilePath",
- DEFAULT_PROFILE_PATH));
+
+ getcwd(cwd, sizeof(cwd)-1);
+ profilePath = res_get_def(res, "profilePath", DEFAULT_PROFILE_PATH);
+ yaz_log(LOG_LOG, "profilePath=%s cwd=%s", profilePath, cwd);
+
+ data1_set_tabpath (reg->dh, profilePath);
data1_set_tabroot (reg->dh, reg_path);
reg->recTypes = recTypes_init (reg->dh);
recTypes_default_handlers (reg->recTypes);
res_close (zs->global_res);
xfree (zs->configName);
- xfree (zs->path_root);
xfree (zs);
return 0;
}
if (zh->iconv_from_utf8 != 0)
yaz_iconv_close (zh->iconv_from_utf8);
- xfree (zh->admin_databaseName);
zebra_mutex_cond_lock (&zs->session_lock);
zebra_lock_destroy (zh->lock_normal);
zebra_lock_destroy (zh->lock_shadow);
zebra_mutex_cond_unlock (&zs->session_lock);
xfree (zh->reg_name);
zh->service=0; /* more likely to trigger an assert */
+ xfree (zh->path_reg);
xfree (zh);
return 0;
}
if (zh->path_reg)
{
sprintf (fname, "%.200s/zebra.cfg", zh->path_reg);
- res = res_open (fname, zh->service->global_res);
+ res = res_open (fname, zh->service->global_res, 0);
if (!res)
res = zh->service->global_res;
}
const char *lock_area =res_get (zh->res, "lockDir");
if (!lock_area && zh->path_reg)
- res_put (zh->res, "lockDir", zh->path_reg);
+ res_set (zh->res, "lockDir", zh->path_reg);
sprintf (fname, "norm.%s.LCK", zh->reg_name);
zh->lock_normal =
zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
if (zebra_select_database(zh, database))
return 1;
zebra_begin_trans (zh, 1);
- xfree (zh->admin_databaseName);
- zh->admin_databaseName = xstrdup(database);
return 0;
}
for (i = 0; i<segment->num_segmentRecords; i++)
{
Z_NamePlusRecord *npr = segment->segmentRecords[i];
- const char *databaseName = npr->databaseName;
- if (!databaseName)
- databaseName = zh->admin_databaseName;
printf ("--------------%d--------------------\n", i);
if (npr->which == Z_NamePlusRecord_intermediateFragment)
{
oct->buf);
sysno = 0;
- extract_rec_in_mem (zh, "grs.sgml",
+
+ zebra_update_record(zh,
+ 0, /* record Type */
+ &sysno,
+ 0, /* match */
+ 0, /* fname */
oct->buf, oct->len,
- databaseName,
- 0 /* delete_flag */,
- 0 /* test_mode */,
- &sysno /* sysno */,
- 1 /* store_keys */,
- 1 /* store_data */,
- 0 /* match criteria */);
+ 0);
}
}
}
}
int zebra_admin_exchange_record (ZebraHandle zh,
- const char *database,
const char *rec_buf,
size_t rec_len,
const char *recid_buf, size_t recid_len,
int action)
+ /* 1 = insert. Fail it already exists */
+ /* 2 = replace. Fail it does not exist */
+ /* 3 = delete. Fail if does not exist */
+ /* 4 = update. Insert/replace */
{
int sysno = 0;
char *rinfo = 0;
char recid_z[256];
ASSERTZH;
- yaz_log(LOG_API,"zebra_admin_exchange_record db=%s ac=%d",
- database, action);
+ yaz_log(LOG_API,"zebra_admin_exchange_record ac=%d", action);
zh->errCode=0;
if (!recid_buf || recid_len <= 0 || recid_len >= sizeof(recid_z))
zebra_end_trans(zh);
return -1;
}
- }
- extract_rec_in_mem (zh, "grs.sgml", rec_buf, rec_len, database,
- action == 3 ? 1 : 0 /* delete flag */,
- 0, &sysno, 1, 1, 0);
+ action = 1; /* make it an insert (if it's an update).. */
+ }
+ buffer_extract_record (zh, rec_buf, rec_len,
+ action == 3 ? 1 : 0 /* delete flag */,
+ 0, /* test mode */
+ 0, /* recordType */
+ &sysno,
+ 0, /* match */
+ 0, /* fname */
+ 0, /* force update */
+ 1 /* allow update */
+ );
if (action == 1)
{
dict_insert (zh->reg->matchDict, recid_z, sizeof(sysno), &sysno);
return zebra_end_trans(zh);
}
+static void read_res_for_transaction(ZebraHandle zh)
+{
+ const char *group = res_get(zh->res, "group");
+ const char *v;
+
+ zh->m_group = group;
+ v = res_get_prefix(zh->res, "followLinks", group, "1");
+ zh->m_follow_links = atoi(v);
+
+ zh->m_record_id = res_get_prefix(zh->res, "recordId", group, 0);
+ zh->m_record_type = res_get_prefix(zh->res, "recordType", group, 0);
+
+ v = res_get_prefix(zh->res, "storeKeys", group, "1");
+ zh->m_store_keys = atoi(v);
+
+ v = res_get_prefix(zh->res, "storeData", group, "1");
+ zh->m_store_data = atoi(v);
+
+ v = res_get_prefix(zh->res, "explainDatabase", group, "0");
+ zh->m_explain_database = atoi(v);
+
+ v = res_get_prefix(zh->res, "openRW", group, "1");
+ zh->m_flag_rw = atoi(v);
+
+ v = res_get_prefix(zh->res, "fileVerboseLimit", group, "100000");
+ zh->m_file_verbose_limit = atoi(v);
+}
+
int zebra_begin_trans (ZebraHandle zh, int rw)
{
if (!zh->res)
zh->reg->last_val = val;
zh->reg->seqno = seqno;
}
+ read_res_for_transaction(zh);
return 0;
}
return 0;
}
-int zebra_repository_update (ZebraHandle zh)
+int zebra_repository_update (ZebraHandle zh, const char *path)
{
ASSERTZH;
zh->errCode=0;
- logf (LOG_LOG|LOG_API, "updating %s", zh->rGroup.path);
- repositoryUpdate (zh);
+ logf (LOG_LOG|LOG_API, "updating %s", path);
+ repositoryUpdate (zh, path);
return zh->errCode;
}
-int zebra_repository_delete (ZebraHandle zh)
+int zebra_repository_delete (ZebraHandle zh, const char *path)
{
ASSERTZH;
zh->errCode=0;
- logf (LOG_LOG|LOG_API, "deleting %s", zh->rGroup.path);
- repositoryDelete (zh);
+ logf (LOG_LOG|LOG_API, "deleting %s", path);
+ repositoryDelete (zh, path);
return zh->errCode;
}
-int zebra_repository_show (ZebraHandle zh)
+int zebra_repository_show (ZebraHandle zh, const char *path)
{
ASSERTZH;
yaz_log(LOG_API,"zebra_repository_show");
zh->errCode=0;
- repositoryShow (zh);
+ repositoryShow (zh, path);
return zh->errCode;
}
return 0;
}
-int zebra_record_insert (ZebraHandle zh, const char *buf, int len, int *sysno)
-{
- int sysn=0;
- ASSERTZH;
- yaz_log(LOG_API,"zebra_record_insert");
- if (sysno)
- *sysno=0;
- zh->errCode=0;
- if (zebra_begin_trans (zh, 1))
- return -1;
- extract_rec_in_mem (zh, "grs.sgml",
- buf, len,
- "Default", /* database */
- 0 /* delete_flag */,
- 0 /* test_mode */,
- &sysn /* sysno */,
- 1 /* store_keys */,
- 1 /* store_data */,
- 0 /* match criteria */);
- if (zebra_end_trans (zh))
- return -1;
- if (sysno)
- *sysno=sysn;
- return 0;
-}
-
-int zebra_set_group (ZebraHandle zh, struct recordGroup *rg)
-{
- ASSERTZH;
- yaz_log(LOG_API,"zebra_set_group");
- zh->errCode=0;
- memcpy (&zh->rGroup, rg, sizeof(*rg));
- return 0;
-}
-
int zebra_result (ZebraHandle zh, int *code, char **addinfo)
{
ASSERTZH;
ASSERTZH;
yaz_log(LOG_API,"zebra_set_resource %s:%s",name,value);
zh->errCode=0;
- res_put(zh->res, name, value);
+ res_set(zh->res, name, value);
return 0;
}
return 0;
}
-int init_recordGroup (struct recordGroup *rg)
-{
- assert(rg);
- yaz_log(LOG_API,"init_recordGroup");
- rg->groupName = NULL;
- rg->databaseName = NULL;
- rg->path = NULL;
- rg->recordId = NULL;
- rg->recordType = NULL;
- rg->flagStoreData = -1;
- rg->flagStoreKeys = -1;
- rg->flagRw = 1;
- rg->databaseNamePath = 0;
- rg->explainDatabase = 0;
- rg->fileVerboseLimit = 100000;
- rg->followLinks = -1;
- return 0;
-}
-
-
-/* This is from extract.c... it seems useful, when extract_rec_in mem is
- called... and in general... Should be moved to somewhere else */
-void res_get_recordGroup (ZebraHandle zh,
- struct recordGroup *rGroup,
- const char *ext)
-{
- char gprefix[128];
- char ext_res[128];
-
- yaz_log(LOG_API,"res_get_recordGroup e=%s",ext);
- if (!rGroup->groupName || !*rGroup->groupName)
- *gprefix = '\0';
- else
- sprintf (gprefix, "%s.", rGroup->groupName);
-
- /* determine file type - depending on extension */
- if (!rGroup->recordType) {
- sprintf (ext_res, "%srecordType.%s", gprefix, ext);
- if (!(rGroup->recordType = res_get (zh->res, ext_res))) {
- sprintf (ext_res, "%srecordType", gprefix);
- rGroup->recordType = res_get (zh->res, ext_res);
- }
- }
- /* determine match criteria */
- if (!rGroup->recordId) {
- sprintf (ext_res, "%srecordId.%s", gprefix, ext);
- if (!(rGroup->recordId = res_get (zh->res, ext_res))) {
- sprintf (ext_res, "%srecordId", gprefix);
- rGroup->recordId = res_get (zh->res, ext_res);
- }
- }
-
- /* determine database name */
- if (!rGroup->databaseName) {
- sprintf (ext_res, "%sdatabase.%s", gprefix, ext);
- if (!(rGroup->databaseName = res_get (zh->res, ext_res))) {
- sprintf (ext_res, "%sdatabase", gprefix);
- rGroup->databaseName = res_get (zh->res, ext_res);
- }
- }
- if (!rGroup->databaseName)
- rGroup->databaseName = "Default";
-
- /* determine if explain database */
- sprintf (ext_res, "%sexplainDatabase", gprefix);
- rGroup->explainDatabase =
- atoi (res_get_def (zh->res, ext_res, "0"));
-
- /* storeData */
- if (rGroup->flagStoreData == -1)
- {
- const char *sval;
- sprintf (ext_res, "%sstoreData.%s", gprefix, ext);
- if (!(sval = res_get (zh->res, ext_res)))
- {
- sprintf (ext_res, "%sstoreData", gprefix);
- sval = res_get (zh->res, ext_res);
- }
- if (sval)
- rGroup->flagStoreData = atoi (sval);
- }
- if (rGroup->flagStoreData == -1)
- rGroup->flagStoreData = 0;
-
- /* storeKeys */
- if (rGroup->flagStoreKeys == -1)
- {
- const char *sval;
-
- sprintf (ext_res, "%sstoreKeys.%s", gprefix, ext);
- sval = res_get (zh->res, ext_res);
- if (!sval)
- {
- sprintf (ext_res, "%sstoreKeys", gprefix);
- sval = res_get (zh->res, ext_res);
- }
- if (!sval)
- sval = res_get (zh->res, "storeKeys");
- if (sval)
- rGroup->flagStoreKeys = atoi (sval);
- }
- if (rGroup->flagStoreKeys == -1)
- rGroup->flagStoreKeys = 0;
-}
-
-
/* almost the same as zebra_records_retrieve ... but how did it work?
I mean for multiple records ??? CHECK ??? */
void api_records_retrieve (ZebraHandle zh, ODR stream,
/* ---------------------------------------------------------------------------
Record insert(=update), delete
- If sysno is provided, then it's used to identify the reocord.
+ If sysno is provided, then it's used to identify the record.
If not, and match_criteria is provided, then sysno is guessed
If not, and a record is provided, then sysno is got from there
NOTE: Now returns 0 at success and updates sysno, which is an int*
20-jun-2003 Heikki
*/
+int zebra_add_record(ZebraHandle zh,
+ const char *buf, int buf_size)
+{
+ int sysno = 0;
+ return zebra_update_record(zh, 0, &sysno, 0, 0, buf, buf_size, 0);
+}
+
int zebra_insert_record (ZebraHandle zh,
- struct recordGroup *rGroup,
const char *recordType,
int *sysno, const char *match, const char *fname,
- const char *buf, int buf_size,
- int force_update) /* This one is ignored */
-
+ const char *buf, int buf_size)
{
int res;
yaz_log(LOG_API,"zebra_insert_record sysno=%d", *sysno);
if (buf_size < 1) buf_size = strlen(buf);
zebra_begin_trans(zh, 1);
- res=bufferExtractRecord (zh, buf, buf_size, rGroup,
- 0, /* delete_flag */
- 0, /* test_mode */
- recordType,
- sysno,
- match, fname,
- force_update,
- 0); /* allow_update */
+ res = buffer_extract_record (zh, buf, buf_size,
+ 0, /* delete_flag */
+ 0, /* test_mode */
+ recordType,
+ sysno,
+ match, fname,
+ 0,
+ 0); /* allow_update */
zebra_end_trans(zh);
- if (res < 0) return (res);
return res;
}
int zebra_update_record (ZebraHandle zh,
- struct recordGroup *rGroup,
const char *recordType,
int* sysno, const char *match, const char *fname,
const char *buf, int buf_size,
if (buf_size < 1) buf_size = strlen(buf);
zebra_begin_trans(zh, 1);
- res=bufferExtractRecord (zh, buf, buf_size, rGroup,
- 0, /* delete_flag */
- 0, /* test_mode */
- recordType,
- sysno,
- match, fname,
- force_update,
- 1); /* allow_update */
+ res = buffer_extract_record (zh, buf, buf_size,
+ 0, /* delete_flag */
+ 0, /* test_mode */
+ recordType,
+ sysno,
+ match, fname,
+ force_update,
+ 1); /* allow_update */
zebra_end_trans(zh);
return res;
}
int zebra_delete_record (ZebraHandle zh,
- struct recordGroup *rGroup,
const char *recordType,
int *sysno, const char *match, const char *fname,
const char *buf, int buf_size,
if (buf_size < 1) buf_size = strlen(buf);
zebra_begin_trans(zh, 1);
- res=bufferExtractRecord (zh, buf, buf_size, rGroup,
- 1, /* delete_flag */
- 0, /* test_mode */
- recordType,
- sysno,
- match,fname,
- force_update,
- 1); /* allow_update */
+ res = buffer_extract_record (zh, buf, buf_size,
+ 1, /* delete_flag */
+ 0, /* test_mode */
+ recordType,
+ sysno,
+ match,fname,
+ force_update,
+ 1); /* allow_update */
zebra_end_trans(zh);
return res;
}
-/* $Id: zebrash.c,v 1.24 2003-12-04 11:20:39 heikki Exp $
- Copyright (C) 2002,2003
+/* $Id: zebrash.c,v 1.25 2004-01-22 11:27:21 adam Exp $
+ Copyright (C) 2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
DEFAULTCONFIG "\n" );
conf=DEFAULTCONFIG;
}
- zs=zebra_start(conf);
+ zs=zebra_start(conf, 0, 0);
if (!zs) {
wrbuf_puts(outbuff, "zebra_start failed" );
return 2;
int rc;
char *rec=restargs(args,1);
- rc=zebra_record_insert(zh,rec, strlen(rec), &sysno);
+ rc = zebra_insert_record(zh,
+ 0, /* record type */
+ &sysno,
+ 0, /* match */
+ 0, /* fname */
+ rec,
+ strlen(rec));
if (0==rc)
{
wrbuf_printf(outbuff,"ok sysno=%d\n",sysno);
static int cmd_exchange_record( char *args[], WRBUF outbuff)
{
- char *base=args[1];
- char *id = args[2];
- char *action = args[3];
+ char *id = args[1];
+ char *action = args[2];
int rc;
- char *rec=restargs(args,4);
- if (!(base && id && action && args[4] ))
+ char *rec=restargs(args,3);
+ if (!(id && action && args[4] ))
{
wrbuf_puts(outbuff,"Missing arguments!\n");
onecommand("help exchange_record", outbuff, "");
return -90;
}
- rc=zebra_admin_exchange_record(zh, base, rec, strlen(rec),
+ rc=zebra_admin_exchange_record(zh, rec, strlen(rec),
id, strlen(id), atoi(action));
return rc;
}
-/* $Id: zrpn.c,v 1.135 2004-01-15 13:31:31 adam Exp $
+/* $Id: zrpn.c,v 1.136 2004-01-22 11:27:21 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
{
/* set was found, but value wasn't defined */
char val_str[32];
- sprintf (val_str, "%d", use_value);
+ sprintf (val_str, "%d 1", use_value);
errCode = 114;
errString = nmem_strdup (stream, val_str);
}
}
if (!prefix_len)
{
+#if 1
+ bases_ok++;
+#else
char val_str[32];
- sprintf (val_str, "%d", use_value);
+ sprintf (val_str, "%d 2", use_value);
errCode = 114;
errString = nmem_strdup (stream, val_str);
+#endif
continue;
}
bases_ok++; /* this has OK attributes */
-/* $Id: zserver.c,v 1.112 2003-11-09 11:48:16 oleg Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: zserver.c,v 1.113 2004-01-22 11:27:21 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
{
Z_External *rec = notToKeep->elements[i]->record;
struct oident *oident = 0;
- Odr_oct *recid = notToKeep->elements[i]->u.opaque;
+ Odr_oct *opaque_recid = 0;
+ int sysno = 0;
- if (!recid)
- {
- rr->errcode = 224;
- rr->errstring = "record Id not supplied";
- break;
- }
- if (notToKeep->elements[i]->which !=
- Z_IUSuppliedRecords_elem_opaque)
- {
- rr->errcode = 224;
- rr->errstring = "only opaque record ID supported";
- break;
+ if (notToKeep->elements[i]->u.opaque)
+ {
+ switch(notToKeep->elements[i]->which)
+ {
+ case Z_IUSuppliedRecords_elem_opaque:
+ opaque_recid = notToKeep->elements[i]->u.opaque;
+ break; /* OK, recid already set */
+ case Z_IUSuppliedRecords_elem_number:
+ sysno = *notToKeep->elements[i]->u.number;
+ break;
+ }
}
-
if (rec->direct_reference)
{
oident = oid_getentbyoid(rec->direct_reference);
action = 3;
if (*toKeep->action ==
Z_IUOriginPartToKeep_specialUpdate)
- action = 1;
+ action = 4;
if (!action)
{
rr->errstring = "unsupported ES Update action";
break;
}
- else
- {
+ else if (opaque_recid)
+ {
int r = zebra_admin_exchange_record (
- zh, toKeep->databaseName,
+ zh,
rec->u.octet_aligned->buf,
rec->u.octet_aligned->len,
- recid->buf, recid->len,
+ opaque_recid->buf, opaque_recid->len,
action);
- if (r && *toKeep->action ==
- Z_IUOriginPartToKeep_specialUpdate)
- {
- r = zebra_admin_exchange_record (
- zh, toKeep->databaseName,
- rec->u.octet_aligned->buf,
- rec->u.octet_aligned->len,
- recid->buf, recid->len,
- 2);
- }
if (r)
{
rr->errcode = 224;
rr->errstring = "record exchange failed";
break;
}
- }
+ }
+ else
+ {
+ int r = -1;
+ switch(action) {
+ case 1:
+ r = zebra_insert_record(
+ zh,
+ 0, /* recordType */
+ &sysno,
+ 0, /* match */
+ 0, /* fname */
+ rec->u.octet_aligned->buf,
+ rec->u.octet_aligned->len);
+ if (r)
+ {
+ rr->errcode = 224;
+ rr->errstring = "insert_record failed";
+ }
+ break;
+ case 2:
+ case 4:
+ r = zebra_update_record(
+ zh,
+ 0, /* recordType */
+ &sysno,
+ 0, /* match */
+ 0, /* fname */
+ rec->u.octet_aligned->buf,
+ rec->u.octet_aligned->len,
+ 1);
+ if (r)
+ {
+ rr->errcode = 224;
+ rr->errstring = "update_record failed";
+ }
+ break;
+ case 3:
+ r = zebra_delete_record(
+ zh,
+ 0, /* recordType */
+ &sysno,
+ 0, /* match */
+ 0, /* fname */
+ rec->u.octet_aligned->buf,
+ rec->u.octet_aligned->len,
+ 0);
+ if (r)
+ {
+ rr->errcode = 224;
+ rr->errstring = "delete_record failed";
+ }
+ break;
+ }
+ }
}
}
zebra_end_trans (zh);
{
if (sob->handle)
zebra_stop((ZebraService) sob->handle);
- sob->handle = zebra_start(sob->configname);
+ sob->handle = zebra_start(sob->configname, 0, 0);
if (!sob->handle)
{
yaz_log (LOG_FATAL, "Failed to read config `%s'", sob->configname);
-/* $Id: isam.c,v 1.27 2002-08-02 19:26:56 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: isam.c,v 1.28 2004-01-22 11:27:21 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
int writeflag, int keysize, Res res)
{
ISAM inew;
- char *nm, *r, *pp[IS_MAX_BLOCKTYPES+1], m[2];
+ char *nm, *pp[IS_MAX_BLOCKTYPES+1], m[2];
int num, size, rs, tmp, i;
+ const char *r;
is_type_header th;
logf (LOG_DEBUG, "is_open(%s, %s)", name, writeflag ? "RW" : "RDONLY");
-/* $Id: rset.c,v 1.18 2004-01-16 15:27:35 heikki Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: rset.c,v 1.19 2004-01-22 11:27:22 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
int rset_default_forward(RSFD rfd, void *buf, const void *untilbuf)
{
- logf (LOG_FATAL, "rset_default-forward not yet implemented (%s)");
+ logf (LOG_FATAL, "rset_default-forward not yet implemented");
+ return 0;
}
RSET_TERM *rset_terms(RSET rs, int *no)
-/* $Id: t1.c,v 1.3 2003-05-20 13:52:41 adam Exp $
+/* $Id: t1.c,v 1.4 2004-01-22 11:27:22 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
yaz_log_init_file("t1.log");
nmem_init();
- zs = zebra_start("t1.cfg");
+ zs = zebra_start("t1.cfg", 0, 0);
zh = zebra_open (zs);
zebra_close (zh);
-/* $Id: t2.c,v 1.7 2003-06-20 14:21:24 heikki Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: t2.c,v 1.8 2004-01-22 11:27:22 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
nmem_init ();
- zs = zebra_start("t2.cfg");
+ zs = zebra_start("t2.cfg", 0, 0);
zh = zebra_open (zs);
zebra_select_database(zh, "Default");
zebra_begin_trans (zh, 1);
- zebra_record_insert (zh, myrec, strlen(myrec),0);
+
+ zebra_add_record (zh, myrec, strlen(myrec));
zebra_search_PQF (zh, "@attr 1=4 my", "set1", &hits);
if (hits < 1)
-# $Id: t2.cfg,v 1.2 2003-04-24 19:35:52 adam Exp $
+# $Id: t2.cfg,v 1.3 2004-01-22 11:27:22 adam Exp $
profilepath: ../../tab
attset: bib1.att
+recordType: grs.sgml
+
-/* $Id: t3.c,v 1.4 2003-06-20 14:21:24 heikki Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: t3.c,v 1.5 2004-01-22 11:27:22 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
nmem_init ();
- zs = zebra_start("t2.cfg");
+ zs = zebra_start("t2.cfg", 0, 0);
zh = zebra_open (zs);
zebra_select_database(zh, "Default");
zebra_begin_trans (zh, 1);
- zebra_record_insert (zh, myrec, strlen(myrec),0);
+ zebra_add_record (zh, myrec, strlen(myrec));
zebra_end_trans (zh);
for (i = 0; i<4; i++)
-/* $Id: t4.c,v 1.4 2003-10-21 09:59:05 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: t4.c,v 1.5 2004-01-22 11:27:22 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
nmem_init ();
- zs = zebra_start("t2.cfg");
+ zs = zebra_start("t2.cfg", 0, 0);
zh = zebra_open (zs);
zebra_select_database(zh, "Default");
zebra_begin_trans (zh, 1);
for (i = 0; i<1200; i++)
- zebra_record_insert (zh, myrec, strlen(myrec),0);
+ zebra_add_record (zh, myrec, strlen(myrec));
zebra_end_trans (zh);
zebra_close(zh);
zebra_stop(zs);
- zs = zebra_start("t2.cfg");
+ zs = zebra_start("t2.cfg", 0, 0);
zh = zebra_open (zs);
zebra_select_database(zh, "Default");
-# $Id: zebra.cfg,v 1.1 2003-08-21 10:42:43 heikki Exp $
+# $Id: zebra.cfg,v 1.2 2004-01-22 11:27:22 adam Exp $
# A fairly minimal zebra.cfg
profilepath: ../../tab
register: reg:100M
lockDir: reg
+recordType: grs.sgml
-/* $Id: res.c,v 1.33 2002-10-22 09:37:56 heikki Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: res.c,v 1.34 2004-01-22 11:27:22 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
char *name;
int init;
Res def_res;
+ Res over_res;
};
static struct res_entry *add_entry (Res r)
fclose (fr);
}
-Res res_open (const char *name, Res def_res)
+Res res_open (const char *name, Res def_res, Res over_res)
{
Res r;
else
r->name=0;
r->def_res = def_res;
+ r->over_res = over_res;
return r;
}
xfree (r);
}
-char *res_get (Res r, const char *name)
+const char *res_get_prefix (Res r, const char *name, const char *prefix,
+ const char *def)
+{
+ const char *v = 0;;
+ if (prefix)
+ {
+ char rname[128];
+
+ if (strlen(name) + strlen(prefix) >= (sizeof(rname)-2))
+ return 0;
+ strcpy(rname, prefix);
+ strcat(rname, ".");
+ strcat(rname, name);
+ v = res_get(r, rname);
+ }
+ if (!v)
+ v = res_get(r, name);
+ if (!v)
+ v = def;
+ return v;
+}
+
+const char *res_get (Res r, const char *name)
{
struct res_entry *re;
+ const char *v;
if (!r)
return 0;
+
+ v = res_get(r->over_res, name);
+ if (v)
+ return v;
+
if (!r->init)
reread (r);
for (re = r->first; re; re=re->next)
return res_get (r->def_res, name);
}
-char *res_get_def (Res r, const char *name, char *def)
+const char *res_get_def (Res r, const char *name, const char *def)
{
- char *t;
+ const char *t;
if (!(t = res_get (r, name)))
{
return 0;
}
-void res_put (Res r, const char *name, const char *value)
+void res_set (Res r, const char *name, const char *value)
{
struct res_entry *re;
assert (r);