* Z39.50 API for the Email gateway - YAZ version
*
* $Log: zaccess-yaz.c,v $
- * Revision 1.10 1995/05/16 09:41:46 adam
+ * Revision 1.11 1995/07/03 08:20:50 adam
+ * Old directory. To be deleted.
+ *
+ * Revision 1.10 1995/05/16 09:41:46 adam
* LICENSE. Uses new versions of odr_{set,get}buf.
*
* Revision 1.9 1995/05/03 10:15:43 quinn
static int send_initreq(struct zass *p, char *auth)
{
- Z_APDU a;
- Z_InitRequest init;
- Odr_bitmask options, protocolVersion;
+ Z_APDU *apdu;
+ Z_InitRequest *req;
char name[512];
Z_IdAuthentication idauth;
- a.which = Z_APDU_initRequest;
- a.u.initRequest = &init;
- init.referenceId = 0;
- init.options = &options;
- ODR_MASK_ZERO(&options);
- ODR_MASK_SET(&options, Z_Options_search);
- ODR_MASK_SET(&options, Z_Options_present);
- ODR_MASK_SET(&options, Z_Options_delSet);
- init.protocolVersion = &protocolVersion;
- ODR_MASK_ZERO(&protocolVersion);
- ODR_MASK_SET(&protocolVersion, Z_ProtocolVersion_1);
- ODR_MASK_SET(&protocolVersion, Z_ProtocolVersion_2);
- init.preferredMessageSize = &p->preferredmessagesize;
- init.maximumRecordSize = &p->maxrecordsize;
+ apdu = zget_APDU (p->encode, Z_APDU_initRequest);
+ req = apdu->u.initRequest;
+ req->preferredMessageSize = &p->preferredmessagesize;
+ req->maximumRecordSize = &p->maxrecordsize;
if (auth)
{
- init.idAuthentication = &idauth;
+ req->idAuthentication = &idauth;
idauth.which = Z_IdAuthentication_open;
idauth.u.open = auth;
}
else
- init.idAuthentication = 0;
- init.implementationId = ZASS_ID;
+ req->idAuthentication = 0;
sprintf(name, "%s (YAZ protocol layer)", ZASS_NAME);
- init.implementationName = name;
- init.implementationVersion = ZASS_VERSION;
- init.userInformationField = 0;
- if (send_apdu(p, &a) < 0)
+ req->implementationName = name;
+ req->implementationVersion = ZASS_VERSION;
+ if (send_apdu(p, apdu) < 0)
return -1;
return 0;
}
odr_malloc(o, sizeof(*a));
a->attributeType = odr_malloc(o, sizeof(int));
*a->attributeType = i->type;
- a->attributeValue = odr_malloc(o, sizeof(*a));
+#ifdef Z_95
+ a->attributeSet = 0;
+ a->which = Z_AttributeValue_numeric;
+ a->value.numeric = odr_malloc(o, sizeof(*a->value.numeric));
+ *a->value.numeric = i->value;
+#else
+ a->attributeValue = odr_malloc(o, sizeof(*a->attributeValue));
*a->attributeValue = i->value;
+#endif
}
return r;
case CCL_RPN_SET:
oident *id;
Z_DiagRec *dr = res->records->u.nonSurrogateDiagnostic;
+#ifdef Z_95
+ if (dr->which != Z_DiagRec_defaultFormat ||
+ !(id = oid_getentbyoid
+ (dr->u.defaultFormat->diagnosticSetId)) ||
+ id->class != CLASS_DIAGSET ||
+ id->value != VAL_BIB1)
+ gw_log(GW_LOG_WARN, ZASS_TYPE,
+ "Missing or unknown diagset - ignoring error!");
+ else
+ {
+ r.errcode = *dr->u.defaultFormat->condition;
+ if (dr->u.defaultFormat->addinfo)
+ {
+ strncpy(r.errstring, dr->u.defaultFormat->addinfo, 512);
+ r.errstring[511] = '\0';
+ }
+ }
+#else
if (!(id = oid_getentbyoid(dr->diagnosticSetId)) ||
id->class != CLASS_DIAGSET || id->value != VAL_BIB1)
gw_log(GW_LOG_WARN, ZASS_TYPE,
r.errstring[511] = '\0';
}
}
+#endif
}
}
return &r;
{
Z_Query q;
Z_RPNQuery rpnq;
- Z_APDU apdu;
- Z_SearchRequest req;
+ Z_APDU *apdu;
+ Z_SearchRequest *req;
oident bib1;
int smallSetUpperBound = 0;
int largeSetLowerBound = 1;
int replaceIndicator = 1;
char *datab[100];
- apdu.which = Z_APDU_searchRequest;
- apdu.u.searchRequest = &req;
- req.referenceId = 0;
- req.smallSetUpperBound = &smallSetUpperBound;
- req.largeSetLowerBound = &largeSetLowerBound;
- req.mediumSetPresentNumber = &mediumSetPresentNumber;
- req.replaceIndicator = &replaceIndicator;
- req.resultSetName = resname;
- req.num_databaseNames = 0;
- req.databaseNames = datab;
- while (*databases && req.num_databaseNames < 100)
+ apdu = zget_APDU (a->encode, Z_APDU_searchRequest);
+ req = apdu->u.searchRequest;
+
+ req->smallSetUpperBound = &smallSetUpperBound;
+ req->largeSetLowerBound = &largeSetLowerBound;
+ req->mediumSetPresentNumber = &mediumSetPresentNumber;
+ req->replaceIndicator = &replaceIndicator;
+ req->resultSetName = resname;
+ req->num_databaseNames = 0;
+ req->databaseNames = datab;
+ while (*databases && req->num_databaseNames < 100)
{
char *p = databases;
int more;
*p = '\0';
if (p - databases)
{
- req.databaseNames[req.num_databaseNames] = odr_malloc(a->encode,
+ req->databaseNames[req->num_databaseNames] = odr_malloc(a->encode,
(p - databases) + 1);
- strcpy(req.databaseNames[req.num_databaseNames++], databases);
+ strcpy(req->databaseNames[req->num_databaseNames++], databases);
}
databases = p + more;
}
- req.smallSetElementSetNames = 0;
- req.mediumSetElementSetNames = 0;
- req.preferredRecordSyntax = 0;
- req.query = &q;
+ req->query = &q;
q.which = Z_Query_type_1;
q.u.type_1 = &rpnq;
bib1.proto = PROTO_Z3950;
*complete = 1;
if (!(rpnq.RPNStructure = rpn2rpn(a->encode, query)))
return 0;
- if (send_apdu(a, &apdu) < 0)
+ if (send_apdu(a, apdu) < 0)
return 0;
if (complete)
{
{
**p = malloc(sizeof(***p));
(**p)->next = 0;
+#ifdef Z_95
+ (**p)->errstring[0] = '\0';
+ if (r->which == Z_DiagRec_defaultFormat)
+ {
+ (**p)->errcode = *r->u.defaultFormat->condition;
+ if (r->u.defaultFormat->addinfo)
+ {
+ strncpy((**p)->errstring, r->u.defaultFormat->addinfo, 200);
+ (**p)->errstring[200] = 0;
+ }
+ }
+ else
+ (**p)->errcode = 0;
+#else
(**p)->errcode = *r->condition;
if (r->addinfo)
{
}
else
(**p)->errstring[0] = '\0';
+#endif
(**p)->which = ZASS_REC_DIAG;
*p = &(**p)->next;
}
static int send_present(ZASS a, char *name, int start, int num,
enum oid_value form)
{
- Z_APDU apdu;
- Z_PresentRequest req;
+ Z_APDU *apdu;
+ Z_PresentRequest *req;
#if 0
oident recsyn;
#endif
- apdu.which = Z_APDU_presentRequest;
- apdu.u.presentRequest = &req;
- req.referenceId = 0;
- req.resultSetId = name;
- req.resultSetStartPoint = &start;
- req.numberOfRecordsRequested = #
- req.elementSetNames = 0;
+ apdu = zget_APDU (a->encode, Z_APDU_presentRequest);
+ req = apdu->u.presentRequest;
+
+ req->resultSetId = name;
+ req->resultSetStartPoint = &start;
+ req->numberOfRecordsRequested = #
#if 0
recsyn.proto = PROTO_Z3950;
recsyn.class = CLASS_RECSYN;
recsyn.value = form;
- req.preferredRecordSyntax = oid_getoidbyent(&recsyn);
+ req->preferredRecordSyntax = oid_getoidbyent(&recsyn);
#else
- req.preferredRecordSyntax = 0;
+ req->preferredRecordSyntax = 0;
#endif
- return send_apdu(a, &apdu);
+ return send_apdu(a, apdu);
}
/*