X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fsrwutil.c;h=45b578598598c1aebc9074030438142a99d7ff73;hb=84c9ccff7f7deb03ea8d8318c1bcad2d7fd66c3e;hp=1f39728558f1c6bba0e41e87650477605d5a8905;hpb=9a931f88892b2d8be796bfafa07e430307b7c5f6;p=yaz-moved-to-github.git diff --git a/src/srwutil.c b/src/srwutil.c index 1f39728..45b5785 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: srwutil.c,v 1.39 2006-05-05 20:02:22 quinn Exp $ + * $Id: srwutil.c,v 1.41 2006-06-02 13:08:27 adam Exp $ */ /** * \file srwutil.c @@ -188,11 +188,11 @@ static int yaz_base64decode(const char *in, char *out) char i0, i1, i2, i3; char *p; - if (!(p = index(map, in[0]))) + if (!(p = strchr(map, in[0]))) return 0; i0 = p - map; len--; - if (!(p = index(map, in[1]))) + if (!(p = strchr(map, in[1]))) return 0; i1 = p - map; len--; @@ -200,7 +200,7 @@ static int yaz_base64decode(const char *in, char *out) olen++; if (in[2] == '=') break; - if (!(p = index(map, in[2]))) + if (!(p = strchr(map, in[2]))) return 0; i2 = p - map; len--; @@ -208,7 +208,7 @@ static int yaz_base64decode(const char *in, char *out) olen++; if (in[3] == '=') break; - if (!(p = index(map, in[3]))) + if (!(p = strchr(map, in[3]))) return 0; i3 = p - map; len--; @@ -249,7 +249,7 @@ static void yaz_srw_decodeauth(Z_SRW_PDU *sr, Z_HTTP_Request *hreq, char *userna olen = yaz_base64decode(basic, out); /* Format of out should be username:password at this point */ strcpy(ubuf, out); - if ((p = index(ubuf, ':'))) { + if ((p = strchr(ubuf, ':'))) { *(p++) = '\0'; if (*p) strcpy(pbuf, p); @@ -1129,7 +1129,7 @@ static int yaz_get_sru_parms(const Z_SRW_PDU *srw_pdu, ODR encode, } int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, - ODR encode, char *charset) + ODR encode, const char *charset) { char *name[30], *value[30]; /* definite upper limit for SRU params */ char *uri_args; @@ -1151,7 +1151,7 @@ int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, } int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, - ODR encode, char *charset) + ODR encode, const char *charset) { char *name[30], *value[30]; /* definite upper limit for SRU params */ char *uri_args; @@ -1172,6 +1172,33 @@ int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, return 0; } +int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, + ODR odr, const char *charset) +{ + Z_SOAP_Handler handlers[2] = { + {"http://www.loc.gov/zing/srw/", 0, (Z_SOAP_fun) yaz_srw_codec}, + {0, 0, 0} + }; + Z_SOAP *p = (Z_SOAP*) odr_malloc(odr, sizeof(*p)); + z_HTTP_header_add_content_type(odr, + &hreq->headers, + "text/xml", charset); + + z_HTTP_header_add(odr, &hreq->headers, + "SOAPAction", "\"\""); + p->which = Z_SOAP_generic; + p->u.generic = (Z_SOAP_Generic *) odr_malloc(odr, sizeof(*p->u.generic)); + p->u.generic->no = 0; + p->u.generic->ns = 0; + p->u.generic->p = srw_pdu; + p->ns = "http://schemas.xmlsoap.org/soap/envelope/"; + + return z_soap_codec_enc(odr, &p, + &hreq->content_buf, + &hreq->content_len, handlers, + charset); +} + /* * Local variables: * c-basic-offset: 4