X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fsrwutil.c;h=25a85e12506f240ea1b2285ed45e23960ebb4511;hp=a3459fec14f95eb752e72f8783e11b52056b8374;hb=a679666e56f9f6ea19e4c22e36089ccb3716dd0f;hpb=66651add5da56151f986e44957cfafc8ee81578c diff --git a/src/srwutil.c b/src/srwutil.c index a3459fe..25a85e1 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -1,8 +1,6 @@ -/* - * Copyright (C) 1995-2007, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2008 Index Data * See the file LICENSE for details. - * - * $Id: srwutil.c,v 1.65 2008-01-28 09:51:02 adam Exp $ */ /** * \file srwutil.c @@ -11,6 +9,7 @@ #include #include +#include #include static int hex_digit (int ch) @@ -177,6 +176,7 @@ char *yaz_uri_val(const char *path, const char *name, ODR o) return 0; } +#if YAZ_HAVE_XML2 static int yaz_base64decode(const char *in, char *out) { const char *map = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -222,6 +222,7 @@ static int yaz_base64decode(const char *in, char *out) *out = '\0'; return olen; } +#endif int yaz_srw_check_content_type(Z_HTTP_Response *hres) { @@ -241,6 +242,7 @@ int yaz_srw_check_content_type(Z_HTTP_Response *hres) * Look for authentication tokens in HTTP Basic parameters or in x-username/x-password * parameters. Added by SH. */ +#if YAZ_HAVE_XML2 static void yaz_srw_decodeauth(Z_SRW_PDU *sr, Z_HTTP_Request *hreq, char *username, char *password, ODR decode) { @@ -275,6 +277,7 @@ static void yaz_srw_decodeauth(Z_SRW_PDU *sr, Z_HTTP_Request *hreq, sr->password = odr_strdup(decode, pbuf); } } +#endif void yaz_uri_val_int(const char *path, const char *name, ODR o, int **intp) { @@ -341,6 +344,34 @@ void yaz_add_sru_update_diagnostic(ODR o, Z_SRW_diagnostic **d, } +void yaz_mk_sru_surrogate(ODR o, Z_SRW_record *record, int pos, + int code, const char *details) +{ + const char *message = yaz_diag_srw_str(code); + int len = 200; + if (message) + len += strlen(message); + if (details) + len += strlen(details); + + record->recordData_buf = (char *) odr_malloc(o, len); + + sprintf(record->recordData_buf, "\n" + " info:srw/diagnostic/1/%d\n", code); + if (details) + sprintf(record->recordData_buf + strlen(record->recordData_buf), + "
%s
\n", details); + if (message) + sprintf(record->recordData_buf + strlen(record->recordData_buf), + " %s\n", message); + sprintf(record->recordData_buf + strlen(record->recordData_buf), + "
\n"); + record->recordData_len = strlen(record->recordData_buf); + record->recordPosition = odr_intdup(o, pos); + record->recordSchema = "info:srw/schema/1/diagnostics-v1.1"; +} + static void grab_charset(ODR o, const char *content_type, char **charset) { if (charset) @@ -430,6 +461,7 @@ int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, return 2; } +#if YAZ_HAVE_XML2 static int yaz_sru_decode_integer(ODR odr, const char *pname, const char *valstr, int **valp, Z_SRW_diagnostic **diag, int *num_diag, @@ -453,6 +485,7 @@ static int yaz_sru_decode_integer(ODR odr, const char *pname, *valp = odr_intdup(odr, ival); return 1; } +#endif /** http://www.loc.gov/z3950/agency/zing/srw/service.html @@ -574,7 +607,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; @@ -1422,7 +1455,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;