-/* $Id: zebrasrv.c,v 1.9 2007-01-17 15:35:48 adam Exp $
+/* $Id: zebrasrv.c,v 1.15 2007-04-17 20:27:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
r->search_info->list[0]->which = Z_OtherInfo_externallyDefinedInfo;
ext = odr_malloc (r->stream, sizeof(*ext));
r->search_info->list[0]->information.externallyDefinedInfo = ext;
- ext->direct_reference =
- yaz_oidval_to_z3950oid (r->stream, CLASS_USERINFO, VAL_SEARCHRES1);
+ ext->direct_reference = odr_oiddup(r->stream,
+ yaz_oid_userinfo_searchresult_1);
ext->indirect_reference = 0;
ext->descriptor = 0;
ext->which = Z_External_searchResult1;
}
-int bend_fetch (void *handle, bend_fetch_rr *r)
+int bend_fetch(void *handle, bend_fetch_rr *r)
{
ZebraHandle zh = (ZebraHandle) handle;
ZebraRetrievalRecord retrievalRecord;
r->basename = retrievalRecord.base;
r->record = retrievalRecord.buf;
r->len = retrievalRecord.len;
- r->output_format = retrievalRecord.format;
+ r->output_format = odr_oiddup(r->stream, retrievalRecord.format);
}
return 0;
}
{
zebra_close ((ZebraHandle) handle);
xmalloc_trav("bend_close");
- nmem_print_list();
}
int bend_sort (void *handle, bend_sort_rr *rr)
for (i = 0; notToKeep && i < notToKeep->num; i++)
{
Z_External *rec = notToKeep->elements[i]->record;
- struct oident *oident = 0;
Odr_oct *opaque_recid = 0;
zint *sysno = 0;
zint sysno_tmp;
}
if (rec->direct_reference)
{
- oident = oid_getentbyoid(rec->direct_reference);
- if (oident)
+ char oid_name_str[OID_STR_MAX];
+ const char *oid_name =
+ yaz_oid_to_string_buf(
+ rec->direct_reference,
+ 0, oid_name_str);
+ if (oid_name)
yaz_log (YLOG_LOG, "record %d type %s", i,
- oident->desc);
+ oid_name);
}
switch (rec->which)
{
rec->u.octet_aligned->len,
rec->u.octet_aligned->buf);
}
- if (oident && oident->value != VAL_TEXT_XML
- && oident->value != VAL_SUTRS)
- {
- rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
- rr->errstring = "only XML update supported";
- break;
- }
if (rec->which == Z_External_octet)
{
- int action = 0;
+ enum zebra_recctrl_action_t action = action_update;
+ char recid_str[256];
+ const char *match_criteria = 0;
+ ZEBRA_RES res;
if (*toKeep->action ==
Z_IUOriginPartToKeep_recordInsert)
- action = 1;
- if (*toKeep->action ==
+ action = action_insert;
+ else if (*toKeep->action ==
Z_IUOriginPartToKeep_recordReplace)
- action = 2;
- if (*toKeep->action ==
+ action = action_replace;
+ else if (*toKeep->action ==
Z_IUOriginPartToKeep_recordDelete)
- action = 3;
- if (*toKeep->action ==
+ action = action_delete;
+ else if (*toKeep->action ==
Z_IUOriginPartToKeep_specialUpdate)
- action = 4;
-
- if (!action)
+ action = action_update;
+ else
{
rr->errcode =
YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
rr->errstring = "unsupported ES Update action";
break;
}
- else if (opaque_recid)
+
+ if (opaque_recid)
{
- int r = zebra_admin_exchange_record (
- zh,
- (const char *) rec->u.octet_aligned->buf,
- rec->u.octet_aligned->len,
- (const char *) opaque_recid->buf,
- opaque_recid->len,
- action);
- if (r)
+ size_t l = opaque_recid->len;
+ if (l >= sizeof(recid_str))
{
- zebra_result(zh, &rr->errcode,
- &rr->errstring);
+ rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
+ rr->errstring = "opaque record ID too large";
break;
}
- }
- else
- {
- ZEBRA_RES r = ZEBRA_FAIL;
- switch(action) {
- case 1:
- r = zebra_insert_record(
- zh,
- 0, /* recordType */
- sysno,
- 0, /* match */
- 0, /* fname */
- (const char *) rec->u.octet_aligned->buf,
- rec->u.octet_aligned->len,
- 0);
- if (r == ZEBRA_FAIL)
- {
- rr->errcode =
- YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
- rr->errstring = "insert_record failed";
- }
- break;
- case 2:
- case 4:
- r = zebra_update_record(
- zh,
- 0, /* recordType */
- sysno,
- 0, /* match */
- 0, /* fname */
- (const char *) rec->u.octet_aligned->buf,
- rec->u.octet_aligned->len,
- 1);
- if (r == ZEBRA_FAIL)
- {
- rr->errcode =
- YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
- rr->errstring = "update_record failed";
- }
- break;
- case 3:
- r = zebra_delete_record(
- zh,
- 0, /* recordType */
- sysno,
- 0, /* match */
- 0, /* fname */
- (const char *) rec->u.octet_aligned->buf,
- rec->u.octet_aligned->len,
- 0);
- if (r == ZEBRA_FAIL)
- {
- rr->errcode =
- YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
- rr->errstring = "delete_record failed";
- }
- break;
- }
- }
+ memcpy(recid_str, opaque_recid->buf, l);
+ recid_str[l] = '\0';
+ match_criteria = recid_str;
+ }
+ res = zebra_update_record(
+ zh, action,
+ 0, /* recordType */
+ sysno, match_criteria, 0, /* fname */
+ (const char *) rec->u.octet_aligned->buf,
+ rec->u.octet_aligned->len);
+ if (res == ZEBRA_FAIL)
+ {
+ rr->errcode =
+ YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
+ rr->errstring = "update_record failed";
+ }
}
}
if (zebra_end_trans (zh) != ZEBRA_OK)
zebra_stop((ZebraService) sob->handle);
res_set(default_res, "profilePath", DEFAULT_PROFILE_PATH);
res_set(default_res, "modulePath", DEFAULT_MODULE_PATH);
- sob->handle = zebra_start(sob->configname);
+ sob->handle = zebra_start_res(sob->configname, default_res, 0);
res_close(default_res);
if (!sob->handle)
{