IDZEBRA  2.2.6
Data Structures | Macros | Functions | Variables
zebrash.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <idzebra/api.h>
#include <yaz/log.h>
#include <yaz/proto.h>
#include <yaz/sortspec.h>
#include <yaz/options.h>
#include <yaz/wrbuf.h>
#include <yaz/oid_db.h>

Go to the source code of this file.

Data Structures

struct  cmdstruct
 

Macros

#define MAX_NO_ARGS   32
 
#define MAX_OUT_BUFF   4096
 
#define MAX_ARG_LEN   1024
 
#define PROMPT   "ZebraSh>"
 
#define DEFAULTCONFIG   "./zebra.cfg"
 
#define DEFAULTDATABASE   "Default"
 
#define DEFAULTRESULTSET   "MyResultSet"
 

Functions

static int split_args (char *line, char **args)
 
static char * defarg (char *arg, char *def)
 
static int defargint (char *arg, int def)
 
static char * restargs (char *args[], int n)
 
int onecommand (char *line, WRBUF outbuff, const char *prevout)
 
int cmd_echo (char *args[], WRBUF outbuff)
 
int cmd_quit (char *args[], WRBUF outbuff)
 
static int cmd_help (char *args[], WRBUF outbuff)
 
static int cmd_zebra_start (char *args[], WRBUF outbuff)
 
static int cmd_zebra_stop (char *args[], WRBUF outbuff)
 
static int cmd_zebra_open (char *args[], WRBUF outbuff)
 
static int cmd_zebra_close (char *args[], WRBUF outbuff)
 
static int cmd_quickstart (char *args[], WRBUF outbuff)
 
static int cmd_yaz_log_file (char *args[], WRBUF outbuff)
 
static int cmd_yaz_log_level (char *args[], WRBUF outbuff)
 
static int cmd_yaz_log_prefix (char *args[], WRBUF outbuff)
 
static int cmd_logf (char *args[], WRBUF outbuff)
 
static int cmd_err (char *args[], WRBUF outbuff)
 
static int cmd_errcode (char *args[], WRBUF outbuff)
 
static int cmd_errstr (char *args[], WRBUF outbuff)
 
static int cmd_erradd (char *args[], WRBUF outbuff)
 
static int cmd_init (char *args[], WRBUF outbuff)
 
static int cmd_select_database (char *args[], WRBUF outbuff)
 
static int cmd_create_database (char *args[], WRBUF outbuff)
 
static int cmd_drop_database (char *args[], WRBUF outbuff)
 
static int cmd_begin_trans (char *args[], WRBUF outbuff)
 
static int cmd_end_trans (char *args[], WRBUF outbuff)
 
static int cmd_record_insert (char *args[], WRBUF outbuff)
 
static int cmd_exchange_record (char *args[], WRBUF outbuff)
 
static int cmd_search_pqf (char *args[], WRBUF outbuff)
 
static int cmd_find (char *args[], WRBUF outbuff)
 
static int cmd_show (char *args[], WRBUF outbuff)
 
static int cmd_sort (char *args[], WRBUF outbuff)
 
static void Zerrors (WRBUF outbuff)
 
void shell (void)
 
static void usage (void)
 
int main (int argc, char **argv)
 

Variables

ZebraService zs =0
 
ZebraHandle zh =0
 
int nextrecno =1
 
static char * default_config = DEFAULTCONFIG
 
static int log_level =0
 
struct cmdstruct cmds []
 

Macro Definition Documentation

◆ DEFAULTCONFIG

#define DEFAULTCONFIG   "./zebra.cfg"

Definition at line 54 of file zebrash.c.

◆ DEFAULTDATABASE

#define DEFAULTDATABASE   "Default"

Definition at line 55 of file zebrash.c.

◆ DEFAULTRESULTSET

#define DEFAULTRESULTSET   "MyResultSet"

Definition at line 56 of file zebrash.c.

◆ MAX_ARG_LEN

#define MAX_ARG_LEN   1024

Definition at line 52 of file zebrash.c.

◆ MAX_NO_ARGS

#define MAX_NO_ARGS   32

Definition at line 50 of file zebrash.c.

◆ MAX_OUT_BUFF

#define MAX_OUT_BUFF   4096

Definition at line 51 of file zebrash.c.

◆ PROMPT

#define PROMPT   "ZebraSh>"

Definition at line 53 of file zebrash.c.

Function Documentation

◆ cmd_begin_trans()

static int cmd_begin_trans ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 337 of file zebrash.c.

References zebra_begin_trans(), and zh.

◆ cmd_create_database()

static int cmd_create_database ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 320 of file zebrash.c.

References defarg(), DEFAULTDATABASE, zebra_create_database(), and zh.

◆ cmd_drop_database()

static int cmd_drop_database ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 328 of file zebrash.c.

References zebra_drop_database(), and zh.

◆ cmd_echo()

int cmd_echo ( char *  args[],
WRBUF  outbuff 
)

Definition at line 137 of file zebrash.c.

References restargs().

◆ cmd_end_trans()

static int cmd_end_trans ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 345 of file zebrash.c.

References zebra_end_trans(), and zh.

◆ cmd_err()

static int cmd_err ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 276 of file zebrash.c.

References zebra_errAdd(), zebra_errCode(), zebra_errString(), and zh.

◆ cmd_erradd()

static int cmd_erradd ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 296 of file zebrash.c.

References zebra_errAdd(), and zh.

◆ cmd_errcode()

static int cmd_errcode ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 284 of file zebrash.c.

References zebra_errCode(), and zh.

◆ cmd_errstr()

static int cmd_errstr ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 290 of file zebrash.c.

References zebra_errString(), and zh.

◆ cmd_exchange_record()

static int cmd_exchange_record ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 375 of file zebrash.c.

References action_update, onecommand(), restargs(), zebra_update_record(), and zh.

◆ cmd_find()

static int cmd_find ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 412 of file zebrash.c.

References DEFAULTRESULTSET, nextrecno, onecommand(), restargs(), zebra_search_PQF(), zh, and ZINT_FORMAT.

◆ cmd_help()

static int cmd_help ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 707 of file zebrash.c.

References cmdstruct::args, cmdstruct::cmd, cmds, and cmdstruct::explanation.

◆ cmd_init()

static int cmd_init ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 307 of file zebrash.c.

References zebra_init(), and zh.

◆ cmd_logf()

static int cmd_logf ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 261 of file zebrash.c.

References defargint(), and restargs().

◆ cmd_quickstart()

static int cmd_quickstart ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 210 of file zebrash.c.

References log_level, onecommand(), zh, and zs.

◆ cmd_quit()

int cmd_quit ( char *  args[],
WRBUF  outbuff 
)

Definition at line 143 of file zebrash.c.

References onecommand(), zh, and zs.

◆ cmd_record_insert()

static int cmd_record_insert ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 353 of file zebrash.c.

References action_insert, restargs(), zebra_update_record(), zh, and ZINT_FORMAT.

◆ cmd_search_pqf()

static int cmd_search_pqf ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 400 of file zebrash.c.

References restargs(), zebra_search_PQF(), zh, and ZINT_FORMAT.

◆ cmd_select_database()

static int cmd_select_database ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 313 of file zebrash.c.

References defarg(), DEFAULTDATABASE, zebra_select_database(), and zh.

◆ cmd_show()

static int cmd_show ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 434 of file zebrash.c.

References defarg(), defargint(), DEFAULTRESULTSET, nextrecno, zebra_records_retrieve(), and zh.

◆ cmd_sort()

static int cmd_sort ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 473 of file zebrash.c.

References DEFAULTRESULTSET, restargs(), zebra_sort(), and zh.

◆ cmd_yaz_log_file()

static int cmd_yaz_log_file ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 237 of file zebrash.c.

References defarg().

◆ cmd_yaz_log_level()

static int cmd_yaz_log_level ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 245 of file zebrash.c.

References defargint().

◆ cmd_yaz_log_prefix()

static int cmd_yaz_log_prefix ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 253 of file zebrash.c.

References defarg().

◆ cmd_zebra_close()

static int cmd_zebra_close ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 201 of file zebrash.c.

References zebra_close(), and zh.

◆ cmd_zebra_open()

static int cmd_zebra_open ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 192 of file zebrash.c.

References zebra_open(), zh, and zs.

◆ cmd_zebra_start()

static int cmd_zebra_start ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 165 of file zebrash.c.

References default_config, zebra_start(), and zs.

◆ cmd_zebra_stop()

static int cmd_zebra_stop ( char *  args[],
WRBUF  outbuff 
)
static

Definition at line 182 of file zebrash.c.

References zebra_stop(), and zs.

◆ defarg()

static char* defarg ( char *  arg,
char *  def 
)
static

◆ defargint()

static int defargint ( char *  arg,
int  def 
)
static

Definition at line 112 of file zebrash.c.

References defarg().

Referenced by cmd_logf(), cmd_show(), and cmd_yaz_log_level().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 844 of file zebrash.c.

References default_config, log_level, shell(), and usage().

◆ onecommand()

int onecommand ( char *  line,
WRBUF  outbuff,
const char *  prevout 
)

◆ restargs()

static char* restargs ( char *  args[],
int  n 
)
static

◆ shell()

void shell ( void  )

Definition at line 771 of file zebrash.c.

References log_level, MAX_ARG_LEN, MAX_OUT_BUFF, onecommand(), PROMPT, and Zerrors().

Referenced by main().

◆ split_args()

static int split_args ( char *  line,
char **  args 
)
static

Definition at line 76 of file zebrash.c.

References MAX_NO_ARGS.

Referenced by onecommand().

◆ usage()

static void usage ( void  )
static

Definition at line 834 of file zebrash.c.

Referenced by main().

◆ Zerrors()

static void Zerrors ( WRBUF  outbuff)
static

Definition at line 750 of file zebrash.c.

References log_level, zebra_errAdd(), zebra_errCode(), zebra_errString(), and zh.

Referenced by shell().

Variable Documentation

◆ cmds

struct cmdstruct cmds[]

Definition at line 473 of file zebrash.c.

Referenced by cmd_help(), and onecommand().

◆ default_config

char* default_config = DEFAULTCONFIG
static

Definition at line 67 of file zebrash.c.

Referenced by cmd_zebra_start(), and main().

◆ log_level

int log_level =0
static

Definition at line 68 of file zebrash.c.

Referenced by cmd_quickstart(), main(), onecommand(), shell(), and Zerrors().

◆ nextrecno

int nextrecno =1

Definition at line 66 of file zebrash.c.

Referenced by cmd_find(), and cmd_show().

◆ zh

ZebraHandle zh =0

Definition at line 64 of file zebrash.c.

Referenced by bend_delete(), bend_esrequest(), bend_fetch(), bend_init(), bend_scan(), bend_search(), bend_segment(), bend_sort(), check_log_limit(), cmd_begin_trans(), cmd_create_database(), cmd_drop_database(), cmd_end_trans(), cmd_err(), cmd_erradd(), cmd_errcode(), cmd_errstr(), cmd_exchange_record(), cmd_find(), cmd_init(), cmd_quickstart(), cmd_quit(), cmd_record_insert(), cmd_search_pqf(), cmd_select_database(), cmd_show(), cmd_sort(), cmd_zebra_close(), cmd_zebra_open(), delete_SU_handle(), delete_w_all_handle(), delete_w_handle(), es_admin(), es_admin_request(), extract_add_index_string(), extract_add_sort_string(), extract_flush_record_keys2(), extract_flush_sort_keys(), extract_get_fname_tmp(), extract_rec_keys_adjust(), extract_rec_keys_log(), extract_schema_add(), extract_set_store_data_cb(), extract_set_store_data_prepare(), extract_snippet(), extract_token_add(), facet_fetch(), file_update_r(), file_update_top(), fileDelete_r(), freq_term(), get_first_snippet_from_rset(), get_match_from_spec(), grep_info_prepare(), init_extractCtrl(), key_heap_init_file(), logRecord(), main(), map_basenames(), numeric_relation(), numeric_term(), perform_facet(), perform_facet_index(), perform_facet_sort(), print_dict_item(), print_rec_keys(), read_res_for_transaction(), repositoryExtract(), repositoryExtractR(), repositoryShow(), resultSetAdd(), resultSetAddRPN(), resultSetAddTerm(), resultSetClone(), resultSetDestroy(), resultSetGet(), resultSetGetBaseNames(), resultSetInsertRank(), resultSetInsertSort(), resultSetInvalidate(), resultSetRank(), resultSetRef(), resultSetSearch(), resultSetSort(), resultSetSortSingle(), rpn_get_top_approx_limit(), rpn_scan(), rpn_scan_norm(), rpn_search_APT(), rpn_search_APT_and_list(), rpn_search_APT_local(), rpn_search_APT_numeric(), rpn_search_APT_or_list(), rpn_search_APT_phrase(), rpn_search_database(), rpn_search_structure(), rpn_search_top(), rpn_search_xpath(), rset_trunc(), scan_save_set(), search_group(), search_position(), search_term(), search_terms(), search_terms_chrmap(), search_terms_list(), searchRecordKey(), snippet_check_fields(), snippet_fetch(), snippet_token_add(), snippet_xml_record(), sort_fetch(), special_index_fetch(), special_index_xml_record(), string_term(), term_collect_freq(), trans_scan_term(), xpath_trunc(), zapt_term_to_utf8(), zebra_add_record(), zebra_admin_import_begin(), zebra_admin_import_end(), zebra_admin_import_segment(), zebra_admin_shutdown(), zebra_admin_start(), zebra_apt_get_ord(), zebra_attr_list_get_ord(), zebra_auth(), zebra_begin_read(), zebra_begin_trans(), zebra_buffer_extract_record(), zebra_check_handle(), zebra_clean(), zebra_close(), zebra_close_res(), zebra_commit(), zebra_commit_ex(), zebra_compact(), zebra_create_database(), zebra_create_record_stream(), zebra_create_rset_isam(), zebra_deleteResultSet(), zebra_drop_database(), zebra_end_read(), zebra_end_trans(), zebra_end_transaction(), zebra_errAdd(), zebra_errCode(), zebra_errString(), zebra_extract_explain(), zebra_extract_file(), zebra_extract_record_stream(), zebra_extract_records_stream(), zebra_flush_reg(), zebra_get_bfs(), zebra_get_encoding(), zebra_get_rec_snippets(), zebra_get_resource(), zebra_get_shadow_enable(), zebra_get_state(), zebra_index_merge(), zebra_init(), zebra_it_key_str_dump(), zebra_key_control_create(), zebra_log_dict_entry(), zebra_meta_records_create(), zebra_meta_records_create_range(), zebra_meta_records_destroy(), zebra_octet_term_encoding(), zebra_open(), zebra_open_fmatch(), zebra_open_res(), zebra_rec_keys_to_snippets1(), zebra_recid_to_sysno(), zebra_record_check(), zebra_record_encoding(), zebra_record_fetch(), zebra_records_retrieve(), zebra_register_check(), zebra_register_statistics(), zebra_remove_file_match(), zebra_repository_delete(), zebra_repository_index(), zebra_repository_show(), zebra_repository_update(), zebra_result(), zebra_result_recid_to_sysno(), zebra_result_set_term_info(), zebra_result_set_term_no(), zebra_scan(), zebra_scan_PQF(), zebra_search_PQF(), zebra_search_RPN(), zebra_search_RPN_x(), zebra_select_database(), zebra_select_databases(), zebra_select_default_database(), zebra_select_register(), zebra_set_approx_limit(), zebra_set_break_handler(), zebra_set_limit(), zebra_set_partial_result(), zebra_set_resource(), zebra_set_shadow_enable(), zebra_set_state(), zebra_setError(), zebra_setError_zint(), zebra_shadow_enable(), zebra_snippets_hit_vector(), zebra_sort(), zebra_sort_by_specstr(), zebra_sort_get_ord(), zebra_special_fetch(), zebra_start_res(), zebra_string_norm(), zebra_term_untrans(), zebra_term_untrans_iconv(), zebra_term_untrans_iconv2(), zebra_trans_no(), zebra_update_file_match(), zebra_update_from_path(), zebra_update_record(), zebraRankLookup(), and Zerrors().

◆ zs

ZebraService zs =0