From: Mike Taylor Date: Tue, 9 Sep 2003 20:12:38 +0000 (+0000) Subject: Return diagnostics on Init failure X-Git-Tag: release.0.0.8.lau~19 X-Git-Url: http://git.indexdata.com/?p=simpleserver-moved-to-github.git;a=commitdiff_plain;h=159d2f7d178c6870b07bb10fc8bcea009ad3e786 Return diagnostics on Init failure --- diff --git a/Changes b/Changes index 2d9cee8..08b1a64 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,12 @@ Revision history for Perl extension Net::Z3950::SimpleServer implementation-ID setting. Now that it does (and has done for eighteen months -- since YAZ release 1.8.6 of 2002/03/25!), I've finally removed the comments. + - Init handler now understands the setting of {ERR_CODE} as + more than a boolean success indicator, and also {ERR_STR}. + They are now passed back to the client (thanks to recent + changes to the YAZ generic front-end server) in accordance + with Z39.50 Implementor Agreement 5, found at + http://lcweb.loc.gov/z3950/agency/agree/initdiag.html 0.07 Fri Jan 03 10:12:15 2003 - Applied Dave Mitchell's (davem@fdgroup.com) GRS-1 parsing patch. diff --git a/SimpleServer.pm b/SimpleServer.pm index 06d1d3e..540a04b 100644 --- a/SimpleServer.pm +++ b/SimpleServer.pm @@ -26,7 +26,10 @@ ## ## $Log: SimpleServer.pm,v $ -## Revision 1.17 2003-09-09 11:40:10 mike +## Revision 1.18 2003-09-09 20:12:38 mike +## Return diagnostics on Init failure +## +## Revision 1.17 2003/09/09 11:40:10 mike ## (Finally!) support implementation-ID ## ## Revision 1.16 2003/01/03 09:01:51 sondberg @@ -286,6 +289,7 @@ The argument hash passed to the init handler has the form IMP_NAME => "", ## Z39.50 Implementation name IMP_VER => "", ## Z39.50 Implementation version ERR_CODE => 0, ## Error code, cnf. Z39.50 manual + ERR_STR => "", ## Error string (additional info.) USER => "xxx" ## If Z39.50 authentication is used, ## this member contains user name PASS => "yyy" ## Under same conditions, this member @@ -308,7 +312,8 @@ Filling these in is optional. The ERR_CODE should be left at 0 (the default value) if you wish to accept the connection. Any other value is interpreted as a failure -and the client will be shown the door. +and the client will be shown the door, with the code and the +associated additional information, ERR_STR returned. =head2 Search handler diff --git a/SimpleServer.xs b/SimpleServer.xs index 6924440..230cd26 100644 --- a/SimpleServer.xs +++ b/SimpleServer.xs @@ -25,7 +25,10 @@ */ /*$Log: SimpleServer.xs,v $ -/*Revision 1.19 2003-09-09 11:40:10 mike +/*Revision 1.20 2003-09-09 20:12:38 mike +/*Return diagnostics on Init failure +/* +/*Revision 1.19 2003/09/09 11:40:10 mike /*(Finally!) support implementation-ID /* /*Revision 1.18 2003/01/03 09:05:41 sondberg @@ -1154,6 +1157,7 @@ bend_initresult *bend_init(bend_initrequest *q) hv_store(href, "IMP_NAME", 8, newSVpv("", 0), 0); hv_store(href, "IMP_VER", 7, newSVpv("", 0), 0); hv_store(href, "ERR_CODE", 8, newSViv(0), 0); + hv_store(href, "ERR_STR", 7, newSViv(0), 0); hv_store(href, "PEER_NAME", 9, newSVpv(q->peer_name, 0), 0); hv_store(href, "HANDLE", 6, newSVsv(&sv_undef), 0); hv_store(href, "PID", 3, newSViv(getpid()), 0); @@ -1201,6 +1205,9 @@ bend_initresult *bend_init(bend_initrequest *q) temp = hv_fetch(href, "ERR_CODE", 8, 1); status = newSVsv(*temp); + temp = hv_fetch(href, "ERR_STR", 7, 1); + err_str = newSVsv(*temp); + temp = hv_fetch(href, "HANDLE", 6, 1); handle= newSVsv(*temp); @@ -1210,6 +1217,10 @@ bend_initresult *bend_init(bend_initrequest *q) LEAVE; zhandle->handle = handle; r->errcode = SvIV(status); + ptr = SvPV(err_str, len); + r->errstring = (char *)odr_malloc(q->stream, len + 1); + strcpy(r->errstring, ptr); + sv_free(err_str); r->handle = zhandle; ptr = SvPV(id, len); q->implementation_id = (char *)xmalloc(len + 1);