From: Adam Dickmeiss Date: Fri, 17 Oct 2008 22:19:43 +0000 (+0200) Subject: Adjustments to make YAZ compile as C++ code. X-Git-Tag: v3.0.38~24 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=bf95c509245f5cb4025ef2db348d5f7ace3b5994;p=yaz-moved-to-github.git Adjustments to make YAZ compile as C++ code. --- diff --git a/src/cqltransform.c b/src/cqltransform.c index dbdd8aa..996fd63 100644 --- a/src/cqltransform.c +++ b/src/cqltransform.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -78,7 +78,7 @@ static int cql_transform_parse_tok_line(cql_transform_t ct, const char *value_str = 0; /* attset type=value OR type=value */ - elem = nmem_malloc(ct->nmem, sizeof(*elem)); + elem = (Z_AttributeElement *) nmem_malloc(ct->nmem, sizeof(*elem)); elem->attributeSet = 0; ae[ae_num] = elem; wrbuf_puts(ct->w, yaz_tok_parse_string(tp)); @@ -143,7 +143,8 @@ static int cql_transform_parse_tok_line(cql_transform_t ct, } else { - Z_ComplexAttribute *ca = nmem_malloc(ct->nmem, sizeof(*ca)); + Z_ComplexAttribute *ca = (Z_ComplexAttribute *) + nmem_malloc(ct->nmem, sizeof(*ca)); elem->which = Z_AttributeValue_complex; elem->value.complex = ca; ca->num_list = 1; @@ -176,7 +177,7 @@ static int cql_transform_parse_tok_line(cql_transform_t ct, (*pp)->attr_list.attributes = 0; else { - (*pp)->attr_list.attributes = + (*pp)->attr_list.attributes = (Z_AttributeElement **) nmem_malloc(ct->nmem, ae_num * sizeof(Z_AttributeElement *)); memcpy((*pp)->attr_list.attributes, ae, diff --git a/src/iconv_decode_marc8.c b/src/iconv_decode_marc8.c index 7b890ad..84af5b3 100644 --- a/src/iconv_decode_marc8.c +++ b/src/iconv_decode_marc8.c @@ -56,7 +56,7 @@ static unsigned long read_marc8(yaz_iconv_t cd, yaz_iconv_decoder_t d, unsigned char *inp, size_t inbytesleft, size_t *no_read) { - struct decoder_data *data = d->data; + struct decoder_data *data = (struct decoder_data *) d->data; unsigned long x; if (data->comb_offset < data->comb_size) { @@ -110,7 +110,7 @@ static unsigned long read_marc8s(yaz_iconv_t cd, yaz_iconv_decoder_t d, unsigned char *inp, size_t inbytesleft, size_t *no_read) { - struct decoder_data *data = d->data; + struct decoder_data *data = (struct decoder_data *) d->data; unsigned long x = read_marc8(cd, d, inp, inbytesleft, no_read); if (x && data->comb_size == 1) { @@ -243,7 +243,7 @@ static size_t init_marc8(yaz_iconv_t cd, yaz_iconv_decoder_t d, unsigned char *inp, size_t inbytesleft, size_t *no_read) { - struct decoder_data *data = d->data; + struct decoder_data *data = (struct decoder_data *) d->data; data->g0_mode = 'B'; data->g1_mode = 'E'; data->comb_offset = data->comb_size = 0; @@ -252,7 +252,7 @@ static size_t init_marc8(yaz_iconv_t cd, yaz_iconv_decoder_t d, void destroy_marc8(yaz_iconv_decoder_t d) { - struct decoder_data *data = d->data; + struct decoder_data *data = (struct decoder_data *) d->data; xfree(data); } @@ -266,7 +266,8 @@ yaz_iconv_decoder_t yaz_marc8_decoder(const char *fromcode, else return 0; { - struct decoder_data *data = xmalloc(sizeof(*data)); + struct decoder_data *data = (struct decoder_data *) + xmalloc(sizeof(*data)); d->data = data; d->init_handle = init_marc8; d->destroy_handle = destroy_marc8; diff --git a/src/iconv_encode_iso_8859_1.c b/src/iconv_encode_iso_8859_1.c index f0a6a5e..afaf46d 100644 --- a/src/iconv_encode_iso_8859_1.c +++ b/src/iconv_encode_iso_8859_1.c @@ -135,7 +135,7 @@ static size_t write_iso_8859_1(yaz_iconv_t cd, yaz_iconv_encoder_t e, unsigned long x, char **outbuf, size_t *outbytesleft) { - struct encoder_data *w = e->data; + struct encoder_data *w = (struct encoder_data *) e->data; /* list of two char unicode sequence that, when combined, are equivalent to single unicode chars that can be represented in ISO-8859-1/Latin-1. @@ -193,7 +193,7 @@ static size_t write_iso_8859_1(yaz_iconv_t cd, yaz_iconv_encoder_t e, static size_t flush_iso_8859_1(yaz_iconv_t cd, yaz_iconv_encoder_t e, char **outbuf, size_t *outbytesleft) { - struct encoder_data *w = e->data; + struct encoder_data *w = (struct encoder_data *) e->data; if (w->compose_char) { unsigned char *outp = (unsigned char *) *outbuf; @@ -213,7 +213,7 @@ static size_t flush_iso_8859_1(yaz_iconv_t cd, yaz_iconv_encoder_t e, void init_iso_8859_1(yaz_iconv_encoder_t e) { - struct encoder_data *w = e->data; + struct encoder_data *w = (struct encoder_data *) e->data; w->compose_char = 0; } @@ -228,7 +228,8 @@ yaz_iconv_encoder_t yaz_iso_8859_1_encoder(const char *tocode, { if (!yaz_matchstr(tocode, "iso88591")) { - struct encoder_data *data = xmalloc(sizeof(*data)); + struct encoder_data *data = (struct encoder_data *) + xmalloc(sizeof(*data)); e->data = data; e->write_handle = write_iso_8859_1; e->flush_handle = flush_iso_8859_1; diff --git a/src/iconv_encode_marc8.c b/src/iconv_encode_marc8.c index 055aa0e..0fa3b56 100644 --- a/src/iconv_encode_marc8.c +++ b/src/iconv_encode_marc8.c @@ -50,7 +50,7 @@ struct encoder_data static void init_marc8(yaz_iconv_encoder_t w) { - struct encoder_data *data = w->data; + struct encoder_data *data = (struct encoder_data *) w->data; data->write_marc8_second_half_char = 0; data->write_marc8_last = 0; data->write_marc8_ncr = 0; @@ -334,7 +334,7 @@ static size_t yaz_write_marc8_2(yaz_iconv_t cd, struct encoder_data *w, static size_t flush_marc8(yaz_iconv_t cd, yaz_iconv_encoder_t en, char **outbuf, size_t *outbytesleft) { - struct encoder_data *w = en->data; + struct encoder_data *w = (struct encoder_data *) en->data; size_t r = flush_combos(cd, w, outbuf, outbytesleft); if (r) return r; @@ -382,21 +382,24 @@ static size_t write_marc8_normal(yaz_iconv_t cd, yaz_iconv_encoder_t e, unsigned long x, char **outbuf, size_t *outbytesleft) { - return yaz_write_marc8_generic(cd, e->data, x, outbuf, outbytesleft, 0); + return yaz_write_marc8_generic(cd, (struct encoder_data *) e->data, + x, outbuf, outbytesleft, 0); } static size_t write_marc8_lossy(yaz_iconv_t cd, yaz_iconv_encoder_t e, unsigned long x, char **outbuf, size_t *outbytesleft) { - return yaz_write_marc8_generic(cd, e->data, x, outbuf, outbytesleft, 1); + return yaz_write_marc8_generic(cd, (struct encoder_data *) e->data, + x, outbuf, outbytesleft, 1); } static size_t write_marc8_lossless(yaz_iconv_t cd, yaz_iconv_encoder_t e, unsigned long x, char **outbuf, size_t *outbytesleft) { - return yaz_write_marc8_generic(cd, e->data, x, outbuf, outbytesleft, 2); + return yaz_write_marc8_generic(cd, (struct encoder_data *) e->data, + x, outbuf, outbytesleft, 2); } static void destroy_marc8(yaz_iconv_encoder_t e) @@ -420,7 +423,8 @@ yaz_iconv_encoder_t yaz_marc8_encoder(const char *tocode, return 0; { - struct encoder_data *data = xmalloc(sizeof(*data)); + struct encoder_data *data = (struct encoder_data *) + xmalloc(sizeof(*data)); e->data = data; e->destroy_handle = destroy_marc8; e->flush_handle = flush_marc8; diff --git a/src/sc.c b/src/sc.c index 9336e60..797f9a2 100644 --- a/src/sc.c +++ b/src/sc.c @@ -41,7 +41,7 @@ struct sc_s { yaz_sc_t yaz_sc_create(const char *service_name, const char *display_name) { - yaz_sc_t s = xmalloc(sizeof(*s)); + yaz_sc_t s = (yaz_sc_t) xmalloc(sizeof(*s)); s->service_name = service_name ? xstrdup(service_name) : 0; s->display_name = display_name ? xstrdup(display_name) : 0; diff --git a/src/srwutil.c b/src/srwutil.c index 58d0d3b..44b1d97 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -606,7 +606,7 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, Z_SRW_extra_arg **l = &extra_args; while (*l) l = &(*l)->next; - *l = odr_malloc(decode, sizeof(**l)); + *l = (Z_SRW_extra_arg *) odr_malloc(decode, sizeof(**l)); (*l)->name = odr_strdup(decode, n); (*l)->value = odr_strdup(decode, v); (*l)->next = 0; @@ -1454,7 +1454,7 @@ void yaz_encode_sru_extra(Z_SRW_PDU *sr, ODR odr, const char *extra_args) while (*name) { - *ea = odr_malloc(odr, sizeof(**ea)); + *ea = (Z_SRW_extra_arg *) odr_malloc(odr, sizeof(**ea)); (*ea)->name = *name; (*ea)->value = *val; ea = &(*ea)->next; diff --git a/src/tcpip.c b/src/tcpip.c index 10d08d1..fcdcce1 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -260,7 +260,7 @@ COMSTACK yaz_tcpip_create(int s, int flags, int protocol, static void tcpip_create_cred(COMSTACK cs) { tcpip_state *sp = (tcpip_state *) cs->cprivate; - sp->cred_ptr = xmalloc(sizeof(*sp->cred_ptr)); + sp->cred_ptr = (struct tcpip_cred_ptr *) xmalloc(sizeof(*sp->cred_ptr)); sp->cred_ptr->ref = 1; gnutls_certificate_allocate_credentials(&sp->cred_ptr->xcred); } diff --git a/test/tstnmem.c b/test/tstnmem.c index aeda13a..f473929 100644 --- a/test/tstnmem.c +++ b/test/tstnmem.c @@ -26,7 +26,7 @@ void tst(void) for (j = 1; j<500; j++) { - cp = nmem_malloc(n, j); + cp = (char *) nmem_malloc(n, j); YAZ_CHECK(cp); if (sizeof(long) >= j) *(long*) cp = 123L; @@ -40,7 +40,7 @@ void tst(void) for (j = 2000; j<20000; j+= 2000) { - cp = nmem_malloc(n, j); + cp = (char *) nmem_malloc(n, j); YAZ_CHECK(cp); } nmem_destroy(n); diff --git a/test/tstodr.c b/test/tstodr.c index 99cef61..4becfe0 100644 --- a/test/tstodr.c +++ b/test/tstodr.c @@ -16,12 +16,12 @@ void tst_MySequence1(ODR encode, ODR decode) int ret; char *ber_buf; int ber_len; - Yc_MySequence *s = odr_malloc(encode, sizeof(*s)); + Yc_MySequence *s = (Yc_MySequence *) odr_malloc(encode, sizeof(*s)); Yc_MySequence *t; YAZ_CHECK(s); s->first = odr_intdup(encode, 12345); - s->second = odr_malloc(encode, sizeof(*s->second)); + s->second = (Odr_oct *) odr_malloc(encode, sizeof(*s->second)); s->second->buf = (unsigned char *) "hello"; s->second->len = 5; s->second->size = 0; @@ -72,11 +72,11 @@ void tst_MySequence1(ODR encode, ODR decode) void tst_MySequence2(ODR encode, ODR decode) { int ret; - Yc_MySequence *s = odr_malloc(encode, sizeof(*s)); + Yc_MySequence *s = (Yc_MySequence *) odr_malloc(encode, sizeof(*s)); YAZ_CHECK(s); s->first = 0; /* deliberately miss this .. */ - s->second = odr_malloc(encode, sizeof(*s->second)); + s->second = (Odr_oct *) odr_malloc(encode, sizeof(*s->second)); s->second->buf = (unsigned char *) "hello"; s->second->len = 5; s->second->size = 0; diff --git a/test/tstsoap2.c b/test/tstsoap2.c index b0d2455..342c86d 100644 --- a/test/tstsoap2.c +++ b/test/tstsoap2.c @@ -23,7 +23,7 @@ static void tst_srw(void) {0, 0, 0} }; Z_SRW_PDU *sr = yaz_srw_get(o, Z_SRW_searchRetrieve_request); - Z_SOAP *p = odr_malloc(o, sizeof(*p)); + Z_SOAP *p = (Z_SOAP *) odr_malloc(o, sizeof(*p)); YAZ_CHECK(o); YAZ_CHECK(sr); @@ -35,7 +35,7 @@ static void tst_srw(void) #endif p->which = Z_SOAP_generic; - p->u.generic = odr_malloc(o, sizeof(*p->u.generic)); + p->u.generic = (Z_SOAP_Generic *) odr_malloc(o, sizeof(*p->u.generic)); p->u.generic->no = 0; p->u.generic->ns = 0; p->u.generic->p = sr; diff --git a/ztest/dummy-opac.c b/ztest/dummy-opac.c index e0ef278..e7b2279 100644 --- a/ztest/dummy-opac.c +++ b/ztest/dummy-opac.c @@ -18,15 +18,18 @@ Z_OPACRecord *dummy_opac(int num, ODR odr, const char *marc_input) { Z_OPACRecord *rec; int i; - rec = odr_malloc(odr, sizeof(*rec)); + rec = (Z_OPACRecord *) odr_malloc(odr, sizeof(*rec)); rec->bibliographicRecord = z_ext_record_usmarc(odr, marc_input, strlen(marc_input)); rec->num_holdingsData = 1; - rec->holdingsData = odr_malloc(odr, sizeof(*rec->holdingsData)); + rec->holdingsData = (Z_HoldingsRecord **) + odr_malloc(odr, sizeof(*rec->holdingsData)); for (i = 0; i < rec->num_holdingsData; i++) { - Z_HoldingsRecord *hr = odr_malloc(odr, sizeof(*hr)); - Z_HoldingsAndCircData *hc = odr_malloc(odr, sizeof(*hc)); + Z_HoldingsRecord *hr = (Z_HoldingsRecord *) + odr_malloc(odr, sizeof(*hr)); + Z_HoldingsAndCircData *hc = (Z_HoldingsAndCircData *) + odr_malloc(odr, sizeof(*hc)); rec->holdingsData[i] = hr; hr->which = Z_HoldingsRecord_holdingsAndCirc; @@ -57,10 +60,10 @@ Z_OPACRecord *dummy_opac(int num, ODR odr, const char *marc_input) hc->volumes = 0; hc->num_circulationData = 1; - hc->circulationData = odr_malloc(odr, - sizeof(*hc->circulationData)); - hc->circulationData[0] = odr_malloc(odr, - sizeof(**hc->circulationData)); + hc->circulationData = (Z_CircRecord **) + odr_malloc(odr, sizeof(*hc->circulationData)); + hc->circulationData[0] = (Z_CircRecord *) + odr_malloc(odr, sizeof(**hc->circulationData)); hc->circulationData[0]->availableNow = odr_intdup(odr, 1); hc->circulationData[0]->availablityDate = 0;