CodeBase
view release on metacpan or search on metacpan
CodeBase.xs view on Meta::CPAN
OUTPUT:
RETVAL
char *
filename(self)
CodeBase::File *self
CODE:
RETVAL = (char *)d4fileName(self->data4);
OUTPUT:
RETVAL
# $reccount = $file->reccount();
#
int
reccount(self)
CodeBase::File *self
CODE:
CB_TRACE(1, ("reccount(%s)\n", SvPV(ST(0),na)));
cb_errno = CB_SUCCESS;
RETVAL = d4recCount(self->data4);
if (RETVAL < 0)
{
cb_errno = RETVAL;
XSRETURN_UNDEF;
}
CB_TRACE(1, ("reccount returns %d\n", RETVAL));
OUTPUT:
RETVAL
# $recwidth = $file->recsize();
#
int
recsize(self)
CodeBase::File *self
CODE:
CB_TRACE(1, ("recsize(%s)\n", SvPV(ST(0),na)));
cb_errno = CB_SUCCESS;
RETVAL = d4recWidth(self->data4);
if (RETVAL < 0)
{
cb_errno = RETVAL;
XSRETURN_UNDEF;
}
CB_TRACE(1, ("recsize returns %d\n", RETVAL));
OUTPUT:
RETVAL
# $file->flush([$tries])
# flushes the data file an its index and memo files to disk
# calls d4flush, which returns 0, r4locked or r4unique.
void
flush(self, ...)
CodeBase::File *self
PREINIT:
/* int tries; */
CODE:
CB_TRACE(1, ("flush(\"%s\")\n", SELF));
cb_errno = d4flush(self->data4);
if (cb_errno)
{
CB_TRACE(1, ("flush returns (errno = %d)\n", cb_errno));
XSRETURN_UNDEF;
}
CB_TRACE(1, ("flush returns OK\n"));
XSRETURN_YES;
# $file->refresh([$tries])
void
refresh(self, ...)
CodeBase::File *self
PREINIT:
/* int tries; */
CODE:
CB_TRACE(1, ("refresh(\"%s\")\n", SELF));
cb_errno = d4refresh(self->data4);
if (cb_errno)
{
CB_TRACE(1, ("refresh returns (errno = %d)\n", cb_errno));
XSRETURN_UNDEF;
}
CB_TRACE(1, ("refresh returns OK\n"));
XSRETURN_YES;
# $rc = $file->lock($what, $tries)
#
void
lock(self, what=".", tries=5)
CodeBase::File *self
char *what
int tries
PREINIT:
int saved_attempts = cb_state.lockAttempts;
long recno;
int retval;
CODE:
CB_TRACE(1, ("lock(\"%s\", what=\"%s\", tries=%d)\n", SELF, what, tries));
cb_errno = CB_SUCCESS;
cb_state.lockAttempts = tries;
if (ISTREQ(what, "FILE"))
{
retval = d4lockAll(self->data4);
}
else
{
if (STREQ(what, "."))
{
recno = d4recNo(self->data4);
}
else
{
recno = SvIV(ST(1));
}
retval = (d4lock(self->data4, recno) == 0);
}
cb_state.lockAttempts = saved_attempts;
if (retval != 0)
{
cb_errno = retval;
CB_TRACE(1, ("lock returns error %d\n", retval));
XSRETURN_UNDEF;
}
CB_TRACE(1, ("lock returns OK\n"));
XSRETURN_YES;
# $rc = $file->unlock()
#
void
unlock(self)
CodeBase::File *self
CODE:
CB_TRACE(1, ("unlock(\"%s\")\n", SELF));
cb_errno = d4unlock(self->data4);
if (cb_errno)
{
CB_TRACE(1, ("unlock returns (errno = %d)\n", cb_errno));
XSRETURN_UNDEF;
}
CB_TRACE(1, ("unlock returns OK\n"));
XSRETURN_YES;
# $file->pack([$compress_memo])
# Pack removes all deleted reocords from the data file
# and also reindexes open index files. an its index and memo files to disk
# Calls d4pack, which returns 0, r4locked, r4unique or an error code < 0.
void
pack(self, compress_memo = FALSE)
CodeBase::File *self
Boolean compress_memo
CODE:
CB_TRACE(1, ("pack(\"%s\", %s)\n", SELF, compress_memo ? "TRUE" : "FALSE"));
cb_errno = CB_SUCCESS;
if ( (d4pack(self->data4) != 0)
|| (compress_memo
&& (d4memoCompress(self->data4) != 0)))
{
CB_TRACE(1, ("pack returns error %d\n", cb_errno));
XSRETURN_UNDEF;
}
CB_TRACE(1, ("close returns OK\n"));
XSRETURN_YES;
void
zap(self, from, to, compress_memo=0)
CodeBase::File *self
long from
long to
int compress_memo
PREINIT:
int rc;
CODE:
if (from < 1 || to < 1 || from > to) {
XSRETURN_UNDEF;
}
rc = d4zap(self->data4, from, to);
if (rc == r4success || rc == r4unique) {
if (compress_memo
&& d4memoCompress(self->data4) != r4success) {
XSRETURN_UNDEF;
}
}
XSRETURN_YES;
# Destructor function - closes the file
void
DESTROY(self)
CodeBase::File *self
CODE:
CB_TRACE(1, ("DESTROY(\"%s\")\n", SELF));
close_fcb(self);
CB_TRACE(1, ("DESTROY returns (errno = %d)\n", cb_errno));
##############################################################################
#
# Record oriented functions:
CodeBase.xs view on Meta::CPAN
if (key)
{
value = SvPV(*key, na);
CB_TRACE(1, ("create_index: tag %d duplicates=\"%s\"\n", tag_no, value));
if (ISTREQ(value, "keep"))
{
tag4info[tag_no].unique = 0;
}
else if (ISTREQ(value, "discard"))
{
tag4info[tag_no].unique = r4unique_continue;
}
}
}
tag4info[tag_no].name = NULL;
if (i4create(self->data4, name, tag4info) == NULL)
{
CB_TRACE(1, ("create_index error %d\n", cb_errno));
XSRETURN_UNDEF;
}
CB_TRACE(1, ("create_index returns OK\n"));
XSRETURN_YES;
# $file->open_index(name)
#
void
open_index(self, ...)
CodeBase::File *self
PREINIT:
char *name;
CODE:
cb_errno = CB_SUCCESS;
if (items == 1)
{
CB_TRACE(1, ("open_index(\"%s\")\n", SELF));
name = NULL;
}
else
{
name = SvPV(ST(1), na);
CB_TRACE(1, ("open_index(\"%s\", \"%s\")\n", SELF, name));
}
if (!i4open(self->data4, name))
{
CB_TRACE(1, ("open_index error %d\n", cb_errno));
XSRETURN_UNDEF;
}
CB_TRACE(1, ("open_index returns OK\n"));
XSRETURN_YES;
# $file->check_indexes()
# Reindexes all index files open for the file.
# Calls d4reindex, which returns 0, r4locked, r4unique or an error code < 0.
void
check_indexes(self)
CodeBase::File *self
CODE:
CB_TRACE(1, ("check_indexes(\"%s\")\n", SELF));
cb_errno = CB_SUCCESS;
if (d4check(self->data4) != 0)
{
CB_TRACE(1, ("check_indexes returns error %d\n", cb_errno));
XSRETURN_UNDEF;
}
CB_TRACE(1, ("check_indexes returns OK\n"));
XSRETURN_YES;
# $file->reindex()
# Reindexes all index files open for the file.
# Calls d4reindex, which returns 0, r4locked, r4unique or an error code < 0.
void
reindex(self)
CodeBase::File *self
CODE:
CB_TRACE(1, ("reindex(\"%s\")\n", SELF));
cb_errno = CB_SUCCESS;
if (d4reindex(self->data4) != 0)
{
CB_TRACE(1, ("reindex returns error %d\n", cb_errno));
XSRETURN_UNDEF;
}
CB_TRACE(1, ("reindex returns OK\n"));
XSRETURN_YES;
##############################################################################
#
# $tagcount = $file->tagcount
#
# Return number of tags associated with current index file.
#
int
tagcount(self)
CodeBase::File *self
PREINIT:
TAG4 *tag = NULL;
int n_tags = 0;
CODE:
CB_TRACE(1, ("tagcount(\"%s\")\n", SELF));
cb_errno = CB_SUCCESS;
while ((tag = d4tagNext(self->data4, tag)) != NULL)
{
n_tags++;
}
CB_TRACE(1, ("tagcount returns %d\n", n_tags));
RETVAL = n_tags;
OUTPUT:
RETVAL
# @taginfo = $file->taginfo
#
# Return tags associated with current index file.
#
void
taginfo(self, index_name = NULL)
CodeBase::File *self
char *index_name
PREINIT:
INDEX4 *index;
HV *hash;
SV *ref;
TAG4INFO *tag4info;
int tag_no;
char *value;
( run in 0.677 second using v1.01-cache-2.11-cpan-e1769b4cff6 )