libkmime

kmime_codec_uuencode.h
1/*
2 kmime_codec_uuencode.h
3
4 This file is part of KMime, the KDE internet mail/usenet news message library.
5 Copyright (c) 2002 Marc Mutz <mutz@kde.org>
6
7 KMime is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License, version 2, as
9 published by the Free Software Foundation.
10
11 KMime is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 In addition, as a special exception, the copyright holders give
21 permission to link the code of this library with any edition of
22 the TQt library by Trolltech AS, Norway (or with modified versions
23 of TQt that use the same license as TQt), and distribute linked
24 combinations including the two. You must obey the GNU General
25 Public License in all respects for all of the code used other than
26 TQt. If you modify this file, you may extend this exception to
27 your version of the file, but you are not obligated to do so. If
28 you do not wish to do so, delete this exception statement from
29 your version.
30*/
31
32#ifndef __KMIME_CODEC_UUENCODE_H__
33#define __KMIME_CODEC_UUENCODE_H__
34
35#include "kmime_codecs.h"
36
37namespace KMime {
38
39class UUCodec : public Codec {
40protected:
41 friend class Codec;
42 UUCodec() : Codec() {}
43
44public:
45 virtual ~UUCodec() {}
46
47 const char * name() const {
48 return "x-uuencode";
49 }
50
51 int maxEncodedSizeFor( int insize, bool withCRLF=false ) const {
52 (void)withCRLF;
53 return insize; // we have no encoder!
54 }
55
56 int maxDecodedSizeFor( int insize, bool withCRLF=false ) const {
57 // assuming all characters are part of the uuencode stream (which
58 // does almost never hold due to required linebreaking; but
59 // additional non-uu chars don't affect the output size), each
60 // 4-tupel of them becomes a 3-tupel in the decoded octet
61 // stream. So:
62 int result = ( ( insize + 3 ) / 4 ) * 3;
63 // but all of them may be \n, so
64 if ( withCRLF )
65 result *= 2; // :-o
66
67 return result;
68 }
69
70 Encoder * makeEncoder( bool withCRLF=false ) const;
71 Decoder * makeDecoder( bool withCRLF=false ) const;
72};
73
74} // namespace KMime
75
76#endif // __KMIME_CODEC_UUENCODE_H__