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
47       supported 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       See Prerequisites.
70

API

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

C API

124       The C API provides functions to convert between Perl IO and APR Perl IO
125       filehandles.
126
127       META: document these
128

See Also

130       mod_perl 2.0 documentation. The perliol(1), perlapio(1) and perl(1)
131       manpages.
132
134       mod_perl 2.0 and its core modules are copyrighted under The Apache
135       Software License, Version 2.0.
136

Authors

138       The mod_perl development team and numerous contributors.
139
140
141
142perl v5.34.0                      2022-02-02         docs::api::APR::PerlIO(3)
Impressum