1 /* $Id: encodeQ.c,v 1.2 1998/02/28 19:03:02 lindberg Exp $*/
2 /* $Name: ezmlm-idx-040 $*/
9 static void die_nomem(fatal
)
12 strerr_die2x(111,fatal
,ERR_NOMEM
);
15 static char *hexchar
= "0123456789ABCDEF";
17 void encodeQ(indata
,n
,outdata
,fatal
)
23 /* converts any character with the high order bit set to */
24 /* quoted printable. In: n chars of indata, out: stralloc outdata*/
34 /* max 3 outchars per inchar & 2 char newline per 72 chars */
35 if (!stralloc_copys(outdata
,"")) die_nomem(fatal
);
36 if (!stralloc_ready(outdata
,n
* 3 + n
/36)) die_nomem(fatal
); /* worst case */
40 if (ch
!= ' ' && ch
!= '\n' && ch
!= '\t' &&
41 (ch
> 126 || ch
< 33 || ch
== 61)) {
43 *(cpout
++) = hexchar
[(ch
>> 4) & 0xf];
44 *(cpout
++) = hexchar
[ch
& 0xf];
57 outdata
->len
= (unsigned int) (cpout
- outdata
->s
);