Decoder.xs

filter: Statementstmt 60.1% 196 / 326 Branchbran 41.9% 88 / 210 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 52.9% 284 / 536 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« srl_reader_misc.h ↑ Summary ptable.h »
1 /* Must be defined before including Perl header files or we slow down by 2x! */
2 #define PERL_NO_GET_CONTEXT
3  
4 #define NEED_newSV_type
5 #include "EXTERN.h"
6 #include "perl.h"
7 #include "XSUB.h"
8  
9 #include "ppport.h"
10  
11 #include "srl_common.h"
12 #include "srl_decoder.h"
13 #include "srl_protocol.h"
14 #include "srl_siphash.h"
15  
16 /* new() marks its handle; a blessed integer from elsewhere is not one. */
17 static MGVTBL srl_handle_vtbl;
18 static int
19 293 srl_is_handle(SV *sv)
20 {
21 MAGIC *mg;
22 293 ▶ if (SvTYPE(sv) < SVt_PVMG)
Branch: 1 branch
BranchTrueFalseTotal
if (SvTYPE(sv) < SVt_PVMG) 0 293 293
23 0 return 0;
24 293 ▶ for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic)
Branch: 1 branch
BranchTrueFalseTotal
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) 293 0 293
25 293 ▶ if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &srl_handle_vtbl)
Branch: 2 branches
BranchTrueFalseTotal
if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &srl_handle_vtbl) 293 0 293
if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &srl_handle_vtbl) 293 0 293
26 293 return 1;
27 0 return 0;
28 }
29 #define SRL_IS_HANDLE(sv) srl_is_handle(sv)
30  
31 #ifndef GvCV_set
32 # define GvCV_set(gv, cv) (GvCV(gv) = (cv))
33 #endif
34  
35 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
36 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
37  
38 /* prototype to pass -Wmissing-prototypes */
39 STATIC void
40 S_croak_xs_usage(pTHX_ const CV *const cv, const char *const params);
41  
42 STATIC void
43 S_croak_xs_usage(pTHX_ const CV *const cv, const char *const params)
44 {
45 const GV *const gv = CvGV(cv);
46  
47 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
48  
49 if (gv) {
50 const char *const gvname = GvNAME(gv);
51 const HV *const stash = GvSTASH(gv);
52 const char *const hvname = stash ? HvNAME(stash) : NULL;
53  
54 if (hvname)
55 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
56 else
57 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
58 } else {
59 /* Pants. I don't think that it should be possible to get here. */
60 Perl_croak_nocontext("Usage: CODE(0x%"UVxf")(%s)", PTR2UV(cv), params);
61 }
62 }
63  
64 #ifdef PERL_IMPLICIT_CONTEXT
65 #define croak_xs_usage(a,b) S_croak_xs_usage(aTHX_ a,b)
66 #else
67 #define croak_xs_usage S_croak_xs_usage
68 #endif
69  
70 #endif
71  
72  
73 #if defined(cv_set_call_checker) && defined(XopENTRY_set)
74 # define USE_CUSTOM_OPS 1
75 #else
76 # define USE_CUSTOM_OPS 0
77 #endif
78  
79 #define OPOPT_DO_BODY (1<<0)
80 #define OPOPT_DO_HEADER (1<<1)
81 #define OPOPT_OFFSET (1<<2)
82 #define OPOPT_OUTARG_BODY (1<<3)
83 #define OPOPT_OUTARG_HEADER (1<<4)
84 #define OPOPT_LOOKS_LIKE (1<<5)
85 #define OPOPT_CHECKSUM (1<<6)
86 #define OPOPT_VALIDATE_CHECKSUM (1<<7)
87  
88 static void
89 0 THX_pp1_checksum(pTHX_ U8 opopt, U8 arity)
90 {
91 0 const int validate = (opopt & OPOPT_VALIDATE_CHECKSUM) != 0;
92 0 const int want_result = GIMME_V != G_VOID;
93 0 SV *src, *key = NULL, *offset_sv = NULL, *result;
94 UV offset;
95 0 dSP;
96 0 ▶ if (arity == 3 || (!validate && arity == 2))
Branch: 3 branches
BranchTrueFalseTotal
if (arity == 3 || (!validate && arity == 2)) 0 0 0
if (arity == 3 || (!validate && arity == 2)) 0 0 0
if (arity == 3 || (!validate && arity == 2)) 0 0 0
97 0 offset_sv = POPs;
98 0 ▶ if (validate && arity >= 2)
Branch: 2 branches
BranchTrueFalseTotal
if (validate && arity >= 2) 0 0 0
if (validate && arity >= 2) 0 0 0
99 0 key = POPs;
100 0 src = POPs;
101 0 PUTBACK;
102 0 ▶ offset = offset_sv ? SvUV(offset_sv) : 0;
Branch: 1 branch
BranchTrueFalseTotal
offset = offset_sv ? SvUV(offset_sv) : 0; 0 0 0
103 0 result = validate
104 0 ▶ ? boolSV(srl_validate_sereal_checksum(aTHX_ src, key, offset))
Branch: 1 branch
BranchTrueFalseTotal
? boolSV(srl_validate_sereal_checksum(aTHX_ src, key, offset)) 0 0 0
105 0 ▶ : sv_2mortal(srl_get_sereal_checksum(aTHX_ src, offset));
Branch: 1 branch
BranchTrueFalseTotal
: sv_2mortal(srl_get_sereal_checksum(aTHX_ src, offset)); 0 0 0
106 0 SPAGAIN;
107 0 ▶ if (want_result)
Branch: 1 branch
BranchTrueFalseTotal
if (want_result) 0 0 0
108 0 ▶ XPUSHs(result);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(result); 0 0 0
109 0 PUTBACK;
110 0 }
111  
112 #define pp1_sereal_decode(opopt) THX_pp1_sereal_decode(aTHX_ opopt)
113 static void
114 249 THX_pp1_sereal_decode(pTHX_ U8 opopt)
115 {
116 249 bool need_retvalue = GIMME_V != G_VOID;
117 SV *decoder_ref_sv, *decoder_sv, *src_sv;
118 UV offset;
119 SV *body_into, *header_into;
120 srl_decoder_t *decoder;
121 char *stash_name;
122 249 dSP;
123  
124 498 header_into = expect_false(opopt & OPOPT_OUTARG_HEADER)
125 10 ? POPs
126 249 ▶ : expect_false(opopt & OPOPT_DO_HEADER) ? sv_newmortal() : NULL;
Branch: 2 branches
BranchTrueFalseTotal
: expect_false(opopt & OPOPT_DO_HEADER) ? sv_newmortal() : NULL; 10 239 249
: expect_false(opopt & OPOPT_DO_HEADER) ? sv_newmortal() : NULL; 0 239 239
127 498 body_into = expect_false(opopt & OPOPT_OUTARG_BODY)
128 237 ? POPs
129 249 ▶ : expect_true(opopt & OPOPT_DO_BODY) ? sv_newmortal() : NULL;
Branch: 2 branches
BranchTrueFalseTotal
: expect_true(opopt & OPOPT_DO_BODY) ? sv_newmortal() : NULL; 237 12 249
: expect_true(opopt & OPOPT_DO_BODY) ? sv_newmortal() : NULL; 8 4 12
130  
131 249 ▶ offset = expect_false(opopt & OPOPT_OFFSET) ? SvUVx(POPs) : 0;
Branch: 1 branch
BranchTrueFalseTotal
offset = expect_false(opopt & OPOPT_OFFSET) ? SvUVx(POPs) : 0; 0 249 249
132 249 src_sv = POPs;
133 249 decoder_ref_sv = POPs;
134 249 PUTBACK;
135  
136 249 ▶ if (!expect_true(
Branch: 14 branches
BranchTrueFalseTotal
if (!expect_true( 249 0 249
if (!expect_true( 249 0 249
if (!expect_true( 249 0 249
if (!expect_true( 249 0 249
if (!expect_true( 249 0 249
if (!expect_true( 249 0 249
if (!expect_true( 0 249 249
if (!expect_true( 0 0 0
if (!expect_true( 249 0 249
if (!expect_true( 0 249 249
if (!expect_true( 249 0 249
if (!expect_true( 249 0 249
if (!expect_true( 249 0 249
if (!expect_true( 0 249 249
137 decoder_ref_sv &&
138 SvROK(decoder_ref_sv) &&
139 (decoder_sv = SvRV(decoder_ref_sv)) &&
140 SvOBJECT(decoder_sv) &&
141 (stash_name = HvNAME(SvSTASH(decoder_sv))) &&
142 !strcmp(stash_name, "Sereal::Decoder") &&
143 SRL_IS_HANDLE(decoder_sv)
144 ))
145 {
146 0 croak("handle is not a Sereal::Decoder handle");
147 }
148  
149 249 decoder = (srl_decoder_t *)SvIV(decoder_sv);
150 /* A callback may clear the variable holding this handle. Retain its
151 * referent, which owns the C decoder, until decode cleanup has run. */
152 249 SAVEFREESV(SvREFCNT_inc(decoder_sv));
153 249 ▶ if (expect_true(opopt & OPOPT_DO_BODY)) {
Branch: 1 branch
BranchTrueFalseTotal
if (expect_true(opopt & OPOPT_DO_BODY)) { 245 4 249
154 245 ▶ if (opopt & OPOPT_DO_HEADER) {
Branch: 1 branch
BranchTrueFalseTotal
if (opopt & OPOPT_DO_HEADER) { 6 239 245
155 6 srl_decode_all_into(aTHX_ decoder, src_sv, header_into,
156 body_into, offset);
157 } else {
158 239 srl_decode_into(aTHX_ decoder, src_sv, body_into, offset);
159 }
160 } else {
161 4 srl_decode_header_into(aTHX_ decoder, src_sv, header_into, offset);
162 }
163  
164 247 ▶ if (expect_true(need_retvalue)) {
Branch: 1 branch
BranchTrueFalseTotal
if (expect_true(need_retvalue)) { 6 241 247
165 SV *retvalue;
166 6 ▶ if (expect_true(opopt & OPOPT_DO_BODY)) {
Branch: 1 branch
BranchTrueFalseTotal
if (expect_true(opopt & OPOPT_DO_BODY)) { 6 0 6
167 6 ▶ if (opopt & OPOPT_DO_HEADER) {
Branch: 1 branch
BranchTrueFalseTotal
if (opopt & OPOPT_DO_HEADER) { 0 6 6
168 0 AV *retav = newAV();
169 0 retvalue = newRV_noinc((SV*)retav);
170 0 sv_2mortal(retvalue);
171 0 av_extend(retav, 1);
172 0 av_store(retav, 0, SvREFCNT_inc(header_into));
173 0 av_store(retav, 1, SvREFCNT_inc(body_into));
174 } else {
175 6 retvalue = body_into;
176 }
177 } else {
178 0 retvalue = header_into;
179 }
180 6 SPAGAIN;
181 6 ▶ XPUSHs(retvalue);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(retvalue); 0 6 6
182 6 PUTBACK;
183 }
184 247 }
185  
186 #define pp1_looks_like_sereal() THX_pp1_looks_like_sereal(aTHX)
187 static void
188 0 THX_pp1_looks_like_sereal(pTHX)
189 {
190 0 dSP;
191 0 SV *data= TOPs;
192 /* Should this be SvPOK()? Or better yet, check if it's *really* a string pointer: SvPOKp(data). After all
193 the serialization format is a string and anything otherwise would not look sereal. */
194 0 ▶ if ( SvOK(data) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( SvOK(data) ) { 0 0 0
195 STRLEN len;
196 0 char *strdata= SvPV(data, len);
197 0 IV ret= srl_validate_header_version_pv_len(aTHX_ strdata, len);
198 0 ▶ if ( ret < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( ret < 0 ) { 0 0 0
199 0 SETs(&PL_sv_no);
200 } else {
201 0 SETs(sv_2mortal(newSViv(ret & SRL_PROTOCOL_VERSION_MASK)));
202 }
203 } else {
204 0 SETs(&PL_sv_no);
205 }
206 0 }
207  
208 #if USE_CUSTOM_OPS
209  
210 /* Custom ops bypass the XSUB compatibility wrapper. Keep their arguments
211 * alive and give their results stack references on RC-stack Perls. */
212 #ifdef PERL_RC_STACK
213 # define SRL_PP(name, nargs) XSPP_wrapped(name, nargs, 0)
214 #else
215 # define SRL_PP(name, nargs) static OP *name(pTHX)
216 #endif
217  
218 3 SRL_PP(THX_pp_sereal_decode,
219 2 + !!(PL_op->op_private & OPOPT_OFFSET)
220 + !!(PL_op->op_private & OPOPT_OUTARG_BODY)
221 + !!(PL_op->op_private & OPOPT_OUTARG_HEADER))
222 {
223 3 pp1_sereal_decode(PL_op->op_private);
224 3 return NORMAL;
225 }
226  
227 0 SRL_PP(THX_pp_looks_like_sereal, 1)
228 {
229 0 pp1_looks_like_sereal();
230 0 return NORMAL;
231 }
232  
233 0 SRL_PP(THX_pp_get_sereal_checksum, PL_op->op_private & 3)
234 {
235 0 THX_pp1_checksum(aTHX_ PL_op->op_private, PL_op->op_private & 3);
236 0 return NORMAL;
237 }
238  
239 0 SRL_PP(THX_pp_validate_sereal_checksum, PL_op->op_private & 3)
240 {
241 0 THX_pp1_checksum(aTHX_ PL_op->op_private, PL_op->op_private & 3);
242 0 return NORMAL;
243 }
244  
245 static OP *
246 45 THX_ck_entersub_args_sereal_decoder(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
247 {
248  
249 /* pull apart a standard entersub op tree */
250  
251 45 CV *cv = (CV*)ckobj;
252 45 I32 cv_private = CvXSUBANY(cv).any_i32;
253 45 U8 opopt = cv_private & 0xff;
254 45 U8 min_arity = (cv_private >> 8) & 0xff;
255 45 U8 max_arity = (cv_private >> 16) & 0xff;
256 OP *pushop, *firstargop, *cvop, *lastargop, *argop, *newop;
257 int arity;
258  
259 /* Walk the OP structure under the "entersub" to validate that we
260 * can use the custom OP implementation. */
261  
262 45 entersubop = ck_entersub_args_proto(entersubop, namegv, (SV*)cv);
263 45 pushop = cUNOPx(entersubop)->op_first;
264 45 ▶ if ( ! OpHAS_SIBLING(pushop) )
Branch: 1 branch
BranchTrueFalseTotal
if ( ! OpHAS_SIBLING(pushop) ) 45 0 45
265 45 pushop = cUNOPx(pushop)->op_first;
266 45 ▶ firstargop = OpSIBLING(pushop);
Branch: 1 branch
BranchTrueFalseTotal
firstargop = OpSIBLING(pushop); 45 0 45
267  
268 139 ▶ for (cvop = firstargop; OpHAS_SIBLING(cvop); cvop = OpSIBLING(cvop)) ;
Branch: 2 branches
BranchTrueFalseTotal
for (cvop = firstargop; OpHAS_SIBLING(cvop); cvop = OpSIBLING(cvop)) ; 94 0 94
for (cvop = firstargop; OpHAS_SIBLING(cvop); cvop = OpSIBLING(cvop)) ; 94 45 139
269  
270 45 lastargop = pushop;
271 45 for (
272 45 arity = 0, lastargop = pushop, argop = firstargop;
273 139 ▶ argop != cvop;
Branch: 1 branch
BranchTrueFalseTotal
argop != cvop; 94 45 139
274 94 lastargop = argop, argop = OpSIBLING(argop)
275 ){
276 94 ▶ arity++;
Branch: 1 branch
BranchTrueFalseTotal
arity++; 94 0 94
277 }
278  
279 45 ▶ if (expect_false(arity < min_arity || arity > max_arity))
Branch: 3 branches
BranchTrueFalseTotal
if (expect_false(arity < min_arity || arity > max_arity)) 45 0 45
if (expect_false(arity < min_arity || arity > max_arity)) 0 45 45
if (expect_false(arity < min_arity || arity > max_arity)) 0 45 45
280 0 return entersubop;
281  
282 /* If we get here, we can replace the entersub with a suitable
283 * custom OP. */
284  
285 45 ▶ if (opopt & OPOPT_CHECKSUM) {
Branch: 1 branch
BranchTrueFalseTotal
if (opopt & OPOPT_CHECKSUM) { 0 45 45
286 0 opopt |= arity;
287 } else {
288 45 ▶ if (arity > min_arity && (opopt & OPOPT_DO_BODY)) {
Branch: 2 branches
BranchTrueFalseTotal
if (arity > min_arity && (opopt & OPOPT_DO_BODY)) { 3 42 45
if (arity > min_arity && (opopt & OPOPT_DO_BODY)) { 2 1 3
289 2 opopt |= OPOPT_OUTARG_BODY;
290 2 min_arity++;
291 }
292  
293 45 ▶ if (arity > min_arity)
Branch: 1 branch
BranchTrueFalseTotal
if (arity > min_arity) 2 43 45
294 2 opopt |= OPOPT_OUTARG_HEADER;
295 }
296  
297 #ifdef op_sibling_splice
298 /* op_sibling_splice is new in 5.31 and we have to do things differenly */
299  
300 /* cut out all ops between the pushmark and the RV2CV */
301 45 op_sibling_splice(NULL, pushop, arity, NULL);
302 /* then throw everything else out */
303 45 op_free(entersubop);
304 45 newop = newUNOP(OP_NULL, 0, NULL);
305  
306 #else
307  
308 OpMORESIB_set(pushop, cvop);
309 OpLASTSIB_set(lastargop, op_parent(lastargop));
310 op_free(entersubop);
311 newop = newUNOP(OP_NULL, 0, firstargop);
312  
313 #endif
314  
315 45 newop->op_type = OP_CUSTOM;
316 45 newop->op_private = opopt;
317 90 newop->op_ppaddr = opopt & OPOPT_CHECKSUM
318 0 ▶ ? (opopt & OPOPT_VALIDATE_CHECKSUM ? THX_pp_validate_sereal_checksum : THX_pp_get_sereal_checksum)
Branch: 1 branch
BranchTrueFalseTotal
? (opopt & OPOPT_VALIDATE_CHECKSUM ? THX_pp_validate_sereal_checksum : THX_pp_get_sereal_checksum) 0 0 0
319 45 ▶ : (opopt & OPOPT_LOOKS_LIKE ? THX_pp_looks_like_sereal : THX_pp_sereal_decode);
Branch: 2 branches
BranchTrueFalseTotal
: (opopt & OPOPT_LOOKS_LIKE ? THX_pp_looks_like_sereal : THX_pp_sereal_decode); 0 45 45
: (opopt & OPOPT_LOOKS_LIKE ? THX_pp_looks_like_sereal : THX_pp_sereal_decode); 0 45 45
320  
321 #ifdef op_sibling_splice
322  
323 /* attach the spliced-out args as children of the custom op, while
324 * deleting the stub op created by newUNOP() */
325 45 op_free(op_sibling_splice(newop, NULL, 1, firstargop));
326  
327 #endif
328  
329 45 return newop;
330 }
331  
332 #endif /* USE_CUSTOM_OPS */
333  
334 static void
335 0 THX_xsfunc_checksum(pTHX_ CV *cv)
336 {
337 0 dMARK;
338 0 dSP;
339 0 SSize_t arity = SP - MARK;
340 0 I32 cv_private = CvXSUBANY(cv).any_i32;
341 0 U8 opopt = cv_private & 0xff;
342 0 U8 max_arity = (cv_private >> 16) & 0xff;
343 0 ▶ if (arity < 1 || arity > max_arity)
Branch: 2 branches
BranchTrueFalseTotal
if (arity < 1 || arity > max_arity) 0 0 0
if (arity < 1 || arity > max_arity) 0 0 0
344 0 ▶ croak_xs_usage(cv, opopt & OPOPT_VALIDATE_CHECKSUM ? "packet [, key [, offset]]" : "packet [, offset]");
Branch: 1 branch
BranchTrueFalseTotal
croak_xs_usage(cv, opopt & OPOPT_VALIDATE_CHECKSUM ? "packet [, key [, offset]]" : "packet [, offset]"); 0 0 0
345 0 THX_pp1_checksum(aTHX_ opopt, (U8)arity);
346 0 }
347  
348 static void
349 246 THX_xsfunc_sereal_decode(pTHX_ CV *cv)
350 {
351 246 dMARK;
352 246 dSP;
353 246 SSize_t arity = SP - MARK;
354 246 I32 cv_private = CvXSUBANY(cv).any_i32;
355 246 U8 opopt = cv_private & 0xff;
356 246 U8 min_arity = (cv_private >> 8) & 0xff;
357 246 U8 max_arity = (cv_private >> 16) & 0xff;
358  
359 246 ▶ if (arity < min_arity || arity > max_arity)
Branch: 2 branches
BranchTrueFalseTotal
if (arity < min_arity || arity > max_arity) 246 0 246
if (arity < min_arity || arity > max_arity) 0 246 246
360 0 croak("bad Sereal decoder usage");
361 246 ▶ if (arity > min_arity && (opopt & OPOPT_DO_BODY)) {
Branch: 2 branches
BranchTrueFalseTotal
if (arity > min_arity && (opopt & OPOPT_DO_BODY)) { 238 8 246
if (arity > min_arity && (opopt & OPOPT_DO_BODY)) { 235 3 238
362 235 opopt |= OPOPT_OUTARG_BODY;
363 235 min_arity++;
364 }
365 246 ▶ if (arity > min_arity)
Branch: 1 branch
BranchTrueFalseTotal
if (arity > min_arity) 8 238 246
366 8 opopt |= OPOPT_OUTARG_HEADER;
367  
368 246 pp1_sereal_decode(opopt);
369 244 }
370  
371 static void
372 0 THX_xsfunc_looks_like_sereal(pTHX_ CV *cv)
373 {
374 0 dMARK;
375 0 dSP;
376 0 SSize_t arity = SP - MARK;
377 0 I32 cv_private = CvXSUBANY(cv).any_i32;
378 0 U8 max_arity = (cv_private >> 16) & 0xff;
379  
380 0 ▶ if (arity < 1 || arity > max_arity)
Branch: 2 branches
BranchTrueFalseTotal
if (arity < 1 || arity > max_arity) 0 0 0
if (arity < 1 || arity > max_arity) 0 0 0
381 0 ▶ croak_xs_usage(cv, max_arity == 1 ? "data" : "[invocant,] data");
Branch: 1 branch
BranchTrueFalseTotal
croak_xs_usage(cv, max_arity == 1 ? "data" : "[invocant,] data"); 0 0 0
382 0 ▶ if(arity == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if(arity == 2) { 0 0 0
383 0 SV *data = POPs;
384 0 SETs(data);
385 0 PUTBACK;
386 }
387 0 pp1_looks_like_sereal();
388 0 }
389  
390 #define MY_CXT_KEY "Sereal::Decoder::_stash" XS_VERSION
391  
392 typedef struct {
393 sv_with_hash options[SRL_DEC_OPT_COUNT];
394 U8 known_option_heads[SRL_OPTION_INDEX_BUCKETS];
395 U8 known_option_next[SRL_DEC_OPT_COUNT];
396 } my_cxt_t;
397  
398 START_MY_CXT
399  
400 static void
401 50 srl_init_my_cxt(pTHX)
402 {
403 dMY_CXT;
404 50 Zero(MY_CXT.known_option_heads, SRL_OPTION_INDEX_BUCKETS, U8);
405 50 Zero(MY_CXT.known_option_next, SRL_DEC_OPT_COUNT, U8);
406 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_ALIAS_SMALLINT, SRL_DEC_OPT_STR_ALIAS_SMALLINT );
407 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_ALIAS_VARINT_UNDER, SRL_DEC_OPT_STR_ALIAS_VARINT_UNDER );
408 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_DESTRUCTIVE_INCREMENTAL, SRL_DEC_OPT_STR_DESTRUCTIVE_INCREMENTAL );
409 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_MAX_NUM_HASH_ENTRIES, SRL_DEC_OPT_STR_MAX_NUM_HASH_ENTRIES );
410 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_MAX_RECURSION_DEPTH, SRL_DEC_OPT_STR_MAX_RECURSION_DEPTH );
411 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_NO_BLESS_OBJECTS, SRL_DEC_OPT_STR_NO_BLESS_OBJECTS );
412 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_REFUSE_OBJECTS, SRL_DEC_OPT_STR_REFUSE_OBJECTS );
413 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_REFUSE_SNAPPY, SRL_DEC_OPT_STR_REFUSE_SNAPPY );
414 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_REFUSE_ZLIB, SRL_DEC_OPT_STR_REFUSE_ZLIB );
415 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_SET_READONLY, SRL_DEC_OPT_STR_SET_READONLY );
416 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_SET_READONLY_SCALARS, SRL_DEC_OPT_STR_SET_READONLY_SCALARS );
417 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_USE_UNDEF, SRL_DEC_OPT_STR_USE_UNDEF );
418 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_VALIDATE_UTF8, SRL_DEC_OPT_STR_VALIDATE_UTF8 );
419 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_REFUSE_ZSTD, SRL_DEC_OPT_STR_REFUSE_ZSTD );
420 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_MAX_NUM_ARRAY_ENTRIES, SRL_DEC_OPT_STR_MAX_NUM_ARRAY_ENTRIES );
421 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_MAX_STRING_LENGTH, SRL_DEC_OPT_STR_MAX_STRING_LENGTH );
422 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_MAX_UNCOMPRESSED_SIZE, SRL_DEC_OPT_STR_MAX_UNCOMPRESSED_SIZE );
423 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_NO_THAW_OBJECTS, SRL_DEC_OPT_STR_NO_THAW_OBJECTS );
424 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_THAW_ALLOW_CLASSES, SRL_DEC_OPT_STR_THAW_ALLOW_CLASSES );
425 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_ALLOWED_CLASSES, SRL_DEC_OPT_STR_ALLOWED_CLASSES );
426 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_PARANOID, SRL_DEC_OPT_STR_PARANOID );
427 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_ALLOW_CLASSES, SRL_DEC_OPT_STR_ALLOW_CLASSES );
428 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_TRACK_CLASSES, SRL_DEC_OPT_STR_TRACK_CLASSES );
429 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_THAW_DENY_ACTION, SRL_DEC_OPT_STR_THAW_DENY_ACTION );
430 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_CHECKSUM_KEY_V1, SRL_DEC_OPT_STR_CHECKSUM_KEY_V1 );
431 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_CHECKSUM_KEY_V2, SRL_DEC_OPT_STR_CHECKSUM_KEY_V2 );
432 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_CHECKSUM_KEY_V3, SRL_DEC_OPT_STR_CHECKSUM_KEY_V3 );
433 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_CHECKSUM_POLICY, SRL_DEC_OPT_STR_CHECKSUM_POLICY );
434 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_UNDEF_DEADLY_POLICY, SRL_DEC_OPT_STR_UNDEF_DEADLY_POLICY );
435 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_UNKNOWN_OPTION_POLICY, SRL_DEC_OPT_STR_UNKNOWN_OPTION_POLICY );
436 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_CHECKSUM_KEY, SRL_DEC_OPT_STR_CHECKSUM_KEY );
437 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_CHECKSUM_MODE, SRL_DEC_OPT_STR_CHECKSUM_MODE );
438 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_LEGACY_FLOAT_BYTEORDER, SRL_DEC_OPT_STR_LEGACY_FLOAT_BYTEORDER );
439 50 SRL_INIT_OPTION( SRL_DEC_OPT_IDX_ALLOW_UNKNOWN_LONG_DOUBLE, SRL_DEC_OPT_STR_ALLOW_UNKNOWN_LONG_DOUBLE );
440 50 }
441  
442  
443 MODULE = Sereal::Decoder PACKAGE = Sereal::Decoder
444 PROTOTYPES: DISABLE
445  
446 SV *
447 prepare_checksum_key(key = NULL, opt_key = NULL)
448 SV *key;
449 SV *opt_key;
450 PREINIT:
451 0 STRLEN key_len = 0;
452 0 STRLEN opt_key_len = 0;
453 0 const U8 *key_bytes = (const U8 *)"";
454 0 ▶ const U8 *opt_key_bytes = (const U8 *)"";
Branch: 1 branch
BranchTrueFalseTotal
const U8 *opt_key_bytes = (const U8 *)""; 0 0 0
455 U8 digest[16];
456 CODE:
457 0 ▶ if (key && SvOK(key))
Branch: 2 branches
BranchTrueFalseTotal
if (key && SvOK(key)) 0 0 0
if (key && SvOK(key)) 0 0 0
458 0 key_bytes = (const U8 *)SvPVbyte(key, key_len);
459 0 ▶ if (opt_key && SvOK(opt_key)) {
Branch: 2 branches
BranchTrueFalseTotal
if (opt_key && SvOK(opt_key)) { 0 0 0
if (opt_key && SvOK(opt_key)) { 0 0 0
460 0 opt_key_bytes = (const U8 *)SvPVbyte(opt_key, opt_key_len);
461 }
462 0 srl_siphash_prepare_key(key_bytes, (size_t)key_len,
463 opt_key_bytes, (size_t)opt_key_len, digest);
464 0 RETVAL = newSVpvn((const char *)digest, sizeof(digest));
465 OUTPUT: RETVAL
466  
467 SV *
468 siphash24(data, key = NULL)
469 SV *data;
470 SV *key;
471 PREINIT:
472 STRLEN data_len;
473 STRLEN key_len;
474 const U8 *data_bytes;
475 const U8 *key_bytes;
476 srl_siphash_ctx sip;
477 srl_u64 digest;
478 U8 digest_bytes[8];
479 unsigned int i;
480 static const U8 zero_key[16] = { 0 };
481 CODE:
482 1 data_bytes = (const U8 *)SvPVbyte(data, data_len);
483 1 ▶ if (key == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (key == NULL) { 0 1 1
484 0 key_bytes = zero_key;
485 }
486 else {
487 1 key_bytes = (const U8 *)SvPVbyte(key, key_len);
488 1 ▶ if (key_len != 16)
Branch: 1 branch
BranchTrueFalseTotal
if (key_len != 16) 0 1 1
489 0 croak("siphash24 key must be exactly 16 bytes");
490 }
491 1 srl_siphash_init_rounds(&sip, key_bytes, 2, 4, 0);
492 1 srl_siphash_update(&sip, data_bytes, (size_t)data_len);
493 1 digest = srl_siphash_final64(&sip);
494 9 ▶ for (i = 0; i < 8; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < 8; i++) 8 1 9
495 8 digest_bytes[i] = (U8)(digest >> (8 * i));
496 1 RETVAL = newSVpvn((const char *)digest_bytes, sizeof(digest_bytes));
497 OUTPUT: RETVAL
498  
499 SV *
500 siphash24_128(data, key = NULL)
501 SV *data;
502 SV *key;
503 PREINIT:
504 STRLEN data_len;
505 STRLEN key_len;
506 const U8 *data_bytes;
507 const U8 *key_bytes;
508 srl_siphash_ctx sip;
509 U8 digest[16];
510 static const U8 zero_key[16] = { 0 };
511 CODE:
512 3 data_bytes = (const U8 *)SvPVbyte(data, data_len);
513 3 ▶ if (key == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (key == NULL) { 0 3 3
514 0 key_bytes = zero_key;
515 }
516 else {
517 3 key_bytes = (const U8 *)SvPVbyte(key, key_len);
518 3 ▶ if (key_len != 16)
Branch: 1 branch
BranchTrueFalseTotal
if (key_len != 16) 0 3 3
519 0 croak("siphash24_128 key must be exactly 16 bytes");
520 }
521 3 srl_siphash_init_rounds(&sip, key_bytes, 2, 4, 1);
522 3 srl_siphash_update(&sip, data_bytes, (size_t)data_len);
523 3 srl_siphash_final128(&sip, digest);
524 3 RETVAL = newSVpvn((const char *)digest, sizeof(digest));
525 OUTPUT: RETVAL
526  
527 SV *
528 siphash36_128(data, key = NULL)
529 SV *data;
530 SV *key;
531 PREINIT:
532 STRLEN data_len;
533 STRLEN key_len;
534 const U8 *data_bytes;
535 const U8 *key_bytes;
536 srl_siphash_ctx sip;
537 U8 digest[16];
538 static const U8 zero_key[16] = { 0 };
539 CODE:
540 1 data_bytes = (const U8 *)SvPVbyte(data, data_len);
541 1 ▶ if (key == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (key == NULL) { 0 1 1
542 0 key_bytes = zero_key;
543 }
544 else {
545 1 key_bytes = (const U8 *)SvPVbyte(key, key_len);
546 1 ▶ if (key_len != 16)
Branch: 1 branch
BranchTrueFalseTotal
if (key_len != 16) 0 1 1
547 0 croak("siphash36_128 key must be exactly 16 bytes");
548 }
549 1 srl_siphash_init_rounds(&sip, key_bytes, 3, 6, 1);
550 1 srl_siphash_update(&sip, data_bytes, (size_t)data_len);
551 1 srl_siphash_final128(&sip, digest);
552 1 RETVAL = newSVpvn((const char *)digest, sizeof(digest));
553 OUTPUT: RETVAL
554  
555 BOOT:
556 {
557 struct {
558 char const *name_suffix;
559 U8 opopt;
560 50 } const funcs_to_install[] = {
561 { "", OPOPT_DO_BODY },
562 { "_only_header", OPOPT_DO_HEADER },
563 { "_with_header", (OPOPT_DO_BODY|OPOPT_DO_HEADER) },
564 { "_with_offset", (OPOPT_DO_BODY|OPOPT_OFFSET) },
565 { "_only_header_with_offset", (OPOPT_DO_HEADER|OPOPT_OFFSET) },
566 { "_with_header_and_offset", (OPOPT_DO_BODY|OPOPT_DO_HEADER|OPOPT_OFFSET) },
567 /*012345678901234567890123*/
568 }, *fti;
569 int i;
570 {
571 MY_CXT_INIT;
572 50 srl_init_my_cxt(aTHX);
573 }
574 #if USE_CUSTOM_OPS
575 {
576 /* Perl borrows this descriptor; it must outlive every interpreter. */
577 static const XOP xop = {
578 XOPf_xop_name | XOPf_xop_desc | XOPf_xop_class,
579 "sereal_decode_with_object", "sereal_decode_with_object", OA_UNOP
580 };
581 50 Perl_custom_op_register(aTHX_ THX_pp_sereal_decode, &xop);
582 }
583 #endif /* USE_CUSTOM_OPS */
584 350 ▶ for (i = sizeof(funcs_to_install)/sizeof(*fti); i--; ) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = sizeof(funcs_to_install)/sizeof(*fti); i--; ) { 300 50 350
585 # define LONG_CLASS_FMT "Sereal::Decoder::sereal_decode%s_with_object"
586 char name[sizeof(LONG_CLASS_FMT)+24];
587 300 char proto[7], *p = proto;
588 U8 opopt;
589 I32 cv_private;
590 GV *gv;
591 CV *cv;
592  
593 300 fti = &funcs_to_install[i];
594 300 opopt = fti->opopt;
595 /*
596 * The cv_private value incorporates flags describing the operation to be
597 * performed by the sub and precomputed arity limits. 0x020200 corresponds
598 * to min_arity=2 and max_arity=2. The various additions to cv_private
599 * increment one or both of these sub-values.
600  
601 * The six subs created there share a single C body function, and are
602 * differentiated only by the option flags in cv_private. The custom ops
603 * likewise share one op_ppaddr function, and the operations they perform
604 * are differentiated by the same flags, stored in op_private.
605 */
606 300 cv_private = opopt | 0x020200;
607  
608 /* Yes, the subs have prototypes. The protoypes have no effect when the
609 * subs are used as methods, so there's no break of compatibility for those
610 * using the documented API. There is a change that could be detected by
611 * code such as "Sereal::Decoder::decode($dec, @v)", that uses the methods
612 * directly in an undocumented way.
613 *
614 * The prototype, specifically the putting of argument expressions into
615 * scalar context, is required in order to be able to resolve arity at
616 * compile time. If this wasn't done, there would have to be a pushmark
617 * op preceding the argument ops, and pp_sereal_decode() would need the
618 * same code as xsfunc_sereal_decode() to check arity and resolve the
619 * optional-parameter flags.
620 */
621 300 *p++ = '$';
622 300 *p++ = '$';
623  
624 300 ▶ if (opopt & OPOPT_OFFSET) {
Branch: 1 branch
BranchTrueFalseTotal
if (opopt & OPOPT_OFFSET) { 150 150 300
625 150 *p++ = '$';
626 150 cv_private += 0x010100;
627 }
628 300 *p++ = ';';
629 300 ▶ if (opopt & OPOPT_DO_BODY) {
Branch: 1 branch
BranchTrueFalseTotal
if (opopt & OPOPT_DO_BODY) { 200 100 300
630 200 *p++ = '$';
631 200 cv_private += 0x010000;
632 }
633 300 ▶ if (opopt & OPOPT_DO_HEADER) {
Branch: 1 branch
BranchTrueFalseTotal
if (opopt & OPOPT_DO_HEADER) { 200 100 300
634 200 *p++ = '$';
635 200 cv_private += 0x010000;
636 }
637 300 *p = 0;
638 /* setup the name of the sub */
639 300 sprintf(name, LONG_CLASS_FMT, fti->name_suffix);
640 300 cv = newXSproto_portable(name, THX_xsfunc_sereal_decode, __FILE__,
641 proto);
642 300 CvXSUBANY(cv).any_i32 = cv_private;
643 #if USE_CUSTOM_OPS
644 300 cv_set_call_checker(cv, THX_ck_entersub_args_sereal_decoder, (SV*)cv);
645 #endif /* USE_CUSTOM_OPS */
646 300 sprintf(name, "Sereal::Decoder::decode%s", fti->name_suffix);
647 300 gv = gv_fetchpv(name, GV_ADDMULTI, SVt_PVCV);
648 300 GvCV_set(gv, cv);
649 }
650 }
651  
652 BOOT:
653 {
654 #if USE_CUSTOM_OPS
655 {
656 static const XOP xop = {
657 XOPf_xop_name | XOPf_xop_desc | XOPf_xop_class,
658 "scalar_looks_like_sereal", "scalar_looks_like_sereal", OA_UNOP
659 };
660 50 Perl_custom_op_register(aTHX_ THX_pp_looks_like_sereal, &xop);
661 }
662 #endif /* USE_CUSTOM_OPS */
663 {
664 CV *cv;
665 50 cv = newXSproto_portable("Sereal::Decoder::scalar_looks_like_sereal", THX_xsfunc_looks_like_sereal, __FILE__, "$");
666 50 CvXSUBANY(cv).any_i32 = 0x010100 | OPOPT_LOOKS_LIKE;
667 #if USE_CUSTOM_OPS
668 50 cv_set_call_checker(cv, THX_ck_entersub_args_sereal_decoder, (SV*)cv);
669 #endif /* USE_CUSTOM_OPS */
670 50 cv = newXS("Sereal::Decoder::looks_like_sereal", THX_xsfunc_looks_like_sereal, __FILE__);
671 50 CvXSUBANY(cv).any_i32 = 0x020100 | OPOPT_LOOKS_LIKE;
672 }
673 }
674  
675 BOOT:
676 {
677 int checksum_i;
678 150 ▶ for (checksum_i = 0; checksum_i < 2; checksum_i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (checksum_i = 0; checksum_i < 2; checksum_i++) { 100 50 150
679 100 const char *name = checksum_i ? "Sereal::Decoder::validate_sereal_checksum"
680 100 ▶ : "Sereal::Decoder::get_sereal_checksum";
Branch: 1 branch
BranchTrueFalseTotal
: "Sereal::Decoder::get_sereal_checksum"; 50 50 100
681 100 ▶ CV *cv = newXSproto_portable(name, THX_xsfunc_checksum, __FILE__, checksum_i ? "$;$$" : "$;$");
Branch: 1 branch
BranchTrueFalseTotal
CV *cv = newXSproto_portable(name, THX_xsfunc_checksum, __FILE__, checksum_i ? "$;$$" : "$;$"); 50 50 100
682 100 CvXSUBANY(cv).any_i32 = OPOPT_CHECKSUM
683 100 ▶ | (checksum_i ? OPOPT_VALIDATE_CHECKSUM | 0x030100 : 0x020100);
Branch: 1 branch
BranchTrueFalseTotal
| (checksum_i ? OPOPT_VALIDATE_CHECKSUM | 0x030100 : 0x020100); 50 50 100
684 #if USE_CUSTOM_OPS
685 {
686 static const XOP xops[2] = {
687 { XOPf_xop_name | XOPf_xop_desc | XOPf_xop_class,
688 "get_sereal_checksum", "get_sereal_checksum", OA_UNOP },
689 { XOPf_xop_name | XOPf_xop_desc | XOPf_xop_class,
690 "validate_sereal_checksum", "validate_sereal_checksum", OA_UNOP }
691 };
692 100 ▶ Perl_custom_op_register(aTHX_ checksum_i ? THX_pp_validate_sereal_checksum : THX_pp_get_sereal_checksum, &xops[checksum_i]);
Branch: 1 branch
BranchTrueFalseTotal
Perl_custom_op_register(aTHX_ checksum_i ? THX_pp_validate_sereal_checksum : THX_pp_get_sereal_checksum, &xops[checksum_i]); 50 50 100
693 }
694 100 cv_set_call_checker(cv, THX_ck_entersub_args_sereal_decoder, (SV*)cv);
695 #endif
696 }
697 }
698  
699 srl_decoder_t *
700 new(CLASS, opt = NULL)
701 char *CLASS;
702 HV *opt;
703 PREINIT:
704 dMY_CXT;
705 CODE:
706 44 RETVAL = srl_build_decoder_struct(aTHX_ opt, MY_CXT.options,
707 MY_CXT.known_option_heads, MY_CXT.known_option_next);
708 44 RETVAL->flags |= SRL_F_DECODER_REUSE;
709 OUTPUT: RETVAL
710  
711 void
712 DESTROY(dec)
713 srl_decoder_t *dec;
714 CODE:
715 44 srl_destroy_decoder(aTHX_ dec);
716  
717 void
718 decode_sereal(src, opt = NULL, into = NULL)
719 SV *src;
720 SV *opt;
721 SV *into;
722 PREINIT:
723 dMY_CXT;
724 0 ▶ srl_decoder_t *dec= NULL;
Branch: 1 branch
BranchTrueFalseTotal
srl_decoder_t *dec= NULL; 0 0 0
725 PPCODE:
726 0 ▶ if (SvROK(src))
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(src)) 0 0 0
727 0 croak("We can't decode a reference as Sereal!");
728 /* Support no opt at all, undef, hashref */
729 0 ▶ if (opt != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (opt != NULL) { 0 0 0
730 0 SvGETMAGIC(opt);
731 0 ▶ if (!SvOK(opt))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(opt)) 0 0 0
732 0 opt = NULL;
733 0 ▶ else if (SvROK(opt) && SvTYPE(SvRV(opt)) == SVt_PVHV)
Branch: 2 branches
BranchTrueFalseTotal
else if (SvROK(opt) && SvTYPE(SvRV(opt)) == SVt_PVHV) 0 0 0
else if (SvROK(opt) && SvTYPE(SvRV(opt)) == SVt_PVHV) 0 0 0
734 0 opt = (SV *)SvRV(opt);
735 else
736 0 croak("Options are neither undef nor hash reference");
737 }
738 0 dec = srl_build_decoder_struct(aTHX_ (HV *)opt, MY_CXT.options,
739 MY_CXT.known_option_heads, MY_CXT.known_option_next);
740 0 ST(0)= srl_decode_into(aTHX_ dec, src, into, 0);
741 0 XSRETURN(1);
742  
743 AV *
744 decode_sereal_with_header_data(src, opt = NULL, body_into = NULL, header_into = NULL)
745 SV *src;
746 SV *opt;
747 SV *body_into;
748 SV *header_into;
749 PREINIT:
750 dMY_CXT;
751 0 ▶ srl_decoder_t *dec= NULL;
Branch: 1 branch
BranchTrueFalseTotal
srl_decoder_t *dec= NULL; 0 0 0
752 CODE:
753 /* Support no opt at all, undef, hashref */
754 0 ▶ if (opt != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (opt != NULL) { 0 0 0
755 0 SvGETMAGIC(opt);
756 0 ▶ if (!SvOK(opt))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(opt)) 0 0 0
757 0 opt = NULL;
758 0 ▶ else if (SvROK(opt) && SvTYPE(SvRV(opt)) == SVt_PVHV)
Branch: 2 branches
BranchTrueFalseTotal
else if (SvROK(opt) && SvTYPE(SvRV(opt)) == SVt_PVHV) 0 0 0
else if (SvROK(opt) && SvTYPE(SvRV(opt)) == SVt_PVHV) 0 0 0
759 0 opt = (SV *)SvRV(opt);
760 else
761 0 croak("Options are neither undef nor hash reference");
762 }
763 0 dec = srl_build_decoder_struct(aTHX_ (HV *)opt, MY_CXT.options,
764 MY_CXT.known_option_heads, MY_CXT.known_option_next);
765 0 ▶ if (body_into == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (body_into == NULL) 0 0 0
766 0 body_into = sv_newmortal();
767 0 ▶ if (header_into == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (header_into == NULL) 0 0 0
768 0 header_into = sv_newmortal();
769 0 srl_decode_all_into(aTHX_ dec, src, header_into, body_into, 0);
770 0 RETVAL = newAV();
771 0 sv_2mortal((SV *)RETVAL);
772 0 av_extend(RETVAL, 1);
773 0 av_store(RETVAL, 0, SvREFCNT_inc(header_into));
774 0 av_store(RETVAL, 1, SvREFCNT_inc(body_into));
775 OUTPUT: RETVAL
776  
777 UV
778 bytes_consumed(dec)
779 srl_decoder_t *dec;
780 CODE:
781 0 ▶ RETVAL = dec->bytes_consumed;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dec->bytes_consumed; 0 0 0
782 OUTPUT: RETVAL
783  
784 U32
785 flags(dec)
786 srl_decoder_t *dec;
787 CODE:
788 0 ▶ RETVAL = dec->flags;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dec->flags; 0 0 0
789 OUTPUT: RETVAL
790  
791 SV*
792 regexp_internals_type()
793 CODE:
794 0 RETVAL = newSVpvs(REGEXP_TYPE);
795 OUTPUT: RETVAL
796  
797 #if defined(USE_ITHREADS) && defined(MY_CXT_KEY)
798 void
799 CLONE(...)
800 CODE:
801 MY_CXT_CLONE;
802 srl_init_my_cxt(aTHX);
803  
804 #endif
« srl_reader_misc.h ↑ Summary ptable.h »