-/* $Id: ZOOM.xs,v 1.34 2005-12-19 17:46:52 mike Exp $ */
+/* $Id: ZOOM.xs,v 1.42 2006-06-15 15:43:13 mike Exp $ */
#include "EXTERN.h"
#include "perl.h"
const char* str
int
+ZOOM_query_cql2rpn(s, str, conn)
+ ZOOM_query s
+ const char* str
+ ZOOM_connection conn
+
+int
+ZOOM_query_ccl2rpn(s, query_str, config, errcode, errstr, errpos)
+ ZOOM_query s
+ const char* query_str
+ const char* config
+ int &errcode
+ const char* &errstr
+ int &errpos
+ OUTPUT:
+ RETVAL
+ errcode
+ errstr
+ errpos
+
+int
ZOOM_query_prefix(s, str)
ZOOM_query s
const char* str
const char * val
# UNTESTED
+#
+# This has to be called with a single argument which is a _reference_
+# to an array -- rather than directly with an array, which is of
+# course identical to passing arbitrarily many arguments. This is
+# because there doesn't seem to be a way to do varargs in an XS
+# function.
+#
int
-ZOOM_event(no, cs)
- int no
- ZOOM_connection * cs
+ZOOM_event(conns)
+ SV* conns
+ INIT:
+ SV *realconns;
+ I32 n, i;
+ int res;
+ ZOOM_connection cs[100];
+ CODE:
+ /*printf("* in ZOOM_event(%p)\n", conns);*/
+ if (!SvROK(conns)) {
+ /*printf("* argument is not a reference\n");*/
+ XSRETURN_IV(-1);
+ }
+ realconns = SvRV(conns);
+ /*printf("* realconns = %p\n", realconns);*/
+ if (SvTYPE(realconns) != SVt_PVAV) {
+ /*printf("* reference is not to an array\n");*/
+ XSRETURN_IV(-2);
+ }
+ n = av_len((AV*) realconns);
+ n++; /* The av_len() return-value is zero-based */
+ if (n == 0) {
+ /*printf("* No connections in referenced array\n");*/
+ XSRETURN_IV(-3);
+ } else if (n >= sizeof(cs)/sizeof(cs[0])) {
+ /*printf("* Too many connections (%d)\n", (int) n);*/
+ XSRETURN_IV(-4);
+ }
+
+ /*printf("* n = %d\n", n);*/
+ for (i = 0; i < n; i++) {
+ SV **connp = av_fetch((AV*) realconns, i, (I32) 0);
+ SV *conn, *sv;
+ /*printf("* %d of %d: connp = %p\n", (int) i, (int) n,connp);*/
+ assert(connp != 0);
+ conn = *connp;
+ /*printf("* conn = %p\n", conn);*/
+ /*
+ * From here on, the tests and assertions seem to
+ * be ignored: if I pass in a reference to
+ * something other than a ZOOM_connection, or even
+ * if I pass a non-reference, the assertions still
+ * pass and everything seems to work until the
+ * segmentation fault bites.
+ */
+ assert(sv_derived_from(conn, "ZOOM_connection"));
+ /*printf("* passed assert(isa(ZOOM_connection))\n");*/
+ assert(SvROK(conn));
+ /*printf("* passed assert SvROK()\n");*/
+ sv = (SV*) SvRV(conn);
+ /*printf("* sv = %p\n", sv);*/
+ cs[i] = INT2PTR(ZOOM_connection, SvIV(sv));
+ /*printf("got cs[%d] of %d = %p\n", (int) i, (int) n, cs[i]);*/
+ }
+ RETVAL = ZOOM_event((int) n, cs);
+ OUTPUT:
+ RETVAL
# UNTESTED
int
ZOOM_connection_last_event(cs)
ZOOM_connection cs
+# ----------------------------------------------------------------------------
+# What follows is the YAZ logging API. This is not strictly part of
+# ZOOM, but it's so useful that it would be silly to omit.
+
+int
+yaz_log_mask_str(str)
+ const char *str
+
+int
+yaz_log_module_level(name)
+ const char *name
+
+void
+yaz_log_init(level, prefix, name)
+ int level
+ const char *prefix
+ const char *name
+
+void
+yaz_log_init_file(fname)
+ const char *fname
+
+void
+yaz_log_init_level(level)
+ int level
+
+void
+yaz_log_init_prefix(prefix)
+ const char *prefix
+
+void
+yaz_log_time_format(fmt)
+ const char *fmt
+
+void
+yaz_log_init_max_size(mx)
+ int mx
+
+# <stdarg.h> interfaces are horrible to code for a Perl-C interface
+# layer. Instead, we expect Perl applications to construct the
+# message themselves, and pass it in as an opaque lump.
+void
+yaz_log(level, str)
+ int level
+ const char *str
+ CODE:
+ yaz_log(level, "%s", str);
+
+# This is also not strictly part of ZOOM
+unsigned long
+yaz_version(version_str, sys_str)
+ char *version_str
+ char *sys_str
+ OUTPUT:
+ RETVAL
+ version_str
+ sys_str
+