IDZEBRA  2.1.2
Data Structures | Macros | Functions | Variables
zebraapi.c File Reference
#include <assert.h>
#include <stdio.h>
#include <limits.h>
#include <yaz/diagbib1.h>
#include <yaz/pquery.h>
#include <yaz/sortspec.h>
#include "index.h"
#include "rank.h"
#include "orddict.h"
#include <charmap.h>
#include <idzebra/api.h>
#include <yaz/oid_db.h>

Go to the source code of this file.

Data Structures

struct  map_baseinfo
 

Macros

#define DEFAULT_APPROX_LIMIT   2000000000
 
#define ASSERTZH   assert(zh && zh->service)
 
#define ASSERTZHRES   assert(zh && zh->service && zh->res)
 
#define ASSERTZS   assert(zs)
 
#define ZEBRA_CHECK_HANDLE(zh)   if (zebra_check_handle(zh) != ZEBRA_OK) return ZEBRA_FAIL
 
#define ZEBRA_CHECK_DICT   1
 
#define ZEBRA_CHECK_ISAM   2
 

Functions

static void zebra_open_res (ZebraHandle zh)
 
static void zebra_close_res (ZebraHandle zh)
 
static ZEBRA_RES zebra_check_handle (ZebraHandle zh)
 
static int zebra_chdir (ZebraService zs)
 
static ZEBRA_RES zebra_flush_reg (ZebraHandle zh)
 
static struct zebra_registerzebra_register_open (ZebraService zs, const char *name, int rw, int useshadow, Res res, const char *reg_path)
 
static void zebra_register_close (ZebraService zs, struct zebra_register *reg)
 
const char * zebra_get_encoding (ZebraHandle zh)
 Returns character set encoding for session. More...
 
ZebraHandle zebra_open (ZebraService zs, Res res)
 Creates a Zebra session handle within service. More...
 
ZebraService zebra_start (const char *configName)
 Creates a Zebra Service. More...
 
ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res)
 Creates a Zebra service with resources. More...
 
void zebra_filter_info (ZebraService zs, void *cd, void(*cb)(void *cd, const char *name))
 Lists enabled Zebra filters. More...
 
void zebra_pidfname (ZebraService zs, char *path)
 
Dict dict_open_res (BFiles bfs, const char *name, int cache, int rw, int compact_flag, Res res)
 
ZEBRA_RES zebra_admin_shutdown (ZebraHandle zh)
 
ZEBRA_RES zebra_admin_start (ZebraHandle zh)
 
ZEBRA_RES zebra_stop (ZebraService zs)
 stops a Zebra service. More...
 
ZEBRA_RES zebra_close (ZebraHandle zh)
 Destroys Zebra session handle. More...
 
static void zebra_select_register (ZebraHandle zh, const char *new_reg)
 
void map_basenames_func (void *vp, const char *name, const char *value)
 
int zebra_select_default_database (ZebraHandle zh)
 
void map_basenames (ZebraHandle zh, ODR stream, int *num_bases, char ***basenames)
 
ZEBRA_RES zebra_select_database (ZebraHandle zh, const char *basename)
 
ZEBRA_RES zebra_select_databases (ZebraHandle zh, int num_bases, const char **basenames)
 
ZEBRA_RES zebra_set_approx_limit (ZebraHandle zh, zint approx_limit)
 Set limit before Zebra does approx hit count. More...
 
void zebra_set_partial_result (ZebraHandle zh)
 
ZEBRA_RES zebra_set_break_handler (ZebraHandle zh, int(*f)(void *client_data), void *client_data)
 
ZEBRA_RES zebra_search_RPN_x (ZebraHandle zh, ODR o, Z_RPNQuery *query, const char *setname, zint *hits, int *estimated_hit_count, int *partial_resultset)
 Search using RPN Query structure (from ASN.1) More...
 
ZEBRA_RES zebra_search_RPN (ZebraHandle zh, ODR o, Z_RPNQuery *query, const char *setname, zint *hits)
 Search using RPN Query structure (from ASN.1) More...
 
ZEBRA_RES zebra_records_retrieve (ZebraHandle zh, ODR stream, const char *setname, Z_RecordComposition *comp, const Odr_oid *input_format, int num_recs, ZebraRetrievalRecord *recs)
 Retrieve records from result set (after search) More...
 
ZEBRA_RES zebra_scan_PQF (ZebraHandle zh, ODR stream, const char *query, int *position, int *num_entries, ZebraScanEntry **entries, int *is_partial, const char *setname)
 performs Scan (taking PQF string) More...
 
ZEBRA_RES zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeset, int *position, int *num_entries, ZebraScanEntry **entries, int *is_partial, const char *setname)
 performs Scan (Z39.50 style) More...
 
ZEBRA_RES zebra_sort (ZebraHandle zh, ODR stream, int num_input_setnames, const char **input_setnames, const char *output_setname, Z_SortKeySpecList *sort_sequence, int *sort_status)
 
int zebra_deleteResultSet (ZebraHandle zh, int function, int num_setnames, char **setnames, int *statuses)
 Deletes one or more resultsets. More...
 
int zebra_errCode (ZebraHandle zh)
 Returns error code for last error. More...
 
const char * zebra_errString (ZebraHandle zh)
 Returns error string for last error. More...
 
char * zebra_errAdd (ZebraHandle zh)
 Returns additional info for last error. More...
 
ZEBRA_RES zebra_auth (ZebraHandle zh, const char *user, const char *pass)
 authenticate user. Returns 0 if OK, != 0 on failure More...
 
ZEBRA_RES zebra_admin_import_begin (ZebraHandle zh, const char *database, const char *record_type)
 
ZEBRA_RES zebra_admin_import_end (ZebraHandle zh)
 
ZEBRA_RES zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment)
 
int delete_w_handle (const char *info, void *handle)
 
int delete_w_all_handle (const char *info, void *handle)
 
static int delete_SU_handle (void *handle, int ord, const char *index_type, const char *string_index, zinfo_index_category_t cat)
 
ZEBRA_RES zebra_drop_database (ZebraHandle zh, const char *db)
 Deletes a database (drop) More...
 
ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *db)
 Creates a database. More...
 
int zebra_string_norm (ZebraHandle zh, const char *index_type, const char *input_str, int input_len, char *output_str, int output_len)
 Normalize zebra term for register (subject to change!) More...
 
static void zebra_set_state (ZebraHandle zh, int val, int seqno)
 set register state (state*.LCK) More...
 
static void zebra_get_state (ZebraHandle zh, char *val, int *seqno)
 
ZEBRA_RES zebra_begin_read (ZebraHandle zh)
 
ZEBRA_RES zebra_end_read (ZebraHandle zh)
 
static void read_res_for_transaction (ZebraHandle zh)
 
ZEBRA_RES zebra_begin_trans (ZebraHandle zh, int rw)
 
ZEBRA_RES zebra_end_trans (ZebraHandle zh)
 
ZEBRA_RES zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
 
ZEBRA_RES zebra_repository_update (ZebraHandle zh, const char *path)
 
ZEBRA_RES zebra_repository_delete (ZebraHandle zh, const char *path)
 
ZEBRA_RES zebra_repository_index (ZebraHandle zh, const char *path, enum zebra_recctrl_action_t action)
 
ZEBRA_RES zebra_repository_show (ZebraHandle zh, const char *path)
 
static ZEBRA_RES zebra_commit_ex (ZebraHandle zh, int clean_only)
 
ZEBRA_RES zebra_clean (ZebraHandle zh)
 
ZEBRA_RES zebra_commit (ZebraHandle zh)
 
ZEBRA_RES zebra_init (ZebraHandle zh)
 
ZEBRA_RES zebra_compact (ZebraHandle zh)
 
static ZEBRA_RES zebra_record_check (ZebraHandle zh, Record rec, zint *no_keys, int message_limit, unsigned flags, zint *no_long_dict_entries, zint *no_failed_dict_lookups, zint *no_invalid_keys, zint *no_invalid_dict_infos, zint *no_invalid_isam_entries)
 
ZEBRA_RES zebra_register_check (ZebraHandle zh, const char *spec)
 
void zebra_result (ZebraHandle zh, int *code, char **addinfo)
 Returns error code and additional info for last error. More...
 
void zebra_shadow_enable (ZebraHandle zh, int value)
 
ZEBRA_RES zebra_octet_term_encoding (ZebraHandle zh, const char *encoding)
 
ZEBRA_RES zebra_record_encoding (ZebraHandle zh, const char *encoding)
 
void zebra_set_resource (ZebraHandle zh, const char *name, const char *value)
 
const char * zebra_get_resource (ZebraHandle zh, const char *name, const char *defaultvalue)
 
int zebra_trans_no (ZebraHandle zh)
 
int zebra_get_shadow_enable (ZebraHandle zh)
 
void zebra_set_shadow_enable (ZebraHandle zh, int value)
 
ZEBRA_RES zebra_add_record (ZebraHandle zh, const char *buf, int buf_size)
 Simple update record. More...
 
ZEBRA_RES zebra_update_record (ZebraHandle zh, enum zebra_recctrl_action_t action, const char *recordType, zint *sysno, const char *match, const char *fname, const char *buf, int buf_size)
 Updates record. More...
 
ZEBRA_RES zebra_search_PQF (ZebraHandle zh, const char *pqf_query, const char *setname, zint *hits)
 Search using PQF Query String. More...
 
int zebra_sort_by_specstr (ZebraHandle zh, ODR stream, const char *sort_spec, const char *output_setname, const char **input_setnames)
 
struct BFiles_structzebra_get_bfs (ZebraHandle zh)
 
ZEBRA_RES zebra_set_limit (ZebraHandle zh, int complement_flag, zint *ids)
 
void zebra_setError (ZebraHandle zh, int code, const char *addinfo)
 
void zebra_setError_zint (ZebraHandle zh, int code, zint i)
 
void zebra_lock_prefix (Res res, char *path)
 

Variables

static int log_level = 0
 
static int log_level_initialized = 0
 

Macro Definition Documentation

#define ASSERTZH   assert(zh && zh->service)
#define ASSERTZHRES   assert(zh && zh->service && zh->res)

Definition at line 49 of file zebraapi.c.

Referenced by zebra_begin_trans().

#define ASSERTZS   assert(zs)
#define DEFAULT_APPROX_LIMIT   2000000000

Definition at line 45 of file zebraapi.c.

Referenced by zebra_open(), and zebra_set_approx_limit().

#define ZEBRA_CHECK_DICT   1

Definition at line 2203 of file zebraapi.c.

Referenced by zebra_record_check(), and zebra_register_check().

#define ZEBRA_CHECK_HANDLE (   zh)    if (zebra_check_handle(zh) != ZEBRA_OK) return ZEBRA_FAIL
#define ZEBRA_CHECK_ISAM   2

Definition at line 2204 of file zebraapi.c.

Referenced by zebra_record_check(), and zebra_register_check().

Function Documentation

static int delete_SU_handle ( void *  handle,
int  ord,
const char *  index_type,
const char *  string_index,
zinfo_index_category_t  cat 
)
static
int delete_w_all_handle ( const char *  info,
void *  handle 
)
int delete_w_handle ( const char *  info,
void *  handle 
)

Definition at line 1455 of file zebraapi.c.

References zebra_register::isamb, isamb_unlink(), and zebra_session::reg.

Referenced by delete_SU_handle(), and delete_w_all_handle().

Dict dict_open_res ( BFiles  bfs,
const char *  name,
int  cache,
int  rw,
int  compact_flag,
Res  res 
)

Definition at line 320 of file zebraapi.c.

References dict_open(), res_get_int(), and ZEBRA_OK.

Referenced by repositoryShow(), zebra_open_fmatch(), and zebra_register_open().

void map_basenames ( ZebraHandle  zh,
ODR  stream,
int *  num_bases,
char ***  basenames 
)
void map_basenames_func ( void *  vp,
const char *  name,
const char *  value 
)
static void read_res_for_transaction ( ZebraHandle  zh)
static
ZEBRA_RES zebra_add_record ( ZebraHandle  zh,
const char *  buf,
int  buf_size 
)

Simple update record.

Parameters
zhsession handle
bufrecord buffer
buf_sizerecord buffer size

This function is a simple wrapper or zebra_update_record with action=action_update (insert or replace) .

Definition at line 2599 of file zebraapi.c.

References action_update, and zebra_update_record().

ZEBRA_RES zebra_admin_import_begin ( ZebraHandle  zh,
const char *  database,
const char *  record_type 
)

Definition at line 1403 of file zebraapi.c.

References log_level, zebra_begin_trans(), ZEBRA_FAIL, and zebra_select_database().

Referenced by es_admin_request().

ZEBRA_RES zebra_admin_import_end ( ZebraHandle  zh)

Definition at line 1413 of file zebraapi.c.

References log_level, ZEBRA_CHECK_HANDLE, and zebra_end_trans().

Referenced by bend_segment().

ZEBRA_RES zebra_admin_import_segment ( ZebraHandle  zh,
Z_Segment *  segment 
)

Definition at line 1420 of file zebraapi.c.

References action_update, log_level, ZEBRA_CHECK_HANDLE, ZEBRA_FAIL, ZEBRA_OK, and zebra_update_record().

Referenced by bend_segment().

ZEBRA_RES zebra_admin_shutdown ( ZebraHandle  zh)
ZEBRA_RES zebra_admin_start ( ZebraHandle  zh)
ZEBRA_RES zebra_auth ( ZebraHandle  zh,
const char *  user,
const char *  pass 
)

authenticate user. Returns 0 if OK, != 0 on failure

Parameters
zhsession handle
useruser name
passpassword

Definition at line 1371 of file zebraapi.c.

References zebra_service::dbaccess, zebra_session::dbaccesslist, zebra_service::global_res, zebra_service::passwd_db, passwd_db_auth(), res_get(), zebra_session::service, zebra_session::user_perm, ZEBRA_CHECK_HANDLE, ZEBRA_FAIL, ZEBRA_OK, and zs.

Referenced by bend_init().

ZEBRA_RES zebra_begin_read ( ZebraHandle  zh)
ZEBRA_RES zebra_begin_trans ( ZebraHandle  zh,
int  rw 
)
static int zebra_chdir ( ZebraService  zs)
static

Definition at line 67 of file zebraapi.c.

References ASSERTZS, zebra_service::global_res, log_level, and res_get().

Referenced by zebra_register_close(), and zebra_start_res().

static ZEBRA_RES zebra_check_handle ( ZebraHandle  zh)
static

Definition at line 58 of file zebraapi.c.

References ZEBRA_FAIL, and ZEBRA_OK.

ZEBRA_RES zebra_clean ( ZebraHandle  zh)

Definition at line 2138 of file zebraapi.c.

References log_level, ZEBRA_CHECK_HANDLE, and zebra_commit_ex().

Referenced by main().

ZEBRA_RES zebra_close ( ZebraHandle  zh)
static void zebra_close_res ( ZebraHandle  zh)
static

Definition at line 750 of file zebraapi.c.

References ASSERTZH, zebra_session::errCode, zebra_session::res, and res_close().

Referenced by zebra_close(), and zebra_select_register().

ZEBRA_RES zebra_commit ( ZebraHandle  zh)

Definition at line 2145 of file zebraapi.c.

References log_level, ZEBRA_CHECK_HANDLE, and zebra_commit_ex().

Referenced by es_admin_request(), main(), and zebra_begin_trans().

static ZEBRA_RES zebra_commit_ex ( ZebraHandle  zh,
int  clean_only 
)
static
ZEBRA_RES zebra_compact ( ZebraHandle  zh)
ZEBRA_RES zebra_create_database ( ZebraHandle  zh,
const char *  db 
)

Creates a database.

Parameters
zhsession handle
dbdatabase to be created

Definition at line 1561 of file zebraapi.c.

References log_level, zebra_session::reg, zebra_begin_trans(), ZEBRA_CHECK_HANDLE, zebra_end_trans(), ZEBRA_FAIL, ZEBRA_OK, zebra_select_database(), zebra_setError(), zebraExplain_newDatabase(), and zebra_register::zei.

Referenced by cmd_create_database(), es_admin_request(), and main().

int zebra_deleteResultSet ( ZebraHandle  zh,
int  function,
int  num_setnames,
char **  setnames,
int *  statuses 
)

Deletes one or more resultsets.

Parameters
zhsession handle
functionZ_DeleteResultSetRequest_{list,all}
num_setnamesnumber of result sets
setnamesresult set names
statusesstatus result

Definition at line 1313 of file zebraapi.c.

References ASSERTZH, log_level, resultSetDestroy(), zebra_begin_read(), and zebra_end_read().

Referenced by bend_delete().

ZEBRA_RES zebra_drop_database ( ZebraHandle  zh,
const char *  db 
)
ZEBRA_RES zebra_end_read ( ZebraHandle  zh)
ZEBRA_RES zebra_end_trans ( ZebraHandle  zh)
ZEBRA_RES zebra_end_transaction ( ZebraHandle  zh,
ZebraTransactionStatus status 
)
char* zebra_errAdd ( ZebraHandle  zh)

Returns additional info for last error.

Parameters
zhzebra session handle.

Definition at line 1362 of file zebraapi.c.

References zebra_session::errString, and log_level.

Referenced by cmd_err(), cmd_erradd(), main(), and Zerrors().

int zebra_errCode ( ZebraHandle  zh)

Returns error code for last error.

Parameters
zhzebra session handle.

Definition at line 1342 of file zebraapi.c.

References zebra_session::errCode, and log_level.

Referenced by cmd_err(), cmd_errcode(), main(), and Zerrors().

const char* zebra_errString ( ZebraHandle  zh)

Returns error string for last error.

Parameters
zhzebra session handle.

Definition at line 1353 of file zebraapi.c.

References zebra_session::errCode, and log_level.

Referenced by cmd_err(), cmd_errstr(), main(), and Zerrors().

void zebra_filter_info ( ZebraService  zs,
void *  cd,
void(*)(void *cd, const char *name)  cb 
)

Lists enabled Zebra filters.

Parameters
zsservice handle
cdcallback parameter (opaque)
cbcallback function

Definition at line 305 of file zebraapi.c.

References ASSERTZS, zebra_service::record_classes, and recTypeClass_info().

Referenced by show_filters().

static ZEBRA_RES zebra_flush_reg ( ZebraHandle  zh)
static
struct BFiles_struct* zebra_get_bfs ( ZebraHandle  zh)

Definition at line 2732 of file zebraapi.c.

References zebra_register::bfs, and zebra_session::reg.

Referenced by zebra_register_statistics().

const char* zebra_get_encoding ( ZebraHandle  zh)

Returns character set encoding for session.

Parameters
zhzebra session handle.
Returns
encoding name (e.g. "iso-8859-1")

Definition at line 106 of file zebraapi.c.

References res_get_def(), and zebra_session::session_res.

Referenced by bend_init(), and zebra_open().

const char* zebra_get_resource ( ZebraHandle  zh,
const char *  name,
const char *  defaultvalue 
)

Definition at line 2564 of file zebraapi.c.

References ASSERTZH, log_level, zebra_session::res, and res_get_def().

Referenced by resultSetAdd().

int zebra_get_shadow_enable ( ZebraHandle  zh)

Definition at line 2585 of file zebraapi.c.

References ASSERTZH, log_level, and zebra_session::shadow_enable.

static void zebra_get_state ( ZebraHandle  zh,
char *  val,
int *  seqno 
)
static
ZEBRA_RES zebra_init ( ZebraHandle  zh)
void zebra_lock_prefix ( Res  res,
char *  path 
)

Definition at line 2773 of file zebraapi.c.

References res_get_def().

Referenced by zebra_pidfname().

ZEBRA_RES zebra_octet_term_encoding ( ZebraHandle  zh,
const char *  encoding 
)
ZebraHandle zebra_open ( ZebraService  zs,
Res  res 
)
static void zebra_open_res ( ZebraHandle  zh)
static
void zebra_pidfname ( ZebraService  zs,
char *  path 
)

Definition at line 313 of file zebraapi.c.

References ASSERTZS, zebra_service::global_res, and zebra_lock_prefix().

Referenced by bend_start(), and bend_stop().

static ZEBRA_RES zebra_record_check ( ZebraHandle  zh,
Record  rec,
zint no_keys,
int  message_limit,
unsigned  flags,
zint no_long_dict_entries,
zint no_failed_dict_lookups,
zint no_invalid_keys,
zint no_invalid_dict_infos,
zint no_invalid_isam_entries 
)
static
ZEBRA_RES zebra_record_encoding ( ZebraHandle  zh,
const char *  encoding 
)

Definition at line 2544 of file zebraapi.c.

References log_level, zebra_session::record_encoding, ZEBRA_CHECK_HANDLE, and ZEBRA_OK.

Referenced by bend_init().

ZEBRA_RES zebra_records_retrieve ( ZebraHandle  zh,
ODR  stream,
const char *  setname,
Z_RecordComposition *  comp,
const Odr_oid *  input_format,
int  num_recs,
ZebraRetrievalRecord recs 
)

Retrieve records from result set (after search)

Parameters
zhsession handle
streamallocate records returned using this ODR
setnamename of result set to retrieve records from
compZ39.50 record composition
input_formattransfer syntax (OID)
num_recsnumber of records to retrieve
recsstore records in this structure (size is num_recs)

Definition at line 1117 of file zebraapi.c.

References zebra_session::approx_limit, ZebraRetrievalRecord::base, ZebraRetrievalRecord::buf, ZebraMetaRecord::db, ZebraRetrievalRecord::errCode, ZebraRetrievalRecord::errString, ZebraRetrievalRecord::format, ZebraRetrievalRecord::len, log_level, zebra_session::res, ZebraRetrievalRecord::score, ZebraMetaRecord::score, ZebraRetrievalRecord::sysno, ZebraMetaRecord::sysno, ZebraMetaRecord::term, zebra_begin_read(), ZEBRA_CHECK_HANDLE, zebra_end_read(), ZEBRA_FAIL, zebra_meta_records_create(), zebra_meta_records_destroy(), ZEBRA_OK, zebra_record_fetch(), zebra_setError(), zebra_setError_zint(), zebra_snippets_create(), zebra_snippets_destroy(), and zebra_snippets_hit_vector().

Referenced by bend_fetch(), and cmd_show().

ZEBRA_RES zebra_register_check ( ZebraHandle  zh,
const char *  spec 
)
static void zebra_register_close ( ZebraService  zs,
struct zebra_register reg 
)
static
static struct zebra_register * zebra_register_open ( ZebraService  zs,
const char *  name,
int  rw,
int  useshadow,
Res  res,
const char *  reg_path 
)
static
ZEBRA_RES zebra_repository_delete ( ZebraHandle  zh,
const char *  path 
)

Definition at line 2011 of file zebraapi.c.

References action_delete, and zebra_repository_index().

ZEBRA_RES zebra_repository_index ( ZebraHandle  zh,
const char *  path,
enum zebra_recctrl_action_t  action 
)
ZEBRA_RES zebra_repository_show ( ZebraHandle  zh,
const char *  path 
)

Definition at line 2037 of file zebraapi.c.

References ASSERTZH, log_level, repositoryShow(), and ZEBRA_OK.

Referenced by main().

ZEBRA_RES zebra_repository_update ( ZebraHandle  zh,
const char *  path 
)

Definition at line 2006 of file zebraapi.c.

References action_update, and zebra_repository_index().

void zebra_result ( ZebraHandle  zh,
int *  code,
char **  addinfo 
)

Returns error code and additional info for last error.

Parameters
zhzebra session handle.
codepointer to returned error code
addinfopointer to returned additional info

Definition at line 2499 of file zebraapi.c.

References zebra_session::errCode, zebra_session::errString, and log_level.

Referenced by bend_esrequest(), bend_fetch(), bend_scan(), bend_search(), bend_sort(), and es_admin_request().

ZEBRA_RES zebra_scan ( ZebraHandle  zh,
ODR  stream,
Z_AttributesPlusTerm *  zapt,
const Odr_oid *  attributeset,
int *  position,
int *  num_entries,
ZebraScanEntry **  entries,
int *  is_partial,
const char *  setname 
)

performs Scan (Z39.50 style)

Parameters
zhsession handle
streamODR handle for result
zaptAttribute plus Term (start term)
attributesetAttributeset for Attribute plus Term
positioninput/output position
num_entriesnumber of terms requested / returned
entrieslist of resulting terms (ODR allocated)
is_partialupon return 1=partial, 0=complete
setnamelimit scan by this set (NULL means no limit)

Definition at line 1257 of file zebraapi.c.

References zebra_session::basenames, log_level, zebra_session::num_basenames, rpn_scan(), zebra_begin_read(), ZEBRA_CHECK_HANDLE, zebra_end_read(), and ZEBRA_FAIL.

Referenced by bend_scan(), and zebra_scan_PQF().

ZEBRA_RES zebra_scan_PQF ( ZebraHandle  zh,
ODR  stream,
const char *  query,
int *  position,
int *  num_entries,
ZebraScanEntry **  entries,
int *  is_partial,
const char *  setname 
)

performs Scan (taking PQF string)

Parameters
zhsession handle
streamODR handle for result
queryPQF scan query
positioninput/output position
num_entriesnumber of terms requested / returned
entrieslist of resulting terms (ODR allocated)
is_partialupon return 1=partial, 0=complete
setnamelimit scan by this set (NULL means no limit)

Definition at line 1231 of file zebraapi.c.

References zebra_session::errCode, ZEBRA_FAIL, and zebra_scan().

ZEBRA_RES zebra_search_PQF ( ZebraHandle  zh,
const char *  pqf_query,
const char *  setname,
zint hits 
)

Search using PQF Query String.

Parameters
zhsession handle
pqf_queryquery
setnamename of resultset
hitsof hits is returned

Definition at line 2650 of file zebraapi.c.

References zebra_session::errCode, log_level, ZEBRA_CHECK_HANDLE, ZEBRA_FAIL, ZEBRA_OK, zebra_search_RPN(), and ZINT_FORMAT.

Referenced by cmd_find(), and cmd_search_pqf().

ZEBRA_RES zebra_search_RPN ( ZebraHandle  zh,
ODR  o,
Z_RPNQuery *  query,
const char *  setname,
zint hits 
)

Search using RPN Query structure (from ASN.1)

Parameters
zhsession handle
oODR handle
queryRPN query using YAZ structure
setnamename of resultset
hitsnumber of hits is returned

Definition at line 1107 of file zebraapi.c.

References zebra_search_RPN_x().

Referenced by zebra_search_PQF().

ZEBRA_RES zebra_search_RPN_x ( ZebraHandle  zh,
ODR  o,
Z_RPNQuery *  query,
const char *  setname,
zint hits,
int *  estimated_hit_count,
int *  partial_resultset 
)

Search using RPN Query structure (from ASN.1)

Parameters
zhsession handle
oODR handle
queryRPN query using YAZ structure
setnamename of resultset
hitsnumber of hits is returned
estimated_hit_countwhether hit count is an estimate
partial_resultsetwhether result is only partially evaluated

Definition at line 1078 of file zebraapi.c.

References zebra_session::basenames, log_level, zebra_session::num_basenames, zebra_session::partial_result, resultSetAddRPN(), zebra_begin_read(), ZEBRA_CHECK_HANDLE, zebra_end_read(), and ZEBRA_FAIL.

Referenced by bend_search(), and zebra_search_RPN().

ZEBRA_RES zebra_select_database ( ZebraHandle  zh,
const char *  basename 
)
ZEBRA_RES zebra_select_databases ( ZebraHandle  zh,
int  num_bases,
const char **  basenames 
)
int zebra_select_default_database ( ZebraHandle  zh)
static void zebra_select_register ( ZebraHandle  zh,
const char *  new_reg 
)
static
ZEBRA_RES zebra_set_approx_limit ( ZebraHandle  zh,
zint  approx_limit 
)

Set limit before Zebra does approx hit count.

Parameters
zhsession handle
approx_limitthe limit

Results will be approximiate if hit count is greater than the limit specified. By default there is a high-limit (no limit).

Definition at line 1055 of file zebraapi.c.

References zebra_session::approx_limit, DEFAULT_APPROX_LIMIT, and ZEBRA_OK.

Referenced by zebra_select_register().

ZEBRA_RES zebra_set_break_handler ( ZebraHandle  zh,
int(*)(void *client_data)  f,
void *  client_data 
)

Definition at line 1069 of file zebraapi.c.

References zebra_session::break_handler_data, zebra_session::break_handler_func, and ZEBRA_OK.

Referenced by bend_search().

ZEBRA_RES zebra_set_limit ( ZebraHandle  zh,
int  complement_flag,
zint ids 
)
void zebra_set_partial_result ( ZebraHandle  zh)

Definition at line 1063 of file zebraapi.c.

References zebra_session::partial_result.

Referenced by numeric_relation(), and string_term().

void zebra_set_resource ( ZebraHandle  zh,
const char *  name,
const char *  value 
)

Definition at line 2555 of file zebraapi.c.

References ASSERTZH, log_level, zebra_session::res, and res_set().

void zebra_set_shadow_enable ( ZebraHandle  zh,
int  value 
)

Definition at line 2592 of file zebraapi.c.

References ASSERTZH, log_level, and zebra_session::shadow_enable.

static void zebra_set_state ( ZebraHandle  zh,
int  val,
int  seqno 
)
static

set register state (state*.LCK)

Parameters
zhZebra handle
valstate
seqnosequence number

val is one of: d=writing to shadow(shadow enabled); writing to register (shadow disabled) o=reading only c=commit (writing to register, reading from shadow, shadow mode only)

Definition at line 1620 of file zebraapi.c.

References ASSERTZH, log_level, zebra_session::reg_name, zebra_session::res, res_get(), and zebra_mk_fname().

Referenced by zebra_begin_trans(), zebra_commit_ex(), zebra_end_transaction(), and zebra_init().

void zebra_setError ( ZebraHandle  zh,
int  code,
const char *  addinfo 
)
void zebra_setError_zint ( ZebraHandle  zh,
int  code,
zint  i 
)
void zebra_shadow_enable ( ZebraHandle  zh,
int  value 
)

Definition at line 2514 of file zebraapi.c.

References ASSERTZH, log_level, and zebra_session::shadow_enable.

Referenced by main().

ZEBRA_RES zebra_sort ( ZebraHandle  zh,
ODR  stream,
int  num_input_setnames,
const char **  input_setnames,
const char *  output_setname,
Z_SortKeySpecList *  sort_sequence,
int *  sort_status 
)
int zebra_sort_by_specstr ( ZebraHandle  zh,
ODR  stream,
const char *  sort_spec,
const char *  output_setname,
const char **  input_setnames 
)
ZebraService zebra_start ( const char *  configName)

Creates a Zebra Service.

Parameters
configNamename of configuration file

This function is a simplified version of zebra_start_res.

Definition at line 191 of file zebraapi.c.

References zebra_start_res().

Referenced by cmd_zebra_start().

ZebraService zebra_start_res ( const char *  configName,
Res  def_res,
Res  over_res 
)

Creates a Zebra service with resources.

Parameters
configNamename of configuration file
def_resdefault resources
over_resoverriding resources

This function typically called once in a program. A Zebra Service acts as a factory for Zebra session handles.

Definition at line 196 of file zebraapi.c.

References zebra_service::dbaccess, zebra_service::global_res, log_level, log_level_initialized, zebra_service::nmem, zebra_service::passwd_db, passwd_db_file_crypt(), passwd_db_file_plain(), passwd_db_open(), zebra_service::path_root, zebra_service::record_classes, recTypeClass_create(), recTypeClass_load_modules(), res_close(), res_get(), res_open(), res_read_file(), zebra_service::session_lock, zebra_service::sessions, zebra_service::timing, zebra_chdir(), zebra_check_res(), zebra_flock_init(), zebra_get_version(), zebra_mutex_cond_init(), ZEBRA_OK, and zh.

Referenced by bend_start(), main(), and zebra_start().

ZEBRA_RES zebra_stop ( ZebraService  zs)
int zebra_string_norm ( ZebraHandle  zh,
const char *  index_type,
const char *  input_str,
int  input_len,
char *  output_str,
int  output_len 
)

Normalize zebra term for register (subject to change!)

Parameters
zhsession handle
index_type"w", "p",..
input_strinput string buffer
input_leninput string length
output_stroutput string buffer
output_lenoutput string length

Definition at line 1586 of file zebraapi.c.

References ASSERTZH, log_level, zebra_session::reg, zebra_map_get(), zebra_register::zebra_maps, and zebra_replace().

int zebra_trans_no ( ZebraHandle  zh)

Definition at line 2578 of file zebraapi.c.

References ASSERTZH, log_level, and zebra_session::trans_no.

ZEBRA_RES zebra_update_record ( ZebraHandle  zh,
enum zebra_recctrl_action_t  action,
const char *  recordType,
zint sysno,
const char *  match,
const char *  fname,
const char *  buf,
int  buf_size 
)

Updates record.

Parameters
zhsession handle
action(insert,replace,delete or update (replace/insert)
recordTypefilter type (0 indicates default)
sysnosystem id (0 may be passed for no known id)
matchmatch criteria (0 may be passed for no known criteria)
fnamefilename to be printed for logging (0 may be passed)
bufrecord buffer
buf_sizerecord buffer size

Definition at line 2610 of file zebraapi.c.

References log_level, zebra_begin_trans(), zebra_buffer_extract_record(), ZEBRA_CHECK_HANDLE, zebra_end_trans(), ZEBRA_FAIL, ZEBRA_OK, and ZINT_FORMAT.

Referenced by bend_esrequest(), cmd_exchange_record(), cmd_record_insert(), zebra_add_record(), and zebra_admin_import_segment().

Variable Documentation

int log_level = 0
static
int log_level_initialized = 0
static

Definition at line 53 of file zebraapi.c.

Referenced by zebra_open(), and zebra_start_res().