Math-String-Charset-Wordlist
view release on metacpan or search on metacpan
Wordlist.xs view on Meta::CPAN
int c;
long i;
int len;
unsigned char *name;
struct Offsets* offset;
long buffer[BUFFER_SIZE];
unsigned char read_buffer[READ_BUFFER_SIZE];
long buffered, idx, base, ofs;
size_t read;
PPCODE:
name = SvPVX(n); /* get ptr to storage */
len = sizeof (struct Offsets);
ST(0) = newSV(len); /* alloc enough to store one ptr */
SvPOK_on(ST(0));
offset = (struct Offsets*) SvPVX(ST(0)); /* get ptr to storage */
SvCUR_set(ST(0), len); /* and set real length */
offset->file = fopen( name, "r");
if (offset->file == NULL)
Wordlist.xs view on Meta::CPAN
##############################################################################
# _records(ptr,n), return the number of records
void
_records(ptr)
SV* ptr
INIT:
struct Offsets* offset;
PPCODE:
offset = (struct Offsets*) SvPVX(ptr); /* get ptr to storage */
ST(0) = sv_2mortal( newSVnv( offset->max_offsets ));
XSRETURN(1);
##############################################################################
# _offset(n), return the offset for record n. If the offset was not yet read,
# and we did not see the EOF yet, read all ofsets until n. Returns either
# the offset, or undef for "record does not exists" (e.g. file has fewer
# records than n).
void
_offset(ptr,n)
SV* ptr
SV* n
INIT:
long N;
struct Offsets* offset;
PPCODE:
N = SvNV(n);
offset = (struct Offsets*) SvPVX(ptr); /* get ptr to storage */
/* offset exists? */
if (N >= 0 && N < offset->max_offsets)
{
ST(0) = sv_2mortal( newSVnv( offset->record_offsets[N] ));
}
else
Wordlist.xs view on Meta::CPAN
_record(ptr,n)
SV* ptr
SV* n
INIT:
unsigned int N;
unsigned int ofs,len;
char* buf;
struct Offsets* offset;
PPCODE:
N = (int)SvNV(n);
offset = (struct Offsets*) SvPVX(ptr); /* get ptr to storage */
if (offset == NULL)
{
printf ("Offset is empty!");
ST(0) = &PL_sv_undef;
XSRETURN(1);
}
( run in 0.891 second using v1.01-cache-2.11-cpan-5511b514fd6 )