X-Git-Url: http://git.indexdata.com/?p=simpleserver-moved-to-github.git;a=blobdiff_plain;f=SimpleServer.xs;h=abd5850751a9cc0a1fd7069df77d9f84ae152048;hp=f0c07c35466ad77eeaf893cebe24fc93e40bf0cb;hb=86e7011ae2c02e51dc3b5e0ecf4c8e4d2f416cc3;hpb=57f69a9fd85b31d5cdd5dd054e0eab74eb233d04 diff --git a/SimpleServer.xs b/SimpleServer.xs index f0c07c3..abd5850 100644 --- a/SimpleServer.xs +++ b/SimpleServer.xs @@ -1,5 +1,5 @@ /* This file is part of simpleserver. - * Copyright (C) 2000-2013 Index Data. + * Copyright (C) 2000-2015 Index Data. * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -482,7 +482,7 @@ static SV *rpn2perl(Z_RPNStructure *s) case Z_Operator_and: type = "Net::Z3950::RPN::And"; break; case Z_Operator_or: type = "Net::Z3950::RPN::Or"; break; case Z_Operator_and_not: type = "Net::Z3950::RPN::AndNot"; break; - case Z_Operator_prox: fatal("proximity not yet supported"); + case Z_Operator_prox: type = "Net::Z3950::RPN::Prox"; break; default: fatal("unknown RPN operator %d", (int) c->roperator->which); } sv = newObject(type, (SV*) (av = newAV())); @@ -492,6 +492,21 @@ static SV *rpn2perl(Z_RPNStructure *s) if ((tmp = rpn2perl(c->s2)) == 0) return 0; av_push(av, tmp); + if (c->roperator->which == Z_Operator_prox) { + Z_ProximityOperator prox = *c->roperator->u.prox; + HV *hv; + tmp = newObject("Net::Z3950::RPN::Prox::Attributes", (SV*) (hv = newHV())); + setMember(hv, "exclusion", newSViv(*prox.exclusion)); + setMember(hv, "distance", newSViv(*prox.distance)); + setMember(hv, "ordered", newSViv(*prox.ordered)); + setMember(hv, "relationType", newSViv(*prox.relationType)); + if (prox.which == Z_ProximityOperator_known) { + setMember(hv, "known", newSViv(*prox.u.known)); + } else { + setMember(hv, "zprivate", newSViv(*prox.u.zprivate)); + } + av_push(av, tmp); + } return sv; } @@ -1002,6 +1017,11 @@ int bend_search(void *handle, bend_search_rr *rr) rr->extra_response_data = odr_strdupn(rr->stream, ptr, len); } + temp = hv_fetch(href, "ESTIMATED" "_HIT_" "COUNT", 19, 0); + if (temp) + { + rr->estimated_hit_count = SvIV(*temp); + } hv_undef(href); av_undef(aref); @@ -1094,7 +1114,6 @@ int bend_fetch(void *handle, bend_fetch_rr *rr) HV *href; SV **temp; SV *basename; - SV *record; SV *last; SV *err_code; SV *err_string; @@ -1135,7 +1154,6 @@ int bend_fetch(void *handle, bend_fetch_rr *rr) hv_store(href, "REQ_FORM", 8, newSVpv((char *)oid_dotted->buf, oid_dotted->pos), 0); hv_store(href, "REP_FORM", 8, newSVpv((char *)oid_dotted->buf, oid_dotted->pos), 0); hv_store(href, "BASENAME", 8, newSVpv("", 0), 0); - hv_store(href, "RECORD", 6, newSVpv("", 0), 0); hv_store(href, "LAST", 4, newSViv(0), 0); hv_store(href, "ERR_CODE", 8, newSViv(0), 0); hv_store(href, "ERR_STR", 7, newSVpv("", 0), 0); @@ -1204,8 +1222,6 @@ int bend_fetch(void *handle, bend_fetch_rr *rr) temp = hv_fetch(href, "BASENAME", 8, 1); basename = newSVsv(*temp); - temp = hv_fetch(href, "RECORD", 6, 1); - record = newSVsv(*temp); temp = hv_fetch(href, "LAST", 4, 1); last = newSVsv(*temp); @@ -1234,9 +1250,6 @@ int bend_fetch(void *handle, bend_fetch_rr *rr) temp = hv_fetch(href, "HANDLE", 6, 1); point = newSVsv(*temp); - - hv_undef(href); - ptr = SvPV(basename, length); rr->basename = odr_strdupn(rr->stream, ptr, length); @@ -1250,18 +1263,26 @@ int bend_fetch(void *handle, bend_fetch_rr *rr) rr->output_format = odr_oiddup(rr->stream, yaz_oid_recsyn_sutrs); } - ptr = SvPV(record, length); - /* Treat GRS-1 records separately */ - if (!oid_oidcmp(rr->output_format, yaz_oid_recsyn_grs_1)) - { - rr->record = (char *) read_grs1(ptr, rr->stream); - rr->len = -1; - } - else + temp = hv_fetch(href, "RECORD", 6, 0); + if (temp) { - rr->record = odr_strdupn(rr->stream, ptr, length); - rr->len = length; + SV *record = newSVsv(*temp); + ptr = SvPV(record, length); + /* Treat GRS-1 records separately */ + if (!oid_oidcmp(rr->output_format, yaz_oid_recsyn_grs_1)) + { + rr->record = (char *) read_grs1(ptr, rr->stream); + rr->len = -1; + } + else + { + rr->record = odr_strdupn(rr->stream, ptr, length); + rr->len = length; + } + sv_free(record); } + hv_undef(href); + zhandle->handle = point; handle = zhandle; rr->last_in_set = SvIV(last); @@ -1277,7 +1298,6 @@ int bend_fetch(void *handle, bend_fetch_rr *rr) wrbuf_destroy(oid_dotted); sv_free((SV*) href); sv_free(basename); - sv_free(record); sv_free(last); sv_free(err_string); sv_free(err_code),