X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=perl%2FIDZebra.i;h=70efba5d4ce6b947e75595239ffe314c84cc46e9;hb=c45742c694d4fa704d4282ada62c7f46c69fea88;hp=1cab21f3a6797da8b7012e054972038644e8ceee;hpb=43d2ebb33d16b27b18e4fc5bc24a81e1be43aba3;p=idzebra-moved-to-github.git diff --git a/perl/IDZebra.i b/perl/IDZebra.i index 1cab21f..70efba5 100644 --- a/perl/IDZebra.i +++ b/perl/IDZebra.i @@ -1,19 +1,39 @@ %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" +#include "yaz/cql.h" %} /* == 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++; } @@ -46,36 +66,87 @@ /* Creates a new Perl array and places a NULL-terminated char ** into it */ %typemap(out) char ** { - AV *myav; - SV **svs; - int i = 0,len = 0; - /* Figure out how many elements we have */ - while ($1[len]) - len++; - svs = (SV **) malloc(len*sizeof(SV *)); - for (i = 0; i < len ; i++) { - svs[i] = sv_newmortal(); - sv_setpv((SV*)svs[i],$1[i]); - }; - myav = av_make(len,svs); - free(svs); + AV *myav; + SV **svs; + int i = 0,len = 0; + /* Figure out how many elements we have */ + while ($1[len]) + len++; + svs = (SV **) malloc(len*sizeof(SV *)); + for (i = 0; i < len ; i++) { + svs[i] = sv_newmortal(); + sv_setpv((SV*)svs[i],$1[i]); + }; + myav = av_make(len,svs); + free(svs); $result = newRV((SV*)myav); sv_2mortal($result); argvi++; } - /* == 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; + int inserted; + int updated; + int deleted; + long utime; + long stime; +} ZebraTransactionStatus; /* == Module initialization and cleanup (zebra_perl.c) ===================== */ void init (void); void DESTROY (void); - /* == Logging facilities (yaz/log.h) ======================================= */ void logLevel (int level); @@ -161,19 +232,14 @@ 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) -void zebra_end_trans (ZebraHandle zh); +void zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *stat); -/* begin retrieval (add read lock) (zebraapi.c) */ -%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); +%name(trans_no) +int zebra_trans_no (ZebraHandle zh); /* commit changes from shadow (zebraapi.c) */ %name(commit) @@ -215,6 +281,7 @@ void zebra_repository_show (ZebraHandle zh); %name(update_record) int zebra_update_record (ZebraHandle zh, recordGroup *rGroup, + const char *recordType, int sysno, const char *match, const char *fname, @@ -224,6 +291,7 @@ int zebra_update_record (ZebraHandle zh, %name(delete_record) int zebra_delete_record (ZebraHandle zh, recordGroup *rGroup, + const char *recordType, int sysno, const char *match, const char *fname, @@ -239,8 +307,16 @@ int zebra_search_PQF (ZebraHandle zh, const char *setname); -/* TODO: search_CCL */ +/* == YAZ - query tools ==================================================== */ + +cql_transform_t cql_transform_open_fname(const char *fname); +void cql_transform_close(cql_transform_t ct); +int cql_transform_error(cql_transform_t ct, const char **addinfo); + +%name(cql2pqf) +int zebra_cql2pqf (cql_transform_t ct, + const char *query, char *res, int len); /* == Retrieval (zebra_api_ext.c) ========================================== */ @@ -264,6 +340,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, @@ -271,15 +354,15 @@ int sort (ZebraHandle zh, const char *output_setname, const char **input_setnames ); -/* -void zebra_sort (ZebraHandle zh, ODR stream, - int num_input_setnames, - const char **input_setnames, - const char *output_setname, - Z_SortKeySpecList *sort_sequence, - int *sort_status); -*/ +/* == Scan ================================================================= */ +%name(scan_PQF) +void zebra_scan_PQF (ZebraHandle zh, + ScanObj *so, + ODR stream, + const char *pqf_query); + +scanEntry *getScanEntry(ScanObj *so, int pos); /* Admin functionality */ /* @@ -287,21 +370,7 @@ void zebra_sort (ZebraHandle zh, ODR stream, %name(admin_shutdown) void zebra_admin_shutdown (ZebraHandle zh); */ -/* Browse -void zebra_scan (ZebraHandle zh, ODR stream, - Z_AttributesPlusTerm *zapt, - oid_value attributeset, - int *position, int *num_entries, - ZebraScanEntry **list, - int *is_partial); -*/ -/* Delete Result Set(s) */ -/* -int zebra_deleleResultSet(ZebraHandle zh, int function, - int num_setnames, char **setnames, - int *statuses); -*/ /* do authentication */ /* @@ -554,6 +623,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);