xref: /aoo4110/main/sal/osl/w32/system.h (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #if OSL_DEBUG_LEVEL == 0
25 #    define NO_DEBUG_CRT
26 #endif
27 
28 #ifndef _WIN32_WINNT
29 #	define _WIN32_WINNT 0x0400
30 #	define _CTYPE_DISABLE_MACROS /* wg. dynamischer C-Runtime MH */
31 #endif
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <stdarg.h>
36 #include <ctype.h>
37 #include <malloc.h>
38 #include <limits.h>
39 #include <process.h>
40 #include <time.h>
41 #include <fcntl.h>
42 #include <sys/types.h>
43 #include <sys/stat.h>
44 #include <io.h>
45 #include <share.h>
46 #include <direct.h>
47 
48 /* Must define this else build breaks because Winsock2.h
49     includes Windows.h and without WIN32_LEAN_AND_MEAN
50     also includes mswsock.h which needs a forward typedef
51     of SOCKET ...
52 */
53 #define WIN32_LEAN_AND_MEAN
54 
55 #ifdef GCC
56     // windows.h includes winsock2.h
57     // if _WIN32_WINNT > 0x0400
58     // so someone cannot include winsock.h
59     // at the same time without patching
60     // windows.h
61     #include <windows.h>
62 #ifdef __MINGW32__
63     #include <winsock2.h>
64     #include <ws2tcpip.h>
65 #endif
66     #include <shlobj.h>
67     #ifndef NO_DEBUG_CRT
68         #include <crtdbg.h>
69     #endif
70 #else
71     // winsock2.h includes windows.h
72     #pragma warning(push,1) /* disable warnings within system headers */
73     #pragma warning(disable:4917)
74     #include <winsock2.h>
75     #include <wsipx.h>
76     #include <shlobj.h>
77     #ifndef NO_DEBUG_CRT
78         #include <crtdbg.h>
79     #endif
80     #pragma warning(pop)
81 #endif
82 
83 #define _MAX_CMD	4096	/* maximum length of commandline     */
84 /* #define _MAX_ENV	4096	 maximum length of environment var (isn't used anywhere) */
85 
86 #ifdef GCC
87     #	ifndef SA_FAMILY_DECL
88     #		define SA_FAMILY_DECL short sa_family
89     #	endif
90 
91 	typedef struct sockaddr_ipx {
92 		SA_FAMILY_DECL;
93 		char sa_netnum[4];
94 		char sa_nodenum[6];
95 		unsigned short sa_socket;
96 	} SOCKADDR_IPX;
97 
98     #	define NSPROTO_IPX		1000
99     #	define NSPROTO_SPX		1256
100     #	define NSPROTO_SPXII	1257
101 #endif // #ifdef GCC
102 
103 #ifdef _DLL_
104 
105 #ifdef __cplusplus
106     extern "C" DWORD g_dwPlatformId;
107 #else
108     extern DWORD g_dwPlatformId;
109 #endif // #ifdef __cplusplus
110 
111     #define IS_NT (g_dwPlatformId == VER_PLATFORM_WIN32_NT)
112 #else
113 
114 #ifdef __cplusplus
115     extern "C" DWORD GetPlatformId(void);
116 #else
117     extern DWORD GetPlatformId(void);
118 #endif // #ifdef __cplusplus
119 
120     #define IS_NT (GetPlatformId() == VER_PLATFORM_WIN32_NT)
121 #endif // #ifdef _DLL_
122 
123