1 /******************************************************************************
2  *
3  *  defs.h -	Global defines, mostly platform-specific stuff
4  *
5  * $Id: defs.h 3029 2014-02-25 13:00:49Z scribe $
6  *
7  * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
8  *	CrossWire Bible Society
9  *	P. O. Box 2528
10  *	Tempe, AZ  85280-2528
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the
14  * Free Software Foundation version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * General Public License for more details.
20  *
21  */
22 // ----------------------------------------------------------------------------
23 //
24 // ----------------------------------------------------------------------------
25 #ifndef SWORDDEFS_H
26 #define SWORDDEFS_H
27 
28 // TODO: What is this? jansorg, why does NO_SWORD_NAMESPACE still define
29 // a C++ namespace, and then force using it?  This makes no sense to me.
30 // see commit 1195
31 #ifdef NO_SWORD_NAMESPACE
32  #define SWORD_NAMESPACE_START namespace sword {
33  #define SWORD_NAMESPACE_END }; using namespace sword;
34 #elif defined(__cplusplus)
35  #define SWORD_NAMESPACE_START namespace sword {
36  #define SWORD_NAMESPACE_END }
37 #else
38  #define SWORD_NAMESPACE_START
39  #define SWORD_NAMESPACE_END
40 #endif
41 
42 SWORD_NAMESPACE_START
43 
44 #define SWTRY try
45 #define SWCATCH(x) catch (x)
46 
47 #ifdef _WIN32_WCE
48 #define SWTRY
49 #define SWCATCH(x) if (0)
50 #define GLOBCONFPATH "/Program Files/sword/sword.conf"
51 #endif
52 
53 #ifdef ANDROID
54 #define _NO_IOSTREAM_
55 #undef SWTRY
56 #undef SWCATCH
57 #define SWTRY
58 #define SWCATCH(x) if (0)
59 #endif
60 
61 // _declspec works in BC++ 5 and later, as well as VC++
62 #if defined(_MSC_VER)
63 
64 #  ifdef SWMAKINGDLL
65 #    define SWDLLEXPORT _declspec( dllexport )
66 #    define SWDLLEXPORT_DATA(type) _declspec( dllexport ) type
67 #    define SWDLLEXPORT_CTORFN
68 #  elif defined(SWUSINGDLL)
69 #    define SWDLLEXPORT _declspec( dllimport )
70 #    define SWDLLEXPORT_DATA(type) _declspec( dllimport ) type
71 #    define SWDLLEXPORT_CTORFN
72 #  else
73 #    define SWDLLEXPORT
74 #    define SWDLLEXPORT_DATA(type) type
75 #    define SWDLLEXPORT_CTORFN
76 #  endif
77 
78 #  define SWDEPRECATED __declspec(deprecated("** WARNING: deprecated method **"))
79 
80 
81 #elif defined(__SWPM__)
82 
83 #  ifdef SWMAKINGDLL
84 #    define SWDLLEXPORT _Export
85 #    define SWDLLEXPORT_DATA(type) _Export type
86 #    define SWDLLEXPORT_CTORFN
87 #  elif defined(SWUSINGDLL)
88 #    define SWDLLEXPORT _Export
89 #    define SWDLLEXPORT_DATA(type) _Export type
90 #    define SWDLLEXPORT_CTORFN
91 #  else
92 #    define SWDLLEXPORT
93 #    define SWDLLEXPORT_DATA(type) type
94 #    define SWDLLEXPORT_CTORFN
95 #  endif
96 
97 #  define SWDEPRECATED
98 
99 
100 #elif defined(__GNUWIN32__)
101 
102 #  ifdef SWMAKINGDLL
103 #    define SWDLLEXPORT __declspec( dllexport )
104 #    define SWDLLEXPORT_DATA(type) __declspec( dllexport ) type
105 #    define SWDLLEXPORT_CTORFN
106 #  elif defined(SWUSINGDLL)
107 #    define SWDLLEXPORT __declspec( dllimport )
108 #    define SWDLLEXPORT_DATA(type) __declspec( dllimport ) type
109 #    define SWDLLEXPORT_CTORFN
110 #  else
111 #    define SWDLLEXPORT
112 #    define SWDLLEXPORT_DATA(type) type
113 #    define SWDLLEXPORT_CTORFN
114 #  endif
115 
116 #  define SWDEPRECATED  __attribute__((__deprecated__))
117 
118 
119 #elif defined(__BORLANDC__)
120 #  ifdef SWMAKINGDLL
121 #    define SWDLLEXPORT _export
122 #    define SWDLLEXPORT_DATA(type) __declspec( dllexport ) type
123 #    define SWDLLEXPORT_CTORFN
124 #  elif defined(SWUSINGDLL)
125 #    define SWDLLEXPORT __declspec( dllimport )
126 #    define SWDLLEXPORT_DATA(type) __declspec( dllimport ) type
127 #    define SWDLLEXPORT_CTORFN
128 #  else
129 #    define SWDLLEXPORT
130 #    define SWDLLEXPORT_DATA(type) type
131 #    define SWDLLEXPORT_CTORFN
132 #  endif
133 
134 #define COMMENT SLASH(/)
135 #define SLASH(s) /##s
136 #  define SWDEPRECATED COMMENT
137 
138 
139 #elif defined(__GNUC__)
140 #  define SWDLLEXPORT
141 #  define SWDLLEXPORT_DATA(type) type
142 #  define SWDLLEXPORT_CTORFN
143 #  define SWDEPRECATED  __attribute__((__deprecated__))
144 
145 
146 #else
147 #  define SWDLLEXPORT
148 #  define SWDLLEXPORT_DATA(type) type
149 #  define SWDLLEXPORT_CTORFN
150 #  define SWDEPRECATED
151 #endif
152 
153 
154 // For ostream, istream ofstream
155 #if defined(__BORLANDC__) && defined( _RTLDLL )
156 #  define SWDLLIMPORT __import
157 #else
158 #  define SWDLLIMPORT
159 #endif
160 
161 
162 
163 #ifdef __cplusplus
164 enum {DIRECTION_LTR = 0, DIRECTION_RTL, DIRECTION_BIDI};
165 enum {FMT_UNKNOWN = 0, FMT_PLAIN, FMT_THML, FMT_GBF, FMT_HTML, FMT_HTMLHREF, FMT_RTF, FMT_OSIS, FMT_WEBIF, FMT_TEI, FMT_XHTML, FMT_LATEX};
166 enum {ENC_UNKNOWN = 0, ENC_LATIN1, ENC_UTF8, ENC_SCSU, ENC_UTF16, ENC_RTF, ENC_HTML};
167 enum {BIB_BIBTEX = 0, /* possible future formats: BIB_MARCXML, BIB_MARC21, BIB_DCMI BIB_OSISHEADER, BIB_SBL_XHTML, BIB_MLA_XHTML, BIB_APA_XHTML, BIB_CHICAGO_XHTML */};
168 #endif
169 
170 SWORD_NAMESPACE_END
171 #endif //SWORDDEFS_H
172