pazpar2  1.13.0
Data Structures | Macros | Functions | Variables
client.c File Reference

Z39.50 client. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <assert.h>
#include <yaz/marcdisp.h>
#include <yaz/comstack.h>
#include <yaz/tcpip.h>
#include <yaz/proto.h>
#include <yaz/readconf.h>
#include <yaz/pquery.h>
#include <yaz/otherinfo.h>
#include <yaz/yaz-util.h>
#include <yaz/nmem.h>
#include <yaz/query-charset.h>
#include <yaz/querytowrbuf.h>
#include <yaz/oid_db.h>
#include <yaz/diagbib1.h>
#include <yaz/snprintf.h>
#include <yaz/rpn2cql.h>
#include <yaz/rpn2solr.h>
#include <yaz/gettimeofday.h>
#include "ppmutex.h"
#include "session.h"
#include "parameters.h"
#include "client.h"
#include "connection.h"
#include "settings.h"
#include "relevance.h"
#include "incref.h"

Go to the source code of this file.

Data Structures

struct  client
 Represents client state for a connection to one search target. More...
 
struct  suggestions
 
struct  show_raw
 

Macros

#define USE_TIMING   0
 
#define XDOC_CACHE_SIZE   100
 

Functions

static int client_use (int delta)
 
int clients_get_count (void)
 
const char * client_get_state_str (struct client *cl)
 
enum client_state client_get_state (struct client *cl)
 
void client_set_state_nb (struct client *cl, enum client_state st)
 
void client_set_state (struct client *cl, enum client_state st)
 
static void client_init_xdoc (struct client *cl)
 
static void client_destroy_xdoc (struct client *cl)
 
xmlDoc * client_get_xdoc (struct client *cl, int record_no)
 
void client_store_xdoc (struct client *cl, int record_no, xmlDoc *xdoc)
 
static void client_show_raw_error (struct client *cl, const char *addinfo)
 
struct connectionclient_get_connection (struct client *cl)
 
struct session_databaseclient_get_database (struct client *cl)
 
struct sessionclient_get_session (struct client *cl)
 
static void client_send_raw_present (struct client *cl)
 
static int nativesyntax_to_type (const char *s, char *type, ZOOM_record rec)
 
static void client_show_immediate (ZOOM_resultset resultset, struct session_database *sdb, int position, void *data, void(*error_handler)(void *data, const char *addinfo), void(*record_handler)(void *data, const char *buf, size_t sz), int binary, const char *nativesyntax)
 
int client_show_raw_begin (struct client *cl, int position, const char *syntax, const char *esn, void *data, void(*error_handler)(void *data, const char *addinfo), void(*record_handler)(void *data, const char *buf, size_t sz), int binary, const char *nativesyntax)
 
static void client_show_raw_delete (struct show_raw *r)
 
void client_show_raw_remove (struct client *cl, void *data)
 
static void client_show_raw_dequeue (struct client *cl)
 
static void client_report_facets (struct client *cl, ZOOM_resultset rs)
 
static void ingest_raw_record (struct client *cl, ZOOM_record rec)
 
struct suggestionsclient_suggestions_create (const char *suggestions_string)
 
static void client_suggestions_destroy (struct client *cl)
 
void client_search_response (struct client *cl)
 
void client_got_records (struct client *cl)
 
static void client_record_ingest (struct client *cl)
 
void client_record_response (struct client *cl, int *got_records)
 
int client_reingest (struct client *cl)
 
static void client_set_facets_request (struct client *cl, ZOOM_connection link)
 
int client_has_facet (struct client *cl, const char *name)
 
static const char * get_strategy_plus_sort (struct client *l, const char *field)
 
void client_update_show_stat (struct client *cl, int cmd)
 
int client_fetch_more (struct client *cl)
 
int client_parse_init (struct client *cl, int same_search)
 
int client_parse_range (struct client *cl, const char *startrecs, const char *maxrecs)
 
const char * client_get_query (struct client *cl, const char **type, NMEM nmem)
 
int client_start_search (struct client *cl)
 
struct clientclient_create (const char *id)
 
void client_lock (struct client *c)
 
void client_unlock (struct client *c)
 
void client_incref (struct client *c)
 
int client_destroy (struct client *c)
 
void client_set_connection (struct client *cl, struct connection *con)
 
void client_disconnect (struct client *cl)
 
void client_mark_dead (struct client *cl)
 
void client_stop (struct client *cl)
 
static CCL_bibset prepare_cclmap (struct client *cl, CCL_bibset base_bibset)
 
static char * make_cqlquery (struct client *cl, Z_RPNQuery *zquery)
 
static char * make_solrquery (struct client *cl, Z_RPNQuery *zquery)
 
const char * client_get_facet_limit_local (struct client *cl, struct session_database *sdb, int *l, NMEM nmem, int *num, char ***values)
 
static void ccl_quote_map_term (CCL_bibset ccl_map, WRBUF w, const char *term)
 
static int apply_limit (struct client *cl, facet_limits_t facet_limits, WRBUF w_pqf, CCL_bibset ccl_map, struct conf_service *service)
 
int client_parse_query (struct client *cl, const char *query, facet_limits_t facet_limits, const char **error_msg)
 
int client_parse_sort (struct client *cl, struct reclist_sortparms *sp, int *has_sortmap)
 
void client_set_session (struct client *cl, struct session *se)
 
int client_is_active (struct client *cl)
 
int client_is_active_preferred (struct client *cl)
 
Odr_int client_get_hits (struct client *cl)
 
Odr_int client_get_approximation (struct client *cl)
 
int client_get_num_records (struct client *cl, int *filtered, int *ingest, int *failed)
 
void client_set_diagnostic (struct client *cl, int diagnostic, const char *message, const char *addinfo)
 
int client_get_diagnostic (struct client *cl, const char **message, const char **addinfo)
 
const char * client_get_suggestions_xml (struct client *cl, WRBUF wrbuf)
 
void client_set_database (struct client *cl, struct session_database *db)
 
const char * client_get_id (struct client *cl)
 
int client_get_maxrecs (struct client *cl)
 
void client_set_preferred (struct client *cl, int v)
 

Variables

static YAZ_MUTEX g_mutex = 0
 
static int no_clients = 0
 
static const char * client_states []
 

Detailed Description

Z39.50 client.

Definition in file client.c.

Macro Definition Documentation

#define USE_TIMING   0

Definition at line 60 of file client.c.

#define XDOC_CACHE_SIZE   100

Definition at line 74 of file client.c.

Referenced by client_destroy_xdoc(), client_get_xdoc(), client_init_xdoc(), and client_store_xdoc().

Function Documentation

static int apply_limit ( struct client cl,
facet_limits_t  facet_limits,
WRBUF  w_pqf,
CCL_bibset  ccl_map,
struct conf_service service 
)
static
static void ccl_quote_map_term ( CCL_bibset  ccl_map,
WRBUF  w,
const char *  term 
)
static

Definition at line 1331 of file client.c.

Referenced by apply_limit().

struct client* client_create ( const char *  id)
int client_destroy ( struct client c)
static void client_destroy_xdoc ( struct client cl)
static

Definition at line 209 of file client.c.

References client::xdoc, and XDOC_CACHE_SIZE.

Referenced by client_destroy(), and client_start_search().

void client_disconnect ( struct client cl)
int client_fetch_more ( struct client cl)
Odr_int client_get_approximation ( struct client cl)

Definition at line 1751 of file client.c.

References client_get_id(), client::filtered, client::hits, and client::record_offset.

Referenced by hitsbytarget_nb(), and show_range_start().

struct connection* client_get_connection ( struct client cl)
struct session_database* client_get_database ( struct client cl)
int client_get_diagnostic ( struct client cl,
const char **  message,
const char **  addinfo 
)

Definition at line 1789 of file client.c.

References client::addinfo, client::diagnostic, and client::message.

Referenced by hitsbytarget_nb().

const char* client_get_facet_limit_local ( struct client cl,
struct session_database sdb,
int *  l,
NMEM  nmem,
int *  num,
char ***  values 
)
Odr_int client_get_hits ( struct client cl)
const char* client_get_id ( struct client cl)
int client_get_maxrecs ( struct client cl)

Definition at line 1838 of file client.c.

References client::maxrecs.

Referenced by ingest_to_cluster().

int client_get_num_records ( struct client cl,
int *  filtered,
int *  ingest,
int *  failed 
)
const char* client_get_query ( struct client cl,
const char **  type,
NMEM  nmem 
)

Definition at line 894 of file client.c.

References client::cqlquery, and client::pquery.

Referenced by hitsbytarget_nb().

struct session* client_get_session ( struct client cl)
enum client_state client_get_state ( struct client cl)

Definition at line 166 of file client.c.

References client::state.

Referenced by session_fetch_more(), session_sort(), and statistics().

const char* client_get_state_str ( struct client cl)

Definition at line 161 of file client.c.

References client_states, and client::state.

Referenced by hitsbytarget_nb(), and session_fetch_more().

const char* client_get_suggestions_xml ( struct client cl,
WRBUF  wrbuf 
)

Definition at line 1799 of file client.c.

References suggestions::num, suggestions::passthrough, and client::suggestions.

Referenced by hitsbytarget_nb().

xmlDoc* client_get_xdoc ( struct client cl,
int  record_no 
)

Definition at line 220 of file client.c.

References client::xdoc, and XDOC_CACHE_SIZE.

Referenced by client_record_ingest().

void client_got_records ( struct client cl)
int client_has_facet ( struct client cl,
const char *  name 
)
void client_incref ( struct client c)

Definition at line 1101 of file client.c.

References client_get_id(), client::mutex, pazpar2_incref(), and client::ref_count.

Referenced by client_set_connection().

static void client_init_xdoc ( struct client cl)
static

Definition at line 200 of file client.c.

References client::xdoc, and XDOC_CACHE_SIZE.

Referenced by client_create(), and client_start_search().

int client_is_active ( struct client cl)
int client_is_active_preferred ( struct client cl)
void client_lock ( struct client c)
void client_mark_dead ( struct client cl)

Definition at line 1170 of file client.c.

References client::connection, and connection_mark_dead().

Referenced by session_remove_cached_clients().

int client_parse_init ( struct client cl,
int  same_search 
)

Definition at line 867 of file client.c.

References client::same_search.

Referenced by session_search(), and session_sort().

int client_parse_query ( struct client cl,
const char *  query,
facet_limits_t  facet_limits,
const char **  error_msg 
)
int client_parse_range ( struct client cl,
const char *  startrecs,
const char *  maxrecs 
)

Definition at line 876 of file client.c.

References client::maxrecs, client::same_search, and client::startrecs.

Referenced by session_search().

int client_parse_sort ( struct client cl,
struct reclist_sortparms sp,
int *  has_sortmap 
)
static void client_record_ingest ( struct client cl)
static
void client_record_response ( struct client cl,
int *  got_records 
)
int client_reingest ( struct client cl)
static void client_report_facets ( struct client cl,
ZOOM_resultset  rs 
)
static
void client_search_response ( struct client cl)
static void client_send_raw_present ( struct client cl)
static
void client_set_connection ( struct client cl,
struct connection con 
)
void client_set_database ( struct client cl,
struct session_database db 
)

Definition at line 1828 of file client.c.

References client::database.

Referenced by select_targets_callback(), and session_remove_cached_clients().

void client_set_diagnostic ( struct client cl,
int  diagnostic,
const char *  message,
const char *  addinfo 
)

Definition at line 1777 of file client.c.

References client::addinfo, client::diagnostic, and client::message.

Referenced by connection_connect(), non_block_events(), and prepare_cclmap().

static void client_set_facets_request ( struct client cl,
ZOOM_connection  link 
)
static
void client_set_preferred ( struct client cl,
int  v 
)

Definition at line 1843 of file client.c.

References client::preferred.

void client_set_session ( struct client cl,
struct session se 
)
void client_set_state ( struct client cl,
enum client_state  st 
)
void client_set_state_nb ( struct client cl,
enum client_state  st 
)

Definition at line 171 of file client.c.

References client::state.

Referenced by connection_connect(), and prepare_cclmap().

static void client_show_immediate ( ZOOM_resultset  resultset,
struct session_database sdb,
int  position,
void *  data,
void(*)(void *data, const char *addinfo)  error_handler,
void(*)(void *data, const char *buf, size_t sz)  record_handler,
int  binary,
const char *  nativesyntax 
)
static

Definition at line 264 of file client.c.

References nativesyntax_to_type().

Referenced by client_show_raw_begin().

int client_show_raw_begin ( struct client cl,
int  position,
const char *  syntax,
const char *  esn,
void *  data,
void(*)(void *data, const char *addinfo)  error_handler,
void(*)(void *data, const char *buf, size_t sz)  record_handler,
int  binary,
const char *  nativesyntax 
)
static void client_show_raw_delete ( struct show_raw r)
static

Definition at line 373 of file client.c.

References show_raw::esn, show_raw::nativesyntax, and show_raw::syntax.

Referenced by client_show_raw_dequeue(), and client_show_raw_remove().

static void client_show_raw_dequeue ( struct client cl)
static

Definition at line 394 of file client.c.

References client_show_raw_delete(), show_raw::next, and client::show_raw.

Referenced by client_show_raw_error(), and ingest_raw_record().

static void client_show_raw_error ( struct client cl,
const char *  addinfo 
)
static
void client_show_raw_remove ( struct client cl,
void *  data 
)

Definition at line 381 of file client.c.

References client_show_raw_delete(), show_raw::data, show_raw::next, and client::show_raw.

int client_start_search ( struct client cl)
void client_stop ( struct client cl)
void client_store_xdoc ( struct client cl,
int  record_no,
xmlDoc *  xdoc 
)

Definition at line 228 of file client.c.

References client::addinfo, client_show_raw_error(), client::xdoc, and XDOC_CACHE_SIZE.

Referenced by ingest_record().

struct suggestions * client_suggestions_create ( const char *  suggestions_string)
static void client_suggestions_destroy ( struct client cl)
static

Definition at line 1884 of file client.c.

References suggestions::nmem, and client::suggestions.

Referenced by client_search_response(), and ingest_raw_record().

void client_unlock ( struct client c)
void client_update_show_stat ( struct client cl,
int  cmd 
)

Definition at line 814 of file client.c.

References client::show_stat_no.

Referenced by show_range_start().

static int client_use ( int  delta)
static

Definition at line 79 of file client.c.

References g_mutex, and no_clients.

Referenced by client_create(), client_destroy(), and clients_get_count().

int clients_get_count ( void  )

Definition at line 93 of file client.c.

References client_use().

Referenced by cmd_info().

static const char* get_strategy_plus_sort ( struct client l,
const char *  field 
)
static
static void ingest_raw_record ( struct client cl,
ZOOM_record  rec 
)
static
static char* make_cqlquery ( struct client cl,
Z_RPNQuery *  zquery 
)
static

Definition at line 1247 of file client.c.

Referenced by client_parse_query().

static char* make_solrquery ( struct client cl,
Z_RPNQuery *  zquery 
)
static

Definition at line 1269 of file client.c.

Referenced by client_parse_query().

static int nativesyntax_to_type ( const char *  s,
char *  type,
ZOOM_record  rec 
)
static
static CCL_bibset prepare_cclmap ( struct client cl,
CCL_bibset  base_bibset 
)
static

Variable Documentation

const char* client_states[]
static
Initial value:
= {
"Client_Connecting",
"Client_Idle",
"Client_Working",
"Client_Error",
"Client_Failed",
"Client_Disconnected"
}

Definition at line 152 of file client.c.

Referenced by client_get_state_str().

YAZ_MUTEX g_mutex = 0
static

Definition at line 76 of file client.c.

Referenced by client_use().

int no_clients = 0
static

Definition at line 77 of file client.c.

Referenced by client_use().