Lines Matching refs:ctx

111 base64_decode_init(base64_decode_ctx_t *ctx, int length, isc_buffer_t *target)
113 ctx->digits = 0;
114 ctx->seen_end = ISC_FALSE;
115 ctx->length = length;
116 ctx->target = target;
120 base64_decode_char(base64_decode_ctx_t *ctx, int c) {
123 if (ctx->seen_end)
127 ctx->val[ctx->digits++] = (int)(s - base64);
128 if (ctx->digits == 4) {
131 if (ctx->val[0] == 64 || ctx->val[1] == 64)
133 if (ctx->val[2] == 64 && ctx->val[3] != 64)
138 if (ctx->val[2] == 64 && (ctx->val[1] & 0xf) != 0)
141 * We don't need to test for ctx->val[2] != 64 as
144 if (ctx->val[3] == 64 && (ctx->val[2] & 0x3) != 0)
146 n = (ctx->val[2] == 64) ? 1 :
147 (ctx->val[3] == 64) ? 2 : 3;
149 ctx->seen_end = ISC_TRUE;
150 if (ctx->val[2] == 64)
151 ctx->val[2] = 0;
152 if (ctx->val[3] == 64)
153 ctx->val[3] = 0;
155 buf[0] = (ctx->val[0]<<2)|(ctx->val[1]>>4);
156 buf[1] = (ctx->val[1]<<4)|(ctx->val[2]>>2);
157 buf[2] = (ctx->val[2]<<6)|(ctx->val[3]);
158 RETERR(mem_tobuffer(ctx->target, buf, n));
159 if (ctx->length >= 0) {
160 if (n > ctx->length)
163 ctx->length -= n;
165 ctx->digits = 0;
171 base64_decode_finish(base64_decode_ctx_t *ctx) {
172 if (ctx->length > 0)
174 if (ctx->digits != 0)
181 base64_decode_ctx_t ctx;
186 base64_decode_init(&ctx, length, target);
188 while (!ctx.seen_end && (ctx.length != 0)) {
201 RETERR(base64_decode_char(&ctx, tr->base[i]));
203 if (ctx.length < 0 && !ctx.seen_end)
205 RETERR(base64_decode_finish(&ctx));
211 base64_decode_ctx_t ctx;
213 base64_decode_init(&ctx, -1, target);
220 RETERR(base64_decode_char(&ctx, c));
222 RETERR(base64_decode_finish(&ctx));