It has not served a purpose for years.
Z_FragmentSyntax_notExternallyTagged;
rec->u.intermediateFragment->u.notExternallyTagged = oct;
- oct->len = oct->size = status.st_size;
- oct->buf = (unsigned char *) odr_malloc (out, oct->size);
- if (fread(oct->buf, 1, oct->size, inf) != (size_t) oct->size)
+ oct->len = status.st_size;
+#if OCT_SIZE
+ oct->size = status.st_size;
+#endif
+ oct->buf = (unsigned char *) odr_malloc (out, oct->len);
+ if (fread(oct->buf, 1, oct->len, inf) != (size_t) oct->len)
{
printf("Incomplete read of file %s\n", fname);
}
if (!refid)
return 0;
id = (Z_ReferenceId *) odr_malloc(out, sizeof(*id));
- id->size = id->len = strlen(refid);
+ id->len = strlen(refid);
+#if OCT_SIZE
+ id->size = id->len;
+#endif
id->buf = (unsigned char *) odr_malloc(out, id->len);
memcpy(id->buf, refid, id->len);
return id;
/* send a very big referenceid to test transport stack etc. */
memset(big, 'A', 2100);
- bigo.len = bigo.size = 2100;
+ bigo.len = 2100;
+#if OCT_SIZE
+ bigo.size = bigo.len;
+#endif
bigo.buf = big;
req->referenceId = &bigo;
}
int i;
print_level(iLevel);
- printf("Ref Id (%d, %d): ", referenceId->len, referenceId->size);
+ printf("Ref Id (%d): ", referenceId->len);
for (i = 0; i < referenceId->len; i++)
printf("%c", referenceId->buf[i]);
printf("\n");
r->u.single_ASN1_type->buf = (unsigned char *)
odr_malloc(out, item_request_size);
r->u.single_ASN1_type->len = item_request_size;
+#if OCT_SIZE
r->u.single_ASN1_type->size = item_request_size;
+#endif
memcpy(r->u.single_ASN1_type->buf, item_request_buf,
item_request_size);
r->u.single_ASN1_type->buf = (unsigned char *)
odr_malloc(out, ill_request_size);
r->u.single_ASN1_type->len = ill_request_size;
+#if OCT_SIZE
r->u.single_ASN1_type->size = ill_request_size;
+#endif
memcpy(r->u.single_ASN1_type->buf, ill_request_buf, ill_request_size);
/* printf("len = %d\n", ill_request_size); */
/* do_hex_dump(ill_request_buf,ill_request_size); */
notToKeep->elements[0]->u.opaque = (Odr_oct *)
odr_malloc(out, sizeof(Odr_oct));
notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
+#if OCT_SIZE
notToKeep->elements[0]->u.opaque->size = strlen(recid);
+#endif
notToKeep->elements[0]->u.opaque->len = strlen(recid);
}
else
notToKeep->elements[0]->u.opaque = (Odr_oct *)
odr_malloc(out, sizeof(Odr_oct));
notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
+#if OCT_SIZE
notToKeep->elements[0]->u.opaque->size = strlen(recid);
+#endif
notToKeep->elements[0]->u.opaque->len = strlen(recid);
}
else
{
req->termListAndStartPoint->term->u.general->buf =
(unsigned char *) odr_strdup(out, term);
- req->termListAndStartPoint->term->u.general->len =
- req->termListAndStartPoint->term->u.general->size =
- strlen(term);
+ req->termListAndStartPoint->term->u.general->len = strlen(term);
+#if OCT_SIZE
+ req->termListAndStartPoint->term->u.general->size = strlen(term);
+#endif
}
}
req->referenceId = set_refid(out);
{
unsigned char *buf;
int len;
- int size;
} Odr_oct;
int odr_octetstring(ODR o, Odr_oct **p, int optional,
<para>
The <literal>buf</literal> field should point to the character array
that holds the octetstring. The <literal>len</literal> field holds the
- actual length, while the <literal>size</literal> field gives the size
- of the allocated array (not of interest to you, in most cases).
+ actual length.
The character array need not be null terminated.
</para>
#define ODR_ENCODE 1
#define ODR_PRINT 2
+#define OCT_SIZE 0
+
typedef struct odr_oct
{
unsigned char *buf;
int len;
+#if OCT_SIZE
int size;
+#endif
} Odr_oct;
typedef void Odr_null;
}
(*p)->buf = (unsigned char *)odr_malloc(o, res);
memcpy((*p)->buf, o->bp, res);
- (*p)->len = (*p)->size = res;
+ (*p)->len = res;
+#if OCT_SIZE
+ (*p)->size = res;
+#endif
o->bp += res;
return 1;
case ODR_ENCODE:
#endif
#include "odr-priv.h"
+#include <yaz/log.h>
+#include <assert.h>
int ber_octetstring(ODR o, Odr_oct *p, int cons)
{
int res, len;
const unsigned char *base;
+#if OCT_SIZE
unsigned char *c;
+#endif
switch (o->direction)
{
odr_seterror(o, OOTHER, 16);
return 0;
}
+#if OCT_SIZE
+ assert(p->size == 0);
+ assert(p->len == 0);
+ yaz_log(YLOG_LOG, "DECODE OCTET1 p->size=%d p->len=%d", p->size, p->len);
if (len + 1 > p->size - p->len)
{
c = (unsigned char *)odr_malloc(o, p->size += len + 1);
+ yaz_log(YLOG_LOG, "DECODE COPY p->size=%d p->len=%d", p->size, p->len);
if (p->len)
memcpy(c, p->buf, p->len);
p->buf = c;
if (len)
memcpy(p->buf + p->len, o->bp, len);
p->len += len;
+ yaz_log(YLOG_LOG, "DECODE OCTET2 p->size=%d p->len=%d", p->size, p->len);
o->bp += len;
/* the final null is really not part of the buffer, but */
/* it helps somes applications that assumes C strings */
if (len)
p->buf[p->len] = '\0';
+#else
+ p->len = len;
+ p->buf = odr_malloc(o, len + 1);
+ memcpy(p->buf, o->bp, len);
+ p->buf[len] = '\0';
+ o->bp += len;
+#endif
return 1;
case ODR_ENCODE:
if ((res = ber_enclen(o, p->len, 5, 0)) < 0)
return 0;
if (!(p->u.octet_aligned->buf = (unsigned char *)odr_malloc(o, len)))
return 0;
- p->u.octet_aligned->len = p->u.octet_aligned->size = len;
+ p->u.octet_aligned->len = len;
+#if OCT_SIZE
+ p->u.octet_aligned->size = len;
+#endif
memcpy(p->u.octet_aligned->buf, buf, len);
return p;
Odr_oct *p = (Odr_oct *) odr_malloc(o, sizeof(Odr_oct));
p->buf = (unsigned char *) odr_malloc(o, sz);
memcpy(p->buf, buf, sz);
+#if OCT_SIZE
p->size = sz;
+#endif
p->len = sz;
return p;
}
if (o->direction == ODR_DECODE)
{
*p = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct));
+#if OCT_SIZE
(*p)->size= 0;
+#endif
(*p)->len = 0;
(*p)->buf = 0;
}
if (o->direction == ODR_ENCODE)
{
t->buf = (unsigned char *) *p;
- t->size = t->len = strlen(*p);
+ t->len = strlen(*p);
+#if OCT_SIZE
+ t->size = t->len;
+#endif
}
else
{
+#if OCT_SIZE
t->size= 0;
+#endif
t->len = 0;
t->buf = 0;
}
odr_seterror(o, ODATA, 44);
return 0;
}
- t->size = t->len = outbuf - (char*) t->buf;
+ t->len = outbuf - (char*) t->buf;
+#if OCT_SIZE
+ t->size = t->len;
+#endif
}
if (!t->buf)
{
t->buf = (unsigned char *) *p;
- t->size = t->len = strlen(*p);
+ t->len = strlen(*p);
+#if OCT_SIZE
+ t->size = t->len;
+#endif
}
}
else
{
+#if OCT_SIZE
t->size= 0;
+#endif
t->len = 0;
t->buf = 0;
}
Odr_oct *term_octet = (Odr_oct *)odr_malloc(o, sizeof(*term_octet));
term_octet->buf = (unsigned char *)odr_malloc(o, 1 + len);
memcpy(term_octet->buf, buf, len);
- term_octet->size = term_octet->len = len;
- term_octet->buf[term_octet->size] = 0; /* null terminate */
+ term_octet->len = len;
+#if OCT_SIZE
+ term_octet->size = len;
+#endif
+ term_octet->buf[term_octet->len] = 0; /* null terminate */
switch (term_type)
{
thisext->which = Z_External_sutrs;
thisext->u.sutrs = sutrs;
sutrs->buf = (unsigned char *)nmem_malloc(nmem, len);
- sutrs->len = sutrs->size = len;
+ sutrs->len = len;
+#if OCT_SIZE
+ sutrs->size = len;
+#endif
memcpy(sutrs->buf, buf, len);
}
else
nmem_malloc(nmem, len)))
return 0;
memcpy(thisext->u.octet_aligned->buf, buf, len);
- thisext->u.octet_aligned->len = thisext->u.octet_aligned->size = len;
+ thisext->u.octet_aligned->len = len;
+#if OCT_SIZE
+ thisext->u.octet_aligned->size = len;
+#endif
}
return thisext;
}
if (!thisext->u.single_ASN1_type->buf)
return 0;
memcpy(thisext->u.single_ASN1_type->buf, buf, len);
- thisext->u.single_ASN1_type->len = thisext->u.single_ASN1_type->size = len;
-
+ thisext->u.single_ASN1_type->len = len;
+#if OCT_SIZE
+ thisext->u.single_ASN1_type->size = len;
+#endif
return thisext;
}
t->term->u.general = o =
(Odr_oct *)odr_malloc(assoc->encode, sizeof(Odr_oct));
o->buf = (unsigned char *)
- odr_malloc(assoc->encode, o->len = o->size =
+ odr_malloc(assoc->encode, o->len =
strlen(bsrr->entries[i].term));
+#if OCT_SIZE
+ o->size = o->len;
+#endif
memcpy(o->buf, bsrr->entries[i].term, o->len);
yaz_log(YLOG_DEBUG, " term #%d: '%s' (" ODR_INT_PRINTF ")", i,
bsrr->entries[i].term, bsrr->entries[i].occurrences);
odr_malloc(out, sizeof(Odr_oct));
i++;
sks->u.missingValueData->len = strlen(sort_flags+i);
+#if OCT_SIZE
sks->u.missingValueData->size = sks->u.missingValueData->len;
+#endif
sks->u.missingValueData->buf = (unsigned char*)
odr_strdup(out, sort_flags+i);
i += strlen(sort_flags+i) - 1;
npr->u.databaseRecord->u.octet_aligned->buf = (unsigned char*)
sru_rec->recordData_buf;
npr->u.databaseRecord->u.octet_aligned->len =
- npr->u.databaseRecord->u.octet_aligned->size =
sru_rec->recordData_len;
-
+#if OCT_SIZE
+ npr->u.databaseRecord->u.octet_aligned->size =
+ sru_rec->recordData_len;
+#endif
if (sru_rec->recordSchema
&& !strcmp(sru_rec->recordSchema,
"info:srw/schema/1/diagnostics-v1.1"))
s->second = (Odr_oct *) odr_malloc(encode, sizeof(*s->second));
s->second->buf = (unsigned char *) "hello";
s->second->len = 5;
+#if OCT_SIZE
s->second->size = 0;
+#endif
s->third = odr_booldup(encode, 1);
s->fourth = odr_nullval();
s->fifth = odr_intdup(encode, YC_MySequence_enum1);
s->second = (Odr_oct *) odr_malloc(encode, sizeof(*s->second));
s->second->buf = (unsigned char *) "hello";
s->second->len = 5;
+#if OCT_SIZE
s->second->size = 0;
+#endif
s->third = odr_booldup(encode, 1);
s->fourth = odr_nullval();
s->fifth = odr_intdup(encode, YC_MySequence_enum1);
odr_malloc(odr,sizeof(*ext->u.single_ASN1_type));
ext->u.single_ASN1_type->buf= (unsigned char *) odr_malloc(odr, siz);
memcpy(ext->u.single_ASN1_type->buf,buf, siz );
- ext->u.single_ASN1_type->len = ext->u.single_ASN1_type->size = siz;
+ ext->u.single_ASN1_type->len = siz;
+#if OCT_SIZE
+ ext->u.single_ASN1_type->size = siz;
+#endif
odr_reset(odr_ext);
odr_reset(odr_prt); /*!*/
buf= odr_getbuf(odr_ext,&siz,0);
e->item->buf= (unsigned char *) odr_malloc(odr, siz);
memcpy(e->item->buf,buf, siz );
- e->item->len = e->item->size = siz;
+ e->item->len = siz;
+#if OCT_SIZE
+ e->item->size = siz;
+#endif
odr_destroy(odr_prt);
odr_destroy(odr_ext);
odr_malloc(odr,sizeof(*ext->u.single_ASN1_type));
ext->u.single_ASN1_type->buf = (unsigned char *) odr_malloc(odr, siz);
memcpy(ext->u.single_ASN1_type->buf,buf, siz );
- ext->u.single_ASN1_type->len = ext->u.single_ASN1_type->size = siz;
+ ext->u.single_ASN1_type->len = siz;
+#if OCT_SIZE
+ ext->u.single_ASN1_type->size = siz;
+#endif
odr_reset(odr_ext);
odr_reset(odr_prt); /*!*/
buf= odr_getbuf(odr_ext,&siz,0);
e->item->buf= (unsigned char *) odr_malloc(odr, siz);
memcpy(e->item->buf, buf, siz);
- e->item->len = e->item->size = siz;
+ e->item->len = siz;
+#if OCT_SIZE
+ e->item->size = siz;
+#endif
odr_destroy(odr_prt);
odr_destroy(odr_ext);
rr->taskPackage->targetReference->buf =
(unsigned char *) odr_strdup(rr->stream, "911");
rr->taskPackage->targetReference->len =
- rr->taskPackage->targetReference->size =
strlen((char *) (rr->taskPackage->targetReference->buf));
+#if OCT_SIZE
+ rr->taskPackage->targetReference->size =
+ strlen((char *) (rr->taskPackage->targetReference->buf));
+#endif
rr->taskPackage->creationDateTime = 0;
rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
rr->taskPackage->packageDiagnostics = 0;
rr->taskPackage->targetReference->buf =
(unsigned char *) odr_strdup(rr->stream, "123");
rr->taskPackage->targetReference->len =
- rr->taskPackage->targetReference->size =
strlen((char *) (rr->taskPackage->targetReference->buf));
+#if OCT_SIZE
+ rr->taskPackage->targetReference->size =
+ rr->taskPackage->targetReference->len;
+#endif
rr->taskPackage->creationDateTime = 0;
rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
rr->taskPackage->packageDiagnostics = 0;