line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT |
2
|
|
|
|
|
|
|
#include "EXTERN.h" |
3
|
|
|
|
|
|
|
#include "perl.h" |
4
|
|
|
|
|
|
|
#include "XSUB.h" |
5
|
|
|
|
|
|
|
#include "perliol.h" |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
|
|
|
static IV PerlIOBufferSize_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab) { |
8
|
1
|
|
|
|
|
|
PerlIOBuf* buffer = PerlIOSelf(f, PerlIOBuf); |
9
|
1
|
50
|
|
|
|
|
if (!(PerlIOBase(f)->tab->kind & PERLIO_K_BUFFERED)) |
10
|
0
|
|
|
|
|
|
Perl_warn(aTHX_ "Parent doesn't appear to be buffered, can't set buffer size"); |
11
|
1
|
50
|
|
|
|
|
else if (!arg || !SvOK(arg)) |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
Perl_warn(aTHX_ "No buffer size is given"); |
13
|
|
|
|
|
|
|
else { |
14
|
1
|
50
|
|
|
|
|
size_t size = SvIV(arg); |
15
|
1
|
50
|
|
|
|
|
if (buffer->buf) { |
16
|
0
|
0
|
|
|
|
|
if (size < buffer->bufsiz) |
17
|
0
|
|
|
|
|
|
Perl_croak(aTHX_ "Can't shrink buffer once in use"); |
18
|
0
|
|
|
|
|
|
Renew(buffer->buf, size, char); |
19
|
|
|
|
|
|
|
} |
20
|
1
|
|
|
|
|
|
buffer->bufsiz = size; |
21
|
1
|
|
|
|
|
|
return 0; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
return -1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
|
static PerlIO* PerlIOBufferSize_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, IV n, const char *mode, int fd, int imode, int perm, PerlIO *old, int narg, SV **args) { |
27
|
1
|
|
|
|
|
|
PerlIO_funcs * const tab = PerlIO_layer_fetch(aTHX_ layers, n - 1, NULL); |
28
|
1
|
50
|
|
|
|
|
if (tab && tab->Open) { |
|
|
50
|
|
|
|
|
|
29
|
1
|
|
|
|
|
|
PerlIO* ret = (*tab->Open)(aTHX_ tab, layers, n - 1, mode, fd, imode, perm, old, narg, args); |
30
|
1
|
50
|
|
|
|
|
if (ret && PerlIO_push(aTHX_ ret, self, mode, PerlIOArg) == NULL) { |
|
|
50
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
PerlIO_close(ret); |
32
|
0
|
|
|
|
|
|
return NULL; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
return ret; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
|
SETERRNO(EINVAL, LIB_INVARG); |
37
|
0
|
|
|
|
|
|
return NULL; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
const PerlIO_funcs PerlIO_buffersize = { |
41
|
|
|
|
|
|
|
sizeof(PerlIO_funcs), |
42
|
|
|
|
|
|
|
"buffersize", |
43
|
|
|
|
|
|
|
0, |
44
|
|
|
|
|
|
|
0, |
45
|
|
|
|
|
|
|
PerlIOBufferSize_pushed, |
46
|
|
|
|
|
|
|
NULL, |
47
|
|
|
|
|
|
|
PerlIOBufferSize_open, |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
MODULE = PerlIO::buffersize PACKAGE = PerlIO::socket |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
BOOT: |
53
|
1
|
|
|
|
|
|
PerlIO_define_layer(aTHX_ (PerlIO_funcs*)&PerlIO_buffersize); |