/* Flush any pending base64 character data out. If we have all three bytes are present, this will generate 4 characters, otherwise it may generate fewer.  */
static void base64_flush(struct jwt_builder *st)
/* Flush any pending base64 character data out. If we have all three bytes are present, this will generate 4 characters, otherwise it may generate fewer.  */
static void base64_flush(struct jwt_builder *st)
{
	if (st->pending < 1) {
		return;
	}
	base64_outch(st, base64_char(st->wip[0] >> 2));
	base64_outch(st, base64_char(((st->wip[0] & 0x03) << 4) |
				(st->wip[1] >> 4)));
	if (st->pending >= 2) {
		base64_outch(st, base64_char(((st->wip[1] & 0x0f) << 2) |
				(st->wip[2] >> 6)));
	}
	if (st->pending >= 3) {
		base64_outch(st, base64_char(st->wip[2] & 0x3f));
	}
	st->pending = 0;
	memset(st->wip, 0, 3);
}