X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=client%2Fclient.c;h=85063a57a531a12caf2805ec37e4f86e303512fc;hb=73453b196192a42ea0ef9c26e0a1a0cc759fd105;hp=035862d9d9f6fee9ef2f7d835cc10fd79199ad5e;hpb=a8fce80377e8bbbbbed33aa4d8927d1a53606f8a;p=yaz-moved-to-github.git diff --git a/client/client.c b/client/client.c index 035862d..85063a5 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * 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 $ + * $Id: client.c,v 1.153 2002-05-19 15:39:54 oleg Exp $ */ #include @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -72,6 +73,8 @@ static char ccl_fields[512] = "default.bib"; static char* esPackageName = 0; static char* yazProxy = 0; static int kilobytes = 1024; +static char* yazCharset = 0; +static char* yazLang = 0; static char last_cmd[32] = "?"; static FILE *marcdump = 0; @@ -89,6 +92,12 @@ static QueryType queryType = QueryType_Prefix; static CCL_bibset bibset; /* CCL bibset handle */ #endif +#if HAVE_READLINE_COMPLETION_OVER + +#else +/* readline doesn't have this var. Define it ourselves. */ +int rl_attempted_completion_over = 0; +#endif /* set this one to 1, to avoid decode of unknown MARCs */ #define AVOID_MARC_DECODE 1 @@ -198,6 +207,23 @@ static void send_initRequest(const char* type_and_host) yaz_oi_set_string_oidval(&req->otherInfo, out, VAL_PROXY, 1, type_and_host); + if (yazCharset || yazLang) { + Z_OtherInformation **p; + Z_OtherInformationUnit *p0; + + yaz_oi_APDU(apdu, &p); + + if (p0=yaz_oi_update(p, out, NULL, 0, 0)) { + ODR_MASK_SET(req->options, Z_Options_negotiationModel); + + p0->which = Z_OtherInfo_externallyDefinedInfo; + p0->information.externallyDefinedInfo = + yaz_set_proposal_charneg(out, + (const char**)&yazCharset, (yazCharset)?1:0, + (const char**)&yazLang, (yazLang)?1:0, 1); + } + } + send_apdu(apdu); printf("Sent initrequest.\n"); } @@ -275,6 +301,24 @@ static int process_initResponse(Z_InitResponse *res) if (ODR_MASK_GET(res->options, Z_Options_queryType104)) printf (" queryType104"); printf ("\n"); + + if (ODR_MASK_GET(res->options, Z_Options_negotiationModel)) { + + Z_CharSetandLanguageNegotiation *p = + yaz_get_charneg_record(res->otherInfo); + + if (p) { + + char *charset, *lang; + int selected; + + yaz_get_response_charneg(session_mem, p, &charset, &lang, &selected); + + printf("Accepted character set : `%s'\n", charset); + printf("Accepted code language : `%s'\n", lang); + printf("Accepted records in ...: %d\n", selected ); + } + } fflush (stdout); return 0; } @@ -2050,6 +2094,10 @@ int cmd_packagename(char* arg) int cmd_proxy(char* arg) { + if (*arg == '\0') { + printf("Current proxy is `%s'\n", (yazCharset)?yazProxy:NULL); + return 1; + } xfree (yazProxy); yazProxy = NULL; if (*arg) @@ -2060,6 +2108,38 @@ int cmd_proxy(char* arg) return 1; } +int cmd_charset(char* arg) +{ + if (*arg == '\0') { + printf("Current character set is `%s'\n", (yazCharset)?yazCharset:NULL); + return 1; + } + xfree (yazCharset); + yazCharset = NULL; + if (*arg) + { + yazCharset = (char *) xmalloc (strlen(arg)+1); + strcpy (yazCharset, arg); + } + return 1; +} + +int cmd_lang(char* arg) +{ + if (*arg == '\0') { + printf("Current language is `%s'\n", (yazLang)?yazLang:NULL); + return 1; + } + xfree (yazLang); + yazLang = NULL; + if (*arg) + { + yazLang = (char *) xmalloc (strlen(arg)+1); + strcpy (yazLang, arg); + } + return 1; +} + int cmd_source(char* arg) { /* first should open the file and read one line at a time.. */ @@ -2495,6 +2575,8 @@ static struct { {"update", cmd_update, "",NULL,0}, {"packagename", cmd_packagename, "",NULL,0}, {"proxy", cmd_proxy, "[('tcp'|'ssl')][':']",NULL,0}, + {"charset", cmd_charset, "",NULL,0}, + {"lang", cmd_lang, "",NULL,0}, {".", cmd_source, "",NULL,1}, {"!", cmd_subshell, "Subshell command",NULL,0}, {"set_apdufile", cmd_set_apdufile, "",NULL,0}, @@ -2601,7 +2683,7 @@ void process_cmd_line(char* line) { printf("Unknown command: %s.\n", word); cmd_help (""); - + res = 1; } if(apdu_file) fflush(apdu_file); @@ -2639,7 +2721,7 @@ char ** readline_completer(char *text, int start, int end) { #if HAVE_READLINE_READLINE_H if(start == 0) { -#ifdef RL_READLINE_VERSION +#if HAVE_READLINE_RL_COMPLETION_MATCHES char** res=rl_completion_matches(text, command_generator); #else @@ -2670,7 +2752,7 @@ char ** readline_completer(char *text, int start, int end) { if(!cmd[i].complete_filenames) rl_attempted_completion_over = 1; if(cmd[i].rl_completerfunction) { -#ifdef RL_READLINE_VERSION +#ifdef HAVE_READLINE_RL_COMPLETION_MATCHES char** res= rl_completion_matches(text, cmd[i].rl_completerfunction);