File-Raw
view release on metacpan or search on metacpan
SvREFCNT_dec(bytes);
ST(0) = &PL_sv_undef;
XSRETURN(1);
}
if (out != bytes) SvREFCNT_dec(bytes);
if (!SvROK(out) || SvTYPE(SvRV(out)) != SVt_PVAV) {
SvREFCNT_dec(out);
croak("File::Raw::lines_iter: plugin must return an arrayref of records");
}
records = (AV *)SvRV(out);
SvREFCNT_inc(records); /* keep the AV alive on its own */
SvREFCNT_dec(out); /* drop the RV wrapper */
idx = alloc_iter_slot();
entry = &g_iters[idx];
entry->fd = -1; /* sentinel: no file behind us */
entry->buffer = NULL;
entry->buf_size = 0;
entry->buf_pos = 0;
entry->buf_len = 0;
entry->eof = 0;
include/file_plugin.h view on Meta::CPAN
typedef SV* (*file_plugin_write_fn) (pTHX_ FilePluginContext *ctx);
/* RECORD: returns the record (possibly transformed) to include, or
* &PL_sv_undef to exclude (caller interprets - grep filters on truthi-
* ness, map keeps everything non-NULL). Return NULL or set ctx->cancel
* to abort iteration. */
typedef SV* (*file_plugin_record_fn) (pTHX_ FilePluginContext *ctx, SV *record);
typedef int (*file_plugin_stream_fn) (pTHX_ FilePluginContext *ctx,
const char *chunk, size_t len, int eof);
/* Plugin registration block. The caller owns the storage - typically a
* file-scope static in the BOOT TU - and must keep it alive for as long
* as the plugin is registered. The registry stores the pointer, not a
* copy. */
typedef struct FilePlugin {
const char *name;
/* Field names are suffixed with _fn because plain `read`/`write` collide
* with Perl's host-IO macros on Win32 (PerlLIO_read/PerlLIO_write), which
* textually expand any `read`/`write` token followed by `(`. */
file_plugin_read_fn read_fn;
file_plugin_write_fn write_fn;
file_plugin_record_fn record_fn;
lib/File/Raw.pm view on Meta::CPAN
SV *callback; /* per-record cb (stream phase) */
HV *options; /* per-call opts; mortal; never NULL*/
int phase;
int cancel; /* set non-zero to cancel op */
void *plugin_state; /* opaque, copied from plugin->state*/
} FilePluginContext;
=item B<FilePlugin>
Registration block; the caller owns the storage (typically a file-scope
static) and must keep it alive for as long as the plugin is registered.
typedef struct FilePlugin {
const char *name;
file_plugin_read_fn read_fn; /* NULL if not implemented */
file_plugin_write_fn write_fn;
file_plugin_record_fn record_fn;
file_plugin_stream_fn stream_fn;
void *state;
} FilePlugin;
( run in 2.617 seconds using v1.01-cache-2.11-cpan-14f38c9f855 )