X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fsrwutil.c;h=3a35a9555dd06bdc88da2e7c73dd81dc0410f77f;hb=3c287bc1d48ee6a1f300054c2cebd0ba312bd5b9;hp=9eff9aaebe82ba0d1b5392eea092a0ffaf318c0f;hpb=38d3fafb8baf5f2d0a3acfcb5a72f5994e75d4a4;p=yaz-moved-to-github.git diff --git a/src/srwutil.c b/src/srwutil.c index 9eff9aa..3a35a95 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "sru-p.h" @@ -45,7 +46,7 @@ Z_AttributeList *yaz_use_attribute_create(ODR o, const char *name) Z_AttributeElement ** elements; attributes->num_attributes = 1; elements = (Z_AttributeElement**) - odr_malloc (o, attributes->num_attributes * sizeof(*elements)); + odr_malloc(o, attributes->num_attributes * sizeof(*elements)); elements[0] = (Z_AttributeElement*) odr_malloc(o,sizeof(**elements)); elements[0]->attributeType = odr_intdup(o, 1); elements[0]->attributeSet = odr_nullval(); @@ -85,52 +86,6 @@ const char *yaz_element_attribute_value_get(xmlNodePtr ptr, } #endif -static int yaz_base64decode(const char *in, char *out) -{ - const char *map = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz0123456789+/"; - int olen = 0; - int len = strlen(in); - - while (len >= 4) - { - char i0, i1, i2, i3; - char *p; - - if (!(p = strchr(map, in[0]))) - return 0; - i0 = p - map; - len--; - if (!(p = strchr(map, in[1]))) - return 0; - i1 = p - map; - len--; - *(out++) = i0 << 2 | i1 >> 4; - olen++; - if (in[2] == '=') - break; - if (!(p = strchr(map, in[2]))) - return 0; - i2 = p - map; - len--; - *(out++) = i1 << 4 | i2 >> 2; - olen++; - if (in[3] == '=') - break; - if (!(p = strchr(map, in[3]))) - return 0; - i3 = p - map; - len--; - *(out++) = i2 << 6 | i3; - olen++; - - in += 4; - } - - *out = '\0'; - return olen; -} - int yaz_srw_check_content_type(Z_HTTP_Response *hres) { const char *content_type = z_HTTP_header_lookup(hres->headers, @@ -161,7 +116,7 @@ static void yaz_srw_decodeauth(Z_SRW_PDU *sr, Z_HTTP_Request *hreq, if (basic) { - int len, olen; + int len; char out[256]; char ubuf[256] = "", pbuf[256] = "", *p; if (strncmp(basic, "Basic ", 6)) @@ -170,7 +125,7 @@ static void yaz_srw_decodeauth(Z_SRW_PDU *sr, Z_HTTP_Request *hreq, len = strlen(basic); if (!len || len > 256) return; - olen = yaz_base64decode(basic, out); + yaz_base64decode(basic, out); /* Format of out should be username:password at this point */ strcpy(ubuf, out); if ((p = strchr(ubuf, ':'))) @@ -222,9 +177,9 @@ void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d, const char *message, const char *details) { Z_SRW_diagnostic *d_new; - d_new = (Z_SRW_diagnostic *) odr_malloc (o, (*num + 1)* sizeof(**d)); + d_new = (Z_SRW_diagnostic *) odr_malloc(o, (*num + 1)* sizeof(**d)); if (*num) - memcpy (d_new, *d, *num *sizeof(**d)); + memcpy(d_new, *d, *num *sizeof(**d)); *d = d_new; yaz_mk_srw_diagnostic(o, *d + *num, uri, message, details); @@ -437,7 +392,6 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, char *startRecord = 0; char *maximumTerms = 0; char *responsePosition = 0; - char *extraRequestData = 0; Z_SRW_extra_arg *extra_args = 0; #endif char **uri_name; @@ -500,7 +454,7 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, else if (!strcmp(n, "responsePosition")) responsePosition = v; else if (!strcmp(n, "extraRequestData")) - extraRequestData = v; + ; /* ignoring extraRequestData */ else if (n[0] == 'x' && n[1] == '-') { Z_SRW_extra_arg **l = &extra_args; @@ -813,6 +767,7 @@ Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version) sr->u.response->nextRecordPosition = 0; sr->u.response->extra_records = 0; sr->u.response->facetList = 0; + sr->u.response->suggestions = 0; break; case Z_SRW_explain_request: sr->u.explain_request = (Z_SRW_explainRequest *)