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.
# 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.
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
* 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
*
*
{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}
};
/*
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}
};
* 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
/* 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)
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");
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;
}
}
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 */
* 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
#include <prt-rsc.h>
#include <prt-acc.h>
#include <prt-exp.h>
+#include <prt-grs.h>
+
#include <prt-ext.h>
#endif
* 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
Z_Response1 *response;
} u;
} Z_PromptObject1;
+
+int z_PromptObject1(ODR o, Z_PromptObject1 **p, int opt);
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
{
/* Specific types */
Z_SUTRS *sutrs;
Z_ExplainRecord *explainRecord;
+ Z_ResourceReport1 *resourceReport1;
+ Z_ResourceReport2 *resourceReport2;
+ Z_PromptObject1 *promptObject1;
+ Z_GenericRecord *grs1;
} u;
};
* 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
char *message;
} Z_ResourceReport1;
+int z_ResourceReport1(ODR o, Z_ResourceReport1 **p, int opt);
+
/* -------------------- Resource-2 -------------------- */
typedef struct Z_Estimate2
char *message; /* OPTIONAL */
} Z_ResourceReport2;
+int z_ResourceReport2(ODR o, Z_ResourceReport2 **p, int opt);
+
#endif
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;
}
# 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
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)
* 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
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;
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,