+static int cmd_show( char *args[], WRBUF outbuff)
+{
+ int start=defargint(args[1], nextrecno);
+ int nrecs=defargint(args[2],1);
+ char *setname=defarg(args[3],DEFAULTRESULTSET);
+ int rc=0;
+ ZebraRetrievalRecord *recs;
+ ODR odr;
+ Z_RecordComposition *pcomp=0;
+ int i;
+
+ odr = odr_createmem(ODR_ENCODE);
+ recs= odr_malloc(odr,sizeof(ZebraRetrievalRecord)*nrecs);
+ rc =z_RecordComposition(odr, &pcomp, 0,"recordComposition");
+
+ for (i=0;i<nrecs;i++)
+ recs[i].position=start+i;
+
+ rc = zebra_records_retrieve(zh, odr, setname,
+ pcomp, yaz_oid_recsyn_xml, nrecs,recs);
+ if (0==rc)
+ {
+ for (i=0;i<nrecs;i++)
+ {
+ printf("Err %d: %d\n",i,recs[i].errCode);
+ if (recs[i].buf)
+ {
+ wrbuf_printf(outbuff,"Record %d\n", recs[i].position);
+ wrbuf_write(outbuff, recs[i].buf, recs[i].len);
+ wrbuf_puts(outbuff, "\n");
+ } else
+ wrbuf_printf(outbuff,"NO Record %d\n", recs[i].position);
+ }
+ nextrecno=start+nrecs;
+ }
+ odr_destroy(odr);
+ return rc;
+} /* cmd_show */
+
+static int cmd_sort( char *args[], WRBUF outbuff)
+{
+ int rc=0;
+ ODR odr;
+ int sortstatus=0;
+ Z_SortKeySpecList *spec=0;
+ const char * inpsets[]={ DEFAULTRESULTSET, 0};
+ /* FIXME - allow the user to specify result sets in/out */
+
+ odr=odr_createmem(ODR_ENCODE);
+ spec=yaz_sort_spec (odr, restargs(args,1));
+ if (!spec)
+ rc=1;
+ if (!rc)
+ rc=zebra_sort(zh, odr,
+ 1, inpsets,
+ DEFAULTRESULTSET,
+ spec,
+ &sortstatus);
+ if (!rc)
+ wrbuf_printf(outbuff, "sort returned status %d\n",sortstatus);
+
+ odr_destroy(odr);
+ return rc;
+} /* cmd_sort */
+/*
+ *
+ * int bend_sort (void *handle, bend_sort_rr *rr)
+ * {
+ * ZebraHandle zh = (ZebraHandle) handle;
+ *
+ * zebra_sort (zh, rr->stream,
+ * rr->num_input_setnames, (const char **)
+ * rr->input_setnames,
+ * rr->output_setname,
+ * rr->sort_sequence,
+ * &rr->sort_status);
+ * zebra_result (zh, &rr->errcode,
+ * &rr->errstring);
+ * return 0;
+ * }
+ *
+ */