2 * Copyright (c) 2000-2001, Index Data.
3 * See the file LICENSE for details.
5 * $Log: yaz-z-server-ill.cpp,v $
6 * Revision 1.1 2001-03-27 14:47:45 adam
7 * New server facility scheme.
12 #include <yaz++/yaz-z-server.h>
17 void Yaz_Facility_ILL::create_databaseRecord (
18 Z_NamePlusRecord *rec, const char *dbname, int format,
19 const void *buf, int len)
21 rec->databaseName = dbname ? odr_strdup (m_odr, dbname) : 0;
22 rec->which = Z_NamePlusRecord_databaseRecord;
23 rec->u.databaseRecord = z_ext_record (m_odr, format,
24 (const char *) buf, len);
28 * surrogate diagnostic.
30 void Yaz_Facility_ILL::create_surrogateDiagnostics(
31 Z_NamePlusRecord *rec, const char *dbname, int error, char *const addinfo)
34 int *err = (int *)odr_malloc (m_odr, sizeof(*err));
36 Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (m_odr, sizeof(*drec));
37 Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
38 odr_malloc (m_odr, sizeof(*dr));
40 bib1.proto = PROTO_Z3950;
41 bib1.oclass = CLASS_DIAGSET;
42 bib1.value = VAL_BIB1;
44 yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo);
46 rec->databaseName = dbname ? odr_strdup (m_odr, dbname) : 0;
47 rec->which = Z_NamePlusRecord_surrogateDiagnostic;
48 rec->u.surrogateDiagnostic = drec;
49 drec->which = Z_DiagRec_defaultFormat;
50 drec->u.defaultFormat = dr;
51 dr->diagnosticSetId = odr_oiddup (m_odr,
52 oid_ent_to_oid(&bib1, oid));
54 dr->which = Z_DefaultDiagFormat_v2Addinfo;
55 dr->u.v2Addinfo = odr_strdup (m_odr, addinfo ? addinfo : "");
58 ODR Yaz_Facility_ILL::odr_encode()
63 int Yaz_Facility_ILL::init(Yaz_Z_Server *s, Z_InitRequest *initRequest,
64 Z_InitResponse *initResponse)
66 Z_Options *req = initRequest->options;
67 Z_Options *res = initResponse->options;
69 if (ODR_MASK_GET(req, Z_Options_extendedServices))
70 ODR_MASK_SET(res, Z_Options_extendedServices);
71 return ill_init (initRequest, initResponse);
74 int Yaz_Facility_ILL::recv(Yaz_Z_Server *s, Z_APDU *apdu_request)
76 Z_APDU *apdu_response;
78 m_odr = s->odr_encode();
79 if (apdu_request->which != Z_APDU_extendedServicesRequest)
82 yaz_log (LOG_LOG, "got extendedSericesRequest p=%p", this);
83 apdu_response = s->create_Z_PDU(Z_APDU_extendedServicesResponse);
84 s->send_Z_PDU(apdu_response);