+ return zebra_update_record(zh, 0, &sysno, 0, 0, buf, buf_size, 0);
+}
+
+int zebra_insert_record (ZebraHandle zh,
+ const char *recordType,
+ int *sysno, const char *match, const char *fname,
+ const char *buf, int buf_size, int force_update)
+{
+ int res;
+ yaz_log(LOG_API,"zebra_insert_record sysno=%d", *sysno);
+
+ if (buf_size < 1) buf_size = strlen(buf);
+
+ if (zebra_begin_trans(zh, 1))
+ return 1;
+ res = buffer_extract_record (zh, buf, buf_size,
+ 0, /* delete_flag */
+ 0, /* test_mode */
+ recordType,
+ sysno,
+ match, fname,
+ 0,
+ 0); /* allow_update */
+ zebra_end_trans(zh);
+ return res;
+}
+
+int zebra_update_record (ZebraHandle zh,
+ const char *recordType,
+ int* sysno, const char *match, const char *fname,
+ const char *buf, int buf_size,
+ int force_update)
+{
+ int res;
+
+ yaz_log(LOG_API,"zebra_update_record sysno=%d", *sysno);
+
+ if (buf_size < 1) buf_size = strlen(buf);
+
+ if (zebra_begin_trans(zh, 1))
+ return 1;
+ res = buffer_extract_record (zh, buf, buf_size,
+ 0, /* delete_flag */
+ 0, /* test_mode */
+ recordType,
+ sysno,
+ match, fname,
+ force_update,
+ 1); /* allow_update */
+ yaz_log(LOG_LOG, "zebra_update_record returned res=%d", res);
+ zebra_end_trans(zh);
+ return res;
+}
+
+int zebra_delete_record (ZebraHandle zh,
+ const char *recordType,
+ int *sysno, const char *match, const char *fname,
+ const char *buf, int buf_size,
+ int force_update)
+{
+ int res;
+ yaz_log(LOG_API,"zebra_delete_record sysno=%d", *sysno);
+
+ if (buf_size < 1) buf_size = strlen(buf);
+
+ if (zebra_begin_trans(zh, 1))
+ return 1;
+ res = buffer_extract_record (zh, buf, buf_size,
+ 1, /* delete_flag */
+ 0, /* test_mode */
+ recordType,
+ sysno,
+ match,fname,
+ force_update,
+ 1); /* allow_update */
+ zebra_end_trans(zh);
+ return res;
+}
+
+/* ---------------------------------------------------------------------------
+ Searching
+*/
+
+int zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
+ const char *setname, int *numhits)
+{
+ int hits = 0;
+ int res=-1;
+ Z_RPNQuery *query;
+ ODR odr = odr_createmem(ODR_ENCODE);
+
+ yaz_log(LOG_API,"zebra_search_PQF s=%s q=%s",setname, pqf_query);
+
+ query = p_query_rpn (odr, PROTO_Z3950, pqf_query);
+
+ if (!query)
+ yaz_log (LOG_WARN, "bad query %s\n", pqf_query);
+ else
+ res=zebra_search_RPN (zh, odr, query, setname, &hits);
+
+ odr_destroy(odr);
+
+ yaz_log(LOG_API,"Hits: %d",hits);
+
+ if (numhits)
+ *numhits=hits;
+
+ return res;