Allow clobbering of a PerlIO::Scalar and more tests
[p5sagit/p5-mst-13.2.git] / ext / PerlIO / Via / Via.pm
CommitLineData
e7a1fdd7 1package PerlIO::Via;
2our $VERSION = '0.01';
3use XSLoader ();
4XSLoader::load 'PerlIO::Via';
51;
6__END__
7
8=head1 NAME
9
10PerlIO::Via - Helper class for PerlIO layers implemented in perl
11
12=head1 SYNOPSIS
13
14 use Some::Package;
15
16 open($fh,"<:Via(Some::Package)",...);
17
18=head1 DESCRIPTION
19
20The package to be used as a layer should implement at least some of the
21following methods. In the method descriptions below I<$fh> will be
22a reference to a glob which can be treated as a perl file handle.
23It refers to the layer below. I<$fh> is not passed if the layer
24is at the bottom of the stack, for this reason and to maintain
25some level of "compatibility" with TIEHANDLE classes it is passed
26last.
27
28=over 4
29
30=item $class->PUSHED([$mode][,$fh])
31
32Should return an object or the class. (Compare TIEHANDLE.)
33Mandatory.
34
35=item $obj->POPPED([$fh])
36
37Optional - layer is about to be removed.
38
39=item $class->OPEN($path,$mode[,$fh])
40
41Not yet in use.
42
43=item $class->FDOPEN($fd)
44
45Not yet in use.
46
47=item $class->SYSOPEN($path,$imode,$perm,$fh)
48
49Not yet in use.
50
51=item $obj->FILENO($fh)
52
47bfe92f 53Returns a numeric value for Unix-like file descriptor. Return -1 if
54there isn't one. Optional. Default is fileno($fh).
e7a1fdd7 55
56=item $obj->READ($buffer,$len,$fh)
57
58Returns the number of octets placed in $buffer (must be less that $len).
47bfe92f 59Optional. Default is to use FILL instead.
e7a1fdd7 60
61=item $obj->WRITE($buffer,$fh)
62
63Returns the number of octets from buffer that have been sucessfully written.
64
65=item $obj->FILL($fh)
66
47bfe92f 67Should return a string to be placed in the buffer. Optional. If not
68provided must provide READ or reject handles open for reading in
69PUSHED.
e7a1fdd7 70
71=item $obj->CLOSE($fh)
72
73Should return 0 on success, -1 on error.
74Optional.
75
76=item $obj->SEEK($posn,$whence,$fh)
77
78Should return 0 on success, -1 on error.
79Optional. Default is to fail, but that is likely to be changed.
80
81=item $obj->TELL($fh)
82
83Returns file postion.
84Optional. Default to be determined.
85
86=item $obj->UNREAD($buffer,$fh)
87
47bfe92f 88Returns the number of octets from buffer that have been sucessfully
89saved to be returned on future FILL/READ calls. Optional. Default is
90to push data into a temporary layer above this one.
e7a1fdd7 91
92=item $obj->FLUSH($fh)
93
47bfe92f 94Flush any buffered write data. May possibly be called on readable
95handles too. Should return 0 on success, -1 on error.
e7a1fdd7 96
97=item $obj->SETLINEBUF($fh)
98
99Optional. No return.
100
101=item $obj->CLEARERR($fh)
102
103Optional. No return.
104
105=item $obj->ERROR($fh)
106
107Optional. Returns error state. Default is no error until a mechanism
108to signal error (die?) is worked out.
109
110=item $obj->EOF($fh)
111
47bfe92f 112Optional. Returns end-of-file state. Default is function of return
113value of FILL or READ.
e7a1fdd7 114
115=back
116
117=cut
118
119