From: Adam Dickmeiss Date: Tue, 10 Sep 2013 14:20:01 +0000 (+0200) Subject: No unsigned char's in public API (except for iconv) X-Git-Tag: v5.0.0~48 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=69b1d8e7b437179163fe97b7cbead51a56835f2a;p=yaz-moved-to-github.git No unsigned char's in public API (except for iconv) --- diff --git a/client/admin.c b/client/admin.c index ed9db68..c7fb4e6 100644 --- a/client/admin.c +++ b/client/admin.c @@ -241,7 +241,7 @@ int cmd_adm_import(const char *arg) #if OCT_SIZE oct->size = status.st_size; #endif - oct->buf = (unsigned char *) odr_malloc (out, oct->len); + oct->buf = (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); diff --git a/client/client.c b/client/client.c index 7b0f926..e6dd25a 100644 --- a/client/client.c +++ b/client/client.c @@ -326,7 +326,7 @@ static Z_ReferenceId *set_refid(ODR out) #if OCT_SIZE id->size = id->len; #endif - id->buf = (unsigned char *) odr_malloc(out, id->len); + id->buf = (char *) odr_malloc(out, id->len); memcpy(id->buf, refid, id->len); return id; } @@ -1563,7 +1563,7 @@ static int send_Z3950_searchRequest(const char *arg) req->referenceId = set_refid(out); if (!strcmp(arg, "@big")) /* strictly for troublemaking */ { - static unsigned char big[2100]; + static char big[2100]; static Odr_oct bigo; /* send a very big referenceid to test transport stack etc. */ @@ -1625,7 +1625,7 @@ static int send_Z3950_searchRequest(const char *arg) case QueryType_CCL: query.which = Z_Query_type_2; query.u.type_2 = &ccl_query; - ccl_query.buf = (unsigned char*) arg; + ccl_query.buf = (char *) arg; ccl_query.len = strlen(arg); break; case QueryType_CCL2RPN: @@ -2138,8 +2138,8 @@ static Z_External *create_external_itemRequest(void) r->u.single_ASN1_type = (Odr_oct *) odr_malloc(out, sizeof(*r->u.single_ASN1_type)); - r->u.single_ASN1_type->buf = (unsigned char *) - odr_malloc(out, item_request_size); + r->u.single_ASN1_type->buf = (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; @@ -2193,8 +2193,8 @@ static Z_External *create_external_ILL_APDU(void) r->u.single_ASN1_type = (Odr_oct *) odr_malloc(out, sizeof(*r->u.single_ASN1_type)); - r->u.single_ASN1_type->buf = (unsigned char *) - odr_malloc(out, ill_request_size); + r->u.single_ASN1_type->buf = (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; @@ -2496,7 +2496,7 @@ static int send_Z3950_update(int version, int action_no, const char *recid, { notToKeep->elements[0]->u.opaque = (Odr_oct *) odr_malloc(out, sizeof(Odr_oct)); - notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid; + notToKeep->elements[0]->u.opaque->buf = (char *) recid; #if OCT_SIZE notToKeep->elements[0]->u.opaque->size = strlen(recid); #endif @@ -2545,7 +2545,7 @@ static int send_Z3950_update(int version, int action_no, const char *recid, { notToKeep->elements[0]->u.opaque = (Odr_oct *) odr_malloc(out, sizeof(Odr_oct)); - notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid; + notToKeep->elements[0]->u.opaque->buf = (char *) recid; #if OCT_SIZE notToKeep->elements[0]->u.opaque->size = strlen(recid); #endif @@ -2596,7 +2596,7 @@ static int cmd_xmles(const char *arg) &ext->u.single_ASN1_type->len) == 0) return 0; - ext->u.single_ASN1_type->buf = (unsigned char *) asn_buf; + ext->u.single_ASN1_type->buf = asn_buf; oid = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_EXTSERV, oid_str, out); @@ -3401,7 +3401,7 @@ static int send_Z3950_scanrequest(const char *set, const char *query, req->termListAndStartPoint->term->u.general) { req->termListAndStartPoint->term->u.general->buf = - (unsigned char *) odr_strdup(out, term); + odr_strdup(out, term); req->termListAndStartPoint->term->u.general->len = strlen(term); #if OCT_SIZE req->termListAndStartPoint->term->u.general->size = strlen(term); diff --git a/include/yaz/odr.h b/include/yaz/odr.h index 9c7ea51..3f3c9f0 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -100,7 +100,7 @@ typedef nmem_bool_t Odr_bool; typedef struct odr_oct { - unsigned char *buf; + char *buf; int len; #if OCT_SIZE int size; @@ -115,7 +115,7 @@ typedef Odr_oct Odr_any; typedef struct odr_bitmask { #define ODR_BITMASK_SIZE 256 - unsigned char bits[ODR_BITMASK_SIZE]; + char bits[ODR_BITMASK_SIZE]; int top; } Odr_bitmask; @@ -132,13 +132,13 @@ struct odr int error; /* current error state (0==OK) */ - unsigned char *buf; /* memory handle */ + char *buf; /* memory handle */ int top; /* top of buffer (max pos when encoding) */ int size; /* current buffer size (encoding+decoding) */ int pos; /* current position (encoding) */ - const unsigned char *bp; /* position in buffer (decoding) */ + const char *bp; /* position in buffer (decoding) */ NMEM mem; /* memory handle for decoding (primarily) */ @@ -194,8 +194,7 @@ YAZ_EXPORT char *odr_strdupn(ODR o, const char *str, size_t n); YAZ_EXPORT char *odr_strdup_null(ODR o, const char *str); YAZ_EXPORT Odr_int *odr_intdup(ODR o, Odr_int v); YAZ_EXPORT Odr_bool *odr_booldup(ODR o, Odr_bool v); -YAZ_EXPORT Odr_oct *odr_create_Odr_oct(ODR o, const unsigned char *buf, - int sz); +YAZ_EXPORT Odr_oct *odr_create_Odr_oct(ODR o, const char *buf, int sz); YAZ_EXPORT NMEM odr_extract_mem(ODR o); YAZ_EXPORT Odr_null *odr_nullval(void); #define odr_release_mem(m) nmem_destroy(m) @@ -235,14 +234,14 @@ YAZ_EXPORT int ber_boolean(ODR o, int *val); YAZ_EXPORT int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt, const char *name); YAZ_EXPORT int ber_enctag(ODR o, int zclass, int tag, int constructed); -YAZ_EXPORT int ber_dectag(const unsigned char *buf, int *zclass, +YAZ_EXPORT int ber_dectag(const char *buf, int *zclass, int *tag, int *constructed, int max); YAZ_EXPORT int odr_bool(ODR o, Odr_bool **p, int opt, const char *name); YAZ_EXPORT int odr_integer(ODR o, Odr_int **p, int opt, const char *name); YAZ_EXPORT int odr_enum(ODR o, Odr_int **p, int opt, const char *name); YAZ_EXPORT int odr_implicit_settag(ODR o, int zclass, int tag); YAZ_EXPORT int ber_enclen(ODR o, int len, int lenlen, int exact); -YAZ_EXPORT int ber_declen(const unsigned char *buf, int *len, int max); +YAZ_EXPORT int ber_declen(const char *buf, int *len, int max); YAZ_EXPORT void odr_prname(ODR o, const char *name); YAZ_EXPORT int ber_null(ODR o); YAZ_EXPORT int odr_null(ODR o, Odr_null **p, int opt, const char *name); @@ -256,7 +255,7 @@ YAZ_EXPORT int odr_sequence_end(ODR o); YAZ_EXPORT int odr_set_end(ODR o); YAZ_EXPORT int ber_octetstring(ODR o, Odr_oct *p, int cons); YAZ_EXPORT int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name); -YAZ_EXPORT int odp_more_chunks(ODR o, const unsigned char *base, int len); +YAZ_EXPORT int odp_more_chunks(ODR o, const char *base, int len); YAZ_EXPORT int odr_constructed_more(ODR o); YAZ_EXPORT int odr_bitstring(ODR o, Odr_bitmask **p, int opt, const char *name); @@ -281,14 +280,13 @@ YAZ_EXPORT int ber_any(ODR o, Odr_any **p); \retval 0 package is incomplete \retval >0 package is complete and length is return value */ -YAZ_EXPORT int completeBER(const unsigned char *buf, int len); +YAZ_EXPORT int completeBER(const char *buf, int len); YAZ_EXPORT void odr_begin(ODR o); YAZ_EXPORT void odr_end(ODR o); YAZ_EXPORT Odr_oid *odr_oiddup(ODR odr, const Odr_oid *o); YAZ_EXPORT Odr_oid *odr_oiddup_nmem(NMEM nmem, const Odr_oid *o); YAZ_EXPORT int odr_grow_block(ODR b, int min_bytes); -YAZ_EXPORT int odr_write(ODR o, unsigned char *buf, int bytes); YAZ_EXPORT int odr_write2(ODR o, const char *buf, int bytes); YAZ_EXPORT int odr_seek(ODR o, int whence, int offset); YAZ_EXPORT int odr_dumpBER(FILE *f, const char *buf, int len); diff --git a/src/ber_any.c b/src/ber_any.c index 0002944..e4bcef3 100644 --- a/src/ber_any.c +++ b/src/ber_any.c @@ -30,7 +30,7 @@ int ber_any(ODR o, Odr_any **p) odr_seterror(o, OPROTO, 2); return 0; } - (*p)->buf = (unsigned char *)odr_malloc(o, res); + (*p)->buf = (char *)odr_malloc(o, res); memcpy((*p)->buf, o->bp, res); (*p)->len = res; #if OCT_SIZE @@ -39,7 +39,7 @@ int ber_any(ODR o, Odr_any **p) o->bp += res; return 1; case ODR_ENCODE: - if (odr_write(o, (*p)->buf, (*p)->len) < 0) + if (odr_write2(o, (*p)->buf, (*p)->len) < 0) return 0; return 1; default: odr_seterror(o, OOTHER, 3); return 0; @@ -48,10 +48,10 @@ int ber_any(ODR o, Odr_any **p) #define BER_ANY_DEBUG 0 -int completeBER_n(const unsigned char *buf, int len, int level) +int completeBER_n(const char *buf, int len, int level) { int res, ll, zclass, tag, cons; - const unsigned char *b = buf; + const char *b = buf; if (level > 1000) { @@ -123,7 +123,7 @@ int completeBER_n(const unsigned char *buf, int len, int level) return (b - buf) + 2; } -int completeBER(const unsigned char *buf, int len) +int completeBER(const char *buf, int len) { int res = completeBER_n(buf, len, 0); #if BER_ANY_DEBUG diff --git a/src/ber_bit.c b/src/ber_bit.c index 00ea535..b2242c4 100644 --- a/src/ber_bit.c +++ b/src/ber_bit.c @@ -20,7 +20,7 @@ int ber_bitstring(ODR o, Odr_bitmask *p, int cons) { int res, len; - const unsigned char *base; + const char *base; switch (o->direction) { @@ -70,7 +70,7 @@ int ber_bitstring(ODR o, Odr_bitmask *p, int cons) return 0; if (p->top < 0) return 1; - if (odr_write(o, p->bits, p->top + 1) < 0) + if (odr_write2(o, p->bits, p->top + 1) < 0) return 0; return 1; case ODR_PRINT: diff --git a/src/ber_int.c b/src/ber_int.c index e9b23a2..7717c07 100644 --- a/src/ber_int.c +++ b/src/ber_int.c @@ -28,7 +28,7 @@ #include "odr-priv.h" static int ber_encinteger(ODR o, Odr_int val); -static int ber_decinteger(const unsigned char *buf, Odr_int *val, int max); +static int ber_decinteger(const char *buf, Odr_int *val, int max); int ber_integer(ODR o, Odr_int *val) { @@ -77,7 +77,7 @@ int ber_encinteger(ODR o, Odr_int val) len = sizeof(uval) - i; if (ber_enclen(o, len, 1, 1) != 1) return -1; - if (odr_write(o, (unsigned char*) tmp + i, len) < 0) + if (odr_write2(o, (const char *) tmp + i, len) < 0) return -1; return 0; } @@ -85,14 +85,14 @@ int ber_encinteger(ODR o, Odr_int val) /* * Returns: Number of bytes read or 0 if no match, -1 if error. */ -int ber_decinteger(const unsigned char *buf, Odr_int *val, int max) +int ber_decinteger(const char *buf, Odr_int *val, int max) { unsigned long long uval = 0; int i, len; int res; - const unsigned char *b = buf; + const unsigned char *b = (const unsigned char *) buf; - if ((res = ber_declen(b, &len, max)) < 0) + if ((res = ber_declen((const char *) b, &len, max)) < 0) return -1; if (len+res > max || len < 0) /* out of bounds or indefinite encoding */ return -1; @@ -107,7 +107,7 @@ int ber_decinteger(const unsigned char *buf, Odr_int *val, int max) uval = (uval << 8) + b[i]; *val = uval; b += len; - return b - buf; + return (const char *) b - buf; } /* * Local variables: diff --git a/src/ber_len.c b/src/ber_len.c index 56674c6..01af404 100644 --- a/src/ber_len.c +++ b/src/ber_len.c @@ -90,9 +90,9 @@ int ber_enclen(ODR o, int len, int lenlen, int exact) * len = -1 indefinite length. * len >= 0 definite length */ -int ber_declen(const unsigned char *buf, int *len, int max) +int ber_declen(const char *buf, int *len, int max) { - const unsigned char *b = buf; + const unsigned char *b = (const unsigned char *) buf; int n; if (max < 1) @@ -122,7 +122,7 @@ int ber_declen(const unsigned char *buf, int *len, int max) } if (*len < 0) return -2; - return (b - buf); + return ((const char *) b - buf); } /* * Local variables: diff --git a/src/ber_oct.c b/src/ber_oct.c index 2928e43..1f547bf 100644 --- a/src/ber_oct.c +++ b/src/ber_oct.c @@ -22,7 +22,7 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons) { int res, len; - const unsigned char *base; + const char *base; #if OCT_SIZE unsigned char *c; #endif @@ -89,7 +89,7 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons) return 0; if (p->len == 0) return 1; - if (odr_write(o, p->buf, p->len) < 0) + if (odr_write2(o, p->buf, p->len) < 0) return 0; return 1; case ODR_PRINT: diff --git a/src/ber_tag.c b/src/ber_tag.c index 422c74d..f005078 100644 --- a/src/ber_tag.c +++ b/src/ber_tag.c @@ -162,9 +162,10 @@ int ber_enctag(ODR o, int zclass, int tag, int constructed) * * Returns number of bytes read or -1 for error. */ -int ber_dectag(const unsigned char *b, int *zclass, int *tag, +int ber_dectag(const char *cp, int *zclass, int *tag, int *constructed, int max) { + const unsigned char *b = (const unsigned char *) cp; int l = 1; if (l > max) diff --git a/src/charneg.c b/src/charneg.c index 4125d26..4794d7c 100644 --- a/src/charneg.c +++ b/src/charneg.c @@ -34,7 +34,7 @@ static Z_External* z_ext_record2(ODR o, const char *buf) p->which = Z_External_octet; if (!(p->u.octet_aligned = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct)))) return 0; - if (!(p->u.octet_aligned->buf = (unsigned char *)odr_malloc(o, len))) + if (!(p->u.octet_aligned->buf = (char *)odr_malloc(o, len))) return 0; p->u.octet_aligned->len = len; #if OCT_SIZE diff --git a/src/comstack.c b/src/comstack.c index 1755fc7..0c502f8 100644 --- a/src/comstack.c +++ b/src/comstack.c @@ -427,7 +427,7 @@ static int cs_complete_auto_x(const char *buf, int len, int head_only) int r = cs_complete_http(buf, len, head_only); return r; } - return completeBER((const unsigned char *) buf, len); + return completeBER(buf, len); } diff --git a/src/dumpber.c b/src/dumpber.c index 5d49e7f..4a7215f 100644 --- a/src/dumpber.c +++ b/src/dumpber.c @@ -30,7 +30,7 @@ static int do_dumpBER(FILE *f, const char *buf, int len, int level, int offset) return 0; if (!buf[0] && !buf[1]) return 0; - if ((res = ber_dectag((unsigned char*)b, &zclass, &tag, &cons, len)) <= 0) + if ((res = ber_dectag(b, &zclass, &tag, &cons, len)) <= 0) return 0; if (res > len) { @@ -62,7 +62,7 @@ static int do_dumpBER(FILE *f, const char *buf, int len, int level, int offset) b += res; taglen = res; len -= res; - if ((res = ber_declen((unsigned char*)b, &ll, len)) <= 0) + if ((res = ber_declen(b, &ll, len)) <= 0) { fprintf(f, "\n%sBad length\n", level_str); return 0; diff --git a/src/http.c b/src/http.c index 746f3e1..e4c3001 100644 --- a/src/http.c +++ b/src/http.c @@ -610,7 +610,7 @@ int yaz_encode_http_response(ODR o, Z_HTTP_Response *hr) odr_write2(o, "\r\n", 2); } } - odr_write(o, (unsigned char *) "\r\n", 2); + odr_write2(o, "\r\n", 2); if (hr->content_buf) odr_write2(o, hr->content_buf, hr->content_len); if (o->direction == ODR_PRINT) diff --git a/src/odr-priv.h b/src/odr-priv.h index b452d10..f968edd 100644 --- a/src/odr-priv.h +++ b/src/odr-priv.h @@ -63,11 +63,11 @@ struct Odr_ber_tag { */ struct odr_constack { - const unsigned char *base; /** starting point of data */ + const char *base; /** starting point of data */ int base_offset; int len; /** length of data, if known, else -1 (decoding only) */ - const unsigned char *lenb; /** where to encode length */ + const char *lenb; /** where to encode length */ int len_offset; int lenlen; /** length of length-field */ const char *name; /** name of stack entry */ diff --git a/src/odr.c b/src/odr.c index 142249f..e424b20 100644 --- a/src/odr.c +++ b/src/odr.c @@ -272,8 +272,8 @@ void odr_destroy(ODR o) void odr_setbuf(ODR o, char *buf, int len, int can_grow) { odr_seterror(o, ONONE, 0); - o->bp = (unsigned char *) buf; - o->buf = (unsigned char *) buf; + o->bp = buf; + o->buf = buf; o->op->can_grow = can_grow; o->top = o->pos = 0; o->size = len; diff --git a/src/odr_cons.c b/src/odr_cons.c index fa203d8..76de621 100644 --- a/src/odr_cons.c +++ b/src/odr_cons.c @@ -88,11 +88,11 @@ int odr_constructed_begin(ODR o, void *xxp, int zclass, int tag, o->op->stack_top->name = name ? name : "?"; if (o->direction == ODR_ENCODE) { - static unsigned char dummy[sizeof(int)+1]; + static char dummy[sizeof(int)+1]; o->op->stack_top->lenlen = lenlen; - if (odr_write(o, dummy, lenlen) < 0) /* dummy */ + if (odr_write2(o, dummy, lenlen) < 0) /* dummy */ { ODR_STACK_POP(o); return 0; diff --git a/src/odr_mem.c b/src/odr_mem.c index 52d850b..2cc6b4a 100644 --- a/src/odr_mem.c +++ b/src/odr_mem.c @@ -62,10 +62,10 @@ size_t odr_total(ODR o) return nmem_total(o->mem); } -Odr_oct *odr_create_Odr_oct(ODR o, const unsigned char *buf, int sz) +Odr_oct *odr_create_Odr_oct(ODR o, const char *buf, int sz) { Odr_oct *p = (Odr_oct *) odr_malloc(o, sizeof(Odr_oct)); - p->buf = (unsigned char *) odr_malloc(o, sz); + p->buf = (char *) odr_malloc(o, sz); memcpy(p->buf, buf, sz); #if OCT_SIZE p->size = sz; @@ -90,10 +90,9 @@ int odr_grow_block(ODR b, int min_bytes) if (togrow < min_bytes) togrow = min_bytes; if (b->size && !(b->buf = - (unsigned char *) xrealloc(b->buf, b->size += togrow))) + (char *) xrealloc(b->buf, b->size += togrow))) abort(); - else if (!b->size && !(b->buf = (unsigned char *) - xmalloc(b->size = togrow))) + else if (!b->size && !(b->buf = (char *) xmalloc(b->size = togrow))) abort(); return 0; } @@ -112,11 +111,6 @@ int odr_write2(ODR o, const char *buf, int bytes) return 0; } -int odr_write(ODR o, unsigned char *buf, int bytes) -{ - return odr_write2(o, (char *) buf, bytes); -} - int odr_seek(ODR o, int whence, int offset) { if (whence == ODR_S_CUR) diff --git a/src/odr_oct.c b/src/odr_oct.c index fc06519..a64648a 100644 --- a/src/odr_oct.c +++ b/src/odr_oct.c @@ -86,7 +86,7 @@ int odr_cstring(ODR o, char **p, int opt, const char *name) t = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct)); /* wrapper for octstring */ if (o->direction == ODR_ENCODE) { - t->buf = (unsigned char *) *p; + t->buf = *p; t->len = strlen(*p); #if OCT_SIZE t->size = t->len; @@ -149,7 +149,7 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name) char *outbuf = (char *) odr_malloc (o, outleft); size_t ret; - t->buf = (unsigned char *) outbuf; + t->buf = outbuf; ret = yaz_iconv(o->op->iconv_handle, &inbuf, &inleft, &outbuf, &outleft); @@ -173,7 +173,7 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name) } if (!t->buf) { - t->buf = (unsigned char *) *p; + t->buf = *p; t->len = strlen(*p); #if OCT_SIZE t->size = t->len; diff --git a/src/odr_util.c b/src/odr_util.c index 6efa6c0..a5c64d6 100644 --- a/src/odr_util.c +++ b/src/odr_util.c @@ -26,7 +26,7 @@ void odr_prname(ODR o, const char *name) odr_printf(o, "%s ", name); } -int odp_more_chunks(ODR o, const unsigned char *base, int len) +int odp_more_chunks(ODR o, const char *base, int len) { if (!len) return 0; diff --git a/src/pquery.c b/src/pquery.c index c787b58..f2c39e8 100644 --- a/src/pquery.c +++ b/src/pquery.c @@ -311,7 +311,7 @@ Z_Term *z_Term_create(ODR o, int term_type, const char *buf, size_t len) { Z_Term *term = (Z_Term *)odr_malloc(o, sizeof(*term)); Odr_oct *term_octet = (Odr_oct *)odr_malloc(o, sizeof(*term_octet)); - term_octet->buf = (unsigned char *)odr_malloc(o, 1 + len); + term_octet->buf = (char *)odr_malloc(o, 1 + len); memcpy(term_octet->buf, buf, len); term_octet->len = len; #if OCT_SIZE diff --git a/src/prt-ext.c b/src/prt-ext.c index e489fb7..b41b6a9 100644 --- a/src/prt-ext.c +++ b/src/prt-ext.c @@ -216,8 +216,8 @@ int z_External(ODR o, Z_External **p, int opt, const char *name) if (zclass == ODR_CONTEXT && tag == 1 && cons == 0) { /* we have an OCTET STRING. decode BER contents from it */ - const unsigned char *o_bp; - unsigned char *o_buf; + const char *o_bp; + char *o_buf; int o_size; char *voidp = 0; Odr_oct *oct; @@ -315,7 +315,7 @@ Z_External *z_ext_record_oid_nmem(NMEM nmem, const Odr_oid *oid, thisext->which = Z_External_sutrs; thisext->u.sutrs = sutrs; - sutrs->buf = (unsigned char *)nmem_malloc(nmem, len); + sutrs->buf = (char *)nmem_malloc(nmem, len); sutrs->len = len; #if OCT_SIZE sutrs->size = len; @@ -328,7 +328,7 @@ Z_External *z_ext_record_oid_nmem(NMEM nmem, const Odr_oid *oid, if (!(thisext->u.octet_aligned = (Odr_oct *) nmem_malloc(nmem, sizeof(Odr_oct)))) return 0; - if (!(thisext->u.octet_aligned->buf = (unsigned char *) + if (!(thisext->u.octet_aligned->buf = (char *) nmem_malloc(nmem, len))) return 0; memcpy(thisext->u.octet_aligned->buf, buf, len); @@ -362,7 +362,7 @@ Z_External *z_ext_record_oid_any(ODR o, const Odr_oid *oid, thisext->u.single_ASN1_type = (Odr_any *) odr_malloc(o, sizeof(Odr_any)); if (!thisext->u.single_ASN1_type) return 0; - thisext->u.single_ASN1_type->buf = (unsigned char *) odr_malloc(o, len); + thisext->u.single_ASN1_type->buf = (char *) odr_malloc(o, len); if (!thisext->u.single_ASN1_type->buf) return 0; memcpy(thisext->u.single_ASN1_type->buf, buf, len); diff --git a/src/seshigh.c b/src/seshigh.c index fccb4e3..898af56 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -3127,7 +3127,7 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb) t->term->which = Z_Term_general; t->term->u.general = o = (Odr_oct *)odr_malloc(assoc->encode, sizeof(Odr_oct)); - o->buf = (unsigned char *) + o->buf = (char *) odr_malloc(assoc->encode, o->len = strlen(bsrr->entries[i].term)); #if OCT_SIZE diff --git a/src/sortspec.c b/src/sortspec.c index 0cdef33..1a24be7 100644 --- a/src/sortspec.c +++ b/src/sortspec.c @@ -124,8 +124,7 @@ Z_SortKeySpecList *yaz_sort_spec(ODR out, const char *arg) #if OCT_SIZE sks->u.missingValueData->size = sks->u.missingValueData->len; #endif - sks->u.missingValueData->buf = (unsigned char*) - odr_strdup(out, sort_flags+i); + sks->u.missingValueData->buf = odr_strdup(out, sort_flags+i); i += strlen(sort_flags+i) - 1; break; } diff --git a/src/xmlquery.c b/src/xmlquery.c index e0db8d3..5aff1ae 100644 --- a/src/xmlquery.c +++ b/src/xmlquery.c @@ -565,7 +565,7 @@ static void yaz_xml2query_term(const xmlNode *ptr, Z_Term **term, ODR odr, { (*term)->which = Z_Term_general; (*term)->u.general = - odr_create_Odr_oct(odr, (unsigned char *)cdata, strlen(cdata)); + odr_create_Odr_oct(odr, cdata, strlen(cdata)); } else if (!xmlStrcmp(type, BAD_CAST "numeric")) { diff --git a/src/zget.c b/src/zget.c index b44279f..5fb5283 100644 --- a/src/zget.c +++ b/src/zget.c @@ -637,7 +637,7 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error, x->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_userinfo_1); x->which = Z_External_octet; x->u.octet_aligned = (Odr_oct *) odr_malloc(odr, sizeof(Odr_oct)); - x->u.octet_aligned->buf = (unsigned char *) odr_malloc(odr, octet_len); + x->u.octet_aligned->buf = (char *) odr_malloc(odr, octet_len); memcpy(x->u.octet_aligned->buf, octet_buf, octet_len); x->u.octet_aligned->len = octet_len; diff --git a/src/zoom-sru.c b/src/zoom-sru.c index 85f597b..bdfe175 100644 --- a/src/zoom-sru.c +++ b/src/zoom-sru.c @@ -331,7 +331,7 @@ static zoom_ret handle_srw_response(ZOOM_connection c, npr->u.databaseRecord->u.octet_aligned = (Odr_oct *) odr_malloc(c->odr_in, sizeof(Odr_oct)); - npr->u.databaseRecord->u.octet_aligned->buf = (unsigned char*) + npr->u.databaseRecord->u.octet_aligned->buf = sru_rec->recordData_buf; npr->u.databaseRecord->u.octet_aligned->len = sru_rec->recordData_len; diff --git a/src/zoom-z3950.c b/src/zoom-z3950.c index 797ffb3..fe86050 100644 --- a/src/zoom-z3950.c +++ b/src/zoom-z3950.c @@ -126,9 +126,7 @@ static Z_External *encode_ill_request(ZOOM_package p) r->which = Z_External_single; r->u.single_ASN1_type = - odr_create_Odr_oct(out, - (unsigned char *)illRequest_buf, - illRequest_size); + odr_create_Odr_oct(out, illRequest_buf, illRequest_size); } return r; } @@ -272,8 +270,7 @@ static Z_APDU *create_xmlupdate_package(ZOOM_package p) ext->indirect_reference = 0; ext->which = Z_External_octet; - ext->u.single_ASN1_type = - odr_create_Odr_oct(p->odr_out, (const unsigned char *) doc, len); + ext->u.single_ASN1_type = odr_create_Odr_oct(p->odr_out, doc, len); return apdu; } @@ -417,8 +414,7 @@ static Z_APDU *create_update_package(ZOOM_package p) if (recordIdOpaque) { notToKeep->elements[0]->u.opaque = - odr_create_Odr_oct(p->odr_out, - (const unsigned char *) recordIdOpaque, + odr_create_Odr_oct(p->odr_out, recordIdOpaque, recordIdOpaque_len); } else if (recordIdNumber) diff --git a/test/test_odr.c b/test/test_odr.c index 6ebd750..65e2ed1 100644 --- a/test/test_odr.c +++ b/test/test_odr.c @@ -25,7 +25,7 @@ void tst_MySequence1(ODR encode, ODR decode) YAZ_CHECK(s); s->first = odr_intdup(encode, 12345); s->second = (Odr_oct *) odr_malloc(encode, sizeof(*s->second)); - s->second->buf = (unsigned char *) "hello"; + s->second->buf = (char *) "hello"; s->second->len = 5; #if OCT_SIZE s->second->size = 0; @@ -82,7 +82,7 @@ void tst_MySequence2(ODR encode, ODR decode) YAZ_CHECK(s); s->first = 0; /* deliberately miss this .. */ s->second = (Odr_oct *) odr_malloc(encode, sizeof(*s->second)); - s->second->buf = (unsigned char *) "hello"; + s->second->buf = (char *) "hello"; s->second->len = 5; #if OCT_SIZE s->second->size = 0; diff --git a/test/test_wrbuf.c b/test/test_wrbuf.c index defdc34..7c27fe5 100644 --- a/test/test_wrbuf.c +++ b/test/test_wrbuf.c @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/util/yaz-illclient.c b/util/yaz-illclient.c index 5cc39a8..b6dd6be 100644 --- a/util/yaz-illclient.c +++ b/util/yaz-illclient.c @@ -364,7 +364,7 @@ ILL_Extension *makepromptextension(struct prog_args *args, ODR odr) { buf= odr_getbuf(odr_ext,&siz,0); ext->u.single_ASN1_type=(Odr_any *) odr_malloc(odr,sizeof(*ext->u.single_ASN1_type)); - ext->u.single_ASN1_type->buf= (unsigned char *) odr_malloc(odr, siz); + ext->u.single_ASN1_type->buf= (char *) odr_malloc(odr, siz); memcpy(ext->u.single_ASN1_type->buf,buf, siz ); ext->u.single_ASN1_type->len = siz; #if OCT_SIZE @@ -383,7 +383,7 @@ ILL_Extension *makepromptextension(struct prog_args *args, ODR odr) { printf("External: \n"); z_External(odr_prt, &ext,0,0); /*!*/ buf= odr_getbuf(odr_ext,&siz,0); - e->item->buf= (unsigned char *) odr_malloc(odr, siz); + e->item->buf= (char *) odr_malloc(odr, siz); memcpy(e->item->buf,buf, siz ); e->item->len = siz; #if OCT_SIZE @@ -429,7 +429,7 @@ ILL_Extension *makeoclcextension(struct prog_args *args, ODR odr) { buf= odr_getbuf(odr_ext,&siz,0); ext->u.single_ASN1_type = (Odr_any*) odr_malloc(odr,sizeof(*ext->u.single_ASN1_type)); - ext->u.single_ASN1_type->buf = (unsigned char *) odr_malloc(odr, siz); + ext->u.single_ASN1_type->buf = (char *) odr_malloc(odr, siz); memcpy(ext->u.single_ASN1_type->buf,buf, siz ); ext->u.single_ASN1_type->len = siz; #if OCT_SIZE @@ -448,7 +448,7 @@ ILL_Extension *makeoclcextension(struct prog_args *args, ODR odr) { printf("External: \n"); z_External(odr_prt, &ext,0,0); /*!*/ buf= odr_getbuf(odr_ext,&siz,0); - e->item->buf= (unsigned char *) odr_malloc(odr, siz); + e->item->buf= (char *) odr_malloc(odr, siz); memcpy(e->item->buf, buf, siz); e->item->len = siz; #if OCT_SIZE diff --git a/ztest/ztest.c b/ztest/ztest.c index 6707c4b..d1dbeed 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -591,7 +591,7 @@ int ztest_esrequest(void *handle, bend_esrequest_rr *rr) rr->taskPackage->targetReference = (Odr_oct *) odr_malloc(rr->stream, sizeof(Odr_oct)); rr->taskPackage->targetReference->buf = - (unsigned char *) odr_strdup(rr->stream, "911"); + odr_strdup(rr->stream, "911"); rr->taskPackage->targetReference->len = strlen((char *) (rr->taskPackage->targetReference->buf)); #if OCT_SIZE @@ -695,7 +695,7 @@ int ztest_esrequest(void *handle, bend_esrequest_rr *rr) rr->taskPackage->targetReference = (Odr_oct *) odr_malloc(rr->stream, sizeof(Odr_oct)); rr->taskPackage->targetReference->buf = - (unsigned char *) odr_strdup(rr->stream, "123"); + odr_strdup(rr->stream, "123"); rr->taskPackage->targetReference->len = strlen((char *) (rr->taskPackage->targetReference->buf)); #if OCT_SIZE