1 //
2 // VMime library (http://www.vmime.org)
3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 3 of
8 // the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // Linking this library statically or dynamically with other modules is making
20 // a combined work based on this library.  Thus, the terms and conditions of
21 // the GNU General Public License cover the whole combination.
22 //
23 
24 #include "vmime/config.hpp"
25 
26 #include "vmime/charset.hpp"
27 #include "vmime/base.hpp"
28 
29 #include "vmime/utility/encoder/encoder.hpp"
30 #include "vmime/utility/encoder/b64Encoder.hpp"
31 #include "vmime/utility/encoder/qpEncoder.hpp"
32 
33 #include "vmime/text.hpp"
34 
35 #include "vmime/parserHelpers.hpp"
36 
37 #include "vmime/utility/stringUtils.hpp"
38 
39 // For initializing
40 #include "vmime/utility/encoder/encoderFactory.hpp"
41 #include "vmime/headerFieldFactory.hpp"
42 #include "vmime/textPartFactory.hpp"
43 #include "vmime/generationContext.hpp"
44 #include "vmime/parsingContext.hpp"
45 
46 #if VMIME_HAVE_MESSAGING_FEATURES
47 	#include "vmime/net/serviceFactory.hpp"
48 #endif
49 
50 
51 namespace vmime
52 {
53 
54 
55 /** "Null" (empty) string.
56   */
57 const string NULL_STRING;
58 
59 /** "Null" (empty) text.
60   */
61 const text NULL_TEXT;
62 
63 /** "Null" (empty) word.
64   */
65 const word NULL_WORD("", vmime::charset(vmime::charsets::US_ASCII));
66 
67 
68 /** Return the library name (eg: "libvmime").
69   *
70   * @return library name
71   */
libname()72 const string libname() { return (VMIME_PACKAGE); }
73 
74 /** Return the library version (eg: "0.5.2").
75   *
76   * @return library version
77   */
libversion()78 const string libversion() { return (VMIME_VERSION " (" __DATE__ " " __TIME__ ")"); }
79 
80 /** Return the library API version (eg: "6:1:6").
81   *
82   * @return library API version
83   */
libapi()84 const string libapi() { return (VMIME_API); }
85 
86 
87 // New line sequence to be used when folding header fields.
88 const string NEW_LINE_SEQUENCE = "\r\n ";
89 const size_t NEW_LINE_SEQUENCE_LENGTH = 1;   // space
90 
91 /** The CR-LF sequence.
92   */
93 const string CRLF = "\r\n";
94 
95 
96 /** The current MIME version supported by VMime.
97   */
98 const string SUPPORTED_MIME_VERSION = "1.0";
99 
100 
101 #ifndef VMIME_BUILDING_DOC
102 
103 /** Null shared pointer.
104   */
105 nullPtrType null;
106 
107 #endif // VMIME_BUILDING_DOC
108 
109 
110 // Line length limits
111 namespace lineLengthLimits
112 {
113 	const size_t infinite = std::numeric_limits <size_t>::max();
114 }
115 
116 
117 const size_t npos = std::numeric_limits <size_t>::max();
118 
119 
120 
121 #ifndef VMIME_BUILDING_DOC
122 
123 //
124 //  V-Mime Initializer
125 // ====================
126 //
127 // Force instanciation of singletons. This is to prevent problems that might
128 // happen in multithreaded applications...
129 //
130 // WARNING: we put the initializer at the end of this compilation unit. This
131 // ensures this object is initialized _after_ all other global variables in
132 // the same compilation unit (in particular "lineLengthLimits::infinite",
133 // which is used by the generate() function (called from "textPartFactory"
134 // constructor, for example).
135 //
136 
137 class initializer
138 {
139 public:
140 
initializer()141 	initializer()
142 	{
143 		parsingContext::getDefaultContext();
144 		generationContext::getDefaultContext();
145 
146 		utility::encoder::encoderFactory::getInstance();
147 		headerFieldFactory::getInstance();
148 		textPartFactory::getInstance();
149 
150 		#if VMIME_HAVE_MESSAGING_FEATURES
151 			net::serviceFactory::getInstance();
152 		#endif
153 	}
154 };
155 
156 initializer theInitializer;
157 
158 #endif // VMIME_BUILDING_DOC
159 
160 
161 } // vmime
162