Small clean ups
[catagits/fcgi2.git] / perl / FCGI.pm
CommitLineData
b716743a 1# $Id: FCGI.pm,v 1.4 1999/08/03 15:52:54 skimo Exp $
1b64d24d 2
3package FCGI;
4
5require Exporter;
6require DynaLoader;
7
8@ISA = qw(Exporter DynaLoader);
9# Items to export into callers namespace by default. Note: do not export
10# names by default without a very good reason. Use EXPORT_OK instead.
11# Do not simply export all your public functions/methods/constants.
12@EXPORT = qw(
13
14);
15
b716743a 16$VERSION = '0.48';
1b64d24d 17
18bootstrap FCGI;
19
20# Preloaded methods go here.
21
22# Autoload methods go after __END__, and are processed by the autosplit program.
23
d8cc97fb 24sub request() {
25 Request();
26}
27
28sub accept(;$***$) {
29 return Accept(@_) if @_ == 5;
30
31 if (defined %FCGI::ENV) {
32 %ENV = %FCGI::ENV;
33 } else {
34 %FCGI::ENV = %ENV;
35 }
36 my $rc = Accept($global_request, \*STDIN, \*STDOUT, \*STDERR, \%ENV);
37
38 # not SFIO
39 $SIG{__WARN__} = $SIG{__DIE__} = $warn_die_handler if (tied (*STDIN));
40
41 return $rc;
42}
43
44sub finish(;$) {
45 return Finish(@_) if @_ == 1;
46
47 %ENV = %FCGI::ENV if (defined %FCGI::ENV);
48
49 # not SFIO
50 if (tied (*STDIN)) {
51 for (qw(__WARN__ __DIE__)) {
52 delete $SIG{$_} if ($SIG{$_} == $warn_die_handler);
53 }
54 }
55
56 Finish ($global_request);
57}
58
59sub flush(;$) {
60 return Flush(@_) if @_ == 1;
61
62 Flush($global_request);
63}
64
65# deprecated
66sub set_exit_status {
67}
68
69sub start_filter_data(;$) {
70 return StartFilterData(@_) if @_ == 1;
71
72 StartFilterData($global_request);
73}
74
75$global_request = Request();
76$warn_die_handler = sub { print STDERR @_ };
77
78package FCGI::Stream;
79
1b64d24d 80sub PRINTF {
81 shift->PRINT(sprintf(shift, @_));
82}
83
841;
85
86=head1 NAME
87
88FCGI - Fast CGI module
89
90=head1 SYNOPSIS
91
92 use FCGI;
93
94 $count = 0;
95 while(FCGI::accept() >= 0) {
96 print("Content-type: text/html\r\n\r\n", ++$count);
97 }
98
99=head1 DESCRIPTION
100
101Functions:
102
103=over 4
104
105=item FCGI::accept()
106
107Accepts a connection. Returns 0 on success.
108If a connection has been accepted before, the old
109one will be finished first.
110
111=item FCGI::finish()
112
113Finishes accepted connection.
114
115=item FCGI::flush()
116
117Flushes accepted connection.
118
119=item FCGI::set_exit_status(status)
120
121Sets the exit status that finish returns to the server.
122
123=item FCGI::start_filter_data()
124
125Does anyone use this function ?
126
127=back
128
129=head1 AUTHOR
130
131Sven Verdoolaege <skimo@kotnet.org>
132
133=cut
134
135__END__