From 3e0c6a2e1651cbc655d1acfd7ecf317745c29803 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 17 Oct 2005 13:42:43 +0000 Subject: [PATCH] Revert "const char*" arguments to their original const-qualified types, now that I have modified the typemap to support this. Add "opaquechar" and "struct datachunk" types, used to get binary data strings in and out of C respectively. These are used by ZOOM_connection_option_setl() and ZOOM_connection_option_getl() respectively. Implemented ZOOM_connection_error_x(). Tested ZOOM_connection_{errcode,errmsg,addinfo)(). Tested ZOOM_options_create(). Add explicit "UNTESTED" markers to not-yet-tested functions. --- ZOOM.xs | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 99 insertions(+), 21 deletions(-) diff --git a/ZOOM.xs b/ZOOM.xs index 8da6efc..78b0508 100644 --- a/ZOOM.xs +++ b/ZOOM.xs @@ -1,4 +1,4 @@ -/* $Id: ZOOM.xs,v 1.12 2005-10-13 13:48:08 mike Exp $ */ +/* $Id: ZOOM.xs,v 1.13 2005-10-17 13:42:43 mike Exp $ */ #include "EXTERN.h" #include "perl.h" @@ -6,23 +6,24 @@ #include +/* Used by the *_setl() functions */ +typedef char opaquechar; + +/* Used as the return value of the *_getl() functions */ +struct datachunk { + char *data; + int len; +}; MODULE = Net::Z3950::ZOOM PACKAGE = Net::Z3950::ZOOM PREFIX=ZOOM_ PROTOTYPES: ENABLE -# It seems that when one of these functions is called from Perl with -# a string-constant argument, that is not recognised as suitable to -# be mapped onto a "const char*" argument. The only fix I can find is -# to delete as the "const" qualifiers from "char*" arguments: -# overriding the auto-generated prototyping with PROTOTYPE: $$ -# doesn't help (and indeed seems to make no difference at all). -# # TESTED ZOOM_connection ZOOM_connection_new(host, portnum) - char* host + const char* host int portnum # TESTED @@ -49,18 +50,36 @@ ZOOM_connection_option_get(c, key) const char *key # TESTED +struct datachunk +ZOOM_connection_option_getl(c, key, len) + ZOOM_connection c + const char *key + int &len + CODE: + RETVAL.data = (char*) ZOOM_connection_option_getl(c, key, &RETVAL.len); + OUTPUT: + RETVAL + +# TESTED void ZOOM_connection_option_set(c, key, val) ZOOM_connection c const char *key const char *val +# In ZOOM-C, the `val' parameter is const char*. However, our typemap +# treats this as T_PV, i.e. it's "known" that it points to a +# NUL-terminated string. Instead, then, I here use const void*, which +# is an opaque pointer. The underlying C function can then use this +# along with `len' to Do The Right Thing. +# +# TESTED void ZOOM_connection_option_setl(c, key, val, len) ZOOM_connection c - const char * key - const char * val - int len + const char* key + opaquechar* val + int len # The reference parameters, `cp' and `addinfo', need to already have # values when this function is called, otherwise an "uninitialised @@ -90,21 +109,37 @@ ZOOM_connection_error(c, cp, addinfo) cp addinfo +# See comments for ZOOM_connection_error() above +# TESTED int ZOOM_connection_error_x(c, cp, addinfo, diagset) ZOOM_connection c - const char ** cp - const char ** addinfo - const char ** diagset + const char * &cp + const char * &addinfo + const char * &diagset + CODE: + const char *ccp, *caddinfo, *cdset; + RETVAL = ZOOM_connection_error_x(c, &ccp, &caddinfo, &cdset); + cp = (char*) ccp; + addinfo = (char*) caddinfo; + diagset = (char*) cdset; + OUTPUT: + RETVAL + cp + addinfo + diagset +# TESTED int ZOOM_connection_errcode(c) ZOOM_connection c +# TESTED const char * ZOOM_connection_errmsg(c) ZOOM_connection c +# TESTED const char * ZOOM_connection_addinfo(c) ZOOM_connection c @@ -114,33 +149,35 @@ const char * ZOOM_diag_str(error) int error +# UNTESTED int ZOOM_connection_last_event(cs) ZOOM_connection cs +# UNTESTED ZOOM_resultset ZOOM_connection_search(arg0, q) ZOOM_connection arg0 ZOOM_query q -# "const" discarded from type of `q' -# # TESTED ZOOM_resultset ZOOM_connection_search_pqf(c, q) ZOOM_connection c - char *q + const char *q # TESTED void ZOOM_resultset_destroy(r) ZOOM_resultset r +# UNTESTED const char * ZOOM_resultset_option_get(r, key) ZOOM_resultset r const char * key +# UNTESTED void ZOOM_resultset_option_set(r, key, val) ZOOM_resultset r @@ -152,6 +189,7 @@ size_t ZOOM_resultset_size(r) ZOOM_resultset r +# UNTESTED void ZOOM_resultset_records(r, recs, start, count) ZOOM_resultset r @@ -165,63 +203,74 @@ ZOOM_resultset_record(s, pos) ZOOM_resultset s size_t pos +# UNTESTED ZOOM_record ZOOM_resultset_record_immediate(s, pos) ZOOM_resultset s size_t pos +# UNTESTED void ZOOM_resultset_cache_reset(r) ZOOM_resultset r -# "const" discarded from type of `type' # See "typemap" for discussion of the "const char *" return-type. # # TESTED +### but should use datachunk const char * ZOOM_record_get(rec, type, len) ZOOM_record rec - char* type + const char* type int &len OUTPUT: RETVAL len +# UNTESTED void ZOOM_record_destroy(rec) ZOOM_record rec +# UNTESTED ZOOM_record ZOOM_record_clone(srec) ZOOM_record srec +# UNTESTED ZOOM_query ZOOM_query_create() +# UNTESTED void ZOOM_query_destroy(s) ZOOM_query s +# UNTESTED int ZOOM_query_cql(s, str) ZOOM_query s const char * str +# UNTESTED int ZOOM_query_prefix(s, str) ZOOM_query s const char * str +# UNTESTED int ZOOM_query_sortby(s, criteria) ZOOM_query s const char * criteria +# UNTESTED ZOOM_scanset ZOOM_connection_scan(c, startterm) ZOOM_connection c const char * startterm +# UNTESTED const char * ZOOM_scanset_term(scan, pos, occ, len) ZOOM_scanset scan @@ -229,6 +278,7 @@ ZOOM_scanset_term(scan, pos, occ, len) int * occ int * len +# UNTESTED const char * ZOOM_scanset_display_term(scan, pos, occ, len) ZOOM_scanset scan @@ -236,86 +286,109 @@ ZOOM_scanset_display_term(scan, pos, occ, len) int * occ int * len +# UNTESTED size_t ZOOM_scanset_size(scan) ZOOM_scanset scan +# UNTESTED void ZOOM_scanset_destroy(scan) ZOOM_scanset scan +# UNTESTED const char * ZOOM_scanset_option_get(scan, key) ZOOM_scanset scan const char * key +# UNTESTED void ZOOM_scanset_option_set(scan, key, val) ZOOM_scanset scan const char * key const char * val +# UNTESTED ZOOM_package ZOOM_connection_package(c, options) ZOOM_connection c ZOOM_options options +# UNTESTED void ZOOM_package_destroy(p) ZOOM_package p +# UNTESTED void ZOOM_package_send(p, type) ZOOM_package p const char * type +# UNTESTED const char * ZOOM_package_option_get(p, key) ZOOM_package p const char * key +# UNTESTED void ZOOM_package_option_set(p, key, val) ZOOM_package p const char * key const char * val +# UNTESTED void ZOOM_resultset_sort(r, sort_type, sort_spec) ZOOM_resultset r const char * sort_type const char * sort_spec +# UNTESTED ZOOM_options_callback ZOOM_options_set_callback(opt, c, handle) ZOOM_options opt ZOOM_options_callback c void * handle -# TESTING +# TESTED ZOOM_options ZOOM_options_create() +# UNTESTED ZOOM_options ZOOM_options_create_with_parent(parent) ZOOM_options parent +# UNTESTED ZOOM_options ZOOM_options_create_with_parent2(parent1, parent2) ZOOM_options parent1 ZOOM_options parent2 +# UNTESTED const char * ZOOM_options_get(opt, name) ZOOM_options opt const char * name +# UNTESTED +const char * +ZOOM_options_getl(opt, name, len) + ZOOM_options opt + const char * name + int &len + +# UNTESTED void ZOOM_options_set(opt, name, v) ZOOM_options opt const char * name const char * v +# UNTESTED void ZOOM_options_setl(opt, name, value, len) ZOOM_options opt @@ -323,28 +396,33 @@ ZOOM_options_setl(opt, name, value, len) const char * value int len +# UNTESTED void ZOOM_options_destroy(opt) ZOOM_options opt +# UNTESTED int ZOOM_options_get_bool(opt, name, defa) ZOOM_options opt const char * name int defa +# UNTESTED int ZOOM_options_get_int(opt, name, defa) ZOOM_options opt const char * name int defa +# UNTESTED void ZOOM_options_set_int(opt, name, value) ZOOM_options opt const char * name int value +# UNTESTED int ZOOM_event(no, cs) int no -- 1.7.10.4