| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
MODULE = PDF::Make PACKAGE = PDF::Make::Attachment |
|
2
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
SV * |
|
5
|
|
|
|
|
|
|
attach(class, doc, ...) |
|
6
|
|
|
|
|
|
|
char *class |
|
7
|
|
|
|
|
|
|
pdfmake_doc_t *doc |
|
8
|
|
|
|
|
|
|
PREINIT: |
|
9
|
27
|
|
|
|
|
|
const char *name = NULL; |
|
10
|
27
|
|
|
|
|
|
const char *filename = NULL; |
|
11
|
27
|
|
|
|
|
|
const char *mime = NULL; |
|
12
|
27
|
|
|
|
|
|
const char *desc = NULL; |
|
13
|
27
|
|
|
|
|
|
const char *path = NULL; |
|
14
|
27
|
|
|
|
|
|
SV *data_sv = NULL; |
|
15
|
|
|
|
|
|
|
pdfmake_attachment_t *att; |
|
16
|
|
|
|
|
|
|
int i; |
|
17
|
|
|
|
|
|
|
CODE: |
|
18
|
|
|
|
|
|
|
PERL_UNUSED_VAR(class); |
|
19
|
128
|
100
|
|
|
|
|
for (i = 2; i < items - 1; i += 2) { |
|
20
|
101
|
|
|
|
|
|
const char *key = SvPV_nolen(ST(i)); |
|
21
|
101
|
|
|
|
|
|
SV *val = ST(i + 1); |
|
22
|
101
|
100
|
|
|
|
|
if (strEQ(key, "name")) name = SvPV_nolen(val); |
|
23
|
75
|
100
|
|
|
|
|
else if (strEQ(key, "filename")) filename = SvPV_nolen(val); |
|
24
|
53
|
100
|
|
|
|
|
else if (strEQ(key, "mime")) mime = SvPV_nolen(val); |
|
25
|
29
|
100
|
|
|
|
|
else if (strEQ(key, "description")) desc = SvPV_nolen(val); |
|
26
|
26
|
50
|
|
|
|
|
else if (strEQ(key, "path")) path = SvPV_nolen(val); |
|
27
|
26
|
50
|
|
|
|
|
else if (strEQ(key, "data")) data_sv = val; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
27
|
100
|
|
|
|
|
if (!name) |
|
31
|
1
|
|
|
|
|
|
croak("PDF::Make::Attachment: 'name' is required"); |
|
32
|
|
|
|
|
|
|
|
|
33
|
26
|
50
|
|
|
|
|
if (path) { |
|
34
|
0
|
|
|
|
|
|
att = pdfmake_doc_attach_file(doc, name, path); |
|
35
|
26
|
100
|
|
|
|
|
} else if (data_sv) { |
|
36
|
|
|
|
|
|
|
STRLEN len; |
|
37
|
25
|
|
|
|
|
|
const uint8_t *data = (const uint8_t *)SvPV(data_sv, len); |
|
38
|
25
|
|
|
|
|
|
att = pdfmake_doc_attach(doc, name, filename, data, len, mime, desc); |
|
39
|
|
|
|
|
|
|
} else { |
|
40
|
1
|
|
|
|
|
|
croak("PDF::Make::Attachment: 'path' or 'data' is required"); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
25
|
50
|
|
|
|
|
if (!att) |
|
44
|
0
|
|
|
|
|
|
croak("PDF::Make::Attachment: failed to attach '%s'", name); |
|
45
|
|
|
|
|
|
|
|
|
46
|
25
|
|
|
|
|
|
RETVAL = sv_newmortal(); |
|
47
|
25
|
|
|
|
|
|
sv_setref_pv(RETVAL, "PDF::Make::Attachment", (void *)att); |
|
48
|
25
|
|
|
|
|
|
SvREFCNT_inc(RETVAL); |
|
49
|
|
|
|
|
|
|
OUTPUT: |
|
50
|
|
|
|
|
|
|
RETVAL |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
const char * |
|
53
|
|
|
|
|
|
|
name(self) |
|
54
|
|
|
|
|
|
|
pdfmake_attachment_t *self |
|
55
|
|
|
|
|
|
|
CODE: |
|
56
|
23
|
|
|
|
|
|
RETVAL = self->name; |
|
57
|
|
|
|
|
|
|
OUTPUT: |
|
58
|
|
|
|
|
|
|
RETVAL |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
const char * |
|
61
|
|
|
|
|
|
|
filename(self) |
|
62
|
|
|
|
|
|
|
pdfmake_attachment_t *self |
|
63
|
|
|
|
|
|
|
CODE: |
|
64
|
3
|
|
|
|
|
|
RETVAL = self->filename; |
|
65
|
|
|
|
|
|
|
OUTPUT: |
|
66
|
|
|
|
|
|
|
RETVAL |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
const char * |
|
69
|
|
|
|
|
|
|
mime_type(self) |
|
70
|
|
|
|
|
|
|
pdfmake_attachment_t *self |
|
71
|
|
|
|
|
|
|
CODE: |
|
72
|
4
|
|
|
|
|
|
RETVAL = self->mime_type; |
|
73
|
|
|
|
|
|
|
OUTPUT: |
|
74
|
|
|
|
|
|
|
RETVAL |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
UV |
|
77
|
|
|
|
|
|
|
size(self) |
|
78
|
|
|
|
|
|
|
pdfmake_attachment_t *self |
|
79
|
|
|
|
|
|
|
CODE: |
|
80
|
23
|
100
|
|
|
|
|
RETVAL = self->data_len; |
|
81
|
|
|
|
|
|
|
OUTPUT: |
|
82
|
|
|
|
|
|
|
RETVAL |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
SV * |
|
85
|
|
|
|
|
|
|
data(self) |
|
86
|
|
|
|
|
|
|
pdfmake_attachment_t *self |
|
87
|
|
|
|
|
|
|
CODE: |
|
88
|
23
|
50
|
|
|
|
|
if (self->data && self->data_len > 0) { |
|
|
|
50
|
|
|
|
|
|
|
89
|
23
|
|
|
|
|
|
RETVAL = newSVpvn((const char *)self->data, self->data_len); |
|
90
|
|
|
|
|
|
|
} else { |
|
91
|
0
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
OUTPUT: |
|
94
|
|
|
|
|
|
|
RETVAL |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
void |
|
97
|
|
|
|
|
|
|
extract_to_file(self, path) |
|
98
|
|
|
|
|
|
|
pdfmake_attachment_t *self |
|
99
|
|
|
|
|
|
|
const char *path |
|
100
|
|
|
|
|
|
|
CODE: |
|
101
|
0
|
0
|
|
|
|
|
if (pdfmake_attachment_extract_to_file(self, path) != PDFMAKE_OK) |
|
102
|
0
|
|
|
|
|
|
croak("PDF::Make::Attachment: extract failed"); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
UV |
|
105
|
|
|
|
|
|
|
write_to_doc(self, doc) |
|
106
|
|
|
|
|
|
|
pdfmake_attachment_t *self |
|
107
|
|
|
|
|
|
|
pdfmake_doc_t *doc |
|
108
|
|
|
|
|
|
|
CODE: |
|
109
|
0
|
|
|
|
|
|
RETVAL = pdfmake_attachment_write(self, doc); |
|
110
|
0
|
0
|
|
|
|
|
if (RETVAL == 0) |
|
111
|
0
|
|
|
|
|
|
croak("PDF::Make::Attachment: write failed"); |
|
112
|
|
|
|
|
|
|
OUTPUT: |
|
113
|
|
|
|
|
|
|
RETVAL |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
void |
|
116
|
|
|
|
|
|
|
DESTROY(self) |
|
117
|
|
|
|
|
|
|
pdfmake_attachment_t *self |
|
118
|
|
|
|
|
|
|
CODE: |
|
119
|
|
|
|
|
|
|
/* Attachment is owned by the document (stored in doc->attachments[]). |
|
120
|
|
|
|
|
|
|
* Do NOT free here — the document frees its attachments in |
|
121
|
|
|
|
|
|
|
* pdfmake_doc_free(). Freeing here would create a dangling pointer |
|
122
|
|
|
|
|
|
|
* in the doc's attachment list. */ |
|
123
|
|
|
|
|
|
|
PERL_UNUSED_VAR(self); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
BOOT: |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
90
|
|
|
|
|
|
HV *stash = gv_stashpv("PDF::Make::Attachment", GV_ADD); |
|
128
|
90
|
50
|
|
|
|
|
PDFMAKE_REGISTER_GETTER(stash, "name", pdfmake_attachment_t, name, PDFMAKE_FIELD_STRING); |
|
|
|
50
|
|
|
|
|
|
|
129
|
90
|
50
|
|
|
|
|
PDFMAKE_REGISTER_GETTER(stash, "filename", pdfmake_attachment_t, filename, PDFMAKE_FIELD_STRING); |
|
|
|
50
|
|
|
|
|
|
|
130
|
90
|
50
|
|
|
|
|
PDFMAKE_REGISTER_GETTER(stash, "mime_type", pdfmake_attachment_t, mime_type, PDFMAKE_FIELD_STRING); |
|
|
|
50
|
|
|
|
|
|
|
131
|
90
|
50
|
|
|
|
|
PDFMAKE_REGISTER_GETTER(stash, "size", pdfmake_attachment_t, data_len, PDFMAKE_FIELD_UV); |
|
|
|
50
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |