code-qp.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2003-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* quoted printable coder
*/
#include <codex.h>
#include <ctype.h>
#include <ccode.h>
#define LINE 76
#define BUFFER SF_BUFSIZE
typedef struct State_s
{
unsigned char* bp;
unsigned char* be;
unsigned char* pp;
unsigned char prv[5];
short xxx;
int col;
} State_t;
static const char hex[] = "0123456789ABCDEFabcdef";
static int
{
ssize_t r;
{
return EOF;
}
}
static int
{
size_t n;
{
}
if (state->bp && (n = state->bp - state->buf) && sfwr(state->codex->sp, state->buf, n, &state->codex->sfdisc) != n)
return EOF;
if (c >= 0)
return 0;
}
static int
{
register int i;
{
return -1;
}
if (flags & CODEX_DECODE)
{
}
return 0;
}
static ssize_t
{
register char* s = (char*)buf;
register char* e = s + n;
register char* x;
register int c;
register int d;
x = 0;
while (s < e)
{
{
case '=':
continue;
{
c |= (d << 4);
x = 0;
break;
}
/*FALLTHROUGH*/
case EOF:
return s - (char*)buf;
case '\n':
if (x)
{
s = x;
x = 0;
}
break;
case ' ':
case '\t':
case '\r':
if (!x)
x = s;
break;
default:
x = 0;
break;
}
*s++ = c;
}
if (x)
return s - (char*)buf;
}
static ssize_t
{
register unsigned char* s;
register unsigned char* e;
register int c;
register int col;
{
}
else
{
s = (unsigned char*)buf;
e = s + n;
}
for (;;)
{
if (s >= e)
{
{
goto again;
}
break;
}
c = *s++;
if (!col++)
{
if (c == 'F')
{
if ((e - s) < 4)
{
s--;
col--;
for (c = 0; c < (e - s); ++c)
break;
}
else if (s[0] == 'r' && s[1] == 'o' && s[2] == 'm' && s[3] == ' ')
goto quote;
}
else if (c == '.')
{
if ((e - s) < 1)
{
s--;
col--;
break;
}
else if (s[0] == '\r' || s[0] == '\n')
goto quote;
}
}
if (c == '\n')
{
col = 0;
continue;
}
{
col = 0;
}
if (c == ' ' || c == '\t')
{
if ((e - s) < 1)
{
s--;
col--;
break;
}
else if (s[0] == '\r' || s[0] == '\n')
goto quote;
else
{
if (c == '\t')
col |= 7;
continue;
}
}
else if (c >= 0x21 && c <= 0x7e && c != '=')
#else
#endif
{
continue;
}
col += 2;
}
return n;
}
static int
{
}
{
"qp",
"quoted printable encoding.",
"[+(version)?codex-qp (AT&T Research) 1998-11-11]"
"[+(author)?Glenn Fowler <gsf@research.att.com>]",
0,
0,
0,
0,
0,
0,
0,
0,
0,
};