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.2 2001-03-29 15:14:26 adam
9 * Revision 1.1 2001/03/27 14:47:45 adam
10 * New server facility scheme.
15 #include <yaz++/yaz-z-server.h>
20 void Yaz_Facility_ILL::create_databaseRecord (
21 Z_NamePlusRecord *rec, const char *dbname, int format,
22 const void *buf, int len)
24 rec->databaseName = dbname ? odr_strdup (m_odr, dbname) : 0;
25 rec->which = Z_NamePlusRecord_databaseRecord;
26 rec->u.databaseRecord = z_ext_record (m_odr, format,
27 (const char *) buf, len);
31 * surrogate diagnostic.
33 void Yaz_Facility_ILL::create_surrogateDiagnostics(
34 Z_NamePlusRecord *rec, const char *dbname, int error, char *const addinfo)
37 int *err = (int *)odr_malloc (m_odr, sizeof(*err));
39 Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (m_odr, sizeof(*drec));
40 Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
41 odr_malloc (m_odr, sizeof(*dr));
43 bib1.proto = PROTO_Z3950;
44 bib1.oclass = CLASS_DIAGSET;
45 bib1.value = VAL_BIB1;
47 yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo);
49 rec->databaseName = dbname ? odr_strdup (m_odr, dbname) : 0;
50 rec->which = Z_NamePlusRecord_surrogateDiagnostic;
51 rec->u.surrogateDiagnostic = drec;
52 drec->which = Z_DiagRec_defaultFormat;
53 drec->u.defaultFormat = dr;
54 dr->diagnosticSetId = odr_oiddup (m_odr,
55 oid_ent_to_oid(&bib1, oid));
57 dr->which = Z_DefaultDiagFormat_v2Addinfo;
58 dr->u.v2Addinfo = odr_strdup (m_odr, addinfo ? addinfo : "");
61 ODR Yaz_Facility_ILL::odr_encode()
66 int Yaz_Facility_ILL::init(Yaz_Z_Server *s, Z_InitRequest *initRequest,
67 Z_InitResponse *initResponse)
69 Z_Options *req = initRequest->options;
70 Z_Options *res = initResponse->options;
72 if (ODR_MASK_GET(req, Z_Options_extendedServices))
73 ODR_MASK_SET(res, Z_Options_extendedServices);
74 return ill_init (initRequest, initResponse);
77 int Yaz_Facility_ILL::recv(Yaz_Z_Server *s, Z_APDU *apdu_request)
79 Z_APDU *apdu_response;
81 m_odr = s->odr_encode();
82 if (apdu_request->which != Z_APDU_extendedServicesRequest)
85 yaz_log (LOG_LOG, "got extendedSericesRequest p=%p", this);
86 apdu_response = s->create_Z_PDU(Z_APDU_extendedServicesResponse);
87 s->send_Z_PDU(apdu_response);