YAZ  5.23.1
Data Structures | Functions | Variables
ztest.c File Reference

yaz-ztest Generic Frontend Server More...

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <yaz/log.h>
#include <yaz/backend.h>
#include <yaz/ill.h>
#include <yaz/diagbib1.h>
#include <yaz/otherinfo.h>
#include <yaz/facet.h>
#include <yaz/backtrace.h>
#include "ztest.h"

Go to the source code of this file.

Data Structures

struct  delay
struct  result_set
struct  session_handle


int ztest_search (void *handle, bend_search_rr *rr)
int ztest_sort (void *handle, bend_sort_rr *rr)
int ztest_present (void *handle, bend_present_rr *rr)
int ztest_esrequest (void *handle, bend_esrequest_rr *rr)
int ztest_delete (void *handle, bend_delete_rr *rr)
static struct result_setget_set (struct session_handle *sh, const char *name)
static void remove_sets (struct session_handle *sh)
static Odr_int get_term_hit (Z_RPNStructure *s, unsigned *hash)
 use term value as hit count More...
static Odr_int get_hit_count (Z_Query *q)
 gets hit count for numeric terms in RPN queries More...
static int check_slow (const char *basename, bend_association association)
 checks if it's a dummy Slow database More...
static int strcmp_prefix (const char *s, const char *p)
static void init_delay (struct delay *delayp)
static int parse_delay (struct delay *delayp, const char *value)
static void ztest_sleep (double d)
static void do_delay (const struct delay *delayp)
static void addterms (ODR odr, Z_FacetField *facet_field, const char *facet_name)
Z_OtherInformationbuild_facet_response (ODR odr, Z_FacetList *facet_list)
static void echo_extra_args (ODR stream, Z_SRW_extra_arg *extra_args, char **extra_response)
int ztest_fetch (void *handle, bend_fetch_rr *r)
int ztest_scan (void *handle, bend_scan_rr *q)
int ztest_explain (void *handle, bend_explain_rr *rr)
int ztest_update (void *handle, bend_update_rr *rr)
bend_initresultbend_init (bend_initrequest *q)
void bend_close (void *handle)
int main (int argc, char **argv)


static int log_level =0
static int log_level_set =0

Detailed Description

yaz-ztest Generic Frontend Server

Definition in file ztest.c.

Function Documentation

static void addterms ( ODR  odr,
Z_FacetField facet_field,
const char *  facet_name 
void bend_close ( void *  handle)

Definition at line 1153 of file ztest.c.

References remove_sets(), and xfree.

Referenced by main(), and statserv_main().

bend_initresult* bend_init ( bend_initrequest q)
Z_OtherInformation* build_facet_response ( ODR  odr,
Z_FacetList facet_list 
static int check_slow ( const char *  basename,
bend_association  association 

checks if it's a dummy Slow database

basenamedatabase name to check
associationbackend association (or NULL if not available)
Return values
1is slow database
0is not a slow database

The Slow database is for testing.. It allows us to simulate a slow server...

Definition at line 180 of file ztest.c.

References bend_assoc_is_alive(), yaz_log(), and YLOG_LOG.

Referenced by ztest_scan(), and ztest_search().

static void do_delay ( const struct delay delayp)

Definition at line 240 of file ztest.c.

References delay::d1, delay::d2, and ztest_sleep().

Referenced by ztest_fetch(), ztest_present(), and ztest_search().

static void echo_extra_args ( ODR  stream,
Z_SRW_extra_arg extra_args,
char **  extra_response 
static Odr_int get_hit_count ( Z_Query q)

gets hit count for numeric terms in RPN queries

qRPN Query
number of hits

This is just for testing.. A real database of course uses the content of a database to establish a value.. In our case, we have a way to trigger a certain hit count. Good for testing of client applications etc

Definition at line 146 of file ztest.c.

References Z_External::cql, get_term_hit(), Z_RPNQuery::RPNStructure, Z_Query::type_1, Z_Query::type_104, Z_External::u, Z_Query::u, Z_External::which, Z_Query::which, Z_External_CQL, Z_Query_type_1, Z_Query_type_101, and Z_Query_type_104.

Referenced by ztest_search().

static struct result_set* get_set ( struct session_handle sh,
const char *  name 

Definition at line 68 of file ztest.c.

References session_handle::result_sets.

Referenced by ztest_fetch(), ztest_present(), and ztest_search().

static Odr_int get_term_hit ( Z_RPNStructure s,
unsigned *  hash 

use term value as hit count

sRPN structure
hashvalue for compuation
>= 0: search term number or -1: not found

Traverse RPN tree 'in order' and use term value as hit count. Only terms that looks a numeric is used.. Returns -1 if no sub tree has a hit count term

Definition at line 100 of file ztest.c.

References Z_Operand::attributesPlusTerm, odr_oct::buf, Z_RPNStructure::complex, Z_Term::general, odr_oct::len, odr_atoi(), Z_Complex::s1, Z_Complex::s2, Z_RPNStructure::simple, Z_AttributesPlusTerm::term, Z_RPNStructure::u, Z_Operand::u, Z_Term::u, Z_RPNStructure::which, Z_Operand::which, Z_Term::which, wrbuf_alloc(), wrbuf_cstr(), wrbuf_destroy(), wrbuf_write(), Z_Operand_APT, Z_RPNStructure_complex, Z_RPNStructure_simple, and Z_Term_general.

Referenced by get_hit_count().

static void init_delay ( struct delay delayp)

Definition at line 212 of file ztest.c.

References delay::d1, and delay::d2.

Referenced by ztest_search().

int main ( int  argc,
char **  argv 

Definition at line 1161 of file ztest.c.

References bend_close(), bend_init(), statserv_main(), and yaz_enable_panic_backtrace().

static int parse_delay ( struct delay delayp,
const char *  value 

Definition at line 217 of file ztest.c.

References delay::d1, and delay::d2.

Referenced by ztest_search().

static void remove_sets ( struct session_handle sh)

Definition at line 77 of file ztest.c.

References result_set::next, session_handle::result_sets, and xfree.

Referenced by bend_close().

static int strcmp_prefix ( const char *  s,
const char *  p 

Definition at line 204 of file ztest.c.

Referenced by ztest_search().

int ztest_delete ( void *  handle,
bend_delete_rr rr 
int ztest_esrequest ( void *  handle,
bend_esrequest_rr rr 

Definition at line 448 of file ztest.c.

References Z_IUOriginPartToKeep::action, Z_IUOriginPartToKeep::actionQualifier, Z_IOOriginPartToKeep::addlBilling, Z_IOTargetPart::auxiliaryStatus, odr_oct::buf, Z_IOOriginPartToKeep::contact, Z_IUTaskPackageRecordStructure::correlationInfo, Z_TaskPackage::creationDateTime, Z_IUOriginPartToKeep::databaseName, bend_esrequest_rr::decode, Z_TaskPackage::description, Z_External::descriptor, Z_External::direct_reference, Z_IUSuppliedRecords::elements, Z_IUOriginPartToKeep::elementSetName, Z_IOContact::email, bend_esrequest_rr::errcode, bend_esrequest_rr::errstring, bend_esrequest_rr::esr, Z_IOItemOrder::esRequest, Z_IUUpdate::esRequest, Z_ExtendedServicesRequest::function, Z_IUTargetPart::globalDiagnostics, ill_APDU(), ill_ItemRequest(), Z_External::indirect_reference, Z_IOResultSetItem::item, Z_External::itemOrder, Z_IOOriginPartNotToKeep::itemRequest, Z_IOTargetPart::itemRequest, odr_oct::len, log_level, Z_IOContact::name, Z_IORequest::notToKeep, Z_IUUpdateEsRequest::notToKeep, Z_IUSuppliedRecords::num, Z_IUTargetPart::num_globalDiagnostics, Z_IUTaskPackageRecordStructure::num_supplementalDiagnostics, Z_IUTargetPart::num_taskPackageRecords, Z_External::octet_aligned, odr_create_Odr_oct(), odr_dumpBER(), odr_errmsg(), ODR_EXTERNAL_single, odr_geterror(), ODR_INT_PRINTF, odr_intdup(), odr_malloc(), odr_nullval(), odr_offset(), odr_oiddup(), odr_reset(), odr_setbuf(), odr_strdup(), oid_oidcmp(), OID_STR_MAX, Z_IOTaskPackage::originPart, Z_IUUpdateTaskPackage::originPart, Z_TaskPackage::packageDiagnostics, Z_TaskPackage::packageName, Z_ExtendedServicesRequest::packageName, Z_TaskPackage::packageType, Z_ExtendedServicesRequest::packageType, Z_TaskPackage::permissions, Z_IOContact::phone, bend_esrequest_rr::print, Z_IUSuppliedRecords_elem::record, Z_IUTaskPackageRecordStructure::record, Z_IUTaskPackageRecordStructure::recordStatus, Z_IOResultSetItem::resultSetId, Z_IOOriginPartNotToKeep::resultSetItem, Z_TaskPackage::retentionTime, Z_IUOriginPartToKeep::schema, Z_External::single_ASN1_type, Z_IOTargetPart::statusOrErrorReport, bend_esrequest_rr::stream, Z_IUTaskPackageRecordStructure::supplementalDiagnostics, Z_External::sutrs, Z_IOTaskPackage::targetPart, Z_IUUpdateTaskPackage::targetPart, Z_TaskPackage::targetReference, Z_IOItemOrder::taskPackage, Z_IUUpdate::taskPackage, bend_esrequest_rr::taskPackage, Z_IUTargetPart::taskPackageRecords, Z_TaskPackage::taskSpecificParameters, Z_ExtendedServicesRequest::taskSpecificParameters, Z_TaskPackage::taskStatus, Z_IORequest::toKeep, Z_IUUpdateEsRequest::toKeep, Z_IOItemOrder::u, Z_IUUpdate::u, Z_External::u, Z_IUTaskPackageRecordStructure::u, Z_External::update, Z_IUTargetPart::updateStatus, Z_TaskPackage::userId, Z_ExtendedServicesRequest::waitAction, Z_IOItemOrder::which, Z_External::which, Z_IUUpdate::which, Z_IUTaskPackageRecordStructure::which, YAZ_BIB1_DATABASE_UNAVAILABLE, yaz_log(), yaz_log_file(), yaz_oid_general_isoill_1, yaz_oid_recsyn_xml, yaz_oid_to_string_buf(), z_ext_record_sutrs(), z_ext_record_xml(), Z_External_itemOrder, Z_External_octet, Z_External_sutrs, Z_External_update, Z_IOItemOrder_esRequest, Z_IOItemOrder_taskPackage, Z_IUOriginPartToKeep_elementUpdate, Z_IUOriginPartToKeep_recordDelete, Z_IUOriginPartToKeep_recordInsert, Z_IUOriginPartToKeep_recordReplace, Z_IUOriginPartToKeep_specialUpdate, Z_IUTaskPackageRecordStructure_record, Z_IUTaskPackageRecordStructure_success, Z_IUUpdate_esRequest, and Z_IUUpdate_taskPackage.

Referenced by bend_init().

int ztest_explain ( void *  handle,
bend_explain_rr rr 

Definition at line 1096 of file ztest.c.

References bend_explain_rr::database, and bend_explain_rr::explain_buf.

Referenced by bend_init().

int ztest_fetch ( void *  handle,
bend_fetch_rr r 
int ztest_present ( void *  handle,
bend_present_rr rr 
int ztest_scan ( void *  handle,
bend_scan_rr q 
int ztest_search ( void *  handle,
bend_search_rr rr 
static void ztest_sleep ( double  d)

Definition at line 228 of file ztest.c.

Referenced by do_delay().

int ztest_sort ( void *  handle,
bend_sort_rr rr 

Definition at line 803 of file ztest.c.

References bend_sort_rr::errcode, bend_sort_rr::sort_status, and Z_SortResponse_success.

Referenced by bend_init().

int ztest_update ( void *  handle,
bend_update_rr rr 

Definition at line 1110 of file ztest.c.

References bend_update_rr::operation_status.

Referenced by bend_init().

Variable Documentation

int log_level =0

Definition at line 40 of file ztest.c.

Referenced by bend_init(), and ztest_esrequest().

int log_level_set =0

Definition at line 41 of file ztest.c.

Referenced by bend_init().