{
/* odr is a handle to memory assocated with RETURNED data from
various functions */
- ODR odr;
+ ODR odr_input, odr_output;
/* zh is our Zebra Handle - describes the server as a whole */
ZebraHandle zh;
nmem_init ();
- odr = odr_createmem (ODR_ENCODE);
+ odr_input = odr_createmem (ODR_DECODE);
+ odr_output = odr_createmem (ODR_ENCODE);
/* open Zebra */
zh = zebra_open ("zebra.cfg");
for (argno = 1; argno < argc; argno++)
{
/* parse the query and generate an RPN structure */
- Z_RPNQuery *query = p_query_rpn (odr, PROTO_Z3950, argv[argno]);
+ Z_RPNQuery *query = p_query_rpn (odr_input, PROTO_Z3950, argv[argno]);
char setname[64];
int errCode;
int i;
if (!query)
{
logf (LOG_WARN, "bad query %s\n", argv[argno]);
- odr_reset (odr);
+ odr_reset (odr_input);
continue;
}
sprintf (setname, "%d", i);
/* fire up the search */
- zebra_search_rpn (zh, odr, query, 1, &base, setname);
+ zebra_search_rpn (zh, odr_input, odr_output, query, 1, &base, setname);
/* status ... */
errCode = zebra_errCode (zh);
noOfRecordsToFetch = zebra_hits(zh);
/* reset our memory - we've finished dealing with search */
- odr_reset (odr);
+ odr_reset (odr_input);
+ odr_reset (odr_output);
/* prepare to fetch ... */
- records = malloc (sizeof(*records) * noOfRecordsToFetch);
+ records = odr_malloc (odr_input, sizeof(*records) * noOfRecordsToFetch);
/* specify position of each record to fetch */
/* first one is numbered 1 and NOT 0 */
for (i = 0; i<noOfRecordsToFetch; i++)
records[i].position = i+1;
/* fetch them and request for GRS-1 records */
- zebra_records_retrieve (zh, odr, setname, NULL, VAL_GRS1,
+ zebra_records_retrieve (zh, odr_input, setname, NULL, VAL_GRS1,
noOfRecordsToFetch, records);
/* status ... */
}
}
}
- free (records);
- odr_reset (odr); /* reset memory */
+ /* reset our memory - we've finished dealing with present */
+ odr_reset (odr_input);
+ odr_reset (odr_output);
}
+ odr_destroy (odr_input);
+ odr_destroy (odr_output);
+ zebra_close (zh);
return 0;
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zebraapi.h,v $
- * Revision 1.4 1998-09-02 13:53:18 adam
+ * Revision 1.5 1998-09-22 10:48:19 adam
+ * Minor changes in search API.
+ *
+ * Revision 1.4 1998/09/02 13:53:18 adam
* Extra parameter decode added to search routines to implement
* persistent queries.
*
YAZ_EXPORT ZebraHandle zebra_open (const char *configName);
/* Search using RPN-Query */
-YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR stream, ODR decode,
+YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR input, ODR output,
Z_RPNQuery *query, int num_bases, char **basenames,
const char *setname);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.85 1998-09-22 10:03:43 adam
+ * Revision 1.86 1998-09-22 10:48:20 adam
+ * Minor changes in search API.
+ *
+ * Revision 1.85 1998/09/22 10:03:43 adam
* Changed result sets to be persistent in the sense that they can
* be re-searched if needed.
* Fixed memory leak in rsm_or.
Z_SortKeySpecList *sort_sequence;
int sort_status, i;
- zlog_rpn (rpn);
-
zh->errCode = 0;
zh->errString = NULL;
zh->hits = 0;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.63 1998-09-02 13:53:21 adam
+ * Revision 1.64 1998-09-22 10:48:21 adam
+ * Minor changes in search API.
+ *
+ * Revision 1.63 1998/09/02 13:53:21 adam
* Extra parameter decode added to search routines to implement
* persistent queries.
*
switch (q->query->which)
{
case Z_Query_type_1: case Z_Query_type_101:
- zebra_search_rpn (zh, q->stream, q->decode, q->query->u.type_1,
+ zebra_search_rpn (zh, q->decode, q->stream, q->query->u.type_1,
q->num_bases, q->basenames, q->setname);
r->errcode = zh->errCode;
r->errstring = zh->errString;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zsets.c,v $
- * Revision 1.18 1998-09-22 10:03:45 adam
+ * Revision 1.19 1998-09-22 10:48:22 adam
+ * Minor changes in search API.
+ *
+ * Revision 1.18 1998/09/22 10:03:45 adam
* Changed result sets to be persistent in the sense that they can
* be re-searched if needed.
* Fixed memory leak in rsm_or.
struct zset_sort_entry **entries;
};
-ZebraSet resultSetAddRPN (ZebraHandle zh, ODR stream, ODR decode,
+ZebraSet resultSetAddRPN (ZebraHandle zh, ODR input, ODR output,
Z_RPNQuery *rpn, int num_bases, char **basenames,
const char *setname)
{
zebraSet->rpn = 0;
zebraSet->num_bases = num_bases;
zebraSet->basenames = basenames;
- zebraSet->nmem = odr_extract_mem (decode);
+ zebraSet->nmem = odr_extract_mem (input);
- zebraSet->rset = rpn_search (zh, stream->mem, rpn,
+ zebraSet->rset = rpn_search (zh, output->mem, rpn,
zebraSet->num_bases,
zebraSet->basenames, zebraSet->name,
zebraSet);