Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/bio/b_dump.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||||||||||||||
7 | int | - | ||||||||||||||||||||||||||||||||||||
8 | BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), | - | ||||||||||||||||||||||||||||||||||||
9 | void *u, const char *s, int len) | - | ||||||||||||||||||||||||||||||||||||
10 | { | - | ||||||||||||||||||||||||||||||||||||
11 | return never executed: BIO_dump_indent_cb(cb, u, s, len, 0);return BIO_dump_indent_cb(cb, u, s, len, 0); never executed: return BIO_dump_indent_cb(cb, u, s, len, 0); | 0 | ||||||||||||||||||||||||||||||||||||
12 | } | - | ||||||||||||||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||||||||||||||
14 | int | - | ||||||||||||||||||||||||||||||||||||
15 | BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), | - | ||||||||||||||||||||||||||||||||||||
16 | void *u, const char *s, int len, int indent) | - | ||||||||||||||||||||||||||||||||||||
17 | { | - | ||||||||||||||||||||||||||||||||||||
18 | int ret = 0; | - | ||||||||||||||||||||||||||||||||||||
19 | char buf[288 + 1], tmp[20], str[128 + 1]; | - | ||||||||||||||||||||||||||||||||||||
20 | int i, j, rows, trc; | - | ||||||||||||||||||||||||||||||||||||
21 | unsigned char ch; | - | ||||||||||||||||||||||||||||||||||||
22 | int dump_width; | - | ||||||||||||||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||||||||||||||
24 | trc = 0; | - | ||||||||||||||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||||||||||||||
27 | for (; (
| 0 | ||||||||||||||||||||||||||||||||||||
28 | trc++; never executed: trc++; | 0 | ||||||||||||||||||||||||||||||||||||
29 | - | |||||||||||||||||||||||||||||||||||||
30 | - | |||||||||||||||||||||||||||||||||||||
31 | if (indent < 0
| 0 | ||||||||||||||||||||||||||||||||||||
32 | indent = 0; never executed: indent = 0; | 0 | ||||||||||||||||||||||||||||||||||||
33 | if (indent
| 0 | ||||||||||||||||||||||||||||||||||||
34 | if (indent > 128
| 0 | ||||||||||||||||||||||||||||||||||||
35 | indent = 128; never executed: indent = 128; | 0 | ||||||||||||||||||||||||||||||||||||
36 | memset(str, ' ', indent); | - | ||||||||||||||||||||||||||||||||||||
37 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
38 | str[indent] = '\0'; | - | ||||||||||||||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||||||||||||||
40 | dump_width = (16 - ((indent - (indent > 6
| 0 | ||||||||||||||||||||||||||||||||||||
41 | rows = (len / dump_width); | - | ||||||||||||||||||||||||||||||||||||
42 | if ((
| 0 | ||||||||||||||||||||||||||||||||||||
43 | rows++; never executed: rows++; | 0 | ||||||||||||||||||||||||||||||||||||
44 | for (i = 0; i < rows
| 0 | ||||||||||||||||||||||||||||||||||||
45 | strlcpy(buf, str, sizeof buf); | - | ||||||||||||||||||||||||||||||||||||
46 | snprintf(tmp, sizeof tmp, "%04x - ", i*dump_width); | - | ||||||||||||||||||||||||||||||||||||
47 | strlcat(buf, tmp, sizeof buf); | - | ||||||||||||||||||||||||||||||||||||
48 | for (j = 0; j < dump_width
| 0 | ||||||||||||||||||||||||||||||||||||
49 | if (((
| 0 | ||||||||||||||||||||||||||||||||||||
50 | strlcat(buf, " ", sizeof buf); | - | ||||||||||||||||||||||||||||||||||||
51 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||||||||
52 | ch = ((unsigned char)*(s + i*dump_width + j)) & 0xff; | - | ||||||||||||||||||||||||||||||||||||
53 | snprintf(tmp, sizeof tmp, "%02x%c", ch, | - | ||||||||||||||||||||||||||||||||||||
54 | j == 7 ? '-' : ' '); | - | ||||||||||||||||||||||||||||||||||||
55 | strlcat(buf, tmp, sizeof buf); | - | ||||||||||||||||||||||||||||||||||||
56 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
57 | } | - | ||||||||||||||||||||||||||||||||||||
58 | strlcat(buf, " ", sizeof buf); | - | ||||||||||||||||||||||||||||||||||||
59 | for (j = 0; j < dump_width
| 0 | ||||||||||||||||||||||||||||||||||||
60 | if (((
| 0 | ||||||||||||||||||||||||||||||||||||
61 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
62 | ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff; | - | ||||||||||||||||||||||||||||||||||||
63 | snprintf(tmp, sizeof tmp, "%c", | - | ||||||||||||||||||||||||||||||||||||
64 | ((ch >= ' ') && (ch <= '~')) ? ch : '.'); | - | ||||||||||||||||||||||||||||||||||||
65 | strlcat(buf, tmp, sizeof buf); | - | ||||||||||||||||||||||||||||||||||||
66 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
67 | strlcat(buf, "\n", sizeof buf); | - | ||||||||||||||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||||||||||||||
71 | ret += cb((void *)buf, strlen(buf), u); | - | ||||||||||||||||||||||||||||||||||||
72 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||||||||||||||
74 | if (trc > 0
| 0 | ||||||||||||||||||||||||||||||||||||
75 | snprintf(buf, sizeof buf, "%s%04x - <SPACES/NULS>\n", | - | ||||||||||||||||||||||||||||||||||||
76 | str, len + trc); | - | ||||||||||||||||||||||||||||||||||||
77 | ret += cb((void *)buf, strlen(buf), u); | - | ||||||||||||||||||||||||||||||||||||
78 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||||||||||||||
80 | return never executed: (ret);return (ret); never executed: return (ret); | 0 | ||||||||||||||||||||||||||||||||||||
81 | } | - | ||||||||||||||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||||||||||||||
83 | static int | - | ||||||||||||||||||||||||||||||||||||
84 | write_fp(const void *data, size_t len, void *fp) | - | ||||||||||||||||||||||||||||||||||||
85 | { | - | ||||||||||||||||||||||||||||||||||||
86 | return never executed: fwrite(data, 1, len, fp);return fwrite(data, 1, len, fp); never executed: return fwrite(data, 1, len, fp); | 0 | ||||||||||||||||||||||||||||||||||||
87 | } | - | ||||||||||||||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||||||||||||||
89 | int | - | ||||||||||||||||||||||||||||||||||||
90 | BIO_dump_fp(FILE *fp, const char *s, int len) | - | ||||||||||||||||||||||||||||||||||||
91 | { | - | ||||||||||||||||||||||||||||||||||||
92 | return never executed: BIO_dump_cb(write_fp, fp, s, len);return BIO_dump_cb(write_fp, fp, s, len); never executed: return BIO_dump_cb(write_fp, fp, s, len); | 0 | ||||||||||||||||||||||||||||||||||||
93 | } | - | ||||||||||||||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||||||||||||||
95 | int | - | ||||||||||||||||||||||||||||||||||||
96 | BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent) | - | ||||||||||||||||||||||||||||||||||||
97 | { | - | ||||||||||||||||||||||||||||||||||||
98 | return never executed: BIO_dump_indent_cb(write_fp, fp, s, len, indent);return BIO_dump_indent_cb(write_fp, fp, s, len, indent); never executed: return BIO_dump_indent_cb(write_fp, fp, s, len, indent); | 0 | ||||||||||||||||||||||||||||||||||||
99 | } | - | ||||||||||||||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||||||||||||||
101 | static int | - | ||||||||||||||||||||||||||||||||||||
102 | write_bio(const void *data, size_t len, void *bp) | - | ||||||||||||||||||||||||||||||||||||
103 | { | - | ||||||||||||||||||||||||||||||||||||
104 | return never executed: BIO_write((BIO *)bp, (const char *)data, len);return BIO_write((BIO *)bp, (const char *)data, len); never executed: return BIO_write((BIO *)bp, (const char *)data, len); | 0 | ||||||||||||||||||||||||||||||||||||
105 | } | - | ||||||||||||||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||||||||||||||
107 | int | - | ||||||||||||||||||||||||||||||||||||
108 | BIO_dump(BIO *bp, const char *s, int len) | - | ||||||||||||||||||||||||||||||||||||
109 | { | - | ||||||||||||||||||||||||||||||||||||
110 | return never executed: BIO_dump_cb(write_bio, bp, s, len);return BIO_dump_cb(write_bio, bp, s, len); never executed: return BIO_dump_cb(write_bio, bp, s, len); | 0 | ||||||||||||||||||||||||||||||||||||
111 | } | - | ||||||||||||||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||||||||||||||
113 | int | - | ||||||||||||||||||||||||||||||||||||
114 | BIO_dump_indent(BIO *bp, const char *s, int len, int indent) | - | ||||||||||||||||||||||||||||||||||||
115 | { | - | ||||||||||||||||||||||||||||||||||||
116 | return never executed: BIO_dump_indent_cb(write_bio, bp, s, len, indent);return BIO_dump_indent_cb(write_bio, bp, s, len, indent); never executed: return BIO_dump_indent_cb(write_bio, bp, s, len, indent); | 0 | ||||||||||||||||||||||||||||||||||||
117 | } | - | ||||||||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |