This snippet show the original C code from zopen.c calling read() and then my substitute in some Inline::C code using perl's read(). I don't know that it is "ok" to call perl builtins from Inline::C by calling CORE:: functions. So is it? And is there a better way to write this?
/* Check the magic number */
if (read(zs->zs_fh, header, sizeof(header)) != sizeof(header) ||
memcmp(header, z_magic, sizeof(z_magic)) != 0) {
errno = EFTYPE;
return (-1);
}
/* Check the magic number */
Inline_Stack_Reset;
Inline_Stack_Push(zs->zs_fh); /* a SV* of a IO handle passed in ea
+rlier */
Inline_Stack_Push(header);
Inline_Stack_Push(sizeof(header));
perl_call_pv("CORE::read",G_SCALAR);
read_rval = (ssize_t)POPi;
Inline_Stack_Done;
if (read_rval != sizeof(header) ||
memcmp(header, z_magic, sizeof(z_magic)) != 0) {
errno = EFTYPE;
return (-1);
}