line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include "ppport.h" |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#define CONSTANT(name, key, value) hv_store(get_hv("PerlIO::Layers::" #name, TRUE), key, sizeof key - 1, newSVuv(value), 0) |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#define INSTANCE_CONSTANT(cons) CONSTANT(FLAG_FOR, #cons, PERLIO_F_##cons) |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#define KIND_CONSTANT(cons) CONSTANT(KIND_FOR, #cons, PERLIO_K_##cons) |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
MODULE = PerlIO::Layers PACKAGE = PerlIO::Layers |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BOOT: |
18
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(EOF); |
19
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(CANWRITE); |
20
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(CANREAD); |
21
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(ERROR); |
22
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(TRUNCATE); |
23
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(APPEND); |
24
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(CRLF); |
25
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(UTF8); |
26
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(UNBUF); |
27
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(WRBUF); |
28
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(RDBUF); |
29
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(LINEBUF); |
30
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(TEMP); |
31
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(OPEN); |
32
|
1
|
|
|
|
|
|
INSTANCE_CONSTANT(FASTGETS); |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
|
KIND_CONSTANT(BUFFERED); |
35
|
1
|
|
|
|
|
|
KIND_CONSTANT(RAW); |
36
|
1
|
|
|
|
|
|
KIND_CONSTANT(CANCRLF); |
37
|
1
|
|
|
|
|
|
KIND_CONSTANT(FASTGETS); |
38
|
1
|
|
|
|
|
|
KIND_CONSTANT(MULTIARG); |
39
|
1
|
|
|
|
|
|
KIND_CONSTANT(UTF8); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
SV* |
42
|
|
|
|
|
|
|
_get_kinds(handle); |
43
|
|
|
|
|
|
|
PerlIO* handle; |
44
|
|
|
|
|
|
|
PREINIT: |
45
|
12
|
|
|
|
|
|
HV* ret = newHV(); |
46
|
|
|
|
|
|
|
CODE: |
47
|
37
|
100
|
|
|
|
|
while (PerlIOBase(handle)) { |
48
|
|
|
|
|
|
|
PerlIOl* current = PerlIOBase(handle); |
49
|
25
|
|
|
|
|
|
hv_store(ret, current->tab->name, strlen(current->tab->name), newSViv(current->tab->kind), 0); |
50
|
25
|
|
|
|
|
|
handle = PerlIONext(handle); |
51
|
|
|
|
|
|
|
} |
52
|
12
|
|
|
|
|
|
RETVAL = newRV_noinc((SV*)ret); |
53
|
|
|
|
|
|
|
OUTPUT: |
54
|
|
|
|
|
|
|
RETVAL |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
IV |
57
|
|
|
|
|
|
|
get_buffer_sizes(handle); |
58
|
|
|
|
|
|
|
PerlIO* handle; |
59
|
|
|
|
|
|
|
PREINIT: |
60
|
|
|
|
|
|
|
PerlIO* current; |
61
|
|
|
|
|
|
|
int counter = 0; |
62
|
|
|
|
|
|
|
PPCODE: |
63
|
3
|
100
|
|
|
|
|
for (current = handle; *current; current = PerlIONext(current)) { |
64
|
|
|
|
|
|
|
PerlIOBuf* buffer; |
65
|
2
|
100
|
|
|
|
|
if (!(PerlIOBase(current)->tab->kind & PERLIO_K_BUFFERED)) |
66
|
1
|
|
|
|
|
|
continue; |
67
|
|
|
|
|
|
|
buffer = PerlIOSelf(current, PerlIOBuf); |
68
|
1
|
50
|
|
|
|
|
if (!buffer->bufsiz && !buffer->buf) |
|
|
50
|
|
|
|
|
|
69
|
1
|
|
|
|
|
|
PerlIO_get_base(current); |
70
|
1
|
50
|
|
|
|
|
mXPUSHu(buffer->bufsiz); |
71
|
1
|
|
|
|
|
|
counter++; |
72
|
|
|
|
|
|
|
} |
73
|
1
|
50
|
|
|
|
|
if (!counter) |
74
|
0
|
|
|
|
|
|
Perl_croak(aTHX_ "Handle not buffered, aborting"); |
75
|
1
|
|
|
|
|
|
PUTBACK; |
76
|
|
|
|
|
|
|
|