+ struct ccl_rpn_node *rpn=NULL;
+
+
+ rpn = ccl_find_str(bibset, arg, &error, &pos);
+
+ if (error) {
+ int ioff = 3+strlen(last_cmd)+1+pos;
+ printf("%*s^ - ", ioff, " ");
+ 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;
+}
+
+
+int cmd_set_otherinfo(const char* args)
+{
+ char oidstr[101], otherinfoString[101];
+ int otherinfoNo;
+ int sscan_res;
+
+ sscan_res = sscanf(args, "%d %100[^ ] %100s",
+ &otherinfoNo, oidstr, otherinfoString);
+
+ if (sscan_res > 0 && otherinfoNo >= maxOtherInfosSupported) {
+ printf("Error otherinfo index too large (%d>=%d)\n",
+ otherinfoNo,maxOtherInfosSupported);
+ return 0;
+ }
+
+
+ if (sscan_res==1)
+ {
+ /* reset this otherinfo */
+ extraOtherInfos[otherinfoNo].oid[0] = -1;
+ xfree(extraOtherInfos[otherinfoNo].value);
+ extraOtherInfos[otherinfoNo].value = 0;
+ return 0;
+ }
+ if (sscan_res != 3) {
+ printf("Error in set_otherinfo command \n");
+ return 0;
+ }
+ else
+ {
+ NMEM oid_tmp = nmem_create();
+ const Odr_oid *oid =
+ yaz_string_to_oid_nmem(yaz_oid_std(),
+ CLASS_GENERAL, oidstr, oid_tmp);
+ oid_oidcpy(extraOtherInfos[otherinfoNo].oid, oid);
+
+ xfree(extraOtherInfos[otherinfoNo].value);
+ extraOtherInfos[otherinfoNo].value = xstrdup(otherinfoString);
+
+ nmem_destroy(oid_tmp);
+ }
+
+ return 0;
+}
+
+int cmd_sleep(const char* args )
+{
+ int sec=atoi(args);
+ if( sec > 0 ) {
+#ifdef WIN32
+ Sleep(sec*1000);
+#else
+ sleep(sec);
+#endif
+ printf("Done sleeping %d seconds\n", sec);
+ }
+ return 1;
+}
+
+int cmd_list_otherinfo(const char* args)
+{
+ int i;
+
+ if (strlen(args)>0)
+ {
+ i = atoi(args);
+ if (i >= maxOtherInfosSupported)
+ {
+ printf("Error otherinfo index to large (%d>%d)\n",i,maxOtherInfosSupported);
+ return 0;
+ }
+ if (extraOtherInfos[i].value)
+ {
+ char name_oid[OID_STR_MAX];
+ oid_class oclass;
+ const char *name =
+ yaz_oid_to_string_buf(extraOtherInfos[i].oid, &oclass,
+ name_oid);
+ printf(" otherinfo %d %s %s\n",
+ i, name ? name : "null",
+ extraOtherInfos[i].value);
+ }
+
+ }
+ else
+ {
+ for(i = 0; i < maxOtherInfosSupported; ++i)
+ {
+ if (extraOtherInfos[i].value)
+ {
+ char name_oid[OID_STR_MAX];
+ oid_class oclass;
+ const char *name =
+ yaz_oid_to_string_buf(extraOtherInfos[i].oid, &oclass,
+ name_oid);
+ printf(" otherinfo %d %s %s\n",
+ i, name ? name : "null",
+ extraOtherInfos[i].value);
+ }
+ }
+ }
+ return 0;
+}
+
+
+int cmd_list_all(const char* args) {
+ int i;
+
+ /* connection options */
+ if (conn)
+ printf("Connected to : %s\n", cur_host);
+ else if (*cur_host)
+ printf("Not connected to : %s\n", cur_host);
+ else
+ printf("Not connected : \n");
+ if (yazProxy) printf("using proxy : %s\n",yazProxy);
+
+ printf("auto_reconnect : %s\n",auto_reconnect?"on":"off");
+ printf("auto_wait : %s\n",auto_wait?"on":"off");
+
+ if (!auth) {
+ printf("Authentication : none\n");
+ } else {
+ switch(auth->which) {
+ case Z_IdAuthentication_idPass:
+ printf("Authentication : IdPass\n");
+ printf(" Login User : %s\n",auth->u.idPass->userId?auth->u.idPass->userId:"");
+ printf(" Login Group : %s\n",auth->u.idPass->groupId?auth->u.idPass->groupId:"");
+ printf(" Password : %s\n",auth->u.idPass->password?auth->u.idPass->password:"");
+ break;
+ case Z_IdAuthentication_open:
+ printf("Authentication : psOpen\n");
+ printf(" Open string : %s\n",auth->u.open);
+ break;
+ default:
+ printf("Authentication : Unknown\n");
+ }
+ }
+ if (negotiationCharset)
+ printf("Neg. Character set : `%s'\n", negotiationCharset);
+
+ /* bases */
+ printf("Bases : ");
+ for (i = 0; i<num_databaseNames; i++) printf("%s ",databaseNames[i]);
+ printf("\n");
+
+ /* Query options */
+ printf("CCL file : %s\n",ccl_fields);
+ printf("CQL file : %s\n",cql_fields);
+ printf("Query type : %s\n",query_type_as_string(queryType));
+
+ printf("Named Result Sets : %s\n",setnumber==-1?"off":"on");
+
+ /* piggy back options */
+ printf("ssub/lslb/mspn : %d/%d/%d\n",smallSetUpperBound,largeSetLowerBound,mediumSetPresentNumber);
+
+ /* print present related options */
+ if (recordsyntax_size > 0)
+ {
+ printf("Format : %s\n", recordsyntax_list[0]);
+ }
+ printf("Schema : %s\n",record_schema ? record_schema : "not set");
+ printf("Elements : %s\n",elementSetNames?elementSetNames->u.generic:"");
+
+ /* loging options */
+ printf("APDU log : %s\n",apdu_file?"on":"off");
+ printf("Record log : %s\n",marc_file?"on":"off");
+
+ /* other infos */
+ printf("Other Info: \n");
+ cmd_list_otherinfo("");
+
+ return 0;
+}
+
+int cmd_clear_otherinfo(const char* args)
+{
+ if(strlen(args)>0) {
+ int otherinfoNo = atoi(args);
+ if (otherinfoNo >= maxOtherInfosSupported) {
+ printf("Error otherinfo index too large (%d>=%d)\n",
+ otherinfoNo, maxOtherInfosSupported);
+ return 0;
+ }
+ if (extraOtherInfos[otherinfoNo].value)
+ {
+ /* only clear if set. */
+ extraOtherInfos[otherinfoNo].oid[0] = -1;
+ xfree(extraOtherInfos[otherinfoNo].value);
+ extraOtherInfos[otherinfoNo].value = 0;
+ }
+ } else {
+ int i;
+ for(i = 0; i < maxOtherInfosSupported; ++i)
+ {
+ if (extraOtherInfos[i].value)
+ {
+ extraOtherInfos[i].oid[0] = -1;
+ xfree(extraOtherInfos[i].value);
+ extraOtherInfos[i].value = 0;
+ }
+ }
+ }
+ return 0;
+}
+
+int cmd_wait_response(const char *arg)
+{
+ int wait_for = atoi(arg);
+ int i=0;
+ if( wait_for < 1 ) {
+ wait_for = 1;
+ };