dthelp: Change to ANSI function definitions
[oweals/cde.git] / cde / programs / dtmail / libDtMail / RFC / RFCMIME.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  *+SNOTICE
25  *
26  *
27  *      $TOG: RFCMIME.hh /main/6 1997/03/28 12:10:13 mgreess $
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *      
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement bertween
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
35  *      Sun's specific written approval.  This documment and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  *+ENOTICE
42  */
43
44 #ifndef I_HAVE_NO_IDENT
45 #endif
46
47 #ifndef _RFCMIME_HH
48 #define _RFCMIME_HH
49
50 #include "RFCFormat.hh"
51
52 class RFCMIME : public RFCFormat {
53   public:
54     RFCMIME(DtMail::Session *);
55     ~RFCMIME(void);
56
57     static void readBase64(char * dest, int & size, const char * text,
58                            const unsigned long text_len);
59
60     static void readQPrint(char * dest, int & size, const char * text,
61                            const unsigned long text_len);
62
63     static void readTextEnriched(char * dest, int & size, const char * text,
64                            const unsigned long text_len);
65
66     void writeBase64(Buffer & buf, const char * bp, 
67                      const unsigned long len);
68   
69     void writeQPrint(Buffer & buf, const char * bp, 
70                      const unsigned long len);
71
72     // digest is:
73     // unsigned char digest[16];
74     //
75     static void md5PlainText(const char * bp,
76                              const unsigned long len,
77                              unsigned char * digest);
78
79     enum Encoding {
80         MIME_7BIT,
81         MIME_8BIT,
82         MIME_QPRINT,
83         MIME_BASE64
84         };
85
86   protected:
87     virtual void formatBodies(DtMailEnv & error,
88                               DtMail::Message & msg,
89                               DtMailBoolean include_content_length,
90                               char ** extra_headers,
91                               Buffer & buf);
92
93     virtual void formatHeaders(DtMailEnv & error,
94                                DtMail::Message & msg,
95                                DtMailBoolean include_unix_from,
96                                const char * extra_headers,
97                                Buffer & buf);
98
99     virtual void rfc1522cpy(Buffer & buf, const char * value);
100
101   private:
102
103     void getMIMEType(
104                         DtMail::BodyPart * bp,
105                         char * mime_type,
106                         DtMailBoolean & is_text);
107     Encoding getHdrEncodingType(
108                         const char *,
109                         const unsigned int,
110                         DtMailBoolean,
111                         const char *);
112     Encoding getEncodingType(
113                         const char *,
114                         const unsigned int,
115                         DtMailBoolean,
116                         int *);
117     Encoding getClearEncoding(
118                         const char *,
119                         const unsigned int,
120                         int *);
121     void writeContentHeaders(
122                         Buffer & buf,
123                         const char * type,
124                         const char * name,
125                         const Encoding,
126                         const char * digest,
127                         DtMailBoolean show_as_attachment,
128                         int is2022ASCII );
129     
130     void writePlainText(
131                         Buffer & buf,
132                         const char * bp,
133                         const unsigned long len);
134     void owCompat(
135                 Buffer & buf, char * type, char * name,
136                 char *contents, unsigned long len);
137 };
138
139 #endif