1N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1N/A * Copyright (c) 1997-1998 Richard Coleman 1N/A * All rights reserved. 1N/A * Permission is hereby granted, without written agreement and without 1N/A * license or royalty fees, to use, copy, modify, and distribute this 1N/A * software and to distribute modified versions of this software for any 1N/A * purpose, provided that the above copyright notice and the following two 1N/A * paragraphs appear in all copies of this software. 1N/A * In no event shall Richard Coleman be liable to any party for direct, 1N/A * indirect, special, incidental, or consequential damages arising out of 1N/A * the use of this software and its documentation, even if Richard Coleman 1N/A * has been advised of the possibility of such damage. 1N/A * Richard Coleman specifically disclaims any warranties, including, but 1N/A * not limited to, the implied warranties of merchantability and fitness 1N/A * for a particular purpose. The software provided hereunder is on an "as 1N/A * is" basis, and Richard Coleman has no obligation to provide maintenance, 1N/A * support, updates, enhancements, or modifications. 1N/A * Parts of this code were derived from metamail, which is ... 1N/A * Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore) 1N/A * Permission to use, copy, modify, and distribute this material 1N/A * for any purpose and without fee is hereby granted, provided 1N/A * that the above copyright notice and this permission notice 1N/A * appear in all copies, and that the name of Bellcore not be 1N/A * used in advertising or publicity pertaining to this 1N/A * material without the specific, prior written permission 1N/A * of an authorized representative of Bellcore. BELLCORE 1N/A * MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 1N/A * OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", 1N/A * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. 1N/A * Copyright (c) 1998, by Sun Microsystems, Inc. 1N/A * All rights reserved. 1N/A -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A 0,
1,
2,
3,
4,
5,
6,
7,
8,
9, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A -
1,
10,
11,
12,
13,
14,
15, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A -
1,
10,
11,
12,
13,
14,
15, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1 1N/A -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1, -
1,
62, -
1, -
1, -
1,
63,
1N/A 52,
53,
54,
55,
56,
57,
58,
59,
60,
61, -
1, -
1, -
1, -
1, -
1, -
1,
1N/A -
1, 0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
1N/A 15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25, -
1, -
1, -
1, -
1, -
1,
1N/A -
1,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
1N/A 41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51, -
1, -
1, -
1, -
1, -
1 1N/A#
define char64(c) (((
unsigned char) (c) >
127) ? -
1 : \
1N/A/* Check if character is linear whitespace */ 1N/A#
define is_lws(c) ((c) ==
' ' || (c) ==
'\t' || (c) ==
'\n')
1N/A * Decode the string as a RFC-2047 header field 1N/A * Do a quick and dirty check for the '=' character. 1N/A * This should quickly eliminate many cases. 1N/A * If we had an '=' character pending from 1N/A * last iteration, then add it first. 1N/A /* count linear whitespace while between encodings */ 1N/A /* Check for initial =? */ 1N/A if (*p ==
'=' && p[
1] && p[
1] ==
'?' && p[
2]) {
1N/A /* Scan ahead for the next '?' character */ 1N/A /* Check for valid encoding type */ 1N/A /* Is encoding quoted printable or base64? */ 1N/A /* Check for next '?' character */ 1N/A * Scan ahead for the ending ?= 1N/A * While doing this, we will also check if encoded 1N/A * word has any embedded linear whitespace. 1N/A else if (*
pp ==
'?' &&
pp[
1] ==
'=') {
1N/A * We've found an encoded word, so we can drop 1N/A * the '=' that was pending 1N/A * If we are between two encoded words separated only 1N/A * by linear whitespace, then we ignore the whitespace. 1N/A * We will roll back the buffer the number of whitespace 1N/A * characters we've seen since last encoded word. 1N/A /* Now decode the text */ 1N/A *q++ = ((
c2 &
0xF) <<
4) |
1N/A * Now that we are done decoding this particular 1N/A * encoded word, advance string to trailing '='. 1N/A /* If an equals was pending at end of string, add it now. */