From: Mike Taylor Date: Mon, 20 Aug 2007 15:36:13 +0000 (+0000) Subject: Initial implementation of Delete RS. X-Git-Tag: CPAN.1.12~52 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=60a0c4dbeddc69d23c1c8a2ab552dae2f96cb952;p=simpleserver-moved-to-github.git Initial implementation of Delete RS. Memory management is screwy. DO NOT USE THIS YET. --- diff --git a/SimpleServer.xs b/SimpleServer.xs index b13498c..f4f4356 100644 --- a/SimpleServer.xs +++ b/SimpleServer.xs @@ -1,5 +1,5 @@ /* - * $Id: SimpleServer.xs,v 1.73 2007-08-20 10:59:11 mike Exp $ + * $Id: SimpleServer.xs,v 1.74 2007-08-20 15:36:13 mike Exp $ * ---------------------------------------------------------------------- * * Copyright (c) 2000-2004, Index Data. @@ -1168,9 +1168,55 @@ int bend_esrequest(void *handle, bend_esrequest_rr *rr) } +/* ### I am not 100% about the memory management in this handler */ int bend_delete(void *handle, bend_delete_rr *rr) { - perl_call_sv(delete_ref, G_VOID | G_DISCARD | G_NOARGS); + Zfront_handle *zhandle = (Zfront_handle *)handle; + HV *href; + CV* handler_cv; + int i; + SV **temp; + + dSP; + ENTER; + SAVETMPS; + + href = newHV(); + hv_store(href, "GHANDLE", 7, newSVsv(zhandle->ghandle), 0); + hv_store(href, "HANDLE", 6, zhandle->handle, 0); + hv_store(href, "STATUS", 6, newSViv(0), 0); + + PUSHMARK(sp); + XPUSHs(sv_2mortal(newRV( (SV*) href))); + PUTBACK; + + handler_cv = simpleserver_sv2cv(delete_ref); + + if (rr->function == 1) { + /* Delete all result setss in the session */ + perl_call_sv( (SV *) handler_cv, G_SCALAR | G_DISCARD); + temp = hv_fetch(href, "STATUS", 6, 1); + rr->delete_status = SvIV(*temp); + } else { + rr->delete_status = 0; + for (i = 0; i < rr->num_setnames; i++) { + hv_store(href, "SETNAME", 7, newSVpv(rr->setnames[i], 0), 0); + perl_call_sv( (SV *) handler_cv, G_SCALAR | G_DISCARD); + temp = hv_fetch(href, "STATUS", 6, 1); + rr->statuses[i] = SvIV(*temp); + if (rr->statuses[i] != 0) + rr->delete_status = rr->statuses[i]; + } + } + + SPAGAIN; + + sv_free( (SV*) href); + + PUTBACK; + FREETMPS; + LEAVE; + return 0; } @@ -1392,7 +1438,9 @@ bend_initresult *bend_init(bend_initrequest *q) q->bend_present = bend_present; } /*q->bend_esrequest = bend_esrequest;*/ - /*q->bend_delete = bend_delete;*/ + if (delete_ref) { + q->bend_delete = bend_delete; + } if (fetch_ref) { q->bend_fetch = bend_fetch;