Makefile
src/Makefile
include/Makefile
+ include/yaz/Makefile
include/yaz++/Makefile
yaz++-config
src/yaz++-config
-SUBDIRS = yaz++
+SUBDIRS = yaz yaz++
* Copyright (c) 2000-2001, Index Data.
* See the file LICENSE for details.
*
- * $Id: yaz-z-server.h,v 1.5 2001-04-03 14:37:19 adam Exp $
+ * $Id: yaz-z-server.h,v 1.6 2001-04-04 14:02:49 adam Exp $
*/
#include <yaz++/yaz-z-assoc.h>
+#include <yaz/zes-ursula.h>
class Yaz_Z_Server;
+class YAZ_EXPORT Yaz_Z_ServerUtility {
+ public:
+ void create_databaseRecord (ODR odr, Z_NamePlusRecord *rec,
+ const char *dbname, int format,
+ const void *buf, int len);
+ void create_surrogateDiagnostics(ODR odr, Z_NamePlusRecord *rec,
+ const char *dbname, int error,
+ char *const addinfo);
+
+ Z_Records *create_nonSurrogateDiagnostics (ODR odr, int error,
+ const char *addinfo);
+};
+
class YAZ_EXPORT IYaz_Server_Facility {
public:
virtual int init(Yaz_Z_Server *server,
};
+class YAZ_EXPORT Yaz_Facility_Ursula : public IYaz_Server_Facility {
+ public:
+ virtual void ursula_service (Z_ExtendedServicesRequest *req,
+ Z_UrsPDU *u,
+ Z_ExtendedServicesResponse *res) = 0;
+
+ int init(Yaz_Z_Server *server,
+ Z_InitRequest *initRequest,
+ Z_InitResponse *initResponse);
+ int recv(Yaz_Z_Server *server, Z_APDU *apdu);
+};
+
+
class YAZ_EXPORT Yaz_Facility_ILL : public IYaz_Server_Facility {
public:
virtual int ill_init (Z_InitRequest *initRequest,
Z_InitResponse *initResponse) = 0;
virtual void ill_service (Z_ExtendedServicesRequest *req,
- Z_ItemOrder *io, Z_ExtendedServicesResponse *res) = 0;
+ Z_ItemOrder *io,
+ Z_ExtendedServicesResponse *res) = 0;
int init(Yaz_Z_Server *server,
Z_InitRequest *initRequest,
Z_InitResponse *initResponse);
int recv(Yaz_Z_Server *server, Z_APDU *apdu);
-
-
- void create_databaseRecord (Z_NamePlusRecord *rec,
- const char *dbname, int format,
- const void *buf, int len);
- void create_surrogateDiagnostics(Z_NamePlusRecord *rec,
- const char *dbname, int error,
- char *const addinfo);
- virtual ODR odr_encode();
- private:
- ODR m_odr;
};
-class YAZ_EXPORT Yaz_Facility_Retrieval : public IYaz_Server_Facility {
+class YAZ_EXPORT Yaz_Facility_Retrieval : public IYaz_Server_Facility,
+ public Yaz_Z_ServerUtility {
public:
virtual int sr_init (Z_InitRequest *initRequest,
Z_InitResponse *initResponse);
int recv(Yaz_Z_Server *server, Z_APDU *apdu);
- void create_databaseRecord (Z_NamePlusRecord *rec,
- const char *dbname, int format,
- const void *buf, int len);
- void create_surrogateDiagnostics(Z_NamePlusRecord *rec,
- const char *dbname, int error,
- char *const addinfo);
-
- Z_Records *create_nonSurrogateDiagnostics (int error,
- const char *addinfo);
- virtual ODR odr_encode();
+ ODR odr_encode();
+ ODR odr_decode();
private:
- Z_Records *pack_records (const char *resultSetName,
+ Z_Records *pack_records (Yaz_Z_Server *s,
+ const char *resultSetName,
int start, int num,
Z_RecordComposition *comp,
int *next, int *pres,
int *oid);
- void fetch_via_piggyback (Z_SearchRequest *searchRequest,
+ void fetch_via_piggyback (Yaz_Z_Server *s,
+ Z_SearchRequest *searchRequest,
Z_SearchResponse *searchResponse);
- void fetch_via_present (Z_PresentRequest *req, Z_PresentResponse *res);
+ void fetch_via_present (Yaz_Z_Server *s,
+ Z_PresentRequest *req, Z_PresentResponse *res);
int m_preferredMessageSize;
int m_maximumRecordSize;
- ODR m_odr;
+ ODR m_odr_encode;
+ ODR m_odr_decode;
};
class YAZ_EXPORT Yaz_Z_Server_Facility_Info {
Yaz_Z_Server_Facility_Info *m_next;
};
+
+
class YAZ_EXPORT Yaz_Z_Server : public Yaz_Z_Assoc {
public:
Yaz_Z_Server(IYaz_PDU_Observable *the_PDU_Observable);
virtual void recv_Z_PDU(Z_APDU *apdu);
void facility_add(IYaz_Server_Facility *facility, const char *name);
void facility_reset ();
+
+
private:
Yaz_Z_Server_Facility_Info *m_facilities;
};
-## $Id: Makefile.am,v 1.3 2001-03-27 14:47:45 adam Exp $
+## $Id: Makefile.am,v 1.4 2001-04-04 14:02:49 adam Exp $
INCLUDES=$(YAZINC) -I$(srcdir)/../include
libyaz___la_SOURCES=yaz-socket-manager.cpp yaz-pdu-assoc.cpp \
yaz-z-assoc.cpp yaz-proxy.cpp yaz-z-query.cpp yaz-ir-assoc.cpp \
yaz-z-server.cpp yaz-pdu-assoc-thread.cpp yaz-z-server-sr.cpp \
- yaz-z-server-ill.cpp
+ yaz-z-server-ill.cpp zes-ursula.c yaz-z-server-ursula.cpp
libyaz___la_LDFLAGS=-version-info 0:0:0
yaz_proxy_SOURCES=yaz-proxy-main.cpp
LDADD=libyaz++.la $(YAZLALIB)
+
+zes-ursula.c $(top_srcdir)/include/yaz/zes-ursula.h: ursula.tcl ursula.asn
+ cd $(srcdir); ../../yaz/util/yaz-comp -d $(srcdir)/../../yaz/z39.50/z.tcl -d ursula.tcl -i yaz -I ../include ursula.asn
--- /dev/null
+ESFormat-Ursula
+{Z39-50-extendedService DBC(105) UrsulaItemOrder (1)} DEFINITIONS ::=
+ -- oid is 1.2.840.10003.9.1000.105.3
+BEGIN
+IMPORTS InternationalString FROM Z39-50-APDU-1995;
+
+-- Ursula Reserveringer / bestillinger
+PDU ::= CHOICE {
+ request [1] Request,
+ update [2] Update,
+ reservation [3] Reservation,
+ renewal [4] Renewal
+}
+
+-- Foresporgsel
+Request ::= SEQUENCE {
+ libraryNo [1] IMPLICIT LibraryNo OPTIONAL,
+ borrowerTickerNo [2] IMPLICIT InternationalString OPTIONAL,
+ disposalType [3] IMPLICIT DisposalType OPTIONAL,
+ lastUseDate [4] IMPLICIT OCTET STRING OPTIONAL,
+ items [5] IMPLICIT SEQUENCE OF RequestItem,
+ counter [6] IMPLICIT ServiceCounter OPTIONAL,
+ priority [7] IMPLICIT Priority OPTIONAL,
+ disposalNote [8] IMPLICIT DisposalNote OPTIONAL,
+ overrule [9] IMPLICIT BOOLEAN OPTIONAL
+}
+
+-- Opdatering/sletning
+Update ::= SEQUENCE {
+ libraryNo [1] IMPLICIT LibraryNo OPTIONAL,
+ disposalId [2] IMPLICIT OCTET STRING OPTIONAL,
+ priority [3] IMPLICIT Priority OPTIONAL,
+ counter [4] IMPLICIT ServiceCounter OPTIONAL,
+ lastUseDate [5] IMPLICIT OCTET STRING OPTIONAL,
+ disposalNote [6] IMPLICIT DisposalNote OPTIONAL
+}
+
+-- Eksemplarreserveringer
+Reservation ::= CHOICE {
+ request [1] IMPLICIT RequestItem,
+ update [2] IMPLICIT SEQUENCE OF UpdateItem,
+ del [3] IMPLICIT DeleteItem
+}
+
+-- Fornyelse
+Renewal ::= SEQUENCE {
+ libraryNo [1] IMPLICIT LibraryNo OPTIONAL,
+ borrowerTicketNo [2] IMPLICIT BorrowerTicketNo OPTIONAL,
+ copies [3] IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+ newReturnDate [4] IMPLICIT InternationalString OPTIONAL,
+ overrule [5] IMPLICIT BOOLEAN OPTIONAL
+}
+
+
+RequestItem ::= SEQUENCE {
+ id [1] IMPLICIT OCTET STRING,
+ titlePartNo [2] IMPLICIT InternationalString
+}
+
+UpdateItem ::= SEQUENCE {
+ copyNo [1] IMPLICIT InternationalString,
+ adviceTxt [2] IMPLICIT InternationalString
+}
+
+DeleteItem ::= SEQUENCE {
+ copyNo [1] IMPLICIT InternationalString
+}
+
+DisposalType ::= OCTET STRING
+
+BorrowerTicketNo ::= InternationalString
+
+Priority ::= INTEGER
+
+ServiceCounter ::= INTEGER
+
+LibraryNo ::= InternationalString
+
+DisposalNote ::= InternationalString
+
--- /dev/null
+# $Id: ursula.tcl,v 1.1 2001-04-04 14:02:49 adam Exp $
+
+set prefix(ESFormat-Ursula) {z_Urs Z_Urs Z_Urs}
+
+set m ESFormat-Ursula
+set filename($m) zes-ursula
* See the file LICENSE for details.
*
* $Log: yaz-my-client.cpp,v $
- * Revision 1.1 2001-03-27 14:47:45 adam
+ * Revision 1.2 2001-04-04 14:02:49 adam
+ * URSULA / Z-ruth service.
+ *
+ * Revision 1.1 2001/03/27 14:47:45 adam
* New server facility scheme.
*
* Revision 1.17 2001/03/26 14:43:49 adam
#include <yaz/log.h>
#include <yaz/options.h>
#include <yaz/diagbib1.h>
+#include <yaz/marcdisp.h>
#include <yaz++/yaz-ir-assoc.h>
#include <yaz++/yaz-pdu-assoc.h>
#include <yaz++/yaz-socket-manager.h>
+#include <yaz/zes-ursula.h>
extern "C" {
#if HAVE_READLINE_READLINE_H
int cmd_init(char *args);
int cmd_format(char *args);
int cmd_proxy(char *args);
+ int cmd_ursula(char *args);
};
*/
if (r->direct_reference)
{
- printf("Record type: ");
+ printf("Record type: ");
if (ent)
printf("%s\n", ent->desc);
}
}
if (r->which == Z_External_octet && record->u.octet_aligned->len)
{
- recv_textRecord((int) ent->value,
- (const char *) record->u.octet_aligned->buf,
- (size_t) record->u.octet_aligned->len);
+ switch (ent->value)
+ {
+ case VAL_ISO2709:
+ case VAL_UNIMARC:
+ case VAL_INTERMARC:
+ case VAL_USMARC:
+ case VAL_UKMARC:
+ case VAL_NORMARC:
+ case VAL_LIBRISMARC:
+ case VAL_DANMARC:
+ case VAL_FINMARC:
+ case VAL_MAB:
+ case VAL_CANMARC:
+ case VAL_SBN:
+ case VAL_PICAMARC:
+ case VAL_AUSMARC:
+ case VAL_IBERMARC:
+ case VAL_CATMARC:
+ case VAL_MALMARC:
+ case VAL_JPMARC:
+ case VAL_SWEMARC:
+ case VAL_SIGLEMARC:
+ case VAL_ISDSMARC:
+ case VAL_RUSMARC:
+ marc_display((char*) record->u.octet_aligned->buf,stdout);
+ break;
+ default:
+ recv_textRecord((int) ent->value,
+ (const char *) record->u.octet_aligned->buf,
+ (size_t) record->u.octet_aligned->len);
+ }
}
else if (ent && ent->value == VAL_SUTRS && r->which == Z_External_sutrs)
recv_textRecord((int) VAL_SUTRS, (const char *) r->u.sutrs->buf,
return 1;
}
+int MyClient::cmd_ursula(char *args)
+{
+ Z_APDU *apdu = create_Z_PDU(Z_APDU_extendedServicesRequest);
+ Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
+
+ req->packageType = odr_getoidbystr(odr_encode(), "1.2.840.10003");
+
+ Z_External *ext = (Z_External *) odr_malloc(odr_encode(), sizeof(*ext));
+ req->taskSpecificParameters = ext;
+ ext->direct_reference = req->packageType;
+ ext->descriptor = 0;
+ ext->indirect_reference = 0;
+
+ ext->which = Z_External_octet;
+ ext->u.single_ASN1_type = (Odr_oct *)
+ odr_malloc (odr_encode(), sizeof(Odr_oct));
+
+ Z_UrsPDU *pdu = (Z_UrsPDU *) odr_malloc (odr_encode(), sizeof(*pdu));
+ pdu->which = Z_UrsPDU_request;
+ pdu->u.request = (Z_UrsRequest *)
+ odr_malloc (odr_encode(), sizeof(*pdu->u.request));
+ pdu->u.request->libraryNo = odr_strdup(odr_encode(), "000200");
+ pdu->u.request->borrowerTickerNo = 0;
+ pdu->u.request->disposalType = 0;
+ pdu->u.request->lastUseDate = 0;
+ pdu->u.request->num_items = 0;
+ pdu->u.request->items = (Z_UrsRequestItem **) odr_nullval();
+ pdu->u.request->counter = 0;
+ pdu->u.request->priority = 0;
+ pdu->u.request->disposalNote = 0;
+ pdu->u.request->overrule = 0;
+
+ if (!z_UrsPDU (odr_encode(), &pdu, 0, ""))
+ {
+ yaz_log (LOG_LOG, "ursula encoding failed");
+ return 1;
+ }
+ char *buf =
+ odr_getbuf (odr_encode(), &ext->u.single_ASN1_type->len, 0);
+
+ ext->u.single_ASN1_type->buf = (unsigned char*)
+ odr_malloc (odr_encode(), ext->u.single_ASN1_type->len);
+ memcpy (ext->u.single_ASN1_type->buf, buf, ext->u.single_ASN1_type->len);
+ ext->u.single_ASN1_type->size = ext->u.single_ASN1_type->len;
+
+ if (send_Z_PDU(apdu) >= 0)
+ wait();
+ return 1;
+}
+
int MyClient::processCommand(const char *commandLine)
{
char cmdStr[1024], cmdArgs[1024];
{"init", &MyClient::cmd_init, ""},
{"format", &MyClient::cmd_format, "<record-syntax>"},
{"proxy", &MyClient::cmd_proxy, "<host>:[':'<port>]"},
+ {"ursula", &MyClient::cmd_ursula, ""},
{0,0,0}
};
* See the file LICENSE for details.
*
* $Log: yaz-my-server.cpp,v $
- * Revision 1.2 2001-03-29 15:14:26 adam
+ * Revision 1.3 2001-04-04 14:02:49 adam
+ * URSULA / Z-ruth service.
+ *
+ * Revision 1.2 2001/03/29 15:14:26 adam
* Minor updates.
*
* Revision 1.1 2001/03/27 14:47:45 adam
public:
int ill_init (Z_InitRequest *initRequest,
Z_InitResponse *initResponse);
+ void ill_service (Z_ExtendedServicesRequest *req,
+ Z_ItemOrder *io,
+ Z_ExtendedServicesResponse *res);
};
class MyRetrieval : public Yaz_Facility_Retrieval, Yaz_USMARC {
Z_Records *records);
};
+class MyUrsula : public Yaz_Facility_Ursula {
+public:
+ void ursula_service (Z_ExtendedServicesRequest *req,
+ Z_UrsPDU *u,
+ Z_ExtendedServicesResponse *res);
+};
+
class MyServer : public Yaz_Z_Server {
public:
~MyServer();
void connectNotify();
private:
- MyRetrieval *m_retrieval;
- MyILL *m_ill;
+ MyRetrieval m_retrieval;
+ MyILL m_ill;
+ MyUrsula m_ursula;
int m_no;
};
return 1;
}
+void MyILL::ill_service (Z_ExtendedServicesRequest *req,
+ Z_ItemOrder *io,
+ Z_ExtendedServicesResponse *res)
+{
+ yaz_log (LOG_LOG, "MyServer::ill_service");
+}
+
+
+void MyUrsula::ursula_service (Z_ExtendedServicesRequest *req,
+ Z_UrsPDU *u,
+ Z_ExtendedServicesResponse *res)
+{
+ yaz_log (LOG_LOG, "MyServer::ursula_service");
+ switch (u->which)
+ {
+ case Z_UrsPDU_request:
+ yaz_log(LOG_LOG, "request");
+ if (u->u.request->libraryNo)
+ yaz_log (LOG_LOG, "libraryNo: %s", u->u.request->libraryNo);
+ break;
+ case Z_UrsPDU_update:
+ yaz_log(LOG_LOG, "request");
+ break;
+ case Z_UrsPDU_reservation:
+ yaz_log(LOG_LOG, "request");
+ break;
+ case Z_UrsPDU_renewal:
+ yaz_log(LOG_LOG, "request");
+ break;
+ default:
+ yaz_log(LOG_LOG, "unknown");
+ break;
+ }
+}
+
int MyRetrieval::sr_init (Z_InitRequest *initRequest,
Z_InitResponse *initResponse)
{
{
yaz_log (LOG_LOG, "MyServer::recv_Z_record");
const char *rec = get_record(position);
- create_databaseRecord (namePlusRecord, 0, VAL_USMARC, rec,
+ create_databaseRecord (odr_encode(), namePlusRecord, 0, VAL_USMARC, rec,
strlen(rec));
}
MyServer::~MyServer()
{
- delete m_ill;
- delete m_retrieval;
}
IYaz_PDU_Observer *MyServer::sessionNotify(
m_no++;
new_server = new MyServer(the_PDU_Observable);
new_server->timeout(900);
- new_server->m_retrieval = new MyRetrieval;
- new_server->m_ill = new MyILL;
- new_server->facility_add(new_server->m_retrieval, "my sr");
- new_server->facility_add(new_server->m_ill, "my ill");
+ new_server->facility_add(&new_server->m_retrieval, "my sr");
+ new_server->facility_add(&new_server->m_ill, "my ill");
+ new_server->facility_add(&new_server->m_ursula, "my ill");
new_server->set_APDU_log(get_APDU_log());
Yaz_Z_Server (the_PDU_Observable)
{
m_no = 0;
- m_ill = 0;
- m_retrieval = 0;
}
void MyServer::timeoutNotify()
* See the file LICENSE for details.
*
* $Log: yaz-z-server-ill.cpp,v $
- * Revision 1.3 2001-04-03 14:37:19 adam
+ * Revision 1.4 2001-04-04 14:02:49 adam
+ * URSULA / Z-ruth service.
+ *
+ * Revision 1.3 2001/04/03 14:37:19 adam
* More work ILL-service.
*
* Revision 1.2 2001/03/29 15:14:26 adam
#include <yaz/log.h>
#include <yaz++/yaz-z-server.h>
-/*
- * database record.
- */
-void Yaz_Facility_ILL::create_databaseRecord (
- Z_NamePlusRecord *rec, const char *dbname, int format,
- const void *buf, int len)
-{
- rec->databaseName = dbname ? odr_strdup (m_odr, dbname) : 0;
- rec->which = Z_NamePlusRecord_databaseRecord;
- rec->u.databaseRecord = z_ext_record (m_odr, format,
- (const char *) buf, len);
-}
-
-/*
- * surrogate diagnostic.
- */
-void Yaz_Facility_ILL::create_surrogateDiagnostics(
- Z_NamePlusRecord *rec, const char *dbname, int error, char *const addinfo)
-{
- int oid[OID_SIZE];
- int *err = (int *)odr_malloc (m_odr, sizeof(*err));
- oident bib1;
- Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (m_odr, sizeof(*drec));
- Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
- odr_malloc (m_odr, sizeof(*dr));
-
- bib1.proto = PROTO_Z3950;
- bib1.oclass = CLASS_DIAGSET;
- bib1.value = VAL_BIB1;
-
- yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo);
- *err = error;
- rec->databaseName = dbname ? odr_strdup (m_odr, dbname) : 0;
- rec->which = Z_NamePlusRecord_surrogateDiagnostic;
- rec->u.surrogateDiagnostic = drec;
- drec->which = Z_DiagRec_defaultFormat;
- drec->u.defaultFormat = dr;
- dr->diagnosticSetId = odr_oiddup (m_odr,
- oid_ent_to_oid(&bib1, oid));
- dr->condition = err;
- dr->which = Z_DefaultDiagFormat_v2Addinfo;
- dr->u.v2Addinfo = odr_strdup (m_odr, addinfo ? addinfo : "");
-}
-
-ODR Yaz_Facility_ILL::odr_encode()
-{
- return m_odr;
-}
-
int Yaz_Facility_ILL::init(Yaz_Z_Server *s, Z_InitRequest *initRequest,
Z_InitResponse *initResponse)
{
{
Z_APDU *apdu_response;
- m_odr = s->odr_encode();
if (apdu_request->which != Z_APDU_extendedServicesRequest)
return 0;
Z_ExtendedServicesRequest *req = apdu_request->u.extendedServicesRequest;
* See the file LICENSE for details.
*
* $Log: yaz-z-server-sr.cpp,v $
- * Revision 1.1 2001-03-27 15:02:14 adam
+ * Revision 1.2 2001-04-04 14:02:49 adam
+ * URSULA / Z-ruth service.
+ *
+ * Revision 1.1 2001/03/27 15:02:14 adam
* New server facility scheme.
*
*/
#include <yaz/log.h>
#include <yaz++/yaz-z-server.h>
-/*
- * database record.
- */
-void Yaz_Facility_Retrieval::create_databaseRecord (
- Z_NamePlusRecord *rec, const char *dbname, int format,
- const void *buf, int len)
-{
- rec->databaseName = dbname ? odr_strdup (m_odr, dbname) : 0;
- rec->which = Z_NamePlusRecord_databaseRecord;
- rec->u.databaseRecord = z_ext_record (m_odr, format,
- (const char *) buf, len);
-}
-
-/*
- * surrogate diagnostic.
- */
-void Yaz_Facility_Retrieval::create_surrogateDiagnostics(
- Z_NamePlusRecord *rec, const char *dbname, int error, char *const addinfo)
-{
- int oid[OID_SIZE];
- int *err = (int *)odr_malloc (m_odr, sizeof(*err));
- oident bib1;
- Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (m_odr, sizeof(*drec));
- Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
- odr_malloc (m_odr, sizeof(*dr));
-
- bib1.proto = PROTO_Z3950;
- bib1.oclass = CLASS_DIAGSET;
- bib1.value = VAL_BIB1;
-
- yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo);
- *err = error;
- rec->databaseName = dbname ? odr_strdup (m_odr, dbname) : 0;
- rec->which = Z_NamePlusRecord_surrogateDiagnostic;
- rec->u.surrogateDiagnostic = drec;
- drec->which = Z_DiagRec_defaultFormat;
- drec->u.defaultFormat = dr;
- dr->diagnosticSetId = odr_oiddup (m_odr,
- oid_ent_to_oid(&bib1, oid));
- dr->condition = err;
- dr->which = Z_DefaultDiagFormat_v2Addinfo;
- dr->u.v2Addinfo = odr_strdup (m_odr, addinfo ? addinfo : "");
-}
-
-Z_Records *Yaz_Facility_Retrieval::create_nonSurrogateDiagnostics (
- int error, const char *addinfo)
-{
- int oid[OID_SIZE];
- Z_Records *rec = (Z_Records *)
- odr_malloc (m_odr, sizeof(*rec));
- oident bib1;
- int *err = (int *)
- odr_malloc (m_odr, sizeof(*err));
- Z_DiagRec *drec = (Z_DiagRec *)
- odr_malloc (m_odr, sizeof(*drec));
- Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
- odr_malloc (m_odr, sizeof(*dr));
-
- bib1.proto = PROTO_Z3950;
- bib1.oclass = CLASS_DIAGSET;
- bib1.value = VAL_BIB1;
-
- *err = error;
- rec->which = Z_Records_NSD;
- rec->u.nonSurrogateDiagnostic = dr;
- dr->diagnosticSetId =
- odr_oiddup (m_odr, oid_ent_to_oid(&bib1, oid));
- dr->condition = err;
- dr->which = Z_DefaultDiagFormat_v2Addinfo;
- dr->u.v2Addinfo = odr_strdup (m_odr, addinfo ? addinfo : "");
- return rec;
-}
-
-Z_Records *Yaz_Facility_Retrieval::pack_records (const char *resultSetName,
- int start, int xnum,
- Z_RecordComposition *comp,
- int *next, int *pres,
- int *format)
+Z_Records *Yaz_Facility_Retrieval::pack_records (Yaz_Z_Server *s,
+ const char *resultSetName,
+ int start, int xnum,
+ Z_RecordComposition *comp,
+ int *next, int *pres,
+ int *format)
{
int recno, total_length = 0, toget = xnum, dumped_records = 0;
Z_Records *records =
- (Z_Records *) odr_malloc (m_odr, sizeof(*records));
+ (Z_Records *) odr_malloc (odr_encode(), sizeof(*records));
Z_NamePlusRecordList *reclist =
- (Z_NamePlusRecordList *) odr_malloc (m_odr, sizeof(*reclist));
+ (Z_NamePlusRecordList *) odr_malloc (odr_encode(), sizeof(*reclist));
Z_NamePlusRecord **list =
- (Z_NamePlusRecord **) odr_malloc (m_odr, sizeof(*list) * toget);
+ (Z_NamePlusRecord **) odr_malloc (odr_encode(), sizeof(*list) * toget);
records->which = Z_Records_DBOSD;
records->u.databaseOrSurDiagnostics = reclist;
for (recno = start; reclist->num_records < toget; recno++)
{
Z_NamePlusRecord *this_rec =
- (Z_NamePlusRecord *) odr_malloc (m_odr, sizeof(*this_rec));
+ (Z_NamePlusRecord *) odr_malloc (odr_encode(), sizeof(*this_rec));
this_rec->databaseName = 0;
this_rec->which = Z_NamePlusRecord_databaseRecord;
this_rec->u.databaseRecord = 0;
if (this_rec->which == Z_NamePlusRecord_databaseRecord &&
this_rec->u.databaseRecord == 0)
{ // handler did not return a record..
- create_surrogateDiagnostics(this_rec, 0, 14, 0);
+ create_surrogateDiagnostics(odr_encode(), this_rec, 0, 14, 0);
}
/*
* we get the number of bytes allocated on the stream before any
* allocation done by the backend - this should give us a reasonable
* idea of the total size of the data so far.
*/
- total_length = odr_total(m_odr) - dumped_records;
- this_length = odr_total(m_odr) - total_length;
+ total_length = odr_total(odr_encode()) - dumped_records;
+ this_length = odr_total(odr_encode()) - total_length;
yaz_log(LOG_LOG, " fetched record, len=%d, total=%d",
this_length, total_length);
if (this_length + total_length > m_preferredMessageSize)
{ /* too big entirely */
yaz_log(LOG_LOG, "Record > maxrcdsz");
reclist->records[reclist->num_records] = this_rec;
- create_surrogateDiagnostics(this_rec,
+ create_surrogateDiagnostics(odr_encode(), this_rec,
this_rec->databaseName, 17, 0);
reclist->num_records++;
*next = recno + 1;
{
yaz_log(LOG_DEBUG, " Dropped it");
reclist->records[reclist->num_records] = this_rec;
- create_surrogateDiagnostics(this_rec,
+ create_surrogateDiagnostics(odr_encode(), this_rec,
this_rec->databaseName,
16, 0);
reclist->num_records++;
return records;
}
-void Yaz_Facility_Retrieval::fetch_via_piggyback (Z_SearchRequest *req,
+void Yaz_Facility_Retrieval::fetch_via_piggyback (Yaz_Z_Server *s,
+ Z_SearchRequest *req,
Z_SearchResponse *res)
{
- bool_t *sr = (bool_t *)odr_malloc (m_odr, sizeof(*sr));
+ bool_t *sr = (bool_t *)odr_malloc (odr_encode(), sizeof(*sr));
*sr = 1;
int toget = 0;
Z_RecordComposition comp, *compp = 0;
int hits = *res->resultCount;
- int *nulint = (int *)odr_malloc (m_odr, sizeof(*nulint));
+ int *nulint = (int *)odr_malloc (odr_encode(), sizeof(*nulint));
*nulint = 0;
comp.which = Z_RecordComp_simple;
if (toget && !res->records)
{
- res->presentStatus = (int *) odr_malloc (m_odr, sizeof(int));
+ res->presentStatus = (int *) odr_malloc (odr_encode(), sizeof(int));
*res->presentStatus = Z_PRES_SUCCESS;
res->records =
- pack_records(req->resultSetName, 1, toget, compp,
+ pack_records(s, req->resultSetName, 1, toget, compp,
res->nextResultSetPosition,
res->presentStatus,
req->preferredRecordSyntax);
}
}
-void Yaz_Facility_Retrieval::fetch_via_present (Z_PresentRequest *req,
- Z_PresentResponse *res)
+void Yaz_Facility_Retrieval::fetch_via_present (Yaz_Z_Server *s,
+ Z_PresentRequest *req,
+ Z_PresentResponse *res)
{
- res->records = pack_records (req->resultSetId,*req->resultSetStartPoint,
- *req->numberOfRecordsRequested,
- req->recordComposition,
- res->nextResultSetPosition,
- res->presentStatus,
- req->preferredRecordSyntax);
+ res->records =
+ pack_records (s, req->resultSetId,*req->resultSetStartPoint,
+ *req->numberOfRecordsRequested,
+ req->recordComposition,
+ res->nextResultSetPosition,
+ res->presentStatus,
+ req->preferredRecordSyntax);
if (res->records->which == Z_Records_DBOSD)
*res->numberOfRecordsReturned =
res->records->u.databaseOrSurDiagnostics->num_records;
}
-ODR Yaz_Facility_Retrieval::odr_encode()
-{
- return m_odr;
-}
-
int Yaz_Facility_Retrieval::init(Yaz_Z_Server *s, Z_InitRequest *initRequest,
Z_InitResponse *initResponse)
{
return sr_init (initRequest, initResponse);
}
+ODR Yaz_Facility_Retrieval::odr_encode()
+{
+ return m_odr_encode;
+}
+
+ODR Yaz_Facility_Retrieval::odr_decode()
+{
+ return m_odr_decode;
+}
+
int Yaz_Facility_Retrieval::recv(Yaz_Z_Server *s, Z_APDU *apdu_request)
{
Z_APDU *apdu_response;
- m_odr = s->odr_encode();
+ m_odr_encode = s->odr_encode();
+ m_odr_decode = s->odr_decode();
switch (apdu_request->which)
{
case Z_APDU_searchRequest:
apdu_response->u.searchResponse);
if (!apdu_response->u.searchResponse->records)
{
- fetch_via_piggyback(apdu_request->u.searchRequest,
+ fetch_via_piggyback(s, apdu_request->u.searchRequest,
apdu_response->u.searchResponse);
}
s->send_Z_PDU(apdu_response);
sr_present (apdu_request->u.presentRequest,
apdu_response->u.presentResponse);
if (!apdu_response->u.presentResponse->records)
- fetch_via_present(apdu_request->u.presentRequest,
+ fetch_via_present(s, apdu_request->u.presentRequest,
apdu_response->u.presentResponse);
s->send_Z_PDU(apdu_response);
return 1;
--- /dev/null
+/*
+ * Copyright (c) 2001, Index Data.
+ * See the file LICENSE for details.
+ *
+ * $Log: yaz-z-server-ursula.cpp,v $
+ * Revision 1.1 2001-04-04 14:02:49 adam
+ * URSULA / Z-ruth service.
+ *
+ */
+
+#include <yaz/log.h>
+#include <yaz++/yaz-z-server.h>
+
+int Yaz_Facility_Ursula::init(Yaz_Z_Server *s, Z_InitRequest *initRequest,
+ Z_InitResponse *initResponse)
+{
+ Z_Options *req = initRequest->options;
+ Z_Options *res = initResponse->options;
+
+ if (ODR_MASK_GET(req, Z_Options_extendedServices))
+ ODR_MASK_SET(res, Z_Options_extendedServices);
+ return 1;
+}
+
+int Yaz_Facility_Ursula::recv(Yaz_Z_Server *s, Z_APDU *apdu_request)
+{
+ Z_APDU *apdu_response;
+
+ if (apdu_request->which != Z_APDU_extendedServicesRequest)
+ return 0;
+ Z_ExtendedServicesRequest *req = apdu_request->u.extendedServicesRequest;
+
+ Z_External *r = req->taskSpecificParameters;
+
+ if (!r)
+ return 0;
+
+ if (r->which != ODR_EXTERNAL_octet)
+ {
+ logf (LOG_LOG, "ursula::recv not octet alighed");
+ return 0;
+ }
+ odr_setbuf (s->odr_decode(), (char*) r->u.octet_aligned->buf,
+ r->u.octet_aligned->len, 0);
+ Z_UrsPDU *pdu = 0;
+ if (!z_UrsPDU (s->odr_decode(), &pdu, 0, ""))
+ {
+ logf (LOG_LOG, "ursula::decode failed");
+ return 0;
+ }
+ yaz_log (LOG_LOG, "got ursula packet");
+ apdu_response = s->create_Z_PDU(Z_APDU_extendedServicesResponse);
+ ursula_service(req, pdu, apdu_response->u.extendedServicesResponse);
+ s->send_Z_PDU(apdu_response);
+ return 1;
+}
* See the file LICENSE for details.
*
* $Log: yaz-z-server.cpp,v $
- * Revision 1.9 2001-03-29 15:14:26 adam
+ * Revision 1.10 2001-04-04 14:02:49 adam
+ * URSULA / Z-ruth service.
+ *
+ * Revision 1.9 2001/03/29 15:14:26 adam
* Minor updates.
*
* Revision 1.8 2001/03/27 14:47:45 adam
}
if (!taken)
{
- yaz_log (LOG_LOG, "got request = %d", apdu_request->which);
+ yaz_log (LOG_LOG, "unhandled request = %d", apdu_request->which);
delete this;
}
}
}
+
+/*
+ * database record.
+ */
+void Yaz_Z_ServerUtility::create_databaseRecord (
+ ODR odr, Z_NamePlusRecord *rec, const char *dbname, int format,
+ const void *buf, int len)
+{
+ rec->databaseName = dbname ? odr_strdup (odr, dbname) : 0;
+ rec->which = Z_NamePlusRecord_databaseRecord;
+ rec->u.databaseRecord = z_ext_record (odr, format,
+ (const char *) buf, len);
+}
+
+/*
+ * surrogate diagnostic.
+ */
+void Yaz_Z_ServerUtility::create_surrogateDiagnostics(
+ ODR odr, Z_NamePlusRecord *rec, const char *dbname,
+ int error, char *const addinfo)
+{
+ int oid[OID_SIZE];
+ int *err = (int *)odr_malloc (odr, sizeof(*err));
+ oident bib1;
+ Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (odr, sizeof(*drec));
+ Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
+ odr_malloc (odr, sizeof(*dr));
+
+ bib1.proto = PROTO_Z3950;
+ bib1.oclass = CLASS_DIAGSET;
+ bib1.value = VAL_BIB1;
+
+ yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo);
+ *err = error;
+ rec->databaseName = dbname ? odr_strdup (odr, dbname) : 0;
+ rec->which = Z_NamePlusRecord_surrogateDiagnostic;
+ rec->u.surrogateDiagnostic = drec;
+ drec->which = Z_DiagRec_defaultFormat;
+ drec->u.defaultFormat = dr;
+ dr->diagnosticSetId = odr_oiddup (odr,
+ oid_ent_to_oid(&bib1, oid));
+ dr->condition = err;
+ dr->which = Z_DefaultDiagFormat_v2Addinfo;
+ dr->u.v2Addinfo = odr_strdup (odr, addinfo ? addinfo : "");
+}
+
+Z_Records *Yaz_Z_ServerUtility::create_nonSurrogateDiagnostics (
+ ODR odr, int error, const char *addinfo)
+{
+ int oid[OID_SIZE];
+ Z_Records *rec = (Z_Records *)
+ odr_malloc (odr, sizeof(*rec));
+ oident bib1;
+ int *err = (int *)
+ odr_malloc (odr, sizeof(*err));
+ Z_DiagRec *drec = (Z_DiagRec *)
+ odr_malloc (odr, sizeof(*drec));
+ Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
+ odr_malloc (odr, sizeof(*dr));
+
+ bib1.proto = PROTO_Z3950;
+ bib1.oclass = CLASS_DIAGSET;
+ bib1.value = VAL_BIB1;
+
+ *err = error;
+ rec->which = Z_Records_NSD;
+ rec->u.nonSurrogateDiagnostic = dr;
+ dr->diagnosticSetId =
+ odr_oiddup (odr, oid_ent_to_oid(&bib1, oid));
+ dr->condition = err;
+ dr->which = Z_DefaultDiagFormat_v2Addinfo;
+ dr->u.v2Addinfo = odr_strdup (odr, addinfo ? addinfo : "");
+ return rec;
+}