X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=perl%2FIDZebra.i;h=8cd8382a9badba67319531ad5232c1f4c67a8a67;hb=138b954cffe470bf0e62d812cae6e859aa57cdb5;hp=e289a540287fbb5997cc65970d530448e7ab2d5d;hpb=4003296c8a5cf45925cf18f2d6feef929ead1f66;p=idzebra-moved-to-github.git diff --git a/perl/IDZebra.i b/perl/IDZebra.i index e289a54..8cd8382 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; @@ -79,7 +142,6 @@ typedef struct { long stime; } ZebraTransactionStatus; - /* == Module initialization and cleanup (zebra_perl.c) ===================== */ void init (void); @@ -87,10 +149,21 @@ void DESTROY (void); /* == Logging facilities (yaz/log.h) ======================================= */ -void logLevel (int level); -void logFile (const char *fname); +%name(logLevel) +void yaz_log_init_level (int level); + +%name(logFile) +void yaz_log_init_file (const char *fname); + +%name(logMsg) void logMsg (int level, const char *message); +%name(logPrefix) +void yaz_log_init_prefix (const char *prefix); + +%name(logPrefix2) +void yaz_log_init_prefix2 (const char *prefix); + #define LOG_FATAL 0x0001 #define LOG_DEBUG 0x0002 #define LOG_WARN 0x0004 @@ -170,7 +243,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) @@ -179,15 +252,6 @@ void zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *stat); %name(trans_no) 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); - /* commit changes from shadow (zebraapi.c) */ %name(commit) int zebra_commit (ZebraHandle zh); @@ -225,34 +289,49 @@ void zebra_repository_show (ZebraHandle zh); If not, and match_criteria is provided, then sysno is guessed If not, and a record is provided, then sysno is got from there */ +%apply int *REFERENCE { int *sysno }; +%name(insert_record) +int zebra_insert_record (ZebraHandle zh, + recordGroup *rGroup, + const char *recordType, + int *sysno, + const char *match, + const char *fname, + const char *buf, + int buf_size, + int force_update); + %name(update_record) int zebra_update_record (ZebraHandle zh, recordGroup *rGroup, const char *recordType, - int sysno, + int *sysno, const char *match, const char *fname, const char *buf, - int buf_size); + int buf_size, + int force_update); %name(delete_record) int zebra_delete_record (ZebraHandle zh, recordGroup *rGroup, const char *recordType, - int sysno, + int *sysno, const char *match, const char *fname, const char *buf, - int buf_size); + int buf_size, + int force_update); -/* == Search (zebra_api_ext.c) ============================================= */ +/* == Search (zebraapi.c) ================================================== */ +%include "typemaps.i" +%apply int *REFERENCE { int *hits }; %name(search_PQF) int zebra_search_PQF (ZebraHandle zh, - ODR odr_input, ODR odr_output, const char *pqf_query, - const char *setname); - + const char *setname, + int *hits); /* == YAZ - query tools ==================================================== */ @@ -287,8 +366,22 @@ 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); + + +/* Resultset terms */ +%name(resultSetTerms) +int zebra_resultSetTerms (ZebraHandle zh, const char *setname, + int no, int *REFERENCE, + int *REFERENCE, char *out, int *REFERENCE); + /* == Sort ================================================================= */ -int sort (ZebraHandle zh, +%name(sort) +int zebra_sort_by_specstr (ZebraHandle zh, ODR stream, const char *sort_spec, const char *output_setname, @@ -302,7 +395,11 @@ void zebra_scan_PQF (ZebraHandle zh, ODR stream, const char *pqf_query); -ScanEntry *getScanEntry(ScanObj *so, int pos); +scanEntry *getScanEntry(ScanObj *so, int pos); + +%typemap(in) int * (int dvalue); +%typemap(argout) int *; + /* Admin functionality */ /* @@ -311,12 +408,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 */ /* @@ -569,6 +660,8 @@ const char *data1_get_tabroot(data1_handle dh); * ========================================================================= */ int grs_perl_readf(struct perl_context *context, size_t len); +int grs_perl_readline(struct perl_context *context); +char grs_perl_getc(struct perl_context *context); off_t grs_perl_seekf(struct perl_context *context, off_t offset); off_t grs_perl_tellf(struct perl_context *context); void grs_perl_endf(struct perl_context *context, off_t offset);