|
YAZ 5.38.1
|
Implements SRW/SRU utilities. More...
#include <stdlib.h>#include <assert.h>#include <yaz/srw.h>#include <yaz/matchstr.h>#include <yaz/base64.h>#include <yaz/yaz-iconv.h>#include <yaz/snprintf.h>#include "sru-p.h"Go to the source code of this file.
Macros | |
| #define | MAX_SRU_PARAMETERS 30 |
Functions | |
| static Z_SRW_extra_arg ** | append_extra_arg (ODR odr, Z_SRW_extra_arg **l, const char *n, const char *v) |
| static Z_SRW_extra_arg ** | append_extra_arg_int (ODR odr, Z_SRW_extra_arg **l, const char *n, Odr_int *v) |
| static char * | yaz_decode_sru_dbpath_odr (ODR n, const char *uri, size_t len) |
| void | yaz_encode_sru_dbpath_buf (char *dst, const char *db) |
| encode SRU database for HTTP path | |
| char * | yaz_encode_sru_dbpath_odr (ODR out, const char *db) |
| encode SRU database for HTTP path | |
| const char * | yaz_element_attribute_value_get (xmlNodePtr ptr, const char *node_name, const char *attribute_name) |
| int | yaz_srw_check_content_type (Z_HTTP_Response *hres) |
| static void | yaz_srw_decodeauth (Z_SRW_PDU *sr, Z_HTTP_Request *hreq, char *username, char *password, ODR decode) |
| void | yaz_mk_srw_diagnostic (ODR o, Z_SRW_diagnostic *d, const char *uri, const char *message, const char *details) |
| void | yaz_mk_std_diagnostic (ODR o, Z_SRW_diagnostic *d, int code, const char *details) |
| void | yaz_add_srw_diagnostic_uri (ODR o, Z_SRW_diagnostic **d, int *num, const char *uri, const char *message, const char *details) |
| void | yaz_add_srw_diagnostic (ODR o, Z_SRW_diagnostic **d, int *num, int code, const char *addinfo) |
| void | yaz_add_sru_update_diagnostic (ODR o, Z_SRW_diagnostic **d, int *num, int code, const char *addinfo) |
| void | yaz_mk_sru_surrogate (ODR o, Z_SRW_record *record, int pos, int code, const char *details) |
| static void | grab_charset (ODR o, const char *content_type, char **charset) |
| int | yaz_srw_decode (Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, Z_SOAP **soap_package, ODR decode, char **charset) |
| static int | yaz_sru_decode_integer (ODR odr, const char *pname, const char *valstr, Odr_int **valp, Z_SRW_diagnostic **diag, int *num_diag, int min_value) |
| int | yaz_sru_decode (Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, Z_SOAP **soap_package, ODR decode, char **charset, Z_SRW_diagnostic **diag, int *num_diag) |
| Z_SRW_extra_record * | yaz_srw_get_extra_record (ODR o) |
| Z_SRW_record * | yaz_srw_get_records (ODR o, int n) |
| Z_SRW_record * | yaz_srw_get_record (ODR o) |
| static Z_SRW_PDU * | yaz_srw_get_core_ver (ODR o, const char *version) |
| Z_SRW_PDU * | yaz_srw_get_core_v_2_0 (ODR o) |
| Z_SRW_PDU * | yaz_srw_get (ODR o, int which) |
| Z_SRW_PDU * | yaz_srw_get_pdu_e (ODR o, int which, Z_SRW_PDU *req) |
| Z_SRW_PDU * | yaz_srw_get_pdu (ODR o, int which, const char *version) |
| void | yaz_add_name_value_int (ODR o, char **name, char **value, int *i, char *a_name, Odr_int *val) |
| void | yaz_add_name_value_str (ODR o, char **name, char **value, int *i, char *a_name, char *val) |
| static int | yaz_get_sru_parms (const Z_SRW_PDU *srw_pdu, ODR encode, char **name, char **value, int max_names) |
| int | yaz_sru_get_encode (Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR encode, const char *charset) |
| int | yaz_sru_post_encode (Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR encode, const char *charset) |
| int | yaz_sru_soap_encode (Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR odr, const char *charset) |
| Z_SRW_recordVersion * | yaz_srw_get_record_versions (ODR odr, int num) |
| const char * | yaz_srw_pack_to_str (int pack) |
| int | yaz_srw_str_to_pack (const char *str) |
| void | yaz_encode_sru_extra (Z_SRW_PDU *sr, ODR odr, const char *extra_args) |
Implements SRW/SRU utilities.
Definition in file srwutil.c.
| #define MAX_SRU_PARAMETERS 30 |
Definition at line 22 of file srwutil.c.
Referenced by yaz_sru_get_encode(), and yaz_sru_post_encode().
|
static |
Definition at line 24 of file srwutil.c.
References append_extra_arg(), Z_SRW_extra_arg::next, odr_malloc(), and odr_strdup().
Referenced by append_extra_arg(), append_extra_arg_int(), yaz_encode_sru_extra(), yaz_sru_decode(), and yaz_srw_get_pdu_e().
|
static |
Definition at line 40 of file srwutil.c.
References append_extra_arg(), append_extra_arg_int(), ODR_INT_PRINTF, and yaz_snprintf().
Referenced by append_extra_arg_int(), and yaz_srw_get_pdu_e().
|
static |
Definition at line 232 of file srwutil.c.
References grab_charset(), and odr_strdup().
Referenced by grab_charset(), and yaz_sru_decode().
| void yaz_add_name_value_int | ( | ODR | o, |
| char ** | name, | ||
| char ** | value, | ||
| int * | i, | ||
| char * | a_name, | ||
| Odr_int * | val ) |
Definition at line 928 of file srwutil.c.
References nmem_printf(), odr_getmem, ODR_INT_PRINTF, and yaz_add_name_value_int().
Referenced by yaz_add_name_value_int(), yaz_get_sru_parms(), yaz_solr_encode_facet_field(), and yaz_solr_encode_request().
| void yaz_add_name_value_str | ( | ODR | o, |
| char ** | name, | ||
| char ** | value, | ||
| int * | i, | ||
| char * | a_name, | ||
| char * | val ) |
Definition at line 939 of file srwutil.c.
References yaz_add_name_value_str().
Referenced by yaz_add_name_value_str(), yaz_get_sru_parms(), yaz_solr_encode_facet_field(), and yaz_solr_encode_request().
| void yaz_add_sru_update_diagnostic | ( | ODR | o, |
| Z_SRW_diagnostic ** | d, | ||
| int * | num, | ||
| int | code, | ||
| const char * | addinfo ) |
Definition at line 194 of file srwutil.c.
References yaz_add_sru_update_diagnostic(), yaz_add_srw_diagnostic_uri(), and yaz_snprintf().
Referenced by srw_bend_update(), and yaz_add_sru_update_diagnostic().
| void yaz_add_srw_diagnostic | ( | ODR | o, |
| Z_SRW_diagnostic ** | d, | ||
| int * | num, | ||
| int | code, | ||
| const char * | addinfo ) |
Definition at line 184 of file srwutil.c.
References yaz_add_srw_diagnostic(), yaz_add_srw_diagnostic_uri(), and yaz_snprintf().
Referenced by srw_bend_init(), srw_bend_scan(), srw_bend_search(), yaz_add_srw_diagnostic(), yaz_solr_decode_error(), yaz_sru_decode(), and yaz_sru_decode_integer().
| void yaz_add_srw_diagnostic_uri | ( | ODR | o, |
| Z_SRW_diagnostic ** | d, | ||
| int * | num, | ||
| const char * | uri, | ||
| const char * | message, | ||
| const char * | details ) |
Definition at line 170 of file srwutil.c.
References odr_malloc(), yaz_add_srw_diagnostic_uri(), and yaz_mk_srw_diagnostic().
Referenced by srw_bend_update(), yaz_add_sru_update_diagnostic(), yaz_add_srw_diagnostic(), and yaz_add_srw_diagnostic_uri().
|
static |
Definition at line 52 of file srwutil.c.
References odr_strdupn(), and yaz_decode_sru_dbpath_odr().
Referenced by yaz_decode_sru_dbpath_odr(), yaz_sru_decode(), and yaz_srw_decode().
| const char * yaz_element_attribute_value_get | ( | xmlNodePtr | ptr, |
| const char * | node_name, | ||
| const char * | attribute_name ) |
Definition at line 72 of file srwutil.c.
References yaz_element_attribute_value_get().
Referenced by get_facet_term_count(), match_xml_node_attribute(), yaz_element_attribute_value_get(), yaz_solr_decode_facet_field(), yaz_solr_decode_misspelled(), yaz_sru_proxy_decode_facet_field(), and yaz_sru_proxy_get_facet_term_count().
| void yaz_encode_sru_dbpath_buf | ( | char * | dst, |
| const char * | db ) |
encode SRU database for HTTP path
| dst | destination buffer (should be at least strlen(db) +2 in size) |
| db | source database |
The resulting database (dst) includes a leading /
Definition at line 57 of file srwutil.c.
References yaz_encode_sru_dbpath_buf().
Referenced by yaz_encode_sru_dbpath_buf(), and yaz_encode_sru_dbpath_odr().
| char * yaz_encode_sru_dbpath_odr | ( | ODR | out, |
| const char * | db ) |
encode SRU database for HTTP path
| out | memory handle for resulting encoded database string |
| db | source database |
Definition at line 64 of file srwutil.c.
References odr_malloc(), yaz_encode_sru_dbpath_buf(), and yaz_encode_sru_dbpath_odr().
Referenced by yaz_encode_sru_dbpath_odr().
Definition at line 1233 of file srwutil.c.
References append_extra_arg(), Z_SRW_PDU::extra_args, yaz_encode_sru_extra(), and yaz_uri_to_array().
Referenced by yaz_encode_sru_extra(), ZOOM_connection_srw_send_scan(), and ZOOM_connection_srw_send_search().
|
static |
Definition at line 950 of file srwutil.c.
References Z_SRW_PDU::extra_args, Z_SRW_extra_arg::name, Z_SRW_extra_arg::next, Z_SRW_PDU::srw_version, Z_SRW_PDU::u, Z_SRW_extra_arg::value, Z_SRW_PDU::which, yaz_add_name_value_int(), yaz_add_name_value_str(), yaz_get_sru_parms(), yaz_sru_facet_request(), Z_SRW_explain_request, Z_SRW_scan_request, Z_SRW_searchRetrieve_request, Z_SRW_sort_type_none, Z_SRW_sort_type_sort, and Z_SRW_update_request.
Referenced by yaz_get_sru_parms(), yaz_sru_get_encode(), and yaz_sru_post_encode().
| void yaz_mk_sru_surrogate | ( | ODR | o, |
| Z_SRW_record * | record, | ||
| int | pos, | ||
| int | code, | ||
| const char * | details ) |
Definition at line 204 of file srwutil.c.
References odr_intdup(), odr_malloc(), Z_SRW_record::recordData_buf, Z_SRW_record::recordData_len, Z_SRW_record::recordPosition, Z_SRW_record::recordSchema, yaz_diag_srw_str(), yaz_mk_sru_surrogate(), and yaz_snprintf().
Referenced by srw_bend_fetch(), and yaz_mk_sru_surrogate().
| void yaz_mk_srw_diagnostic | ( | ODR | o, |
| Z_SRW_diagnostic * | d, | ||
| const char * | uri, | ||
| const char * | message, | ||
| const char * | details ) |
Definition at line 146 of file srwutil.c.
References Z_SRW_diagnostic::details, Z_SRW_diagnostic::message, odr_strdup(), Z_SRW_diagnostic::uri, and yaz_mk_srw_diagnostic().
Referenced by yaz_add_srw_diagnostic_uri(), yaz_mk_srw_diagnostic(), and yaz_mk_std_diagnostic().
| void yaz_mk_std_diagnostic | ( | ODR | o, |
| Z_SRW_diagnostic * | d, | ||
| int | code, | ||
| const char * | details ) |
Definition at line 161 of file srwutil.c.
References yaz_mk_srw_diagnostic(), yaz_mk_std_diagnostic(), and yaz_snprintf().
Referenced by yaz_mk_std_diagnostic().
| int yaz_sru_decode | ( | Z_HTTP_Request * | hreq, |
| Z_SRW_PDU ** | srw_pdu, | ||
| Z_SOAP ** | soap_package, | ||
| ODR | decode, | ||
| char ** | charset, | ||
| Z_SRW_diagnostic ** | diag, | ||
| int * | num_diag ) |
http://www.loc.gov/standards/sru/companionSpecs/srw.html
Definition at line 357 of file srwutil.c.
References append_extra_arg(), Z_HTTP_Request::content_buf, Z_SRW_PDU::extra_args, grab_charset(), Z_HTTP_Request::headers, Z_HTTP_Request::method, Z_SOAP_Handler::ns, odr_malloc(), Z_HTTP_Request::path, Z_SRW_PDU::srw_version, Z_SRW_PDU::u, yaz_add_srw_diagnostic(), yaz_decode_sru_dbpath_odr(), yaz_negotiate_sru_version(), yaz_sru_decode(), yaz_sru_decode_integer(), yaz_sru_facet_request(), yaz_srw_codec(), yaz_srw_decodeauth(), yaz_srw_get(), YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED, YAZ_SRW_UNSUPP_OPERATION, YAZ_SRW_UNSUPP_PARAMETER, YAZ_SRW_UNSUPP_VERSION, yaz_strcmp_del(), yaz_uri_to_array(), YAZ_XMLNS_SRU_v1_1, z_HTTP_header_lookup(), Z_SOAP_generic, Z_SRW_explain_request, Z_SRW_scan_request, Z_SRW_searchRetrieve_request, and Z_SRW_sort_type_sort.
Referenced by process_http_request(), and yaz_sru_decode().
|
static |
Definition at line 329 of file srwutil.c.
References odr_intdup(), yaz_add_srw_diagnostic(), yaz_sru_decode_integer(), and YAZ_SRW_UNSUPP_PARAMETER_VALUE.
Referenced by yaz_sru_decode(), and yaz_sru_decode_integer().
| int yaz_sru_get_encode | ( | Z_HTTP_Request * | hreq, |
| Z_SRW_PDU * | srw_pdu, | ||
| ODR | encode, | ||
| const char * | charset ) |
Definition at line 1103 of file srwutil.c.
References Z_HTTP_Request::headers, MAX_SRU_PARAMETERS, Z_HTTP_Request::method, nmem_printf(), odr_getmem, Z_SRW_PDU::password, Z_HTTP_Request::path, Z_SRW_PDU::username, yaz_array_to_uri(), yaz_get_sru_parms(), yaz_sru_get_encode(), z_HTTP_header_add_basic_auth(), and z_HTTP_header_add_content_type().
Referenced by send_srw(), and yaz_sru_get_encode().
| int yaz_sru_post_encode | ( | Z_HTTP_Request * | hreq, |
| Z_SRW_PDU * | srw_pdu, | ||
| ODR | encode, | ||
| const char * | charset ) |
Definition at line 1133 of file srwutil.c.
References Z_HTTP_Request::content_buf, Z_HTTP_Request::content_len, Z_HTTP_Request::headers, MAX_SRU_PARAMETERS, Z_HTTP_Request::method, Z_SRW_PDU::password, Z_SRW_PDU::username, yaz_array_to_uri(), yaz_get_sru_parms(), yaz_sru_post_encode(), z_HTTP_header_add_basic_auth(), and z_HTTP_header_add_content_type().
Referenced by send_srw(), and yaz_sru_post_encode().
| int yaz_sru_soap_encode | ( | Z_HTTP_Request * | hreq, |
| Z_SRW_PDU * | srw_pdu, | ||
| ODR | odr, | ||
| const char * | charset ) |
Definition at line 1157 of file srwutil.c.
References Z_HTTP_Request::content_buf, Z_HTTP_Request::content_len, Z_HTTP_Request::headers, Z_SOAP::ns, odr_malloc(), Z_SRW_PDU::password, Z_SOAP::u, Z_SRW_PDU::username, Z_SOAP::which, Z_SRW_PDU::which, yaz_sru_soap_encode(), yaz_srw_codec(), yaz_ucp_codec(), YAZ_XMLNS_SRU_v1_1, YAZ_XMLNS_UPDATE_v0_9, z_HTTP_header_add(), z_HTTP_header_add_basic_auth(), z_HTTP_header_add_content_type(), z_soap_codec_enc(), Z_SOAP_generic, Z_SRW_update_request, and Z_SRW_update_response.
Referenced by send_srw(), and yaz_sru_soap_encode().
| int yaz_srw_check_content_type | ( | Z_HTTP_Response * | hres | ) |
Definition at line 89 of file srwutil.c.
References Z_HTTP_Response::headers, yaz_srw_check_content_type(), yaz_strcmp_del(), and z_HTTP_header_lookup().
Referenced by yaz_srw_check_content_type(), and ZOOM_handle_sru().
| int yaz_srw_decode | ( | Z_HTTP_Request * | hreq, |
| Z_SRW_PDU ** | srw_pdu, | ||
| Z_SOAP ** | soap_package, | ||
| ODR | decode, | ||
| char ** | charset ) |
Definition at line 258 of file srwutil.c.
References Z_HTTP_Request::content_buf, Z_HTTP_Request::content_len, Z_HTTP_Request::headers, Z_HTTP_Request::method, Z_HTTP_Request::path, Z_SRW_PDU::u, yaz_decode_sru_dbpath_odr(), yaz_srw_codec(), yaz_srw_decode(), yaz_srw_decodeauth(), yaz_strcmp_del(), yaz_ucp_codec(), YAZ_XMLNS_SRU_v1_0, YAZ_XMLNS_SRU_v1_1, YAZ_XMLNS_SRU_v2_mask, YAZ_XMLNS_UPDATE_v0_9, z_HTTP_header_lookup(), z_soap_codec(), Z_SOAP_generic, Z_SRW_explain_request, Z_SRW_scan_request, Z_SRW_searchRetrieve_request, and Z_SRW_update_request.
Referenced by process_http_request(), and yaz_srw_decode().
|
static |
Look for authentication tokens in HTTP Basic parameters or in x-username/x-password parameters. Added by SH.
Definition at line 109 of file srwutil.c.
References Z_HTTP_Request::headers, odr_strdup(), Z_SRW_PDU::password, Z_SRW_PDU::username, yaz_base64decode(), yaz_srw_decodeauth(), and z_HTTP_header_lookup().
Referenced by yaz_sru_decode(), yaz_srw_decode(), and yaz_srw_decodeauth().
Definition at line 756 of file srwutil.c.
References yaz_srw_get(), and yaz_srw_get_pdu().
Referenced by yaz_solr_decode_response(), yaz_sru_decode(), and yaz_srw_get().
Definition at line 751 of file srwutil.c.
References yaz_srw_get_core_v_2_0(), and yaz_srw_get_core_ver().
Referenced by yaz_srw_codec(), yaz_srw_get_core_v_2_0(), and yaz_ucp_codec().
Definition at line 739 of file srwutil.c.
References Z_SRW_PDU::extra_args, Z_SRW_PDU::extraResponseData_buf, Z_SRW_PDU::extraResponseData_len, odr_malloc(), odr_strdup(), Z_SRW_PDU::password, Z_SRW_PDU::srw_version, Z_SRW_PDU::username, and yaz_srw_get_core_ver().
Referenced by yaz_srw_get_core_v_2_0(), yaz_srw_get_core_ver(), and yaz_srw_get_pdu().
| Z_SRW_extra_record * yaz_srw_get_extra_record | ( | ODR | o | ) |
Definition at line 706 of file srwutil.c.
References Z_SRW_extra_record::extraRecordData_buf, Z_SRW_extra_record::extraRecordData_len, odr_malloc(), Z_SRW_extra_record::recordIdentifier, and yaz_srw_get_extra_record().
Referenced by srw_bend_update(), and yaz_srw_get_extra_record().
Definition at line 817 of file srwutil.c.
References Z_SRW_PDU::extraResponseData_buf, Z_SRW_PDU::extraResponseData_len, odr_malloc(), Z_SRW_PDU::u, Z_SRW_PDU::which, yaz_srw_get_core_ver(), yaz_srw_get_pdu(), Z_SRW_explain_request, Z_SRW_explain_response, Z_SRW_recordPacking_string, Z_SRW_scan_request, Z_SRW_scan_response, Z_SRW_searchRetrieve_request, Z_SRW_searchRetrieve_response, Z_SRW_sort_type_none, Z_SRW_update_request, and Z_SRW_update_response.
Referenced by process_http_request(), yaz_srw_get(), yaz_srw_get_pdu(), yaz_srw_get_pdu_e(), and ZOOM_srw_get_pdu().
Definition at line 762 of file srwutil.c.
References append_extra_arg(), append_extra_arg_int(), Z_SRW_PDU::extra_args, Z_SRW_extra_arg::name, Z_SRW_extra_arg::next, Z_SRW_PDU::srw_version, Z_SRW_PDU::u, Z_SRW_PDU::which, yaz_srw_get_pdu(), yaz_srw_get_pdu_e(), Z_SRW_explain_request, Z_SRW_explain_response, Z_SRW_searchRetrieve_request, Z_SRW_searchRetrieve_response, and Z_SRW_sort_type_sort.
Referenced by process_http_request(), and yaz_srw_get_pdu_e().
| Z_SRW_record * yaz_srw_get_record | ( | ODR | o | ) |
Definition at line 734 of file srwutil.c.
References yaz_srw_get_record(), and yaz_srw_get_records().
Referenced by srw_bend_update(), yaz_srw_get_record(), and yaz_ucp_codec().
| Z_SRW_recordVersion * yaz_srw_get_record_versions | ( | ODR | odr, |
| int | num ) |
Definition at line 1195 of file srwutil.c.
References odr_malloc(), Z_SRW_recordVersion::versionType, Z_SRW_recordVersion::versionValue, and yaz_srw_get_record_versions().
Referenced by yaz_srw_get_record_versions().
| Z_SRW_record * yaz_srw_get_records | ( | ODR | o, |
| int | n ) |
Definition at line 718 of file srwutil.c.
References odr_malloc(), Z_SRW_record::recordData_buf, Z_SRW_record::recordData_len, Z_SRW_record::recordPacking, Z_SRW_record::recordPosition, Z_SRW_record::recordSchema, yaz_srw_get_records(), and Z_SRW_recordPacking_string.
Referenced by yaz_srw_get_record(), and yaz_srw_get_records().
| const char * yaz_srw_pack_to_str | ( | int | pack | ) |
Definition at line 1208 of file srwutil.c.
References yaz_srw_pack_to_str(), Z_SRW_recordPacking_string, Z_SRW_recordPacking_URL, and Z_SRW_recordPacking_XML.
Referenced by srw_bend_update(), yaz_srw_pack_to_str(), and yaz_srw_record().
| int yaz_srw_str_to_pack | ( | const char * | str | ) |
Definition at line 1222 of file srwutil.c.
References yaz_matchstr(), yaz_srw_str_to_pack(), Z_SRW_recordPacking_string, Z_SRW_recordPacking_URL, and Z_SRW_recordPacking_XML.
Referenced by srw_bend_explain(), srw_bend_search(), srw_bend_update(), and yaz_srw_str_to_pack().