view f-demime/b2q_in.c @ 0:7e0d08176f32

f-demime starting code
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 May 2023 06:14:03 +0000
parents
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);
}