view f-demime/b2q_in.c @ 8:a92d0d59b669 default tip

f-demime: indicate X-backslash-escapes encoding in output
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 May 2023 17:00:23 +0000
parents 7e0d08176f32
children
line wrap: on
line source

/*
 * This module implements the input side of base64-to-QP conversion.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "defs.h"

extern void (*dec_outf)();
extern FILE *tempfile;

static int cr_state;

static void
output_func(ch)
{
	if (cr_state) {
		cr_state = 0;
		if (ch == '\n') {
			putc('\n', tempfile);
			return;
		} else
			putc('\r', tempfile);
	}
	if (ch == '\r')
		cr_state = 1;
	else
		putc(ch, tempfile);
}

void
b2q_conv_init()
{
	dec_outf = output_func;
	cr_state = 0;
}

void
b2q_conv_finish()
{
	if (cr_state)
		putc('\r', tempfile);
}