File-LibMagic
view release on metacpan or search on metacpan
LibMagic.xs view on Meta::CPAN
int flags;
SV *content;
STRLEN len;
char *string;
const char *description;
const char *mime;
const char *encoding;
SV *d;
SV *m;
SV *e;
PPCODE:
if (SvROK(buffer)) {
content = SvRV(buffer);
}
else {
content = buffer;
}
if ( ! SvPOK(content) ) {
croak("info_from_string requires a scalar or reference to a scalar as its argument");
}
LibMagic.xs view on Meta::CPAN
PREINIT:
magic_t magic;
int flags;
char *file;
const char *description;
const char *mime;
const char *encoding;
SV *d;
SV *m;
SV *e;
PPCODE:
if ( ! SvPOK(filename) ) {
croak("info_from_filename requires a scalar as its argument");
}
file = SvPV_nolen(filename);
RETURN_INFO(self, magic_file, file);
void _info_from_handle(self, handle)
SV *self
LibMagic.xs view on Meta::CPAN
PerlIO *io;
char buf[BUFSIZE];
Off_t pos;
SSize_t read;
const char *description;
const char *mime;
const char *encoding;
SV *d;
SV *m;
SV *e;
PPCODE:
if ( ! SvOK(handle) ) {
croak("info_from_handle requires a scalar filehandle as its argument");
}
io = IoIFP(sv_2io(handle));
if ( ! io ) {
croak("info_from_handle requires a scalar filehandle as its argument");
}
pos = PerlIO_tell(io);
const/inc.xs view on Meta::CPAN
dTARGET;
#endif
STRLEN len;
int type;
IV iv = 0; /* avoid uninit var warning */
/* NV nv; Uncomment this if you need to return NVs */
/* const char *pv; Uncomment this if you need to return PVs */
INPUT:
SV * sv;
const char * s = SvPV(sv, len);
PPCODE:
/* Change this to constant(aTHX_ s, len, &iv, &nv);
if you need to return both NVs and IVs */
type = constant(aTHX_ s, len, &iv);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
sv =
sv_2mortal(newSVpvf("%s is not a valid File::LibMagic macro", s));
PUSHs(sv);
( run in 0.539 second using v1.01-cache-2.11-cpan-5511b514fd6 )