#ifndef USE_SFIO
-void
+SV *
PRINT(stream, ...)
FCGI::Stream stream;
PREINIT:
- int n, sum = 0, ret = 0;
+ int n;
STRLEN len;
register char *str;
+ bool ok = TRUE;
CODE:
- for (n = 1; n < items; ++n) {
+ for (n = 1; ok && n < items; ++n) {
#ifdef DO_UTF8
- if (DO_UTF8(ST(n)) && !sv_utf8_downgrade(ST(n), 1))
- croak("Wide character in FCGI::Stream::PRINT");
+ if (DO_UTF8(ST(n)) && !sv_utf8_downgrade(ST(n), 1))
+ croak("Wide character in FCGI::Stream::PRINT");
#endif
str = (char *)SvPV(ST(n),len);
- if ((ret = FCGX_PutStr(str, len, stream)) < 0)
- break;
-
- sum += ret;
+ if (FCGX_PutStr(str, len, stream) < 0)
+ ok = FALSE;
}
- if (sum == 0 && ret < 0)
- XSRETURN_UNDEF;
-
+ if (ok && SvTRUEx(perl_get_sv("|", FALSE)) && FCGX_FFlush(stream) < 0)
+ ok = FALSE;
- if (SvTRUEx(perl_get_sv("|", FALSE)))
- FCGX_FFlush(stream);
- XSRETURN_YES;
+ RETVAL = ok ? &PL_sv_yes : &PL_sv_undef;
int
WRITE(stream, bufsv, len, ...)