line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT /* we want efficiency */ |
2
|
|
|
|
|
|
|
#include "EXTERN.h" |
3
|
|
|
|
|
|
|
#include "perl.h" |
4
|
|
|
|
|
|
|
#include "XSUB.h" |
5
|
|
|
|
|
|
|
#include "ppport.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
/* #include */ |
8
|
|
|
|
|
|
|
#include "buffer.h" |
9
|
|
|
|
|
|
|
#include "uri.h" |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
MODULE = URI::XSEscape PACKAGE = URI::XSEscape |
12
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
################################################################# |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
SV* |
17
|
|
|
|
|
|
|
uri_escape(SV* string, ...) |
18
|
|
|
|
|
|
|
PREINIT: |
19
|
|
|
|
|
|
|
Buffer answer; |
20
|
135
|
|
|
|
|
|
STRLEN slen = 0; |
21
|
135
|
|
|
|
|
|
const char* sstr = 0; |
22
|
|
|
|
|
|
|
Buffer sbuf; |
23
|
135
|
|
|
|
|
|
SV* escape = 0; |
24
|
135
|
|
|
|
|
|
STRLEN elen = 0; |
25
|
135
|
|
|
|
|
|
const char* estr = 0; |
26
|
|
|
|
|
|
|
Buffer ebuf; |
27
|
|
|
|
|
|
|
CODE: |
28
|
135
|
50
|
|
|
|
|
buffer_init(&answer, 0); |
29
|
|
|
|
|
|
|
do { |
30
|
135
|
50
|
|
|
|
|
if (!string || !SvOK(string) || SvROK(string)) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
croak("uri_escape's mandatory first argument must be a string or number"); |
32
|
|
|
|
|
|
|
break; |
33
|
|
|
|
|
|
|
} |
34
|
135
|
50
|
|
|
|
|
if (items > 2) { |
35
|
0
|
|
|
|
|
|
croak("uri_escape called with too many arguments"); |
36
|
|
|
|
|
|
|
break; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
135
|
100
|
|
|
|
|
sstr = SvPVbyte(string, slen); |
40
|
135
|
100
|
|
|
|
|
buffer_wrap(&sbuf, sstr, slen); |
|
|
50
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
135
|
100
|
|
|
|
|
if (items == 1) { |
43
|
31
|
|
|
|
|
|
uri_encode(&sbuf, slen, &answer); |
44
|
31
|
|
|
|
|
|
break; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
104
|
|
|
|
|
|
escape = ST(1); |
48
|
104
|
50
|
|
|
|
|
if (!escape || !SvOK(escape) || !SvPOK(escape)) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
croak("uri_escape's optional second argument must be a string"); |
50
|
|
|
|
|
|
|
break; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
104
|
50
|
|
|
|
|
estr = SvPVbyte(escape, elen); |
54
|
104
|
50
|
|
|
|
|
buffer_wrap(&ebuf, estr, elen); |
|
|
0
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
104
|
|
|
|
|
|
uri_encode_matrix(&sbuf, slen, &ebuf, &answer); |
57
|
|
|
|
|
|
|
} while (0); |
58
|
135
|
|
|
|
|
|
RETVAL = newSVpv(answer.data, answer.pos); |
59
|
135
|
50
|
|
|
|
|
buffer_fini(&answer); |
|
|
100
|
|
|
|
|
|
60
|
|
|
|
|
|
|
OUTPUT: RETVAL |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
SV* |
63
|
|
|
|
|
|
|
uri_unescape(SV* string) |
64
|
|
|
|
|
|
|
PREINIT: |
65
|
|
|
|
|
|
|
Buffer answer; |
66
|
12
|
|
|
|
|
|
STRLEN slen = 0; |
67
|
12
|
|
|
|
|
|
const char* sstr = 0; |
68
|
|
|
|
|
|
|
Buffer sbuf; |
69
|
|
|
|
|
|
|
CODE: |
70
|
12
|
50
|
|
|
|
|
buffer_init(&answer, 0); |
71
|
|
|
|
|
|
|
do { |
72
|
12
|
50
|
|
|
|
|
if (!string || !SvOK(string) || !SvPOK(string)) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
croak("uri_unescape's mandatory first argument must be a string"); |
74
|
|
|
|
|
|
|
break; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
12
|
50
|
|
|
|
|
sstr = SvPV_const(string, slen); |
78
|
12
|
100
|
|
|
|
|
buffer_wrap(&sbuf, sstr, slen); |
|
|
50
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
12
|
|
|
|
|
|
uri_decode(&sbuf, slen, &answer); |
81
|
|
|
|
|
|
|
} while (0); |
82
|
12
|
|
|
|
|
|
RETVAL = newSVpv(answer.data, answer.pos); |
83
|
12
|
50
|
|
|
|
|
buffer_fini(&answer); |
|
|
100
|
|
|
|
|
|
84
|
|
|
|
|
|
|
OUTPUT: RETVAL |