Fixed minor problems with GRS-1. Added support in c&s.
authorSebastian Hammer <quinn@indexdata.com>
Thu, 17 Aug 1995 12:44:55 +0000 (12:44 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Thu, 17 Aug 1995 12:44:55 +0000 (12:44 +0000)
12 files changed:
CHANGELOG
asn/Makefile
asn/prt-ext.c
client/client.c
include/backend.h
include/proto.h
include/prt-acc.h
include/prt-ext.h
include/prt-rsc.h
odr/odr_util.c
server/Makefile
server/seshigh.c

index 2c4a21c..6c4f9de 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,7 +6,11 @@ Fixed bug in the frontend-server. The numberOfRecordsReturned field was
 handled incorrectly when records were requested in the searchResponse. This
 will only affect you if you use the frontend-server.
 
-Added Explain encoders/decoders to the service-level API. Strictly alfa.
+Added Explain encoders/decoders to the service-level API. Untested.
+
+Added GRS-1 encoders/decoders to the service-level API. Lightly tested.
+Test-client will ask for and ODR pretty-print GRS1. Ztest will return
+dummy records.
 
 Moved pretty-printing of structure-wrappers ({..}) from odr_seq.c to
 odr_cons.c, which causes a more correct output.
index 9caa283..0ef61da 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.17 1995-08-15 11:58:33 quinn Exp $
+# $Id: Makefile,v 1.18 1995-08-17 12:44:59 quinn Exp $
 
 SHELL=/bin/sh
 INCLUDE=-I../include -I.
@@ -11,7 +11,7 @@ LIBINCLUDE=-L$(LIBDIR)
 DEFS=$(INCLUDE)
 LIB=$(LIBDIR)/libasn.a
 LIBS=-lodr -lasn
-PO = proto.o diagbib1.o zget.o prt-rsc.o prt-acc.o prt-exp.o prt-ext.o
+PO = proto.o diagbib1.o zget.o prt-rsc.o prt-acc.o prt-exp.o prt-ext.o prt-grs.o
 CPP=$(CC) -E
 RANLIB=ranlib
 
index ae50510..3b5b49f 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: prt-ext.c,v $
- * Revision 1.1  1995-08-15 13:37:41  quinn
+ * Revision 1.2  1995-08-17 12:45:00  quinn
+ * Fixed minor problems with GRS-1. Added support in c&s.
+ *
+ * Revision 1.1  1995/08/15  13:37:41  quinn
  * Improved EXTERNAL
  *
  *
@@ -22,9 +25,16 @@ int z_External(ODR o, Z_External **p, int opt)
        {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_External_octet, odr_octetstring},
        {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_External_arbitrary, odr_bitstring},
 
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_SUTRS, z_SUTRS},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_sutrs, z_SUTRS},
        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_explainRecord,
            z_ExplainRecord},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport1,
+           z_ResourceReport1},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport2,
+           z_ResourceReport2},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_promptObject1,
+           z_PromptObject1},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_grs1, z_GenericRecord},
        {-1, -1, -1, -1, 0}
     };
     /*
@@ -38,8 +48,12 @@ int z_External(ODR o, Z_External **p, int opt)
        int what;          /* discriminator value for the external CHOICE */
     } tab[] =
     {
-       {VAL_SUTRS, Z_External_SUTRS},
+       {VAL_SUTRS, Z_External_sutrs},
        {VAL_EXPLAIN, Z_External_explainRecord},
+       {VAL_RESOURCE1, Z_External_resourceReport1},
+       {VAL_RESOURCE2, Z_External_resourceReport2},
+       {VAL_PROMPT1, Z_External_promptObject1},
+       {VAL_GRS1, Z_External_grs1},
        {VAL_NONE, 0}
     };
 
index 3ada612..4636814 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: client.c,v $
- * Revision 1.16  1995-08-15 12:00:04  quinn
+ * Revision 1.17  1995-08-17 12:45:02  quinn
+ * Fixed minor problems with GRS-1. Added support in c&s.
+ *
+ * Revision 1.16  1995/08/15  12:00:04  quinn
  * Updated External
  *
  * Revision 1.15  1995/06/22  09:28:03  quinn
@@ -267,9 +270,42 @@ int cmd_authentication(char *arg)
 
 /* SEARCH SERVICE ------------------------------ */
 
+void display_grs1(Z_GenericRecord *r, int level)
+{
+    int i;
+
+    if (!r)
+       return;
+    for (i = 0; i < r->num_elements; i++)
+    {
+       Z_TaggedElement *t;
+
+       printf("%*s", level * 4, "");
+       t = r->elements[i];
+       printf("(");
+       if (t->tagType)
+           printf("%d,", *t->tagType);
+       else
+           printf("?,");
+       if (t->tagValue->which == Z_StringOrNumeric_numeric)
+           printf("%d) ", *t->tagValue->u.numeric);
+       else
+           printf("%s) ", t->tagValue->u.string);
+       if (t->content->which == Z_ElementData_subtree)
+       {
+           printf("\n");
+           display_grs1(t->content->u.subtree, level+1);
+       }
+       else if (t->content->which == Z_ElementData_string)
+           printf("%s\n", t->content->u.string);
+       else
+           printf("??????\n");
+    }
+}
+
 void display_record(Z_DatabaseRecord *p)
 {
-    Z_External *r = (Odr_external*) p;
+    Z_External *r = (Z_External*) p;
     oident *ent = oid_getentbyoid(r->direct_reference);
 
     if (r->direct_reference)
@@ -287,13 +323,22 @@ void display_record(Z_DatabaseRecord *p)
        marc_display ((char*)p->u.octet_aligned->buf, stdout);
     else if (ent->value == VAL_SUTRS)
     {
-       if (r->which != Z_External_SUTRS)
+       if (r->which != Z_External_sutrs)
        {
            printf("Expecting single SUTRS type for SUTRS.\n");
            return;
        }
        printf("%.*s", r->u.sutrs->len, r->u.sutrs->buf);
     }
+    else if (ent->value == VAL_GRS1)
+    {
+       if (r->which != Z_External_grs1)
+       {
+           printf("Expecting single GRS type for GRS.\n");
+           return;
+       }
+       display_grs1(r->u.grs1, 0);
+    }
     else 
     {
        printf("Unknown record representation.\n");
@@ -724,9 +769,15 @@ int cmd_format(char *arg)
        recordsyntax = VAL_DANMARC;
        return 1;
     }
+    else if (!strcmp(arg, "grs1"))
+    {
+       printf("Preferred format is GRS1\n");
+       recordsyntax = VAL_GRS1;
+       return 1;
+    }
     else
     {
-       printf("Specify one of {sutrs,usmarc,danmarc}.\n");
+       printf("Specify one of {sutrs,usmarc,danmarc,grs1}.\n");
        return 0;
     }
 }
index da2ee29..73f40e2 100644 (file)
@@ -70,12 +70,13 @@ typedef struct bend_fetchrequest
     char *setname;             /* set name */
     int number;                /* record number */
     oid_value format;          /* One of the CLASS_RECSYN members */
+    ODR stream;                /* encoding stream - memory source if required */
 } bend_fetchrequest;
 
 typedef struct bend_fetchresult
 {
     char *basename;            /* name of database that provided record */
-    int len;                   /* length of record */
+    int len;                   /* length of record or -1 if structured */
     char *record;              /* record */
     int last_in_set;           /* is it?  */
     oid_value format;          /* format */
index be2de47..4d6b8e5 100644 (file)
  * OF THIS SOFTWARE.
  *
  * $Log: proto.h,v $
- * Revision 1.21  1995-08-15 12:00:11  quinn
+ * Revision 1.22  1995-08-17 12:45:14  quinn
+ * Fixed minor problems with GRS-1. Added support in c&s.
+ *
+ * Revision 1.21  1995/08/15  12:00:11  quinn
  * Updated External
  *
  * Revision 1.20  1995/08/10  08:54:35  quinn
@@ -1092,6 +1095,8 @@ Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which);
 #include <prt-rsc.h>
 #include <prt-acc.h>
 #include <prt-exp.h>
+#include <prt-grs.h>
+
 #include <prt-ext.h>
 
 #endif
index 4b78e46..999a430 100644 (file)
  * OF THIS SOFTWARE.
  *
  * $Log: prt-acc.h,v $
- * Revision 1.2  1995-08-15 12:00:13  quinn
+ * Revision 1.3  1995-08-17 12:45:16  quinn
+ * Fixed minor problems with GRS-1. Added support in c&s.
+ *
+ * Revision 1.2  1995/08/15  12:00:13  quinn
  * Updated External
  *
  * Revision 1.1  1995/06/02  09:49:49  quinn
@@ -145,3 +148,5 @@ typedef struct Z_PromptObject1
        Z_Response1 *response;
     } u;
 } Z_PromptObject1;
+
+int z_PromptObject1(ODR o, Z_PromptObject1 **p, int opt);
index a04b2e3..7c5a06f 100644 (file)
@@ -42,8 +42,12 @@ struct Z_External
        Z_External_arbitrary,
 
        /* Specific types */
-       Z_External_SUTRS,
-       Z_External_explainRecord
+       Z_External_sutrs,
+       Z_External_explainRecord,
+       Z_External_resourceReport1,
+       Z_External_resourceReport2,
+       Z_External_promptObject1,
+       Z_External_grs1
     } which;
     union
     {
@@ -55,6 +59,10 @@ struct Z_External
        /* Specific types */
        Z_SUTRS *sutrs;
        Z_ExplainRecord *explainRecord;
+       Z_ResourceReport1 *resourceReport1;
+       Z_ResourceReport2 *resourceReport2;
+       Z_PromptObject1 *promptObject1;
+       Z_GenericRecord *grs1;
     } u;
 };
 
index 5199e44..2796bc3 100644 (file)
  * OF THIS SOFTWARE.
  *
  * $Log: prt-rsc.h,v $
- * Revision 1.2  1995-06-02 09:49:50  quinn
+ * Revision 1.3  1995-08-17 12:45:17  quinn
+ * Fixed minor problems with GRS-1. Added support in c&s.
+ *
+ * Revision 1.2  1995/06/02  09:49:50  quinn
  * Add access control
  *
  * Revision 1.1  1995/06/01  11:24:52  quinn
@@ -69,6 +72,8 @@ typedef struct Z_ResourceReport1
     char *message;
 } Z_ResourceReport1;
 
+int z_ResourceReport1(ODR o, Z_ResourceReport1 **p, int opt);
+
 /* -------------------- Resource-2 -------------------- */
 
 typedef struct Z_Estimate2
@@ -84,4 +89,6 @@ typedef struct Z_ResourceReport2
     char *message;                       /* OPTIONAL */
 } Z_ResourceReport2;
 
+int z_ResourceReport2(ODR o, Z_ResourceReport2 **p, int opt);
+
 #endif
index d399f9e..7a07775 100644 (file)
@@ -5,8 +5,11 @@
 char *odr_indent(ODR o)
 {
     static char buf[512];
+    int i = o->indent;
 
     memset(buf, ' ', 512);
+    if (i >= 128)
+       i = 127;
     buf[o->indent * 4] = 0;
     return buf;
 }
index d21f397..d56bd87 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.27 1995-06-27 13:20:59 quinn Exp $
+# $Id: Makefile,v 1.28 1995-08-17 12:45:22 quinn Exp $
 
 LIBDIR=../lib
 
@@ -18,7 +18,7 @@ $(LIBDIR)/libcomstack.a $(LIBMOSI) $(LIBDIR)/libutil.a $(ELIBS)
 PO = eventl.o seshigh.o statserv.o requestq.o
 CPP=$(CC) -E
 PROG=ztest
-PROGO=ztest.o
+PROGO=ztest.o read-grs.o
 RANLIB=ranlib
 
 all: $(LIBDIR) $(LIB) $(PROG)
index 6bed31c..a9dfd99 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: seshigh.c,v $
- * Revision 1.43  1995-08-15 12:00:31  quinn
+ * Revision 1.44  1995-08-17 12:45:25  quinn
+ * Fixed minor problems with GRS-1. Added support in c&s.
+ *
+ * Revision 1.43  1995/08/15  12:00:31  quinn
  * Updated External
  *
  * Revision 1.42  1995/08/15  11:16:50  quinn
@@ -762,6 +765,7 @@ static Z_Records *pack_records(association *a, char *setname, int start,
        freq.setname = setname;
        freq.number = recno;
        freq.format = format;
+       freq.stream = a->encode;
        if (!(fres = bend_fetch(a->backend, &freq, 0)))
        {
            *pres = Z_PRES_FAILURE;
@@ -826,50 +830,39 @@ static Z_Records *pack_records(association *a, char *setname, int start,
            oid_getoidbyent(&recform));
        thisext->indirect_reference = 0;
        thisext->descriptor = 0;
-       if (fres->format == VAL_SUTRS) /* SUTRS is a single-ASN.1-type */
+       if (fres->len < 0) /* Structured data */
+       {
+           switch (fres->format)
+           {
+               case VAL_SUTRS: thisext->which = Z_External_sutrs; break;
+               case VAL_GRS1: thisext->which = Z_External_grs1; break;
+               case VAL_EXPLAIN: thisext->which = Z_External_explainRecord;
+                   break;
+
+               default:
+                   logf(LOG_FATAL, "Unknown structured format from backend.");
+                   return 0;
+           }
+
+           /*
+            * We cheat on the pointers here. Obviously, the record field
+            * of the backend-fetch structure should have been a union for
+            * correctness, but we're stuck with this for backwards
+            * compatibility.
+            */
+           thisext->u.grs1 = (Z_GenericRecord*) fres->record;
+       }
+       else if (fres->format == VAL_SUTRS) /* SUTRS is a single-ASN.1-type */
        {
            Odr_oct *sutrs = odr_malloc(a->encode, sizeof(*sutrs));
 
-           thisext->which = Z_External_SUTRS;
+           thisext->which = Z_External_sutrs;
            thisext->u.sutrs = sutrs;
            sutrs->buf = odr_malloc(a->encode, fres->len);
            sutrs->len = sutrs->size = fres->len;
            memcpy(sutrs->buf, fres->record, fres->len);
-#if 0
-           Odr_oct sutrs_asn;
-           Odr_oct *sp = &sutrs_asn;
-           Odr_any *single = odr_malloc(a->encode, sizeof(*single));
-           char *buf, *remember;
-           int len, s_remember;
-
-           sutrs_asn.buf = (unsigned char*) fres->record;
-           sutrs_asn.len = sutrs_asn.size = fres->len;
-           /*
-            * we borrow the encoding stream for preparing the buffer. This
-            * is not the most elegant solution - a better way might have been
-            * to reserve a different stream, or to devise a better system
-            * for handling externals in general.
-            */
-           remember = odr_getbuf(a->encode, &len, &s_remember);
-           buf = odr_malloc(a->encode, fres->len + 10); /* buf for encoding */
-           odr_setbuf(a->encode, buf, fres->len + 10, 0); /* can_grow==0 */
-           if (!z_SUTRS(a->encode, &sp, 0))
-           {
-               logf(LOG_LOG, "ODR error encoding SUTRS: %s",
-                   odr_errlist[odr_geterror(a->encode)]);
-               return 0;
-           }
-           thisext->which = ODR_EXTERNAL_single;
-           thisext->u.single_ASN1_type = single;
-           single->buf = (unsigned char*)odr_getbuf(a->encode, &single->len,
-               &single->size);
-           /* Now restore the encoding stream */
-           odr_setbuf(a->encode, remember, s_remember, 1);
-           logf(LOG_DEBUG, "   Format is SUTRS. len %d, encoded len %d",
-               fres->len, single->len);
-#endif
        }
-       else /* octet-aligned record. Easy as pie */
+       else /* octet-aligned record. */
        {
            thisext->which = Z_External_octet;
            if (!(thisext->u.octet_aligned = odr_malloc(a->encode,