… | |
… | |
218 | else |
218 | else |
219 | return newSVpvn ("", 0); |
219 | return newSVpvn ("", 0); |
220 | } |
220 | } |
221 | |
221 | |
222 | static void |
222 | static void |
223 | need_storable(void) |
223 | need_storable (void) |
224 | { |
224 | { |
225 | load_module (PERL_LOADMOD_NOIMPORT, serializer_package, Nullsv); |
225 | require_pv (SvPVbyte_nolen (serializer_package)); |
226 | |
226 | |
227 | storable_mstore = GvCV (gv_fetchpv (SvPVbyte_nolen (serializer_mstore ), TRUE, SVt_PVCV)); |
227 | storable_mstore = (CV *)SvREFCNT_inc (GvCV (gv_fetchpv (SvPVbyte_nolen (serializer_mstore ), TRUE, SVt_PVCV))); |
228 | storable_mretrieve = GvCV (gv_fetchpv (SvPVbyte_nolen (serializer_mretrieve), TRUE, SVt_PVCV)); |
228 | storable_mretrieve = (CV *)SvREFCNT_inc (GvCV (gv_fetchpv (SvPVbyte_nolen (serializer_mretrieve), TRUE, SVt_PVCV))); |
229 | } |
229 | } |
230 | |
230 | |
231 | MODULE = Compress::LZF PACKAGE = Compress::LZF |
231 | MODULE = Compress::LZF PACKAGE = Compress::LZF |
232 | |
232 | |
233 | BOOT: |
233 | BOOT: |
… | |
… | |
243 | PROTOTYPE: $$$ |
243 | PROTOTYPE: $$$ |
244 | PPCODE: |
244 | PPCODE: |
245 | SvSetSV (serializer_package , package ); |
245 | SvSetSV (serializer_package , package ); |
246 | SvSetSV (serializer_mstore , mstore ); |
246 | SvSetSV (serializer_mstore , mstore ); |
247 | SvSetSV (serializer_mretrieve, mretrieve); |
247 | SvSetSV (serializer_mretrieve, mretrieve); |
248 | storable_mstore = |
248 | SvREFCNT_dec (storable_mstore ); storable_mstore = 0; |
249 | storable_mretrieve = 0; |
249 | SvREFCNT_dec (storable_mretrieve); storable_mretrieve = 0; |
250 | |
250 | |
251 | void |
251 | void |
252 | compress(data) |
252 | compress(data) |
253 | SV * data |
253 | SV * data |
254 | PROTOTYPE: $ |
254 | PROTOTYPE: $ |
… | |
… | |
283 | && SvTYPE(sv) != SVt_PVIV |
283 | && SvTYPE(sv) != SVt_PVIV |
284 | && SvTYPE(sv) != SVt_PVNV |
284 | && SvTYPE(sv) != SVt_PVNV |
285 | && SvTYPE(sv) != SVt_PVMG)) /* mstore */ |
285 | && SvTYPE(sv) != SVt_PVMG)) /* mstore */ |
286 | { |
286 | { |
287 | int deref = !SvROK (sv); |
287 | int deref = !SvROK (sv); |
|
|
288 | char *pv; |
288 | |
289 | |
289 | if (!storable_mstore) |
290 | if (!storable_mstore) |
|
|
291 | { |
|
|
292 | PUTBACK; |
290 | need_storable (); |
293 | need_storable (); |
|
|
294 | SPAGAIN; |
|
|
295 | } |
291 | |
296 | |
292 | if (deref) |
297 | if (deref) |
293 | sv = newRV_noinc (sv); |
298 | sv = newRV_noinc (sv); |
294 | |
299 | |
295 | PUSHMARK (SP); |
300 | PUSHMARK (SP); |
296 | XPUSHs (sv); |
301 | XPUSHs (sv); |
297 | PUTBACK; |
302 | PUTBACK; |
298 | |
303 | |
299 | if (1 != call_sv ((SV *)storable_mstore, G_SCALAR)) |
304 | if (1 != call_sv ((SV *)storable_mstore, G_SCALAR)) |
300 | croak ("Storable::mstore didn't return a single scalar"); |
305 | croak ("%s didn't return a single scalar", SvPVbyte_nolen (serializer_mstore)); |
301 | |
306 | |
302 | SPAGAIN; |
307 | SPAGAIN; |
303 | |
308 | |
304 | sv = POPs; |
309 | sv = POPs; |
|
|
310 | pv = SvPV_nolen (sv); |
305 | |
311 | |
306 | if (SvPVX (sv)[0] == MAGIC_R) |
312 | if (*pv == MAGIC_R) |
307 | { |
313 | { |
308 | if (deref) |
314 | if (deref) |
309 | SvPVX (sv)[0] = MAGIC_R_deref; |
315 | *pv = MAGIC_R_deref; |
310 | } |
316 | } |
311 | else |
317 | else |
312 | { |
318 | { |
313 | char pfx[2]; |
319 | char pfx[2]; |
314 | |
320 | |
… | |
… | |
363 | croak ("Compress::LZF::sthaw(): invalid data, maybe you need a newer version of Compress::LZF?"); |
369 | croak ("Compress::LZF::sthaw(): invalid data, maybe you need a newer version of Compress::LZF?"); |
364 | |
370 | |
365 | sv_chop (sv, SvPVX (sv) + 2); |
371 | sv_chop (sv, SvPVX (sv) + 2); |
366 | |
372 | |
367 | if (!storable_mstore) |
373 | if (!storable_mstore) |
|
|
374 | { |
|
|
375 | PUTBACK; |
368 | need_storable (); |
376 | need_storable (); |
|
|
377 | SPAGAIN; |
|
|
378 | } |
369 | |
379 | |
370 | PUSHMARK (SP); |
380 | PUSHMARK (SP); |
371 | XPUSHs (sv); |
381 | XPUSHs (sv); |
372 | PUTBACK; |
382 | PUTBACK; |
373 | |
383 | |
374 | if (1 != call_sv ((SV *)storable_mretrieve, G_SCALAR)) |
384 | if (1 != call_sv ((SV *)storable_mretrieve, G_SCALAR)) |
375 | croak ("Storable::mstore didn't return a single scalar"); |
385 | croak ("%s didn't return a single scalar", SvPVbyte_nolen (serializer_mretrieve)); |
376 | |
386 | |
377 | SPAGAIN; |
387 | SPAGAIN; |
378 | |
388 | |
379 | if (deref) |
389 | if (deref) |
380 | SETs (sv_2mortal (SvREFCNT_inc (SvRV (TOPs)))); |
390 | SETs (sv_2mortal (SvREFCNT_inc (SvRV (TOPs)))); |
… | |
… | |
407 | goto redo; |
417 | goto redo; |
408 | |
418 | |
409 | case MAGIC_R: |
419 | case MAGIC_R: |
410 | handle_MAGIC_R: |
420 | handle_MAGIC_R: |
411 | if (!storable_mstore) |
421 | if (!storable_mstore) |
|
|
422 | { |
|
|
423 | PUTBACK; |
412 | need_storable (); |
424 | need_storable (); |
|
|
425 | SPAGAIN; |
|
|
426 | } |
413 | |
427 | |
414 | PUSHMARK (SP); |
428 | PUSHMARK (SP); |
415 | XPUSHs (sv); |
429 | XPUSHs (sv); |
416 | PUTBACK; |
430 | PUTBACK; |
417 | |
431 | |
418 | if (1 != call_sv ((SV *)storable_mretrieve, G_SCALAR)) |
432 | if (1 != call_sv ((SV *)storable_mretrieve, G_SCALAR)) |
419 | croak ("Storable::mstore didn't return a single scalar"); |
433 | croak ("%s didn't return a single scalar", SvPVbyte_nolen (serializer_mretrieve)); |
420 | |
434 | |
421 | SPAGAIN; |
435 | SPAGAIN; |
422 | |
436 | |
423 | if (deref) |
437 | if (deref) |
424 | { |
438 | { |