<commit_before>/*
 * Copyright (c) 1995-2002, Index Data
 * See the file LICENSE for details.
 *
 * $Id: client.c,v 1.147 2002-03-20 14:35:42 adam Exp $
 */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <yaz/yaz-util.h>

#include <yaz/tcpip.h>
#ifdef USE_XTIMOSI
#include <yaz/xmosi.h>
#endif

#include <yaz/proto.h>
#include <yaz/marcdisp.h>
#include <yaz/diagbib1.h>
#include <yaz/otherinfo.h>

#include <yaz/pquery.h>
#include <yaz/sortspec.h>

#if YAZ_MODULE_ill
#include <yaz/ill.h>
#endif

#if YAZ_MODULE_ccl
#include <yaz/yaz-ccl.h>
#endif

#if HAVE_READLINE_READLINE_H
#include <readline/readline.h>
#endif
#if HAVE_READLINE_HISTORY_H
#include <readline/history.h>
#endif

#include <sys/stat.h>


#include "admin.h"
#include "tabcomplete.h"

#define C_PROMPT "Z> "

static ODR out, in, print;              /* encoding and decoding streams */
static FILE *apdu_file = 0;
static COMSTACK conn = 0;               /* our z-association */
static Z_IdAuthentication *auth = 0;    /* our current auth definition */
char *databaseNames[128];
int num_databaseNames = 0;
static Z_External *record_last = 0;
static int setnumber = -1;               /* current result set number */
static int smallSetUpperBound = 0;
static int largeSetLowerBound = 1;
static int mediumSetPresentNumber = 0;
static Z_ElementSetNames *elementSetNames = 0; 
static int setno = 1;                   /* current set offset */
static enum oid_proto protocol = PROTO_Z3950;      /* current app protocol */
static enum oid_value recordsyntax = VAL_USMARC;
static enum oid_value schema = VAL_NONE;
static int sent_close = 0;
static NMEM session_mem = NULL;      /* memory handle for init-response */
static Z_InitResponse *session = 0;     /* session parameters */
static char last_scan_line[512] = "0";
static char last_scan_query[512] = "0";
static char ccl_fields[512] = "default.bib";
static char* esPackageName = 0;
static char* yazProxy = 0;
static int kilobytes = 1024;

static char last_cmd[32] = "?";
static FILE *marcdump = 0;
static char *refid = NULL;

typedef enum {
    QueryType_Prefix,
    QueryType_CCL,
    QueryType_CCL2RPN
} QueryType;

static QueryType queryType = QueryType_Prefix;

#if YAZ_MODULE_ccl
static CCL_bibset bibset;               /* CCL bibset handle */
#endif


/* set this one to 1, to avoid decode of unknown MARCs  */
#define AVOID_MARC_DECODE 1

/* nice helper macro as extensive tabbing gives spaces at the en of the args lines */
#define REMOVE_TAILING_BLANKS(a) {\
  char* args_end=(a)+strlen(a)-1; \
  while(isspace(*args_end)) {*args_end=0;--args_end;}; \<commit_msg>Fix for old readline<commit_after>/*
 * Copyright (c) 1995-2002, Index Data
 * See the file LICENSE for details.
 *
 * $Id: client.c,v 1.148 2002-04-08 11:40:41 adam Exp $
 */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <yaz/yaz-util.h>

#include <yaz/tcpip.h>
#ifdef USE_XTIMOSI
#include <yaz/xmosi.h>
#endif

#include <yaz/proto.h>
#include <yaz/marcdisp.h>
#include <yaz/diagbib1.h>
#include <yaz/otherinfo.h>

#include <yaz/pquery.h>
#include <yaz/sortspec.h>

#if YAZ_MODULE_ill
#include <yaz/ill.h>
#endif

#if YAZ_MODULE_ccl
#include <yaz/yaz-ccl.h>
#endif

#if HAVE_READLINE_READLINE_H
#include <readline/readline.h>
#endif
#if HAVE_READLINE_HISTORY_H
#include <readline/history.h>
#endif

#include <sys/stat.h>


#include "admin.h"
#include "tabcomplete.h"

#define C_PROMPT "Z> "

static ODR out, in, print;              /* encoding and decoding streams */
static FILE *apdu_file = 0;
static COMSTACK conn = 0;               /* our z-association */
static Z_IdAuthentication *auth = 0;    /* our current auth definition */
char *databaseNames[128];
int num_databaseNames = 0;
static Z_External *record_last = 0;
static int setnumber = -1;               /* current result set number */
static int smallSetUpperBound = 0;
static int largeSetLowerBound = 1;
static int mediumSetPresentNumber = 0;
static Z_ElementSetNames *elementSetNames = 0; 
static int setno = 1;                   /* current set offset */
static enum oid_proto protocol = PROTO_Z3950;      /* current app protocol */
static enum oid_value recordsyntax = VAL_USMARC;
static enum oid_value schema = VAL_NONE;
static int sent_close = 0;
static NMEM session_mem = NULL;      /* memory handle for init-response */
static Z_InitResponse *session = 0;     /* session parameters */
static char last_scan_line[512] = "0";
static char last_scan_query[512] = "0";
static char ccl_fields[512] = "default.bib";
static char* esPackageName = 0;
static char* yazProxy = 0;
static int kilobytes = 1024;

static char last_cmd[32] = "?";
static FILE *marcdump = 0;
static char *refid = NULL;

typedef enum {
    QueryType_Prefix,
    QueryType_CCL,
    QueryType_CCL2RPN
} QueryType;

static QueryType queryType = QueryType_Prefix;

#if YAZ_MODULE_ccl
static CCL_bibset bibset;               /* CCL bibset handle */
#endif

#if HAVE_READLINE_READLINE_H
#ifndef RL_READLINE_VERSION
int rl_attempted_completion_over = 0;
#endif
#endif

/* set this one to 1, to avoid decode of unknown MARCs  */
#define AVOID_MARC_DECODE 1

/* nice helper macro as extensive tabbing gives spaces at the en of the args lines */
#define REMOVE_TAILING_BLANKS(a) {\
  char* args_end=(a)+strlen(a)-1; \
  while(isspace(*args_end)) {*args_end=0;--args_end;}; \
{'fraction_non_alphanumeric': 0.11649755730928223, 'fraction_numerical': 0.027245396467493424, 'mean_word_length': 3.901473296500921, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6461487', 'n_tokens_mistral': 2048, 'n_tokens_neox': 1891, 'n_words': 546}