X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=perl%2FIDZebra.i;h=b4344901e973ce013fb4463fcc68d941303b8cc3;hb=316571421f340cca21ed5c70215cd890e5243306;hp=bbbdcff010f0f9c3ff7499f0010b66794e0b6e57;hpb=0a34a94a93dc7d594d0f6a7f359a63dbc1297775;p=idzebra-moved-to-github.git diff --git a/perl/IDZebra.i b/perl/IDZebra.i index bbbdcff..b434490 100644 --- a/perl/IDZebra.i +++ b/perl/IDZebra.i @@ -1,9 +1,9 @@ %module "IDZebra" %include typemaps.i // Load the typemaps librayr + %{ #include "zebraapi.h" -#include "zebra_api_ext.h" #include "zebra_perl.h" #include "data1.h" #include "yaz/odr.h" @@ -12,10 +12,28 @@ /* == Typemaps ============================================================= */ +%typemap(in) int * { + int i; + if (!SvIOK($input)) + croak("Argument $argnum is not an integer."); + i = SvIV($input); + $1 = &i; +} + +%typemap(out) int * { + $result=newSViv($1) + sv_2mortal($result); + argvi++; +} + /* RetrievalRecordBuff is a special construct, to allow to map a char * buf to non-null terminated perl string scalar value (SVpv). */ %typemap(out) RetrievalRecordBuf * { - $result = newSVpv($1->buf,$1->len); + if ($1->len) { + $result = newSVpv($1->buf,$1->len); + } else { + $result = newSVpv("",0); + } sv_2mortal($result); argvi++; } @@ -68,7 +86,52 @@ /* == Structures for shadow classes ======================================= */ -%include "zebra_perl.h" + +/*%include "zebra_perl.h" */ +typedef struct { + char *groupName; + char *databaseName; + char *path; + char *recordId; + char *recordType; + int flagStoreData; + int flagStoreKeys; + int flagRw; + int fileVerboseLimit; + int databaseNamePath; + int explainDatabase; + int followLinks; +} recordGroup; + +typedef struct { + int noOfRecords; + ZebraRetrievalRecord *records; +} RetrievalObj; + +typedef struct { + int errCode; /* non-zero if error when fetching this */ + char *errString; /* error string */ + int position; /* position of record in result set (1,2,..) */ + char *base; + int sysno; + int score; + char *format; /* record syntax */ + RetrievalRecordBuf *buf; +} RetrievalRecord; + +/* Scan Term Descriptor */ +typedef struct { + int occurrences; /* scan term occurrences */ + char *term; /* scan term string */ +} scanEntry; + +typedef struct { + int num_entries; + int position; + int is_partial; + scanEntry *entries; +} ScanObj; + typedef struct { int processed; @@ -80,6 +143,8 @@ typedef struct { } ZebraTransactionStatus; + + /* == Module initialization and cleanup (zebra_perl.c) ===================== */ void init (void); @@ -170,7 +235,7 @@ int zebra_select_databases (ZebraHandle zh, int num_bases, /* begin transaction (add write lock) (zebraapi.c) */ %name(begin_trans) -void zebra_begin_trans (ZebraHandle zh); +int zebra_begin_trans (ZebraHandle zh, int rw); /* end transaction (remove write lock) (zebraapi.c) */ %name(end_trans) @@ -182,8 +247,6 @@ int zebra_trans_no (ZebraHandle zh); %name(begin_read) int zebra_begin_read (ZebraHandle zh); -void zts_test (ZebraTransactionStatus *stat); - /* end retrieval (remove read lock) (zebraapi.c) */ %name(end_read) void zebra_end_read (ZebraHandle zh); @@ -287,6 +350,13 @@ void record_retrieve(RetrievalObj *ro, RetrievalRecord *res, int pos); +/* Delete Result Set(s) (zebraapi.c) */ +%name(deleteResultSet) +int zebra_deleleResultSet(ZebraHandle zh, int function, + int num_setnames, char **setnames, + int *statuses); + + /* == Sort ================================================================= */ int sort (ZebraHandle zh, ODR stream, @@ -302,7 +372,7 @@ void zebra_scan_PQF (ZebraHandle zh, ODR stream, const char *pqf_query); -ScanEntry *getScanEntry(ScanObj *so, int pos); +scanEntry *getScanEntry(ScanObj *so, int pos); /* Admin functionality */ /* @@ -311,12 +381,6 @@ ScanEntry *getScanEntry(ScanObj *so, int pos); */ -/* Delete Result Set(s) */ -/* -int zebra_deleleResultSet(ZebraHandle zh, int function, - int num_setnames, char **setnames, - int *statuses); -*/ /* do authentication */ /*