pazpar2  1.6.30
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

Functions

static int client_use (int delta)
int clients_count (void)
int clients_count_total (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_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)
void client_check_preferred_watch (struct client *cl)
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)
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)
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 int apply_limit (struct session_database *sdb, 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)
int client_parse_sort (struct client *cl, struct reclist_sortparms *sp)
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 client_get_num_records_filtered (struct client *cl)
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 int no_clients_total = 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.

Function Documentation

static int apply_limit ( struct session_database sdb,
facet_limits_t  facet_limits,
WRBUF  w_pqf,
CCL_bibset  ccl_map,
struct conf_service service 
)
static
void client_check_preferred_watch ( struct client cl)
struct client* client_create ( const char *  id)
read
int client_destroy ( struct client c)
void client_disconnect ( struct client cl)
int client_fetch_more ( struct client cl)
Odr_int client_get_approximation ( struct client cl)

Definition at line 1587 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)
read
struct session_database* client_get_database ( struct client cl)
read
int client_get_diagnostic ( struct client cl,
const char **  message,
const char **  addinfo 
)

Definition at line 1623 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)

Definition at line 1582 of file client.c.

References client::hits.

Referenced by hitsbytarget_nb(), ingest_to_cluster(), show_range_start(), and statistics().

const char* client_get_id ( struct client cl)
int client_get_maxrecs ( struct client cl)

Definition at line 1673 of file client.c.

References client::maxrecs.

Referenced by ingest_to_cluster().

int client_get_num_records ( struct client cl)

Definition at line 1601 of file client.c.

References client::record_offset.

Referenced by hitsbytarget_nb().

int client_get_num_records_filtered ( struct client cl)

Definition at line 1606 of file client.c.

References client::filtered.

Referenced by hitsbytarget_nb().

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

Definition at line 176 of file client.c.

References client::state.

Referenced by client_prep_connection(), session_fetch_more(), session_sort_unlocked(), and statistics().

const char* client_get_state_str ( struct client cl)

Definition at line 171 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 1633 of file client.c.

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

Referenced by hitsbytarget_nb().

void client_got_records ( struct client cl)
int client_has_facet ( struct client cl,
const char *  name 
)
void client_incref ( struct client c)
int client_is_active ( struct client cl)
int client_is_active_preferred ( struct client cl)
void client_lock ( struct client c)
int client_parse_init ( struct client cl,
int  same_search 
)

Definition at line 819 of file client.c.

References client::same_search.

Referenced by session_search(), and session_sort_unlocked().

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

Definition at line 828 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 
)
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 1663 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 1611 of file client.c.

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

Referenced by 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 1678 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 181 of file client.c.

References client::state.

Referenced by 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 230 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 339 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 360 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 347 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)
struct suggestions * client_suggestions_create ( const char *  suggestions_string)
read
static void client_suggestions_destroy ( struct client cl)
static

Definition at line 1719 of file client.c.

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

Referenced by client_search_response().

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

Definition at line 767 of file client.c.

References client::show_stat_no.

Referenced by show_range_start().

static int client_use ( int  delta)
static

Definition at line 78 of file client.c.

References g_mutex, no_clients, and no_clients_total.

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

int clients_count ( void  )

Definition at line 94 of file client.c.

References client_use().

Referenced by cmd_server_status().

int clients_count_total ( void  )

Definition at line 99 of file client.c.

References g_mutex, and no_clients_total.

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 1148 of file client.c.

Referenced by client_parse_query().

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

Definition at line 1170 of file client.c.

Referenced by client_parse_query().

static int nativesyntax_to_type ( const char *  s,
char *  type,
ZOOM_record  rec 
)
static

Definition at line 412 of file client.c.

Referenced by client_record_ingest(), client_show_immediate(), and ingest_raw_record().

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 162 of file client.c.

Referenced by client_get_state_str().

YAZ_MUTEX g_mutex = 0
static

Definition at line 74 of file client.c.

Referenced by client_use(), and clients_count_total().

int no_clients = 0
static

Definition at line 75 of file client.c.

Referenced by client_use().

int no_clients_total = 0
static

Definition at line 76 of file client.c.

Referenced by client_use(), and clients_count_total().