home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / coreincl / platform.h < prev   
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.4 KB  |  285 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*-----------------------------------------------------------------------------
  20.     platform.h
  21.     Cross-Platform Core Types
  22. -----------------------------------------------------------------------------*/
  23.  
  24. /*-----------------------------------------------------------------------------
  25.     Platform-specific defines
  26.         
  27.         XP_WIN              XP_IS_WIN       XP_WIN_ARG(X)
  28.         XP_MAC              XP_IS_MAC         XP_MAC_ARG(X)
  29.         XP_UNIX             XP_IS_UNIX        XP_UNIX_ARG(X)
  30.         XP_CPLUSPLUS        XP_IS_CPLUSPLUS
  31.         defined iff         always defined    defined to nothing
  32.         on that platform    as 0 or 1         or X
  33.         
  34.         Also Bool, Int32, Int16, Int, Uint32, Uint16, Uint, and nil
  35.         And TRUE, FALSE, ON, OFF, YES, NO
  36. -----------------------------------------------------------------------------*/
  37.  
  38. #ifndef _XP_Core_
  39.  
  40. #ifndef _platform_h_
  41. #define _platform_h_
  42.  
  43. /* Suppress the old file in dual environments */
  44. #define _XP_Core_
  45. /* Suppress obsolete NS prototypes */
  46. #define PROTOTYPES_H
  47.  
  48.  
  49. /* which system are we on, get the base macro defined */
  50.  
  51. #if defined(macintosh) || defined(__MWERKS__) || defined(applec)
  52. #ifndef macintosh
  53. #define macintosh 1
  54. #endif
  55. #endif
  56.  
  57. #if defined(__unix) || defined(unix) || defined(UNIX) || defined(XP_UNIX)
  58. #ifndef unix
  59. #define unix 1
  60. #endif
  61. #endif
  62.  
  63. #if !defined(macintosh) && !defined(_WINDOWS) && !defined(unix)
  64.   /* #error xp library can't determine system type */
  65. #endif
  66.  
  67. /* flush out all the system macros */
  68.  
  69. #ifdef macintosh
  70. # define XP_MAC 1
  71. # define XP_IS_MAC 1
  72. # define XP_MAC_ARG(x) x
  73. #else
  74. # define XP_IS_MAC 0
  75. # define XP_MAC_ARG(x)
  76. #endif
  77.  
  78. #ifdef _WINDOWS
  79. # define XP_WIN
  80. # define XP_IS_WIN 1
  81. # define XP_WIN_ARG(x) x
  82. #if defined(_WIN32) || defined(WIN32)
  83. # define XP_WIN32
  84. #else
  85. # define XP_WIN16
  86. #endif
  87. #else
  88. # define XP_IS_WIN 0
  89. # define XP_WIN_ARG(x)
  90. #endif
  91.  
  92. #ifdef unix
  93. # ifndef XP_UNIX
  94. # define XP_UNIX
  95. # endif
  96. # define XP_IS_UNIX 1
  97. # define XP_UNIX_ARG(x) x
  98. #else
  99. # define XP_IS_UNIX 0
  100. # define XP_UNIX_ARG(x)
  101. #endif
  102.  
  103. /* what language do we have? */
  104.  
  105. #if defined(__cplusplus)
  106. # define XP_CPLUSPLUS
  107. # define XP_IS_CPLUSPLUS 1
  108. #else
  109. # define XP_IS_CPLUSPLUS 0
  110. #endif
  111.  
  112. #if defined(DEBUG) || !defined(XP_CPLUSPLUS)
  113. #define XP_REQUIRES_FUNCTIONS
  114. #endif
  115.  
  116. /*
  117.     language macros
  118.     
  119.     If C++ code includes a prototype for a function *compiled* in C, it needs to be
  120.     wrapped in extern "C" for the linking to work properly. On the Mac, all code is
  121.     being compiled in C++ so this isn't necessary, and Unix compiles it all in C. So
  122.     only Windows actually will make use of the defined macros.
  123. */
  124.  
  125. #if defined(XP_CPLUSPLUS)
  126. # define XP_BEGIN_PROTOS extern "C" {
  127. # define XP_END_PROTOS }
  128. #else
  129. # define XP_BEGIN_PROTOS
  130. # define XP_END_PROTOS
  131. #endif
  132.  
  133. /* simple common types */
  134.  
  135. #ifdef XP_WIN
  136. #ifndef RESOURCE_STR
  137. #include "prtypes.h"
  138. #endif /* RESOURCE_STR */
  139. #else /* XP_WIN */
  140. #include "prtypes.h"
  141. #endif /* XP_WIN */
  142.  
  143. #ifdef XP_MAC
  144. #include <Types.h>
  145.     typedef char BOOL;
  146.     typedef char Bool;
  147.     typedef char XP_Bool;
  148. #elif defined(XP_WIN)
  149.     typedef int Bool;
  150.     typedef int XP_Bool;
  151. #else
  152.     typedef char Bool;
  153.     typedef char XP_Bool;
  154. #endif
  155.  
  156. #ifdef XP_WIN
  157. #ifndef BOOL
  158. #define BOOL Bool
  159. #endif
  160. #ifndef TRUE
  161. #define FALSE 0
  162. #define TRUE !FALSE
  163. #endif
  164. #define MIN(a, b)     min((a), (b))
  165. #endif
  166.  
  167. #if defined(XP_UNIX) && !defined(MIN)
  168. #define MIN(a,b) (((a)<(b))?(a):(b))
  169. #endif
  170.  
  171. #ifndef FALSE
  172. #define FALSE 0
  173. #endif
  174.  
  175. /* disable the TRUE redefinition warning
  176.  * TRUE is defined by windows.h in the MSVC
  177.  * development environment, and creates a
  178.  * nasty warning for every file.  The only
  179.  * way to turn it off is to disable all
  180.  * macro redefinition warnings or to not
  181.  * define TRUE here
  182.  */
  183. #if !defined(TRUE) && !defined(XP_WIN)
  184. #define TRUE !FALSE
  185. #endif
  186.  
  187. #define YES 1
  188. #define NO 0
  189.  
  190. #define ON 1
  191. #define OFF 0
  192.  
  193. #ifndef nil
  194. #define nil 0
  195. #endif
  196.  
  197. #ifndef NULL
  198. #define NULL 0
  199. #endif
  200.  
  201. #ifndef TRACEMSG
  202. #ifdef DEBUG
  203. #define TRACEMSG(msg)  do { if(MKLib_trace_flag)  XP_Trace msg; } while (0)
  204. #else
  205. #define TRACEMSG(msg)  
  206. #endif /* DEBUG */
  207. #endif /* TRACEMSG */
  208.  
  209. #define _INT16
  210. #define _UINT16
  211. #define _INT32
  212. #define _UINT32
  213.  
  214. typedef int             intn;
  215.  
  216. /* function classifications */
  217.  
  218. #define PUBLIC
  219. #define MODULE_PRIVATE
  220. #define PRIVATE static
  221.  
  222. /* common typedefs */
  223. typedef struct _XP_List XP_List;
  224.  
  225. /* standard system headers */
  226.  
  227. #if !defined(RC_INVOKED)
  228. #include <assert.h>
  229. #include <ctype.h>
  230. #ifdef __sgi
  231. # include <float.h>
  232. #endif
  233. #ifdef XP_UNIX
  234. #include <stdarg.h>
  235. #endif
  236. #include <limits.h>
  237. #include <locale.h>
  238. #if defined(XP_WIN) && defined(XP_CPLUSPLUS) && defined(_MSC_VER) && _MSC_VER >= 1020
  239. /* math.h under MSVC 4.2 needs C++ linkage when C++. */
  240. extern "C++"    {
  241. #include <math.h>
  242. }
  243. #else
  244. #include <math.h>
  245. #endif
  246. #include <setjmp.h>
  247. #include <stddef.h>
  248. #include <stdio.h>
  249. #include <stdlib.h>
  250. #include <string.h>
  251. #include <time.h>
  252. #endif
  253.  
  254.  
  255.  
  256. #define CR '\015'
  257. #define LF '\012'
  258. #define VTAB '\013'
  259. #define FF '\014'
  260. #define TAB '\011'
  261. #define CRLF "\015\012"     /* A CR LF equivalent string */
  262.  
  263. #ifdef XP_MAC
  264. #  define LINEBREAK        "\015"
  265. #  define LINEBREAK_LEN    1
  266. #else
  267. #  ifdef XP_WIN
  268. #    define LINEBREAK        "\015\012"
  269. #    define LINEBREAK_LEN    2
  270. #  else
  271. #    ifdef XP_UNIX
  272. #      define LINEBREAK        "\012"
  273. #      define LINEBREAK_LEN    1
  274. #    endif /* XP_UNIX */
  275. #  endif /* XP_WIN */
  276. #endif /* XP_MAC */
  277.  
  278. #ifndef _xp_observer_h_
  279. typedef int NS_Error;
  280. #endif /* _xp_observer_h_ */
  281.  
  282. #endif /* _platform_h_ */
  283.  
  284. #endif /* _XP_Core_ */
  285.