X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=perl%2FIDZebra.i;h=8b5f86e7d272f31aaf8de839546ab1d17c629f51;hb=4cea1b9769079a2cdc143f4fe483e69d5b77a813;hp=61a8c6155ea35d2d0512f39ac033ae900ce0b233;hpb=e035737c20ac0caf47e9e48e3b11f006e9132e9c;p=idzebra-moved-to-github.git diff --git a/perl/IDZebra.i b/perl/IDZebra.i index 61a8c61..8b5f86e 100644 --- a/perl/IDZebra.i +++ b/perl/IDZebra.i @@ -3,9 +3,9 @@ %{ -#include "zebraapi.h" +#include #include "zebra_perl.h" -#include "data1.h" +#include #include "yaz/odr.h" #include "yaz/cql.h" %} @@ -26,6 +26,20 @@ argvi++; } +/* * * * * * Fix for broken swig implementation */ +%typemap(argout) long long *INOUT { + char temp[256]; + if (argvi >= items) { + EXTEND(sp,1); + } + /* sprintf(temp,"%lld", $1); */ + sprintf(temp,"%lld", *$1); + $result = sv_newmortal(); + sv_setpv($result,temp); + 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 * { @@ -88,20 +102,6 @@ /*%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; @@ -113,7 +113,7 @@ typedef struct { char *errString; /* error string */ int position; /* position of record in result set (1,2,..) */ char *base; - int sysno; + long long sysno; int score; char *format; /* record syntax */ RetrievalRecordBuf *buf; @@ -142,9 +142,6 @@ typedef struct { long stime; } ZebraTransactionStatus; - - - /* == Module initialization and cleanup (zebra_perl.c) ===================== */ void init (void); @@ -152,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 @@ -208,18 +216,16 @@ const char * zebra_errString (ZebraHandle zh); char * zebra_errAdd (ZebraHandle zh); -/* == Record groups and database selection ================================= */ +/* == Zebra resources and database selection =============================== */ -/* initialize a recordGroup (zebra_api_ext.c); */ -void init_recordGroup (recordGroup *rg); +/* set a resource */ +%name(set_resource) +void zebra_set_resource(ZebraHandle zh, const char *name, const char *value); -/* set up a recordGroup for a specific file extension from zebra.cfg - (zebra_api_ext.c); */ -void res_get_recordGroup (ZebraHandle zh, recordGroup *rg, - const char *ext); -/* set current record group for update purposes (zebraapi.c) */ -%name(set_group) -void zebra_set_group (ZebraHandle zh, struct recordGroup *rg); +/* get a resource */ +%name(get_resource) +const char *zebra_set_resource(ZebraHandle zh, const char *name, + const char *defaultvalue); /* select database for update purposes (zebraapi.c) */ %name(select_database) @@ -235,7 +241,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) @@ -244,13 +250,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); - -/* 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); @@ -273,13 +272,13 @@ int zebra_init (ZebraHandle zh); int zebra_compact (ZebraHandle zh); %name(repository_update) -void zebra_repository_update (ZebraHandle zh); +void zebra_repository_update (ZebraHandle zh, const char *path); %name(repository_delete) -void zebra_repository_delete (ZebraHandle zh); +void zebra_repository_delete (ZebraHandle zh, const char *path); %name(repository_show) -void zebra_repository_show (ZebraHandle zh); +void zebra_repository_show (ZebraHandle zh, const char *path); /* == Record update/delete (zebra_api_ext.c) =============================== */ @@ -288,34 +287,50 @@ 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 long long *INOUT { long long *sysno }; + +%name(insert_record) +int zebra_insert_record (ZebraHandle zh, + const char *recordType, + long long *sysno, + const char *match, + const char *fname, + const char *buf, + int buf_size, + int force_update); +/* actually, sysno is only output param in insert_record, but kept */ +/* as inout for symmetry in the interface. The session class assures */ +/* that nothing goes in... */ + + %name(update_record) int zebra_update_record (ZebraHandle zh, - recordGroup *rGroup, const char *recordType, - int sysno, + long long *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, + long long *sysno, const char *match, const char *fname, const char *buf, - int buf_size); - -/* == Search (zebra_api_ext.c) ============================================= */ + int buf_size, + int force_update); +/* == 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 ==================================================== */ @@ -357,8 +372,17 @@ int zebra_deleleResultSet(ZebraHandle zh, int function, int *statuses); +/* Resultset terms */ +/* disabled +%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, @@ -374,6 +398,10 @@ void zebra_scan_PQF (ZebraHandle zh, scanEntry *getScanEntry(ScanObj *so, int pos); +%typemap(in) int * (int dvalue); +%typemap(argout) int *; + + /* Admin functionality */ /* %name(admin_start) void zebra_admin_start (ZebraHandle zh);