| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* vim:set ts=4 sw=4 et syntax=xs.doxygen: */ |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
4
|
|
|
|
|
|
|
#include "perl.h" |
|
5
|
|
|
|
|
|
|
#include "XSUB.h" |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include "ppport.h" |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#include "ps_parser.h" |
|
10
|
|
|
|
|
|
|
#include "stringstore.h" |
|
11
|
|
|
|
|
|
|
#include "convert.h" |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
static char _error_msg[256] = "Unknown error"; |
|
14
|
3
|
|
|
|
|
|
static void _register_error(const char *msg) |
|
15
|
|
|
|
|
|
|
{ |
|
16
|
3
|
|
|
|
|
|
strncpy(_error_msg, msg, sizeof _error_msg); |
|
17
|
3
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
|
static void _croak(const char *msg) |
|
20
|
|
|
|
|
|
|
{ |
|
21
|
3
|
|
|
|
|
|
SV *errsv = get_sv("@", TRUE); |
|
22
|
3
|
|
|
|
|
|
sv_setsv(errsv, newSVpvf("%s\n", msg)); |
|
23
|
3
|
|
|
|
|
|
croak(Nullch); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
MODULE = PHP::Serialization::XS PACKAGE = PHP::Serialization::XS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
SV * |
|
31
|
|
|
|
|
|
|
_c_decode(SV *input, SV *preference, ...) |
|
32
|
|
|
|
|
|
|
CODE: |
|
33
|
|
|
|
|
|
|
struct ps_parser_state *ps_state; |
|
34
|
19
|
|
|
|
|
|
ps_parser_error_handler = _register_error; |
|
35
|
19
|
50
|
|
|
|
|
if (ps_init(&ps_state)) |
|
36
|
0
|
|
|
|
|
|
_croak("ERROR: Failed to init ps_parser"); |
|
37
|
|
|
|
|
|
|
|
|
38
|
19
|
|
|
|
|
|
const char *str = SvPV_nolen_const(input); |
|
39
|
19
|
|
|
|
|
|
ps_read_string_init(ps_state, (void*)str); |
|
40
|
19
|
|
|
|
|
|
struct ps_node *node = ps_parse(ps_state); |
|
41
|
19
|
100
|
|
|
|
|
if (node == PS_PARSE_FAILURE) |
|
42
|
3
|
|
|
|
|
|
_croak(_error_msg); |
|
43
|
|
|
|
|
|
|
|
|
44
|
16
|
|
|
|
|
|
const char *claxx = NULL; |
|
45
|
16
|
50
|
|
|
|
|
if (items > 2 && SvOK(ST(2))) |
|
|
|
100
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
|
claxx = (char *)SvPV_nolen(ST(2)); |
|
47
|
|
|
|
|
|
|
|
|
48
|
16
|
|
|
|
|
|
RETVAL = _convert_recurse(node, SvIV(preference), claxx); |
|
49
|
|
|
|
|
|
|
|
|
50
|
16
|
|
|
|
|
|
ps_read_string_fini(ps_state); |
|
51
|
16
|
|
|
|
|
|
ps_free(node); |
|
52
|
16
|
|
|
|
|
|
ps_fini(&ps_state); |
|
53
|
|
|
|
|
|
|
OUTPUT: |
|
54
|
|
|
|
|
|
|
RETVAL |
|
55
|
|
|
|
|
|
|
|