YAZ  5.23.1
Macros | Functions
srwutil.c File Reference

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 "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 More...
 
char * yaz_encode_sru_dbpath_odr (ODR out, const char *db)
 encode SRU database for HTTP path More...
 
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_recordyaz_srw_get_extra_record (ODR o)
 
Z_SRW_recordyaz_srw_get_records (ODR o, int n)
 
Z_SRW_recordyaz_srw_get_record (ODR o)
 
static Z_SRW_PDUyaz_srw_get_core_ver (ODR o, const char *version)
 
Z_SRW_PDUyaz_srw_get_core_v_2_0 (ODR o)
 
Z_SRW_PDUyaz_srw_get (ODR o, int which)
 
Z_SRW_PDUyaz_srw_get_pdu_e (ODR o, int which, Z_SRW_PDU *req)
 
Z_SRW_PDUyaz_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_recordVersionyaz_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)
 

Detailed Description

Implements SRW/SRU utilities.

Definition in file srwutil.c.

Macro Definition Documentation

#define MAX_SRU_PARAMETERS   30

Definition at line 21 of file srwutil.c.

Referenced by yaz_sru_get_encode(), and yaz_sru_post_encode().

Function Documentation

static Z_SRW_extra_arg** append_extra_arg ( ODR  odr,
Z_SRW_extra_arg **  l,
const char *  n,
const char *  v 
)
static
static Z_SRW_extra_arg** append_extra_arg_int ( ODR  odr,
Z_SRW_extra_arg **  l,
const char *  n,
Odr_int v 
)
static

Definition at line 39 of file srwutil.c.

References append_extra_arg(), and ODR_INT_PRINTF.

Referenced by yaz_srw_get_pdu_e().

static void grab_charset ( ODR  o,
const char *  content_type,
char **  charset 
)
static

Definition at line 233 of file srwutil.c.

References odr_strdup().

Referenced by 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 929 of file srwutil.c.

References ODR_INT_PRINTF, and odr_malloc().

Referenced by 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 
)
void yaz_add_sru_update_diagnostic ( ODR  o,
Z_SRW_diagnostic **  d,
int *  num,
int  code,
const char *  addinfo 
)

Definition at line 195 of file srwutil.c.

References yaz_add_srw_diagnostic_uri().

Referenced by srw_bend_update().

void yaz_add_srw_diagnostic ( ODR  o,
Z_SRW_diagnostic **  d,
int *  num,
int  code,
const char *  addinfo 
)
void yaz_add_srw_diagnostic_uri ( ODR  o,
Z_SRW_diagnostic **  d,
int *  num,
const char *  uri,
const char *  message,
const char *  details 
)
static char* yaz_decode_sru_dbpath_odr ( ODR  n,
const char *  uri,
size_t  len 
)
static

Definition at line 51 of file srwutil.c.

References odr_strdupn().

Referenced by yaz_sru_decode(), and yaz_srw_decode().

const char* yaz_element_attribute_value_get ( xmlNodePtr  ptr,
const char *  node_name,
const char *  attribute_name 
)
void yaz_encode_sru_dbpath_buf ( char *  dst,
const char *  db 
)

encode SRU database for HTTP path

Parameters
dstdestination buffer (should be at least strlen(db) +2 in size)
dbsource database

The resulting database (dst) includes a leading /

Definition at line 56 of file srwutil.c.

Referenced by yaz_encode_sru_dbpath_odr().

char* yaz_encode_sru_dbpath_odr ( ODR  out,
const char *  db 
)

encode SRU database for HTTP path

Parameters
outmemory handle for resulting encoded database string
dbsource database
Returns
encoded database path (includes leading /)

Definition at line 63 of file srwutil.c.

References odr_malloc(), and yaz_encode_sru_dbpath_buf().

void yaz_encode_sru_extra ( Z_SRW_PDU sr,
ODR  odr,
const char *  extra_args 
)
static int yaz_get_sru_parms ( const Z_SRW_PDU srw_pdu,
ODR  encode,
char **  name,
char **  value,
int  max_names 
)
static
void yaz_mk_sru_surrogate ( ODR  o,
Z_SRW_record record,
int  pos,
int  code,
const char *  details 
)
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 
)

Definition at line 162 of file srwutil.c.

References yaz_mk_srw_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 358 of file srwutil.c.

References append_extra_arg(), Z_HTTP_Request::content_buf, Z_SRW_searchRetrieveRequest::database, Z_SRW_explainRequest::database, Z_SRW_scanRequest::database, Z_SRW_PDU::explain_request, Z_SRW_PDU::extra_args, Z_SRW_searchRetrieveRequest::facetList, grab_charset(), Z_HTTP_Request::headers, Z_SRW_searchRetrieveRequest::maximumRecords, Z_SRW_scanRequest::maximumTerms, Z_HTTP_Request::method, Z_SOAP_Handler::ns, odr_malloc(), Z_SRW_searchRetrieveRequest::packing, Z_SRW_explainRequest::packing, Z_HTTP_Request::path, Z_SRW_searchRetrieveRequest::query, Z_SRW_searchRetrieveRequest::queryType, Z_SRW_scanRequest::queryType, Z_SRW_searchRetrieveRequest::recordPacking, Z_SRW_explainRequest::recordPacking, Z_SRW_searchRetrieveRequest::recordSchema, Z_SRW_searchRetrieveRequest::recordXPath, Z_SRW_PDU::request, Z_SRW_scanRequest::responsePosition, Z_SRW_PDU::scan_request, Z_SRW_scanRequest::scanClause, Z_SRW_searchRetrieveRequest::sort, Z_SRW_searchRetrieveRequest::sort_type, Z_SRW_searchRetrieveRequest::sortKeys, Z_SRW_PDU::srw_version, Z_SRW_searchRetrieveRequest::startRecord, Z_SRW_searchRetrieveRequest::stylesheet, Z_SRW_explainRequest::stylesheet, Z_SRW_scanRequest::stylesheet, Z_SRW_PDU::u, yaz_add_srw_diagnostic(), yaz_decode_sru_dbpath_odr(), yaz_negotiate_sru_version(), 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().

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 
)
static

Definition at line 330 of file srwutil.c.

References odr_intdup(), yaz_add_srw_diagnostic(), and YAZ_SRW_UNSUPP_PARAMETER_VALUE.

Referenced by yaz_sru_decode().

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 
)
int yaz_srw_check_content_type ( Z_HTTP_Response hres)

Definition at line 90 of file srwutil.c.

References Z_HTTP_Response::headers, yaz_strcmp_del(), and z_HTTP_header_lookup().

Referenced by ZOOM_handle_sru().

int yaz_srw_decode ( Z_HTTP_Request hreq,
Z_SRW_PDU **  srw_pdu,
Z_SOAP **  soap_package,
ODR  decode,
char **  charset 
)
static void yaz_srw_decodeauth ( Z_SRW_PDU sr,
Z_HTTP_Request hreq,
char *  username,
char *  password,
ODR  decode 
)
static

Look for authentication tokens in HTTP Basic parameters or in x-username/x-password parameters. Added by SH.

Definition at line 110 of file srwutil.c.

References Z_HTTP_Request::headers, odr_strdup(), Z_SRW_PDU::password, Z_SRW_PDU::username, yaz_base64decode(), and z_HTTP_header_lookup().

Referenced by yaz_sru_decode(), and yaz_srw_decode().

Z_SRW_PDU* yaz_srw_get ( ODR  o,
int  which 
)

Definition at line 757 of file srwutil.c.

References yaz_srw_get_pdu().

Referenced by yaz_solr_decode_response(), and yaz_sru_decode().

Z_SRW_PDU* yaz_srw_get_core_v_2_0 ( ODR  o)

Definition at line 752 of file srwutil.c.

References yaz_srw_get_core_ver().

Referenced by yaz_srw_codec(), and yaz_ucp_codec().

static Z_SRW_PDU* yaz_srw_get_core_ver ( ODR  o,
const char *  version 
)
static
Z_SRW_extra_record* yaz_srw_get_extra_record ( ODR  o)
Z_SRW_PDU* yaz_srw_get_pdu ( ODR  o,
int  which,
const char *  version 
)

Definition at line 818 of file srwutil.c.

References Z_SRW_searchRetrieveRequest::database, Z_SRW_explainRequest::database, Z_SRW_scanRequest::database, Z_SRW_updateRequest::database, Z_SRW_searchRetrieveResponse::diagnostics, Z_SRW_explainResponse::diagnostics, Z_SRW_scanResponse::diagnostics, Z_SRW_updateResponse::diagnostics, Z_SRW_PDU::explain_request, Z_SRW_PDU::explain_response, Z_SRW_explainResponse::extra_record, Z_SRW_updateRequest::extra_record, Z_SRW_updateResponse::extra_record, Z_SRW_searchRetrieveResponse::extra_records, Z_SRW_updateRequest::extraRequestData_buf, Z_SRW_updateRequest::extraRequestData_len, Z_SRW_updateResponse::extraResponseData_buf, Z_SRW_updateResponse::extraResponseData_len, Z_SRW_searchRetrieveRequest::facetList, Z_SRW_searchRetrieveResponse::facetList, Z_SRW_searchRetrieveRequest::maximumRecords, Z_SRW_scanRequest::maximumTerms, Z_SRW_searchRetrieveResponse::nextRecordPosition, Z_SRW_searchRetrieveRequest::none, Z_SRW_searchRetrieveResponse::num_diagnostics, Z_SRW_explainResponse::num_diagnostics, Z_SRW_scanResponse::num_diagnostics, Z_SRW_updateResponse::num_diagnostics, Z_SRW_searchRetrieveResponse::num_records, Z_SRW_updateRequest::num_recordVersions, Z_SRW_updateResponse::num_recordVersions, Z_SRW_scanResponse::num_terms, Z_SRW_searchRetrieveResponse::numberOfRecords, odr_malloc(), Z_SRW_updateResponse::operationStatus, Z_SRW_searchRetrieveRequest::packing, Z_SRW_explainRequest::packing, Z_SRW_searchRetrieveRequest::query, Z_SRW_searchRetrieveRequest::queryType, Z_SRW_scanRequest::queryType, Z_SRW_explainResponse::record, Z_SRW_updateRequest::record, Z_SRW_updateResponse::record, Z_SRW_record::recordData_buf, Z_SRW_record::recordData_len, Z_SRW_updateRequest::recordId, Z_SRW_updateResponse::recordId, Z_SRW_record::recordPacking, Z_SRW_searchRetrieveRequest::recordPacking, Z_SRW_explainRequest::recordPacking, Z_SRW_record::recordPosition, Z_SRW_searchRetrieveResponse::records, Z_SRW_record::recordSchema, Z_SRW_searchRetrieveRequest::recordSchema, Z_SRW_updateRequest::recordVersions, Z_SRW_updateResponse::recordVersions, Z_SRW_searchRetrieveRequest::recordXPath, Z_SRW_PDU::request, Z_SRW_PDU::response, Z_SRW_scanRequest::responsePosition, Z_SRW_searchRetrieveResponse::resultCountPrecision, Z_SRW_searchRetrieveResponse::resultSetId, Z_SRW_searchRetrieveResponse::resultSetIdleTime, Z_SRW_searchRetrieveRequest::resultSetTTL, Z_SRW_PDU::scan_request, Z_SRW_PDU::scan_response, Z_SRW_scanRequest::scanClause, Z_SRW_searchRetrieveRequest::sort, Z_SRW_searchRetrieveRequest::sort_type, Z_SRW_searchRetrieveRequest::startRecord, Z_SRW_searchRetrieveRequest::stylesheet, Z_SRW_explainRequest::stylesheet, Z_SRW_scanRequest::stylesheet, Z_SRW_updateRequest::stylesheet, Z_SRW_searchRetrieveResponse::suggestions, Z_SRW_scanResponse::terms, Z_SRW_PDU::u, Z_SRW_PDU::update_request, Z_SRW_PDU::update_response, Z_SRW_PDU::which, yaz_srw_get_core_ver(), 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_e(), and ZOOM_srw_get_pdu().

Z_SRW_PDU* yaz_srw_get_pdu_e ( ODR  o,
int  which,
Z_SRW_PDU req 
)
Z_SRW_record* yaz_srw_get_record ( ODR  o)

Definition at line 735 of file srwutil.c.

References yaz_srw_get_records().

Referenced by srw_bend_update(), and yaz_ucp_codec().

Z_SRW_recordVersion* yaz_srw_get_record_versions ( ODR  odr,
int  num 
)
Z_SRW_record* yaz_srw_get_records ( ODR  o,
int  n 
)
const char* yaz_srw_pack_to_str ( int  pack)
int yaz_srw_str_to_pack ( const char *  str)