X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fsrwutil.c;h=25f2fca55aed95d814453e3e084352c68c9d4f12;hb=4d377a28c907f9fee3f576f32d96020fb7a8436c;hp=624efaa9db725f33c20d98eb04173ceaac5846c2;hpb=184f0911dd1ef651b6ba659df0eb33ff2455014c;p=yaz-moved-to-github.git diff --git a/src/srwutil.c b/src/srwutil.c index 624efaa..25f2fca 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: srwutil.c,v 1.46 2006-08-16 22:47:10 adam Exp $ + * $Id: srwutil.c,v 1.51 2006-10-05 15:19:33 adam Exp $ */ /** * \file srwutil.c @@ -80,7 +80,7 @@ static void yaz_array_to_uri_ex(char **path, ODR o, char **name, char **value, void yaz_array_to_uri(char **path, ODR o, char **name, char **value) { - return yaz_array_to_uri_ex(path, o, name, value, 0); + yaz_array_to_uri_ex(path, o, name, value, 0); } int yaz_uri_array(const char *path, ODR o, char ***name, char ***val) @@ -411,10 +411,10 @@ int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, return 2; } -static int yaz_sru_integer_decode(ODR odr, const char *pname, +static int yaz_sru_decode_integer(ODR odr, const char *pname, const char *valstr, int **valp, - Z_SRW_diagnostic **diag, int *num_diag) - + Z_SRW_diagnostic **diag, int *num_diag, + int min_value) { int ival; if (!valstr) @@ -425,9 +425,16 @@ static int yaz_sru_integer_decode(ODR odr, const char *pname, YAZ_SRW_UNSUPP_PARAMETER_VALUE, pname); return 0; } + if (min_value >= 0 && ival < min_value) + { + yaz_add_srw_diagnostic(odr, diag, num_diag, + YAZ_SRW_UNSUPP_PARAMETER_VALUE, pname); + return 0; + } *valp = odr_intdup(odr, ival); return 1; } + /** http://www.loc.gov/z3950/agency/zing/srw/service.html */ @@ -599,13 +606,13 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, sr->u.request->recordPacking = recordPacking; sr->u.request->stylesheet = stylesheet; - yaz_sru_integer_decode(decode, "maximumRecords", maximumRecords, + yaz_sru_decode_integer(decode, "maximumRecords", maximumRecords, &sr->u.request->maximumRecords, - diag, num_diag); - - yaz_sru_integer_decode(decode, "startRecord", startRecord, + diag, num_diag, 0); + + yaz_sru_decode_integer(decode, "startRecord", startRecord, &sr->u.request->startRecord, - diag, num_diag); + diag, num_diag, 1); sr->u.request->database = db; @@ -677,15 +684,15 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED, "scanClause"); sr->u.scan_request->database = db; - yaz_sru_integer_decode(decode, "maximumTerms", + yaz_sru_decode_integer(decode, "maximumTerms", maximumTerms, &sr->u.scan_request->maximumTerms, - diag, num_diag); - - yaz_sru_integer_decode(decode, "responsePosition", + diag, num_diag, 0); + + yaz_sru_decode_integer(decode, "responsePosition", responsePosition, &sr->u.scan_request->responsePosition, - diag, num_diag); + diag, num_diag, 0); sr->u.scan_request->stylesheet = stylesheet; @@ -753,6 +760,16 @@ Z_SRW_extra_record *yaz_srw_get_extra_record(ODR o) return res; } +Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o) +{ + Z_SRW_PDU *p = (Z_SRW_PDU *) odr_malloc(o, sizeof(*p)); + p->srw_version = odr_strdup(o, "1.1"); + p->username = 0; + p->password = 0; + p->extra_args = 0; + return p; +} + Z_SRW_PDU *yaz_srw_get(ODR o, int which) { Z_SRW_PDU *sr = yaz_srw_get_core_v_1_1(o);