I know you don't need *FunctionTable.pm, but hey, it's free.
--- ../modperl-2.0/src/modules/perl/modperl_filter.h Tue May 22 11:07:28 2001
+++ src/modules/perl/modperl_filter.h Tue May 29 14:16:26 2001
@@ -42,6 +42,15 @@
SV *buffer,
apr_ssize_t wanted);
+MP_INLINE int modperl_output_filter_eof(pTHX_
+ modperl_filter_t *filter);
+
+MP_INLINE int modperl_output_filter_tell(pTHX_
+ modperl_filter_t *filter);
+
+MP_INLINE int modperl_output_filter_close(pTHX_
+ modperl_filter_t *filter);
+
MP_INLINE apr_status_t modperl_output_filter_write(modperl_filter_t *filter,
const char *buf,
apr_ssize_t *len);
--- ../modperl-2.0/src/modules/perl/modperl_types.h Thu May 10 14:48:17 2001
+++ src/modules/perl/modperl_types.h Tue May 29 14:27:02 2001
@@ -179,7 +179,9 @@
} modperl_filter_mode_e;
typedef struct {
- int eos;
+ uint eos:1; /* EOS found */
+ uint eof:1; /* No more data to send to Perl code */
+ apr_ssize_t read_cnt; /* bytes actually read */
ap_filter_t *f;
char *leftover;
apr_ssize_t remaining;
--- ../modperl-2.0/xs/Apache/Filter/Apache__Filter.h Tue May 22 11:05:24 2001
+++ xs/Apache/Filter/Apache__Filter.h Tue May 29 13:53:56 2001
@@ -32,6 +32,33 @@
return bytes;
}
+
+static MP_INLINE int mpxs_Apache__Filter_eof(pTHX_ I32 items,
+ SV **MARK, SV **SP)
+{
+ modperl_filter_t *modperl_filter;
+ mpxs_usage_va_1(modperl_filter, "$filter->eof()");
+ return modperl_output_filter_eof(aTHX_ modperl_filter);
+}
+
+
+static MP_INLINE int mpxs_Apache__Filter_tell(pTHX_ I32 items,
+ SV **MARK, SV **SP)
+{
+ modperl_filter_t *modperl_filter;
+ mpxs_usage_va_1(modperl_filter, "$filter->tell()");
+ return modperl_output_filter_tell(aTHX_ modperl_filter);
+}
+
+static MP_INLINE int mpxs_Apache__Filter_close(pTHX_ I32 items,
+ SV **MARK, SV **SP)
+{
+ modperl_filter_t *modperl_filter;
+ mpxs_usage_va_1(modperl_filter, "$filter->close()");
+ return modperl_output_filter_send_EOS(modperl_filter);
+}
+
+
static MP_INLINE apr_size_t mpxs_Apache__Filter_read(pTHX_ I32 items,
SV **MARK, SV **SP)
{
--- ../modperl-2.0/t/filter/TestFilter/api.pm Thu Apr 19 21:57:26 2001
+++ t/filter/TestFilter/api.pm Tue May 29 14:01:17 2001
@@ -23,15 +23,35 @@
sub handler {
my $filter = shift;
- $filter->read(my $buffer); #slurp everything;
-
init_test_pm($filter);
- plan tests => 6;
+ plan tests => 14;
+
+ ok $filter->isa('Apache::Filter');
+
+ ok !$filter->eof;
+
+ ok !$filter->tell;
+
+ my $s = $filter->read(my $buffer); #slurp everything;
+
+ ok $s == length $response_data;
ok $buffer eq $response_data;
- ok $filter->isa('Apache::Filter');
+ ok $filter->tell == length $response_data;
+
+ ok !$filter->eof;
+
+ $s = $filter->read($buffer); #try to slurp a bit more
+
+ ok $filter->tell == length $response_data;
+
+ ok !$s;
+
+ ok !$filter->close ;
+
+ #ok $filter->eof; Hmmm, no EOS => no eof. Rats.
my $frec = $filter->frec;
--- ../modperl-2.0/src/modules/perl/modperl_filter.c Thu May 24 10:55:51 2001
+++ src/modules/perl/modperl_filter.c Tue May 29 14:20:06 2001
@@ -223,6 +223,7 @@
sv_catpvn(buffer, filter->leftover, wanted);
filter->leftover += wanted;
filter->remaining -= wanted;
+ filter->read_cnt += wanted;
return wanted;
}
else {
@@ -237,6 +238,9 @@
if (!filter->bb) {
MP_TRACE_f(MP_FUNC, "bucket brigade has been emptied\n");
+ if (filter->eos) {
+ filter->eof=1;
+ }
return 0;
}
@@ -269,6 +273,7 @@
MP_TRACE_f(MP_FUNC,
"apr_bucket_read error: %s\n",
modperl_apr_strerror(filter->rc));
+ filter->read_cnt += len;
return len;
}
@@ -298,8 +303,27 @@
}
#endif
+ if (!len && filter->eos && !filter->remaining) {
+ filter->eof=1;
+ }
+
+ filter->read_cnt += len;
return len;
}
+
+MP_INLINE apr_ssize_t modperl_output_filter_eof(pTHX_
+ modperl_filter_t *filter)
+{
+ return filter->eof;
+}
+
+
+MP_INLINE apr_ssize_t modperl_output_filter_tell(pTHX_
+ modperl_filter_t *filter)
+{
+ return filter->read_cnt;
+}
+
MP_INLINE apr_status_t modperl_output_filter_flush(modperl_filter_t *filter)
{
--- ../modperl-2.0/xs/maps/modperl_functions.map Thu May 10 14:51:49 2001
+++ xs/maps/modperl_functions.map Tue May 29 13:54:30 2001
@@ -36,6 +36,9 @@
mpxs_Apache__Filter_print | | ...
mpxs_Apache__Filter_read | | ...
+ mpxs_Apache__Filter_eof | | ...
+ mpxs_Apache__Filter_tell | | ...
+ mpxs_Apache__Filter_close | | ...
SV *:DEFINE_TIEHANDLE | | SV *:stashsv, SV *:sv=Nullsv
int:DEFINE_PRINT | | ...
--- ../modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm Thu May 10 14:52:08
2001
+++ xs/tables/current/ModPerl/FunctionTable.pm Tue May 29 14:28:19 2001
@@ -2059,6 +2059,48 @@
'name' => 'modperl_output_filter_read'
},
{
+ 'return_type' => 'int',
+ 'args' => [
+ {
+ 'name' => 'my_perl',
+ 'type' => 'PerlInterpreter *'
+ },
+ {
+ 'name' => 'filter',
+ 'type' => 'modperl_filter_t *'
+ },
+ ],
+ 'name' => 'modperl_output_filter_eof'
+ },
+ {
+ 'return_type' => 'int',
+ 'args' => [
+ {
+ 'name' => 'my_perl',
+ 'type' => 'PerlInterpreter *'
+ },
+ {
+ 'name' => 'filter',
+ 'type' => 'modperl_filter_t *'
+ },
+ ],
+ 'name' => 'modperl_output_filter_tell'
+ },
+ {
+ 'return_type' => 'int',
+ 'args' => [
+ {
+ 'name' => 'my_perl',
+ 'type' => 'PerlInterpreter *'
+ },
+ {
+ 'name' => 'filter',
+ 'type' => 'modperl_filter_t *'
+ },
+ ],
+ 'name' => 'modperl_output_filter_close'
+ },
+ {
'return_type' => 'apr_status_t',
'args' => [
{
@@ -3644,6 +3686,72 @@
}
],
'name' => 'mpxs_Apache__Filter_read'
+ },
+ {
+ 'return_type' => 'int',
+ 'args' => [
+ {
+ 'name' => 'my_perl',
+ 'type' => 'PerlInterpreter *'
+ },
+ {
+ 'name' => 'items',
+ 'type' => 'I32'
+ },
+ {
+ 'name' => 'mark',
+ 'type' => 'SV **'
+ },
+ {
+ 'name' => 'sp',
+ 'type' => 'SV **'
+ }
+ ],
+ 'name' => 'mpxs_Apache__Filter_eof'
+ },
+ {
+ 'return_type' => 'int',
+ 'args' => [
+ {
+ 'name' => 'my_perl',
+ 'type' => 'PerlInterpreter *'
+ },
+ {
+ 'name' => 'items',
+ 'type' => 'I32'
+ },
+ {
+ 'name' => 'mark',
+ 'type' => 'SV **'
+ },
+ {
+ 'name' => 'sp',
+ 'type' => 'SV **'
+ }
+ ],
+ 'name' => 'mpxs_Apache__Filter_tell'
+ },
+ {
+ 'return_type' => 'int',
+ 'args' => [
+ {
+ 'name' => 'my_perl',
+ 'type' => 'PerlInterpreter *'
+ },
+ {
+ 'name' => 'items',
+ 'type' => 'I32'
+ },
+ {
+ 'name' => 'mark',
+ 'type' => 'SV **'
+ },
+ {
+ 'name' => 'sp',
+ 'type' => 'SV **'
+ }
+ ],
+ 'name' => 'mpxs_Apache__Filter_close'
},
{
'return_type' => 'U32 *',
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]