Lines Matching refs:ctx
88 // |ctx|.
89 static int hexdump_write(struct hexdump_ctx *ctx, const uint8_t *data,
99 if (ctx->used == 0) {
101 BIO_indent(ctx->bio, ctx->indent, UINT_MAX);
103 hexbyte(&buf[0], ctx->n >> 24);
104 hexbyte(&buf[2], ctx->n >> 16);
105 hexbyte(&buf[4], ctx->n >> 8);
106 hexbyte(&buf[6], ctx->n);
108 if (BIO_write(ctx->bio, buf, 10) < 0) {
116 if (ctx->used == 7) {
120 } else if (ctx->used == 15) {
128 if (BIO_write(ctx->bio, buf, l) < 0) {
131 ctx->right_chars[ctx->used] = to_char(data[i]);
132 ctx->used++;
133 ctx->n++;
134 if (ctx->used == 16) {
135 ctx->right_chars[16] = '|';
136 ctx->right_chars[17] = '\n';
137 if (BIO_write(ctx->bio, ctx->right_chars, sizeof(ctx->right_chars)) < 0) {
140 ctx->used = 0;
147 // finish flushes any buffered data in |ctx|.
148 static int finish(struct hexdump_ctx *ctx) {
150 const unsigned n_bytes = ctx->used;
161 for (; ctx->used < 16; ctx->used++) {
163 if (ctx->used == 7) {
165 } else if (ctx->used == 15) {
168 if (BIO_write(ctx->bio, buf, l) < 0) {
173 ctx->right_chars[n_bytes] = '|';
174 ctx->right_chars[n_bytes + 1] = '\n';
175 if (BIO_write(ctx->bio, ctx->right_chars, n_bytes + 2) < 0) {
182 struct hexdump_ctx ctx;
183 OPENSSL_memset(&ctx, 0, sizeof(ctx));
184 ctx.bio = bio;
185 ctx.indent = indent;
187 if (!hexdump_write(&ctx, data, len) || !finish(&ctx)) {