int SMIME_crlf_copy(BIO *in, BIO *out, int flags)
{
	char eol;
	int len;
	char linebuf[MAX_SMLEN];
	if(flags & PKCS7_BINARY) {
		while((len = BIO_read(in, linebuf, MAX_SMLEN)) > 0)
						BIO_write(out, linebuf, len);
		return 1;
	}
	if(flags & PKCS7_TEXT)
		BIO_printf(out, "Content-Type: text/plain\r\n\r\n");
	while ((len = BIO_gets(in, linebuf, MAX_SMLEN)) > 0) {
		eol = strip_eol(linebuf, &len);
		if (len)
			BIO_write(out, linebuf, len);
		if(eol) BIO_write(out, "\r\n", 2);
	}
	return 1;
}