Filter-Crypto
view release on metacpan or search on metacpan
CryptFile/CryptFile.xs view on Meta::CPAN
if (update_mode) {
sv_catsv(to_sv, from2_sv);
#ifdef FILTER_CRYPTO_DEBUG_MODE
FilterCrypto_HexDumpSV(aTHX_ from2_sv,
"Appended %d bytes to output buffer", SvCUR(from2_sv)
);
#endif
sv_setuv(num_bytes, SvUV(num_bytes) + SvCUR(from2_sv));
}
else {
/* Get the data and length to output. */
const unsigned char *from2_text =
(const unsigned char *)SvPVX_const(from2_sv);
int from2_len = SvCUR(from2_sv);
if (PerlIO_write(to_fh, from2_text, from2_len) < from2_len) {
FilterCrypto_SetErrStr(aTHX_
"Can't write to output filehandle: %s",
FILTER_CRYPTO_SYS_ERR_STR
);
return FALSE;
}
#ifdef FILTER_CRYPTO_DEBUG_MODE
FilterCrypto_HexDump(aTHX_ from2_text, from2_len,
"Wrote %d bytes to output stream", from2_len
);
#endif
sv_setuv(num_bytes, SvUV(num_bytes) + from2_len);
}
FilterCrypto_SvSetCUR(from_sv, 0);
return TRUE;
}
/*============================================================================*/
MODULE = Filter::Crypto::CryptFile PACKAGE = Filter::Crypto::CryptFile
#===============================================================================
# XS CODE SECTION
#===============================================================================
PROTOTYPES: ENABLE
VERSIONCHECK: ENABLE
INCLUDE: const-xs.inc
INCLUDE: ../CryptoCommon-xs.inc
# Private function to expose the FILTER_CRYPTO_DEBUG_MODE constant.
void
_debug_mode();
PROTOTYPE:
PPCODE:
{
#ifdef FILTER_CRYPTO_DEBUG_MODE
XSRETURN_YES;
#else
XSRETURN_EMPTY;
#endif
}
# Private function to expose the FilterCrypto_CryptFh() function above, as
# called with one in-out filehandle.
void
_crypt_fh(fh, crypt_mode_ex, num_bytes);
PROTOTYPE: $$$
INPUT:
InOutStream fh;
FILTER_CRYPTO_MODE_EX crypt_mode_ex
SV* num_bytes
PPCODE:
{
if (FilterCrypto_CryptFh(aTHX_ fh, (PerlIO *)NULL, crypt_mode_ex,
num_bytes))
XSRETURN_YES;
else
XSRETURN_EMPTY;
}
# Private function to expose the FilterCrypto_CryptFh() function above, as
# called with one input filehandle and one output filehandle.
void
_crypt_fhs(in_fh, out_fh, crypt_mode_ex, num_bytes);
PROTOTYPE: $$$$
INPUT:
InputStream in_fh;
OutputStream out_fh;
FILTER_CRYPTO_MODE_EX crypt_mode_ex;
SV* num_bytes;
PPCODE:
{
if (FilterCrypto_CryptFh(aTHX_ in_fh, out_fh, crypt_mode_ex, num_bytes))
XSRETURN_YES;
else
XSRETURN_EMPTY;
}
#===============================================================================
( run in 1.976 second using v1.01-cache-2.11-cpan-5511b514fd6 )