projects
/
simpleserver-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ztest.pl returns display_term for one of the entries
[simpleserver-moved-to-github.git]
/
SimpleServer.xs
diff --git
a/SimpleServer.xs
b/SimpleServer.xs
index
eb492e3
..
d0fa5e9
100644
(file)
--- a/
SimpleServer.xs
+++ b/
SimpleServer.xs
@@
-40,6
+40,7
@@
#include <stdio.h>
#include <yaz/mutex.h>
#include <yaz/oid_db.h>
#include <stdio.h>
#include <yaz/mutex.h>
#include <yaz/oid_db.h>
+#include <yaz/yaz-version.h>
#ifdef WIN32
#else
#include <unistd.h>
#ifdef WIN32
#else
#include <unistd.h>
@@
-91,15
+92,13
@@
PerlInterpreter *root_perl_context;
*/
char *string_or_undef(SV **svp, ODR stream) {
STRLEN len;
*/
char *string_or_undef(SV **svp, ODR stream) {
STRLEN len;
- char *ptr, *buf;
+ char *ptr;
if (!SvOK(*svp))
return 0;
ptr = SvPV(*svp, len);
if (!SvOK(*svp))
return 0;
ptr = SvPV(*svp, len);
- buf = (char*) odr_malloc(stream, len+1);
- strcpy(buf, ptr);
- return buf;
+ return odr_strdupn(stream, ptr, len);
}
}
@@
-1421,6
+1420,7
@@
int bend_scan(void *handle, bend_scan_rr *rr)
struct scan_entry *scan_list;
struct scan_entry *buffer;
int *step_size = rr->step_size;
struct scan_entry *scan_list;
struct scan_entry *buffer;
int *step_size = rr->step_size;
+ int scan_list_size = rr->num_entries;
int i;
char **basenames;
SV **temp;
int i;
char **basenames;
SV **temp;
@@
-1514,7
+1514,12
@@
int bend_scan(void *handle, bend_scan_rr *rr)
rr->errcode = SvIV(err_code);
rr->num_entries = SvIV(number);
rr->status = SvIV(status);
rr->errcode = SvIV(err_code);
rr->num_entries = SvIV(number);
rr->status = SvIV(status);
+ if (yaz_version(NULL, NULL) >= 0x4022c && rr->num_entries <= scan_list_size) {
+ /* entries has been initialized by yaz and is big enough to hold all entries */
+ scan_list = rr->entries;
+ } else {
scan_list = (struct scan_entry *) odr_malloc (rr->stream, rr->num_entries * sizeof(*scan_list));
scan_list = (struct scan_entry *) odr_malloc (rr->stream, rr->num_entries * sizeof(*scan_list));
+ }
buffer = scan_list;
entries = (AV *)SvRV(entries_ref);
if (rr->errcode == 0) for (i = 0; i < rr->num_entries; i++)
buffer = scan_list;
entries = (AV *)SvRV(entries_ref);
if (rr->errcode == 0) for (i = 0; i < rr->num_entries; i++)
@@
-1522,10
+1527,15
@@
int bend_scan(void *handle, bend_scan_rr *rr)
scan_item = (HV *)SvRV(sv_2mortal(av_shift(entries)));
temp = hv_fetch(scan_item, "TERM", 4, 1);
ptr = SvPV(*temp, len);
scan_item = (HV *)SvRV(sv_2mortal(av_shift(entries)));
temp = hv_fetch(scan_item, "TERM", 4, 1);
ptr = SvPV(*temp, len);
- buffer->term = (char *) odr_malloc (rr->stream, len + 1);
- strcpy(buffer->term, ptr);
+ buffer->term = odr_strdupn(rr->stream, ptr, len);
temp = hv_fetch(scan_item, "OCCURRENCE", 10, 1);
buffer->occurrences = SvIV(*temp);
temp = hv_fetch(scan_item, "OCCURRENCE", 10, 1);
buffer->occurrences = SvIV(*temp);
+ temp = hv_fetch(scan_item, "DISPLAY_TERM", 12, 0);
+ if (temp)
+ {
+ ptr = SvPV(*temp, len);
+ buffer->display_term = odr_strdupn(rr->stream, ptr,len);
+ }
buffer++;
hv_undef(scan_item);
}
buffer++;
hv_undef(scan_item);
}