IDZEBRA  2.1.2
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

#define DEFAULTCONFIG   "./zebra.cfg"

Definition at line 54 of file zebrash.c.

#define DEFAULTDATABASE   "Default"

Definition at line 55 of file zebrash.c.

Referenced by cmd_create_database(), and cmd_select_database().

#define DEFAULTRESULTSET   "MyResultSet"

Definition at line 56 of file zebrash.c.

Referenced by cmd_find(), cmd_show(), and cmd_sort().

#define MAX_ARG_LEN   1024

Definition at line 52 of file zebrash.c.

Referenced by onecommand(), and shell().

#define MAX_NO_ARGS   32

Definition at line 50 of file zebrash.c.

Referenced by onecommand(), and split_args().

#define MAX_OUT_BUFF   4096

Definition at line 51 of file zebrash.c.

Referenced by shell().

#define PROMPT   "ZebraSh>"

Definition at line 53 of file zebrash.c.

Referenced by shell().

Function Documentation

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

Definition at line 337 of file zebrash.c.

References zebra_begin_trans().

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

Definition at line 320 of file zebrash.c.

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

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

Definition at line 328 of file zebrash.c.

References zebra_drop_database().

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

Definition at line 137 of file zebrash.c.

References restargs().

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

Definition at line 345 of file zebrash.c.

References zebra_end_trans().

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

Definition at line 276 of file zebrash.c.

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

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

Definition at line 296 of file zebrash.c.

References zebra_errAdd().

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

Definition at line 284 of file zebrash.c.

References zebra_errCode().

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

Definition at line 290 of file zebrash.c.

References zebra_errString().

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

Definition at line 375 of file zebrash.c.

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

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

Definition at line 707 of file zebrash.c.

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

Referenced by cmd_quit().

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

Definition at line 307 of file zebrash.c.

References zebra_init().

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

Definition at line 261 of file zebrash.c.

References defargint(), and restargs().

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

Definition at line 210 of file zebrash.c.

References log_level, and onecommand().

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

Definition at line 143 of file zebrash.c.

References cmd_help(), and onecommand().

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(), and ZINT_FORMAT.

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

Definition at line 400 of file zebrash.c.

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

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

Definition at line 313 of file zebrash.c.

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

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

Definition at line 434 of file zebrash.c.

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

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

Definition at line 473 of file zebrash.c.

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

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

Definition at line 237 of file zebrash.c.

References defarg().

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

Definition at line 245 of file zebrash.c.

References defargint().

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

Definition at line 253 of file zebrash.c.

References defarg().

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

Definition at line 201 of file zebrash.c.

References zebra_close().

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

Definition at line 192 of file zebrash.c.

References zebra_open().

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

Definition at line 165 of file zebrash.c.

References default_config, and zebra_start().

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

Definition at line 182 of file zebrash.c.

References zebra_stop().

static char* defarg ( char *  arg,
char *  def 
)
static
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().

int main ( int  argc,
char **  argv 
)

Definition at line 844 of file zebrash.c.

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

int onecommand ( char *  line,
WRBUF  outbuff,
const char *  prevout 
)
static char* restargs ( char *  args[],
int  n 
)
static
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().

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

Definition at line 76 of file zebrash.c.

References MAX_NO_ARGS.

Referenced by onecommand().

static void usage ( void  )
static

Definition at line 834 of file zebrash.c.

Referenced by main().

static void Zerrors ( WRBUF  outbuff)
static

Definition at line 750 of file zebrash.c.

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

Referenced by shell().

Variable Documentation

struct cmdstruct cmds[]

Definition at line 530 of file zebrash.c.

char* default_config = DEFAULTCONFIG
static

Definition at line 67 of file zebrash.c.

Referenced by cmd_zebra_start(), and main().

int log_level =0
static

Definition at line 68 of file zebrash.c.

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

int nextrecno =1

Definition at line 66 of file zebrash.c.

Referenced by cmd_find(), and cmd_show().

ZebraHandle zh =0
ZebraService zs =0