2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "NGMimeHeaderFieldGenerator.h"
24 #include "NGMimeHeaderFields.h"
27 @implementation NGMimeHeaderFieldGenerator
33 + (id)headerFieldGenerator {
34 return [[[self alloc] init] autorelease];
37 - (NSData *)generateDataForHeaderFieldNamed:(NSString *)_headerField
40 [self subclassResponsibility:_cmd];
44 @end /* NGMimeHeaderFieldGenerator */
47 int NGEncodeQuotedPrintableMime
48 (const unsigned char *_src, unsigned _srcLen,
49 unsigned char *_dest, unsigned _destLen)
51 /* decode also spaces*/
55 hexT[16] = {'0','1','2','3','4','5','6','7','8',
56 '9','A','B','C','D','E','F'};
58 if (_srcLen > _destLen)
61 for (cnt = 0; (cnt < _srcLen) && (destCnt < _destLen); cnt++) {
62 register unsigned char c = _src[cnt];
64 if (((c > 47) && (c < 58)) ||
65 ((c > 64) && (c < 91)) ||
66 ((c > 96) && (c < 123))) {
71 else { // need to be quoted
72 if (_destLen - destCnt > 2) {
73 _dest[destCnt] = '='; destCnt++;
74 _dest[destCnt] = hexT[(c >> 4) & 15]; destCnt++;
75 _dest[destCnt] = hexT[c & 15]; destCnt++;
86 #else /* TODO: this one was declared in NGMimeMessageGenerator, any diff? */
88 static int NGEncodeQuotedPrintableMime(const char *_src, unsigned _srcLen,
89 char *_dest, unsigned _destLen) {
90 /* decode also spaces*/
93 char hexT[16] = {'0','1','2','3','4','5','6','7','8',
94 '9','A','B','C','D','E','F'};
96 if (_srcLen > _destLen)
99 for (cnt = 0; (cnt < _srcLen) && (destCnt < _destLen); cnt++) {
102 if (((c > 47) && (c < 58)) ||
103 ((c > 64) && (c < 91)) ||
104 ((c > 96) && (c < 123))) { // no quoting
105 _dest[destCnt++] = c;
107 else { // need to be quoted
108 if (_destLen - destCnt > 2) {
109 _dest[destCnt++] = '=';
110 _dest[destCnt++] = hexT[(c >> 4) & 15];
111 _dest[destCnt++] = hexT[c & 15];