dthelp: Change to ANSI function definitions
[oweals/cde.git] / cde / programs / dtmail / libDtMail / RFC / RFCFormat.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  *      $XConsortium: RFCFormat.hh /main/4 1996/04/02 16:20:29 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 _RFCFORMAT_HH
48 #define _RFCFORMAT_HH
49
50 #include <DtMail/DtMail.hh>
51 #include <DtMail/Buffer.hh>
52
53 class RFCFormat : public DtCPlusPlusAllocator {
54   public:
55     RFCFormat(DtMail::Session * session);
56     ~RFCFormat(void);
57
58     virtual void msgToBuffer(DtMailEnv & error,
59                              DtMail::Message & msg,
60                              DtMailBoolean include_content_length,
61                              DtMailBoolean include_unix_from,
62                              DtMailBoolean process_ignores,
63                              Buffer & headers,
64                              Buffer & body);
65            //call setIsWriteBcc when log message to files so that the BCC
66            // field will log to those files. 
67     void setIsWriteBcc() { _is_write_bcc = DTM_TRUE;}
68     void unsetIsWriteBcc() { _is_write_bcc = DTM_FALSE;}
69     DtMailBoolean getIsWriteBcc() { return _is_write_bcc;}
70   
71   protected:
72     DtMail::Session     *_session;
73     DtMailBoolean       _use_cr;
74     DtMailBoolean       _is_write_bcc;  // if log to file: Yes
75                                         //     send out: No (RFC 822)
76
77
78     virtual void formatBodies(DtMailEnv & error,
79                               DtMail::Message & msg,
80                               DtMailBoolean include_content_length,
81                               char ** extra_headers,
82                               Buffer & buf) = 0;
83
84     virtual void formatHeaders(DtMailEnv & error,
85                                DtMail::Message & msg,
86                                DtMailBoolean include_unix_from,
87                                const char * extra_headers,
88                                Buffer & buf) = 0;
89
90     void writeHeaders(DtMailEnv & error,
91                       DtMail::Message & msg,
92                       DtMailBoolean include_unix_from,
93                       const char * extra_headers,
94                       const char ** suppress_headers,
95                       Buffer & buf);
96
97     virtual void rfc1522cpy(Buffer & buf, const char * value);
98     void getCharSet(char * charset);
99     void getCharSet(char * charset, char *special);
100         int OpenLcxDb(void);
101         void DtXlateStdToOpLocale(char *op, char *std, char *dflt, char **ret);
102         void DtXlateOpToStdLocale(char *op, char *opLoc, char **retLoc, char **ret_retLang, char **retSet);
103         char *targetTagName();
104
105     void crlf(Buffer & buf)
106   {
107       const char * term = (_use_cr ? "\r\n" : "\n");
108       int len = (_use_cr ? 2 : 1);
109       buf.appendData(term, len);
110   }
111
112 };
113
114 inline void
115 appendString(Buffer & buf, const char * str)
116 {
117     buf.appendData(str, strlen(str));
118 }
119
120 #endif