##
##
-## $Id: SimpleServer.pm,v 1.26 2006-04-19 13:17:52 sondberg Exp $
+## $Id: SimpleServer.pm,v 1.27 2006-06-02 16:03:25 quinn Exp $
package Net::Z3950::SimpleServer;
if (defined($self->{SORT})) {
set_sort_handler($self->{SORT});
}
+ if (defined($self->{EXPLAIN})) {
+ set_explain_handler($self->{EXPLAIN});
+ }
start_server(@args);
}
SEARCH => \&my_search_handler,
PRESENT => \&my_present_handler,
SCAN => \&my_scan_handler,
- FETCH => \&my_fetch_handler);
+ FETCH => \&my_fetch_handler,
+ EXPLAIN => \&my_explain_handler);
If you want your SimpleServer to start a thread (threaded mode) to
handle each incoming Z39.50 request instead of forking a process
/*
- * $Id: SimpleServer.xs,v 1.45 2006-06-02 10:06:11 sondberg Exp $
+ * $Id: SimpleServer.xs,v 1.46 2006-06-02 16:03:25 quinn Exp $
* ----------------------------------------------------------------------
*
* Copyright (c) 2000-2004, Index Data.
SV *esrequest_ref;
SV *delete_ref;
SV *scan_ref;
+ SV *explain_ref;
NMEM nmem;
int stop_flag; /* is used to stop server prematurely .. */
} Zfront_handle;
SV *esrequest_ref = NULL;
SV *delete_ref = NULL;
SV *scan_ref = NULL;
+SV *explain_ref = NULL;
PerlInterpreter *root_perl_context;
int MAX_OID = 15;
return 0;
}
+int bend_explain(void *handle, bend_explain_rr *q)
+{
+ HV *href;
+ CV *handler_cv = 0;
+ SV **temp;
+ char *explain;
+ SV *explainsv;
+ STRLEN len;
+
+ dSP;
+ ENTER;
+ SAVETMPS;
+
+ href = newHV();
+ hv_store(href, "EXPLAIN", 7, newSVpv("", 0), 0);
+ hv_store(href, "DATABASE", 8, newSVpv(q->database, 0), 0);
+
+ PUSHMARK(sp);
+ XPUSHs(sv_2mortal(newRV((SV*) href)));
+ PUTBACK;
+
+ handler_cv = simpleserver_sv2cv(explain_ref);
+ perl_call_sv((SV*) handler_cv, G_SCALAR | G_DISCARD);
+
+ SPAGAIN;
+
+ temp = hv_fetch(href, "EXPLAIN", 7, 1);
+ explainsv = newSVsv(*temp);
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+
+ explain = SvPV(explainsv, len);
+ q->explain_buf = (char*) odr_malloc(q->stream, len + 1);
+ strcpy(q->explain_buf, explain);
+
+ return 0;
+}
+
bend_initresult *bend_init(bend_initrequest *q)
{
int dummy = simpleserver_clone();
{
q->bend_scan = bend_scan;
}
+ if (explain_ref)
+ {
+ q->bend_explain = bend_explain;
+ }
href = newHV();
hv_store(href, "IMP_ID", 6, newSVpv("", 0), 0);
CODE:
scan_ref = newSVsv(arg);
+void
+set_explain_handler(arg)
+ SV *arg
+ CODE:
+ explain_ref = newSVsv(arg);
int
start_server(...)