1docs::api::APR::PerlIO(U3s)er Contributed Perl Documentatdioocns::api::APR::PerlIO(3)
2
3
4

NAME

6       APR::PerlIO -- Perl IO layer for APR
7

Synopsis

9         # under mod_perl
10         use APR::PerlIO ();
11
12         sub handler {
13             my $r = shift;
14
15             die "This Perl build doesn't support PerlIO layers"
16                 unless APR::PerlIO::PERLIO_LAYERS_ARE_ENABLED;
17
18             open my $fh, ">:APR", $filename, $r->pool or die $!;
19             # work with $fh as normal $fh
20             close $fh;
21
22             return Apache2::Const::OK;
23         }
24
25         # outside mod_perl
26         % perl -MAPR -MAPR::PerlIO -MAPR::Pool -le \
27         'open my $fh, ">:APR", "/tmp/apr", APR::Pool->new or die "$!"; \
28          print $fh "whoah!"; \
29          close $fh;'
30

Description

32       "APR::PerlIO" implements a Perl IO layer using APR's file manipulation
33       API internally.
34
35       Why do you want to use this? Normally you shouldn't, probably it won't
36       be faster than Perl's default layer. It's only useful when you need to
37       manipulate a filehandle opened at the APR side, while using Perl.
38
39       Normally you won't call open() with APR layer attribute, but some
40       mod_perl functions will return a filehandle which is internally hooked
41       to APR. But you can use APR Perl IO directly if you want.
42

Prerequisites

44       Not every Perl will have full "APR::PerlIO" functionality available.
45
46       Before using the Perl IO APR layer one has to check whether it's sup‐
47       ported by the used APR/Perl build. Perl 5.8.x or higher with perlio
48       enabled is required. You can check whether your Perl fits the bill by
49       running:
50
51         % perl -V:useperlio
52         useperlio='define';
53
54       It should say define.
55
56       If you need to do the checking in the code, there is a special constant
57       provided by "APR::PerlIO", which can be used as follows:
58
59         use APR::PerlIO ();
60         die "This Perl build doesn't support PerlIO layers"
61             unless APR::PerlIO::PERLIO_LAYERS_ARE_ENABLED;
62
63       Notice that loading "APR::PerlIO" won't fail when Perl IO layers aren't
64       available since "APR::PerlIO" provides functionality for Perl builds
65       not supporting Perl IO layers.
66

Constants

68       "APR::PerlIO::PERLIO_LAYERS_ARE_ENABLED"
69
70       See Prerequisites.
71

API

73       Most of the API is as in normal perl IO with a few nuances listed in
74       the following sections.
75
76       META: need to rework the exception mechanism here. Current success in
77       using errno ($!) being set (e.g. on open()) is purely accidental and
78       not guaranteed across all platforms and functions. So don't rely on $!.
79       Will use "APR::Error" for that purpose.
80
81       "open"
82
83       Open a file via APR Perl IO layer.
84
85         open my $fh, ">:APR", $filename, $r->pool or die $!;
86
87       arg1: $fh ( GLOB filehandle )
88           The filehandle.
89
90       arg2: $mode ( string )
91           The mode to open the file, constructed from two sections separated
92           by the ":" character: the first section is the mode to open the
93           file under (>, <, etc) and the second section must be a string APR.
94           For more information refer to the open entry in the perlfunc man‐
95           page.
96
97       arg3: $filename ( string )
98           The path to the filename to open
99
100       arg4: $p ( "APR::Pool" )
101           The pool object to use to allocate APR::PerlIO layer.
102
103       ret: ( integer )
104           success or failure value (boolean).
105
106       since: 2.0.00
107
108       "seek"
109
110       Sets $fh's position, just like the "seek()" Perl call:
111
112         seek($fh, $offset, $whence);
113
114       If $offset is zero, "seek()" works normally.
115
116       However if $offset is non-zero and Perl has been compiled with with
117       large files support ("-Duselargefiles"), whereas APR wasn't, this func‐
118       tion will croak. This is because largefile size "Off_t" simply cannot
119       fit into a non-largefile size "apr_off_t".
120
121       To solve the problem, rebuild Perl with "-Uuselargefiles". Currently
122       there is no way to force APR to build with large files support.
123
124       since: 2.0.00
125

C API

127       The C API provides functions to convert between Perl IO and APR Perl IO
128       filehandles.
129
130       META: document these
131

See Also

133       mod_perl 2.0 documentation. The perliol(1), perlapio(1) and perl(1)
134       manpages.
135
137       mod_perl 2.0 and its core modules are copyrighted under The Apache
138       Software License, Version 2.0.
139

Authors

141       The mod_perl development team and numerous contributors.
142
143
144
145perl v5.8.8                       2006-11-19         docs::api::APR::PerlIO(3)
Impressum