Commit | Line | Data |
b716743a |
1 | # $Id: FCGI.pm,v 1.4 1999/08/03 15:52:54 skimo Exp $ |
1b64d24d |
2 | |
3 | package FCGI; |
4 | |
5 | require Exporter; |
6 | require 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 | |
18 | bootstrap FCGI; |
19 | |
20 | # Preloaded methods go here. |
21 | |
22 | # Autoload methods go after __END__, and are processed by the autosplit program. |
23 | |
d8cc97fb |
24 | sub request() { |
25 | Request(); |
26 | } |
27 | |
28 | sub 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 | |
44 | sub 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 | |
59 | sub flush(;$) { |
60 | return Flush(@_) if @_ == 1; |
61 | |
62 | Flush($global_request); |
63 | } |
64 | |
65 | # deprecated |
66 | sub set_exit_status { |
67 | } |
68 | |
69 | sub 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 | |
78 | package FCGI::Stream; |
79 | |
1b64d24d |
80 | sub PRINTF { |
81 | shift->PRINT(sprintf(shift, @_)); |
82 | } |
83 | |
84 | 1; |
85 | |
86 | =head1 NAME |
87 | |
88 | FCGI - 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 | |
101 | Functions: |
102 | |
103 | =over 4 |
104 | |
105 | =item FCGI::accept() |
106 | |
107 | Accepts a connection. Returns 0 on success. |
108 | If a connection has been accepted before, the old |
109 | one will be finished first. |
110 | |
111 | =item FCGI::finish() |
112 | |
113 | Finishes accepted connection. |
114 | |
115 | =item FCGI::flush() |
116 | |
117 | Flushes accepted connection. |
118 | |
119 | =item FCGI::set_exit_status(status) |
120 | |
121 | Sets the exit status that finish returns to the server. |
122 | |
123 | =item FCGI::start_filter_data() |
124 | |
125 | Does anyone use this function ? |
126 | |
127 | =back |
128 | |
129 | =head1 AUTHOR |
130 | |
131 | Sven Verdoolaege <skimo@kotnet.org> |
132 | |
133 | =cut |
134 | |
135 | __END__ |