+ if (send_scanrequest(last_scan, 1, 20) < 0)
+ return 0;
+ return 2;
+}
+
+int cmd_format(char *arg)
+{
+ if (!arg || !*arg)
+ {
+ printf("Usage: format <recordsyntax>\n");
+ return 0;
+ }
+ if (!strcmp(arg, "sutrs"))
+ {
+ printf("Preferred format is SUTRS.\n");
+ recordsyntax = VAL_SUTRS;
+ return 1;
+ }
+ else if (!strcmp(arg, "usmarc"))
+ {
+ printf("Preferred format is USMARC\n");
+ recordsyntax = VAL_USMARC;
+ return 1;
+ }
+ else if (!strcmp(arg, "danmarc"))
+ {
+ printf("Preferred format is DANMARC\n");
+ recordsyntax = VAL_DANMARC;
+ return 1;
+ }
+ else if (!strcmp(arg, "grs1"))
+ {
+ printf("Preferred format is GRS1\n");
+ recordsyntax = VAL_GRS1;
+ return 1;
+ }
+ else if (!strcmp(arg, "explain"))
+ {
+ printf("Preferred format is Explain\n");
+ recordsyntax = VAL_EXPLAIN;
+ return 1;
+ }
+ else
+ {
+ printf("Specify one of {sutrs,usmarc,danmarc,grs1}.\n");
+ return 0;
+ }
+}
+
+int cmd_elements(char *arg)
+{
+ static Z_ElementSetNames esn;
+ static char what[100];
+
+ if (!arg || !*arg)
+ {
+ printf("Usage: elements <esn>\n");
+ return 0;
+ }
+ strcpy(what, arg);
+ esn.which = Z_ElementSetNames_generic;
+ esn.u.generic = what;
+ elementSetNames = &esn;
+ return 1;
+}
+
+int cmd_attributeset(char *arg)
+{
+ char what[100];
+ oid_value v;
+
+ if (!arg || !*arg)
+ {
+ printf("Usage: attributeset <setname>\n");
+ return 0;
+ }
+ sscanf(arg, "%s", what);
+ if ((v = oid_getvalbyname(what)) == VAL_NONE)
+ {
+ printf("Unknown attribute set name\n");
+ return 0;
+ }
+ attributeset = v;
+ return 1;
+}
+
+int cmd_querytype (char *arg)
+{
+ if (!strcmp (arg, "ccl"))
+ queryType = QueryType_CCL;
+ else if (!strcmp (arg, "prefix"))
+ queryType = QueryType_Prefix;
+#if CCL2RPN
+ else if (!strcmp (arg, "ccl2rpn") || !strcmp (arg, "cclrpn"))
+ queryType = QueryType_CCL2RPN;
+#endif
+ else
+ {
+ printf ("Querytype must be one of:\n");
+ printf (" prefix - Prefix query\n");
+ printf (" ccl - CCL query\n");
+#if CCL2RPN
+ printf (" ccl2rpn - CCL query converted to RPN\n");
+#endif
+ return 0;
+ }
+ return 1;
+}
+
+int cmd_close(char *arg)
+{
+ Z_APDU *apdu = zget_APDU(out, Z_APDU_close);
+ Z_Close *req = apdu->u.close;
+
+ *req->closeReason = Z_Close_finished;
+ send_apdu(apdu);
+ printf("Sent close request.\n");
+ sent_close = 1;