From c064e18765f4932d753d524c1453511e24578a5c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 3 Jul 1995 08:20:50 +0000 Subject: [PATCH] Old directory. To be deleted. --- zlayer/zaccess-yaz.c | 143 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 58 deletions(-) diff --git a/zlayer/zaccess-yaz.c b/zlayer/zaccess-yaz.c index bc09552..4bd4d23 100644 --- a/zlayer/zaccess-yaz.c +++ b/zlayer/zaccess-yaz.c @@ -47,7 +47,10 @@ * 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 @@ -167,41 +170,28 @@ static int send_apdu(struct zass *z, Z_APDU *a) 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; } @@ -343,8 +333,15 @@ static Z_RPNStructure *rpn2rpn(ODR o, struct ccl_rpn_node *q) 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: @@ -400,6 +397,24 @@ const struct zass_searchent *zass_searchresult(ZASS a, int *complete) 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, @@ -413,6 +428,7 @@ const struct zass_searchent *zass_searchresult(ZASS a, int *complete) r.errstring[511] = '\0'; } } +#endif } } return &r; @@ -423,8 +439,8 @@ const struct zass_searchent *zass_search(ZASS a, struct ccl_rpn_node *query, { 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; @@ -432,17 +448,17 @@ const struct zass_searchent *zass_search(ZASS a, struct ccl_rpn_node *query, 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; @@ -456,16 +472,13 @@ const struct zass_searchent *zass_search(ZASS a, struct ccl_rpn_node *query, *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; @@ -477,7 +490,7 @@ const struct zass_searchent *zass_search(ZASS a, struct ccl_rpn_node *query, *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) { @@ -496,6 +509,20 @@ void get_diagrec(zass_record ***p, Z_DiagRec *r) { **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) { @@ -504,6 +531,7 @@ void get_diagrec(zass_record ***p, Z_DiagRec *r) } else (**p)->errstring[0] = '\0'; +#endif (**p)->which = ZASS_REC_DIAG; *p = &(**p)->next; } @@ -571,28 +599,27 @@ static void zass_records_free(zass_record *p) 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); } /* -- 1.7.10.4