From: ja7 Date: Fri, 12 Jul 2002 12:20:34 +0000 (+0000) Subject: Added new command ccl_parse which parses a ccl find command X-Git-Tag: YAZ.1.8.8~17 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=f13b69ddee7417ad6430f6965982295e43ea687a;p=yaz-moved-to-github.git Added new command ccl_parse which parses a ccl find command and print the qpn query for the given ccl find command. Changed to not coredump when retriving octet_alingned record the client is unable to handle. now it just telles about the error and treats the octets as sutrs. --- diff --git a/client/client.c b/client/client.c index b54419f..8a7424f 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.160 2002-06-18 21:30:25 adam Exp $ + * $Id: client.c,v 1.161 2002-07-12 12:20:34 ja7 Exp $ */ #include @@ -596,17 +596,18 @@ static void display_record(Z_External *r) odr_perror(in, "Decoding constructed record."); fprintf(stderr, "[Near %d]\n", odr_offset(in)); fprintf(stderr, "Packet dump:\n---------\n"); - odr_dumpBER(stderr, (char*)r->u.octet_aligned->buf, - r->u.octet_aligned->len); + odr_dumpBER(stderr, (char*)r->u.octet_aligned->buf,r->u.octet_aligned->len); fprintf(stderr, "---------\n"); - exit(1); - } - /* - * Note: we throw away the original, BER-encoded record here. - * Do something else with it if you want to keep it. - */ - r->u.sutrs = (Z_SUTRS *) rr; /* we don't actually check the type here. */ - r->which = type->what; + + /* note just ignores the error ant print the bytes form the octet_aligned laiter */ + } else { + /* + * Note: we throw away the original, BER-encoded record here. + * Do something else with it if you want to keep it. + */ + r->u.sutrs = (Z_SUTRS *) rr; /* we don't actually check the type here. */ + r->which = type->what; + }; } } if (ent && ent->oclass != CLASS_RECSYN) @@ -2390,9 +2391,7 @@ void source_rcfile() static void initialize(void) { -#if YAZ_MODULE_ccl FILE *inf; -#endif if (!(out = odr_createmem(ODR_ENCODE)) || !(in = odr_createmem(ODR_DECODE)) || !(print = odr_createmem(ODR_PRINT))) @@ -2406,7 +2405,6 @@ static void initialize(void) if (apdu_file) odr_setprint(print, apdu_file); -#if YAZ_MODULE_ccl bibset = ccl_qual_mk (); inf = fopen (ccl_fields, "r"); if (inf) @@ -2414,7 +2412,6 @@ static void initialize(void) ccl_qual_file (bibset, inf); fclose (inf); } -#endif cmd_base("Default"); #if HAVE_READLINE_READLINE_H @@ -2541,6 +2538,33 @@ void wait_and_handle_responce() } +int cmd_cclparse(char* arg) { + int error, pos; + struct ccl_rpn_node *rpn=NULL; + + + rpn = ccl_find_str (bibset, arg, &error, &pos); + + if (error) { + printf ("%*s^ - ", 3+strlen(last_cmd)+1+pos, " "); + printf ("%s\n", ccl_err_msg (error)); + } + else + { + if (rpn) + { + ccl_pr_tree(rpn, stdout); + } + } + if (rpn) + ccl_rpn_delete(rpn); + + printf ("\n"); + + return 0; +}; + + static int cmd_help (char *line); typedef char *(*completerFunctionType)(const char *text, int state); @@ -2550,7 +2574,6 @@ static struct { int (*fun)(char *arg); char *ad; completerFunctionType rl_completerfunction; - //char *(*rl_completerfunction)(const char *text, int state); int complete_filenames; char **local_tabcompletes; } cmd[] = { @@ -2587,10 +2610,11 @@ static struct { {"!", cmd_subshell, "Subshell command",NULL,1,NULL}, {"set_apdufile", cmd_set_apdufile, "",NULL,1,NULL}, {"set_marcdump", cmd_set_marcdump," ",NULL,1,NULL}, - {"set_cclfiele", cmd_set_cclfields," ",NULL,1,NULL}, + {"set_cclfile", cmd_set_cclfields," ",NULL,1,NULL}, {"register_oid", cmd_register_oid," ",NULL,0,NULL}, {"push_command", cmd_push_command,"",command_generator,0,NULL}, {"register_tab", cmd_register_tab," ",command_generator,0,NULL}, + {"cclparse", cmd_cclparse,"",NULL,0,NULL}, /* Server Admin Functions */ {"adm-reindex", cmd_adm_reindex, "",NULL,0,NULL}, {"adm-truncate", cmd_adm_truncate, "('database'|'index')",NULL,0,NULL}, @@ -2688,6 +2712,7 @@ int cmd_register_tab(char* arg) { return 1; } + void process_cmd_line(char* line) { int i,res; @@ -2905,19 +2930,19 @@ int main(int argc, char **argv) exit (1); } break; - case 'c': - strncpy (ccl_fields, arg, sizeof(ccl_fields)-1); - ccl_fields[sizeof(ccl_fields)-1] = '\0'; - break; + case 'c': + strncpy (ccl_fields, arg, sizeof(ccl_fields)-1); + ccl_fields[sizeof(ccl_fields)-1] = '\0'; + break; case 'a': if (!strcmp(arg, "-")) apdu_file=stderr; else apdu_file=fopen(arg, "a"); break; - case 'p': - yazProxy=strdup(arg); - break; + case 'p': + yazProxy=strdup(arg); + break; case 'u': if (!auth_command) {