Adding Z39.50-1992 stuff to proto.c. Adding zget.c
authorSebastian Hammer <quinn@indexdata.com>
Mon, 22 May 1995 11:30:15 +0000 (11:30 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Mon, 22 May 1995 11:30:15 +0000 (11:30 +0000)
asn/Makefile
asn/proto.c
asn/zget.c [new file with mode: 0644]

index 9fbab3b..1bc5c9f 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.10 1995-04-11 11:52:01 quinn Exp $
+# $Id: Makefile,v 1.11 1995-05-22 11:30:15 quinn Exp $
 
 SHELL=/bin/sh
 INCLUDE=-I../include -I.
 
 SHELL=/bin/sh
 INCLUDE=-I../include -I.
@@ -11,7 +11,7 @@ LIBINCLUDE=-L$(LIBDIR)
 DEFS=$(INCLUDE)
 LIB=$(LIBDIR)/libasn.a
 LIBS=-lodr -lasn
 DEFS=$(INCLUDE)
 LIB=$(LIBDIR)/libasn.a
 LIBS=-lodr -lasn
-PO = proto.o diagbib1.o oid.o
+PO = proto.o diagbib1.o oid.o zget.o
 CPP=$(CC) -E
 
 all: $(LIB)
 CPP=$(CC) -E
 
 all: $(LIB)
index a886b06..6930f81 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: proto.c,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: proto.c,v $
- * Revision 1.22  1995-05-17 08:40:56  quinn
+ * Revision 1.23  1995-05-22 11:30:18  quinn
+ * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
+ *
+ * Revision 1.22  1995/05/17  08:40:56  quinn
  * Added delete. Fixed some sequence_begins. Smallish.
  *
  * Revision 1.21  1995/05/16  08:50:24  quinn
  * Added delete. Fixed some sequence_begins. Smallish.
  *
  * Revision 1.21  1995/05/16  08:50:24  quinn
@@ -103,6 +106,7 @@ int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
 
 /* ---------------------- INITIALIZE SERVICE ------------------- */
 
 
 /* ---------------------- INITIALIZE SERVICE ------------------- */
 
+#if 0
 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
 {
     if (!odr_sequence_begin(o, p, sizeof(**p)))
 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
 {
     if (!odr_sequence_begin(o, p, sizeof(**p)))
@@ -113,6 +117,7 @@ int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
        odr_visiblestring(o, &(*p)->account, 0) &&
        odr_sequence_end(o);
 }
        odr_visiblestring(o, &(*p)->account, 0) &&
        odr_sequence_end(o);
 }
+#endif
 
 int z_IdPass(ODR o, Z_IdPass **p, int opt)
 {
 
 int z_IdPass(ODR o, Z_IdPass **p, int opt)
 {
@@ -136,7 +141,7 @@ int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
     static Odr_arm arm[] =
     {
        {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
     static Odr_arm arm[] =
     {
        {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
-       {-1, -1, -1, Z_IdAuthentication_idPass, z_NSRAuthentication},
+       {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
        {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
        {-1, -1, -1, Z_IdAuthentication_other, odr_external},
        {-1, -1, -1, -1, 0}
        {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
        {-1, -1, -1, Z_IdAuthentication_other, odr_external},
        {-1, -1, -1, -1, 0}
@@ -388,6 +393,28 @@ int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
        odr_sequence_end(o);
 }
 
        odr_sequence_end(o);
 }
 
+int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
+{
+    static Odr_arm arm[] =
+    {
+       {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
+       {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
+       {-1, -1, -1, -1, 0}
+    };
+
+    if (!odr_sequence_begin(o, p, sizeof(**p)))
+       return opt && odr_ok(o);
+    return
+       odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
+       odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
+       odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
+       odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
+       odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
+       odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
+       odr_constructed_end(o) &&
+       odr_sequence_end(o);
+}
+
 int z_Operator(ODR o, Z_Operator **p, int opt)
 {
     static Odr_arm arm[] =
 int z_Operator(ODR o, Z_Operator **p, int opt)
 {
     static Odr_arm arm[] =
@@ -395,6 +422,7 @@ int z_Operator(ODR o, Z_Operator **p, int opt)
        {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
        {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
        {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
        {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
        {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
        {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
+       {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
        {-1, -1, -1, -1, 0}
     };
     int dummy = 999;
        {-1, -1, -1, -1, 0}
     };
     int dummy = 999;
@@ -604,6 +632,51 @@ int z_Records(ODR o, Z_Records **p, int opt)
     return opt && odr_ok(o);
 }
 
     return opt && odr_ok(o);
 }
 
+/* ------------------------ ACCESS CTRL SERVICE ----------------------- */
+
+int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
+{
+    static Odr_arm arm[] = 
+    {
+       {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
+           odr_octetstring},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
+           odr_external},
+       {-1, -1, -1, -1, 0}
+    };
+    if (!odr_sequence_begin(o, p, sizeof(**p)))
+       return opt && odr_ok(o);
+    return
+       z_ReferenceId(o, &(*p)->referenceId, 1) &&
+       odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
+#ifdef Z_OTHERINFO
+       z_OtherInformation(o, &(*p)->otherInfo, 1) &&
+#endif
+       odr_sequence_end(o);
+}
+
+int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
+{
+    static Odr_arm arm[] = 
+    {
+       {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
+           odr_octetstring},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
+           odr_external},
+       {-1, -1, -1, -1, 0}
+    };
+    if (!odr_sequence_begin(o, p, sizeof(**p)))
+       return opt && odr_ok(o);
+    return
+       z_ReferenceId(o, &(*p)->referenceId, 1) &&
+       odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
+       odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
+#ifdef Z_OTHERINFO
+       z_OtherInformation(o, &(*p)->otherInfo, 1) &&
+#endif
+       odr_sequence_end(o);
+}
+
 /* ------------------------ SCAN SERVICE -------------------- */
 
 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
 /* ------------------------ SCAN SERVICE -------------------- */
 
 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
diff --git a/asn/zget.c b/asn/zget.c
new file mode 100644 (file)
index 0000000..71477d0
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 1995, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: zget.c,v $
+ * Revision 1.1  1995-05-22 11:30:20  quinn
+ * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
+ *
+ *
+ */
+
+#include <proto.h>
+#include "../version.h"
+
+Z_InitRequest *zget_InitRequest(ODR o)
+{
+    Z_InitRequest *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->options = odr_malloc(o, sizeof(*r->options));
+    ODR_MASK_ZERO(r->options);
+    r->protocolVersion = odr_malloc(o, sizeof(*r->protocolVersion));
+    ODR_MASK_ZERO(r->protocolVersion);
+    r->preferredMessageSize = odr_malloc(o, sizeof(int));
+    *r->preferredMessageSize = 30*1024;
+    r->maximumRecordSize = odr_malloc(o, sizeof(int));
+    *r->maximumRecordSize = 30*1024;
+    r->idAuthentication = 0;
+    r->implementationId = "YAZ";
+    r->implementationName = "Index Data/YAZ";
+    r->implementationVersion = YAZ_VERSION;
+    r->userInformationField = 0;
+    return r;
+}
+
+Z_InitResponse *zget_InitResponse(ODR o)
+{
+    Z_InitResponse *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->options = odr_malloc(o, sizeof(*r->options));
+    ODR_MASK_ZERO(r->options);
+    r->protocolVersion = odr_malloc(o, sizeof(*r->protocolVersion));
+    ODR_MASK_ZERO(r->protocolVersion);
+    r->preferredMessageSize = odr_malloc(o, sizeof(int));
+    *r->preferredMessageSize = 30*1024;
+    r->maximumRecordSize = odr_malloc(o, sizeof(int));
+    *r->maximumRecordSize = 30*1024;
+    r->implementationId = "YAZ";
+    r->implementationName = "Index Data YAZ Z39.50/SR implementation";
+    r->implementationVersion = YAZ_VERSION;
+    r->userInformationField = 0;
+    return r;
+}
+
+Z_SearchRequest *zget_SearchRequest(ODR o)
+{
+    Z_SearchRequest *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->smallSetUpperBound = odr_malloc(o, sizeof(int));
+    *r->smallSetUpperBound = 0;
+    r->largeSetLowerBound = odr_malloc(o, sizeof(int));
+    *r->largeSetLowerBound = 1;
+    r->mediumSetPresentNumber = odr_malloc(o, sizeof(int));
+    *r->mediumSetPresentNumber = 0;
+    r->replaceIndicator = odr_malloc(o, sizeof(bool_t));
+    *r->replaceIndicator = 1;
+    r->resultSetName = "Default";
+    r->num_databaseNames = 0;
+    r->databaseNames = 0;
+    r->smallSetElementSetNames = 0;
+    r->mediumSetElementSetNames = 0;
+    r->preferredRecordSyntax = 0;
+    r->query = 0;
+    return r;
+}
+
+Z_SearchResponse *zget_SearchResponse(ODR o)
+{
+    Z_SearchResponse *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->resultCount = odr_malloc(o, sizeof(int));
+    *r->resultCount = 0;
+    r->numberOfRecordsReturned = odr_malloc(o, sizeof(int));
+    *r->numberOfRecordsReturned = 0;
+    r->nextResultSetPosition = odr_malloc(o, sizeof(int));
+    *r->nextResultSetPosition = 0;
+    r->searchStatus = odr_malloc(o, sizeof(bool_t));
+    *r->searchStatus = 1;
+    r->resultSetStatus = 0;
+    r->presentStatus = 0;
+    r->records = 0;
+    return r;
+}
+
+Z_PresentRequest *zget_PresentRequest(ODR o)
+{
+    Z_PresentRequest *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->resultSetId = "Default";
+    r->resultSetStartPoint = odr_malloc(o, sizeof(int));
+    *r->resultSetStartPoint = 1;
+    r->numberOfRecordsRequested = odr_malloc(o, sizeof(int));
+    *r->numberOfRecordsRequested = 10;
+    r->elementSetNames = 0;
+    r->preferredRecordSyntax = 0;
+    return r;
+}
+
+Z_PresentResponse *zget_PresentResponse(ODR o)
+{
+    Z_PresentResponse *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->numberOfRecordsReturned = odr_malloc(o, sizeof(int));
+    *r->numberOfRecordsReturned = 0;
+    r->nextResultSetPosition = odr_malloc(o, sizeof(int));
+    *r->nextResultSetPosition = 0;
+    r->presentStatus = odr_malloc(o, sizeof(int));
+    *r->presentStatus = Z_PRES_SUCCESS;
+    r->records = 0;
+    return r;
+}
+
+Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o)
+{
+    Z_DeleteResultSetRequest *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->deleteFunction = odr_malloc(o, sizeof(int));
+    *r->deleteFunction = Z_DeleteRequest_list;
+    r->num_ids = 0;
+    r->resultSetList = 0;
+    return r;
+}
+
+Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o)
+{
+    Z_DeleteResultSetResponse *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->deleteOperationStatus = odr_malloc(o, sizeof(int));
+    *r->deleteOperationStatus = Z_DeleteStatus_success;
+    r->num_statuses = 0;
+    r->deleteListStatuses = 0;
+    r->numberNotDeleted = 0;
+    r->num_bulkStatuses = 0;
+    r->bulkStatuses = 0;
+    r->deleteMessage = 0;
+    return r;
+}
+
+Z_ScanRequest *zget_ScanRequest(ODR o)
+{
+    Z_ScanRequest *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->num_databaseNames = 0;
+    r->databaseNames = 0;
+    r->attributeSet = 0;
+    r->termListAndStartPoint = 0;
+    r->stepSize = 0;
+    r->numberOfTermsRequested = odr_malloc(o, sizeof(int));
+    *r->numberOfTermsRequested = 20;
+    r->preferredPositionInResponse = 0;
+    return r;
+}
+
+Z_ScanResponse *zget_ScanResponse(ODR o)
+{
+    Z_ScanResponse *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->stepSize = 0;
+    r->scanStatus = odr_malloc(o, sizeof(int));
+    *r->scanStatus = Z_Scan_success;
+    r->numberOfEntriesReturned = odr_malloc(o, sizeof(int));
+    *r->numberOfEntriesReturned = 0;
+    r->positionOfTerm =0;
+    r->entries = 0;
+    r->attributeSet = 0;
+    return r;
+}
+
+Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o)
+{
+    Z_TriggerResourceControlRequest *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->requestedAction = odr_malloc(o, sizeof(int));
+    *r->requestedAction = Z_TriggerResourceCtrl_resourceReport;
+    r->prefResourceReportFormat = 0;
+    r->resultSetWanted = 0;
+    return r;
+}
+
+Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o)
+{
+    Z_ResourceControlRequest *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->suspendedFlag = 0;
+    r->resourceReport = 0;
+    r->partialResultsAvailable = 0;
+    r->responseRequired = odr_malloc(o, sizeof(bool_t));
+    *r->responseRequired = 0;
+    r->triggeredRequestFlag = 0;
+    return r;
+}
+
+Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o)
+{
+    Z_ResourceControlResponse *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->continueFlag = odr_malloc(o, sizeof(bool_t));
+    *r->continueFlag = 1;
+    r->resultSetWanted = 0;
+    return r;
+}
+
+Z_AccessControlRequest *zget_AccessControlRequest(ODR o)
+{
+    Z_AccessControlRequest *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->which = Z_AccessRequest_simpleForm;
+    r->u.simpleForm = 0;
+    return r;
+}
+
+Z_AccessControlResponse *zget_AccessControlResponse(ODR o)
+{
+    Z_AccessControlResponse *r = odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->which = Z_AccessResponse_simpleForm;
+    r->u.simpleForm = 0;
+    r->diagnostic = 0;
+    return r;
+}
+
+Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which)
+{
+    Z_APDU *r = odr_malloc(o, sizeof(*r));
+    
+    switch (r->which = which)
+    {
+       case Z_APDU_initRequest:
+           r->u.initRequest = zget_InitRequest(o); break;
+       case Z_APDU_initResponse:
+           r->u.initResponse = zget_InitResponse(o); break;
+       case Z_APDU_searchRequest:      
+           r->u.searchRequest = zget_SearchRequest(o); break;
+       case Z_APDU_searchResponse:
+           r->u.searchResponse = zget_SearchResponse(o); break;
+       case Z_APDU_presentRequest:
+           r->u.presentRequest = zget_PresentRequest(o); break;
+       case Z_APDU_presentResponse:
+           r->u.presentResponse = zget_PresentResponse(o); break;
+       case Z_APDU_deleteResultSetRequest:
+           r->u.deleteResultSetRequest = zget_DeleteResultSetRequest(o); break;
+       case Z_APDU_deleteResultSetResponse:
+           r->u.deleteResultSetResponse = zget_DeleteResultSetResponse(o);
+           break;
+       case Z_APDU_scanRequest:
+           r->u.scanRequest = zget_ScanRequest(o); break;
+       case Z_APDU_scanResponse:
+           r->u.scanResponse = zget_ScanResponse(o); break;
+       case Z_APDU_triggerResourceControlRequest:
+           r->u.triggerResourceControlRequest =
+               zget_TriggerResourceControlRequest(o); break;
+       case Z_APDU_resourceControlRequest:
+           r->u.resourceControlRequest = zget_ResourceControlRequest(o);
+           break;
+       case Z_APDU_resourceControlResponse:
+           r->u.resourceControlResponse = zget_ResourceControlResponse(o);
+           break;
+       default:
+           fprintf(stderr, "Bad APDU-type to zget_APDU");
+           exit(1);
+    }
+    return r;
+}