| line |
true |
false |
branch |
|
20
|
0 |
1 |
if (!dot) return "application/octet-stream"; |
|
22
|
0 |
1 |
if (strcasecmp(dot, "pdf") == 0) return "application/pdf"; |
|
23
|
0 |
1 |
if (strcasecmp(dot, "txt") == 0) return "text/plain"; |
|
24
|
0 |
1 |
if (strcasecmp(dot, "html") == 0) return "text/html"; |
|
25
|
0 |
1 |
if (strcasecmp(dot, "htm") == 0) return "text/html"; |
|
26
|
0 |
1 |
if (strcasecmp(dot, "xml") == 0) return "application/xml"; |
|
27
|
1 |
0 |
if (strcasecmp(dot, "json") == 0) return "application/json"; |
|
28
|
0 |
0 |
if (strcasecmp(dot, "csv") == 0) return "text/csv"; |
|
29
|
0 |
0 |
if (strcasecmp(dot, "jpg") == 0) return "image/jpeg"; |
|
30
|
0 |
0 |
if (strcasecmp(dot, "jpeg") == 0) return "image/jpeg"; |
|
31
|
0 |
0 |
if (strcasecmp(dot, "png") == 0) return "image/png"; |
|
32
|
0 |
0 |
if (strcasecmp(dot, "gif") == 0) return "image/gif"; |
|
33
|
0 |
0 |
if (strcasecmp(dot, "svg") == 0) return "image/svg+xml"; |
|
34
|
0 |
0 |
if (strcasecmp(dot, "zip") == 0) return "application/zip"; |
|
35
|
0 |
0 |
if (strcasecmp(dot, "xlsx") == 0) return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; |
|
36
|
0 |
0 |
if (strcasecmp(dot, "docx") == 0) return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; |
|
54
|
25 |
0 |
if (!doc || !name || !data) return NULL; |
|
|
25 |
0 |
if (!doc || !name || !data) return NULL; |
|
|
0 |
25 |
if (!doc || !name || !data) return NULL; |
|
56
|
10 |
15 |
if (doc->attach_count >= doc->attach_cap) { |
|
57
|
4 |
6 |
new_cap = doc->attach_cap == 0 ? 4 : doc->attach_cap * 2; |
|
59
|
0 |
10 |
if (!new_arr) return NULL; |
|
65
|
0 |
25 |
if (!att) return NULL; |
|
68
|
22 |
3 |
strncpy(att->filename, filename ? filename : name, sizeof(att->filename) - 1); |
|
70
|
24 |
1 |
if (mime_type) { |
|
76
|
3 |
22 |
if (description) { |
|
81
|
0 |
25 |
if (!att->data) { free(att); return NULL; } |
|
103
|
0 |
0 |
if (!doc || !name || !path) return NULL; |
|
|
0 |
0 |
if (!doc || !name || !path) return NULL; |
|
|
0 |
0 |
if (!doc || !name || !path) return NULL; |
|
106
|
0 |
0 |
if (!fp) return NULL; |
|
110
|
0 |
0 |
if (file_len < 0) { fclose(fp); return NULL; } |
|
114
|
0 |
0 |
if (!buf) { fclose(fp); return NULL; } |
|
119
|
0 |
0 |
if ((long)nread != file_len) { free(buf); return NULL; } |
|
125
|
0 |
0 |
if (slash && slash > fname) fname = slash + 1; |
|
|
0 |
0 |
if (slash && slash > fname) fname = slash + 1; |
|
126
|
0 |
0 |
if (bslash && bslash > fname) fname = bslash + 1; |
|
|
0 |
0 |
if (bslash && bslash > fname) fname = bslash + 1; |
|
137
|
0 |
0 |
return doc ? doc->attach_count : 0; |
|
141
|
0 |
0 |
if (!doc || idx >= doc->attach_count) return NULL; |
|
|
0 |
0 |
if (!doc || idx >= doc->attach_count) return NULL; |
|
149
|
0 |
0 |
if (!doc || !name) return NULL; |
|
|
0 |
0 |
if (!doc || !name) return NULL; |
|
150
|
0 |
0 |
for (i = 0; i < doc->attach_count; i++) { |
|
152
|
0 |
0 |
if (strcmp(att->name, name) == 0) return att; |
|
160
|
0 |
0 |
return att ? att->name : NULL; |
|
163
|
0 |
0 |
return att ? att->filename : NULL; |
|
166
|
0 |
0 |
return att ? att->mime_type : NULL; |
|
169
|
0 |
0 |
return att ? att->data_len : 0; |
|
175
|
0 |
0 |
if (!att) { if (out_len) *out_len = 0; return NULL; } |
|
|
0 |
0 |
if (!att) { if (out_len) *out_len = 0; return NULL; } |
|
176
|
0 |
0 |
if (out_len) *out_len = att->data_len; |
|
184
|
0 |
0 |
if (!att || !path || !att->data) return PDFMAKE_EINVAL; |
|
|
0 |
0 |
if (!att || !path || !att->data) return PDFMAKE_EINVAL; |
|
|
0 |
0 |
if (!att || !path || !att->data) return PDFMAKE_EINVAL; |
|
186
|
0 |
0 |
if (!fp) return PDFMAKE_EINVAL; |
|
189
|
0 |
0 |
return (written == att->data_len) ? PDFMAKE_OK : PDFMAKE_EINVAL; |
|
210
|
4 |
0 |
if (!att || !doc || !att->data) return 0; |
|
|
4 |
0 |
if (!att || !doc || !att->data) return 0; |
|
|
0 |
4 |
if (!att || !doc || !att->data) return 0; |
|
211
|
0 |
4 |
if (att->fs_obj_num) return att->fs_obj_num; |
|
223
|
0 |
4 |
if (ef_stream.kind != PDFMAKE_STREAM) { |
|
228
|
4 |
0 |
if (use_flate && compressed.len < att->data_len) { |
|
|
0 |
4 |
if (use_flate && compressed.len < att->data_len) { |
|
243
|
4 |
0 |
if (att->mime_type[0]) { |
|
245
|
46 |
4 |
for (i = 0; att->mime_type[i] && ei < sizeof(encoded) - 4; i++) { |
|
|
46 |
0 |
for (i = 0; att->mime_type[i] && ei < sizeof(encoded) - 4; i++) { |
|
246
|
4 |
42 |
if (att->mime_type[i] == '/') { |
|
257
|
0 |
4 |
if (use_flate) { |
|
270
|
0 |
4 |
pdfmake_dict_set(arena, &ef_dict_obj, k, |
|
275
|
0 |
4 |
if (att->ef_obj_num == 0) return 0; |
|
288
|
3 |
1 |
if (att->description[0]) { |
|
323
|
3 |
0 |
if (!doc || doc->attach_count == 0) return PDFMAKE_OK; |
|
|
0 |
3 |
if (!doc || doc->attach_count == 0) return PDFMAKE_OK; |
|
328
|
4 |
3 |
for (i = 0; i < doc->attach_count; i++) { |
|
330
|
4 |
0 |
if (!att->fs_obj_num) { |
|
331
|
0 |
4 |
if (pdfmake_attachment_write(att, doc) == 0) |
|
338
|
4 |
3 |
for (i = 0; i < doc->attach_count; i++) { |
|
358
|
3 |
0 |
if (!catalog || catalog->kind != PDFMAKE_DICT) return PDFMAKE_EINVAL; |
|
|
0 |
3 |
if (!catalog || catalog->kind != PDFMAKE_DICT) return PDFMAKE_EINVAL; |