Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
osver.h
Go to the documentation of this file.
1 //
2 // BEGINSOFTWARE_AND_SERVICES_COPYRIGHT
3 //
4 // Copyright (C) 2010-2012,2018 Software and Services LLC, All Rights Reserved.
5 //
6 // NOTICE:
7 //
8 // THIS SOURCE CODE BELONGS TO Software and Services LLC.
9 // THIS CODE IS PROPERTY OF THE COPYRIGHT HOLDER AND IS NOT TO
10 // BE DIVULGED OR USED BY PARTIES WHO HAVE NOT RECEIVED WRITTEN
11 // AUTHORIZATION FROM THE OWNER.
12 //
13 // THIS SOFTWARE AND MANUAL ARE BOTH PROTECTED BY UNITED STATES
14 // COPYRIGHT LAW (TITLE 17 UNITED STATES CODE). UNAUTHORIZED REPRODUCTION
15 // AND/OR SALE MAY RESULT IN IMPRISONMENT OF UP TO ONE YEAR AND FINES
16 // OF UP TO $100,000 (17 USC 506). COPYRIGHT INFRINGERS MAY ALSO
17 // BE SUBJECT TO CIVIL LIABILITY.
18 //
19 // THIS NOTICE AND THE ABOVE COPYRIGHT NOTICE MUST REMAIN IN ALL
20 // COPIES AND ANY DERIVED WORK.
21 //
22 // ALL OF THIS CODE IS ORIGINAL WORK BY THE COPYRIGHT HOLDER.
23 //
24 // THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN IS
25 // PROVIDED ON AN "AS IS" BASIS AND Software and Services LLC.
26 // DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
27 // NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
28 // HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
29 // WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
30 // PURPOSE.
31 //
32 // ENDSOFTWARE_AND_SERVICES_COPYRIGHT
33 //
34 
39 #ifndef SOFTWARE_AND_SERVICES_LIBRARY_COMMON_OSVER_H_
40 #define SOFTWARE_AND_SERVICES_LIBRARY_COMMON_OSVER_H_
41 
42 //
43 // This used to be passed on the command line as compiler flags.
44 // Now its computed.
45 //
46 #ifdef OS
47 #undef OS
48 #endif // OS
49 
50 #ifdef OS_s
51 #undef OS_s
52 #endif // OS_s
53 // End of old-pre-defined
54 //
55 
56 #define AIX_OS 1024
57 #define BSD_OS 1025
58 #define HPUX_OS 1026
59 #define Linux_OS 1027
60 #define IOS_OS 1028
61 #define SUN_OS 1029
62 #define CYGWIN_OS 1030
63 #define WINDOWS_OS 1031
64 #define UNIX_OS 1032
65 
66 #ifdef _AIX
67 #define Aix 1
68 #define OS AIX_OS
69 #define OS_s "AIX"
70 #ifdef __unix__
71 #define OSTYPE UNIX
72 #define OSTYPE_s "UINX"
73 #endif // __unix__
74 #endif // __AIX
75 
76 #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
77 #include <sys/param.h>
78 #if defined(BSD)
79 #define Bsd 1
80 #define OS BSD_OS
81 #defind OS_s "BSD"
82 #ifdef __unix__
83 #define OSTYPE UNIX
84 #define OSTYPE_s "UINX"
85 #endif // __uinx__
86 #endif // BSD
87 #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
88 
89 #ifdef __hpux
90 #define Hpux 1
91 #define OS HPUX_OS
92 #define OS_s "HPUX"
93 #define OSTYPE UNIX
94 #define OSTYPE_s "UINX"
95 #endif // __hpux
96 
97 #ifdef __linux__
98 #define Linux 1
99 #define OS Linux_OS
100 #define OS_s "Linux"
101 #define OSTYPE UNIX
102 #define OSTYPE_S "UINX"
103 
104 #include <stdint.h>
105 #endif // __linux__
106 
107 #if defined(__APPLE__) && defined(__MACH__)
108 #define Apple 1
109 #define OS IOS_OS
110 #define OS_s "IOS_s"
111 #define OSTYPE APPLE
112 #define OSTYPE_s "APPLE"
113 
114 /* Apple OSX and iOS (Darwin). ------------------------------ */
115 #include <TargetConditionals.h>
116 #if TARGET_IPHONE_SIMULATOR == 1
117 /* iOS in Xcode simulator */
118 
119 #elif TARGET_OS_IPHONE == 1
120 /* iOS on iPhone, iPad, etc. */
121 #elif TARGET_OS_MAC == 1
122 /* OSX */
123 #endif // TARGET
124 
125 #endif // defined(__APPLE__) && defined(__MACH__)
126 
127 #if defined(__clang__)
128 /* Clang/LLVM. ---------------------------------------------- */
129 #define COMPILER CLANG
130 
131 #elif defined(__ICC) || defined(__INTEL_COMPILER)
132 /* Intel ICC/ICPC. ------------------------------------------ */
133 #define COMPILER INTEL
134 
135 #elif defined(__GNUC__) || defined(__GNUG__)
136 /* GNU GCC/G++. --------------------------------------------- */
137 #define COMPILER GCC
138 
139 #elif defined(__HP_cc) || defined(__HP_aCC)
140 /* Hewlett-Packard C/aC++. ---------------------------------- */
141 #define COMPILER HP
142 
143 #elif defined(__IBMC__) || defined(__IBMCPP__)
144 /* IBM XL C/C++. -------------------------------------------- */
145 #define COMPILER IBM
146 
147 #elif defined(_MSC_VER)
148 /* Microsoft Visual Studio. --------------------------------- */
149 #define COMPILER MS
150 
151 #elif defined(__PGI)
152 /* Portland Group PGCC/PGCPP. ------------------------------- */
153 #define COMPILER PORTLAND
154 
155 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
156 /* Oracle Solaris Studio. ----------------------------------- */
157 #define COMPILER SUNPRO
158 #endif // COMPILER
159 
160 // PROCESSOR
161 //
162 #if defined(__ia64) || defined(__itanium__) || defined(_M_IA64)
163 #define PROCESSOR ITANIUM
164 #define PROCESSOR_BITS 32
165 #endif // defined(__ia64) || defined(__itanium__) || defined(_M_IA64)
166 
167 #if defined(__powerpc__) || defined(__ppc__) || defined(__PPC__)
168 #define PROCESSOR POWERPC
169 #endif // defined(__powerpc__) || defined(__ppc__) || defined(__PPC__)
170 
171 #if defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) || \
172  defined(__64BIT__) || defined(_LP64) || defined(__LP64__)
173 #define PROCESSOR_BITS 64
174 #else // defined(__powerpc64__) || defined(__ppc64__) ...
175 #define PROCESSOR_BITS 32
176 #endif // defined(__powerpc64__) || defined(__ppc64__) ...
177 
178 #ifdef __sparc
179 #define PROCESSOR SPARC
180 #endif // __sparc
181 
182 #if defined(__x86_64__) || defined(_M_X64)
183 #define PROCESSOR X86_64
184 #elif defined(__i386) || defined(_M_IX86)
185 #define PROCESSOR X86_32
186 #endif // PROCESSOR ...
187 
188 
189 #ifdef __sun
190 #define SunOS 1
191 #define OS SunOS_OS
192 #define OS_s "SunOS"
193 #ifdef __SVR4
194 #define OSTYPE SolarisSVR4
195 #define OSTYPE_s "SolarisSVR4"
196 #else // __SVR4
197 #define OSTYPE SolarisBSD
198 #define OSTYPE_s "SolarisBSD"
199 #endif // __SVR4
200 
201 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
202 #ifdef OSVER
203 #undef OSVER
204 #endif
205 #ifdef OSVER_s
206 #undef OSVER_s
207 #endif
208 #if defined(__SunOS_5_6)
209 #define OSVER 56
210 #define OSVER_s "56"
211 #elif defined(__SunOS_5_7)
212 #define OSVER 57
213 #define OSVER_s "57"
214 #elif defined(__SunOS_5_8)
215 #define OSVER 58
216 #define OSVER_s "58"
217 #elif defined(__SunOS_5_9)
218 #define OSVER 59
219 #define OSVER_s "59"
220 #elif defined(__SunOS_5_10)
221 #define OSVER 510
222 #define OSVER_s "510"
223 #elif defined(__SunOS_5_11)
224 #define OSVER 511
225 #define OSVER_s "511"
226 #else
227 // Default to oldest
228 #define OSVER 56
229 #define OSVER_s "56"
230 #endif
231 #else
232 // Default to oldest
233 #define OSVER 56
234 #define OSVER_s "56"
235 #endif
236 
237 #endif // __sun
238 
239 #ifdef __CYGWIN__
240 #define CYGWIN 1
241 #define OS CYGWIN_OS
242 #define OS_s "CGWIN"
243 #define OSTYPE WINUNIX
244 #define OSTYPE_S "WINUNIX"
245 #endif // __CYGWIN__
246 
247 #if defined(__MINGW32__) && defined(__MINGW64__)
248 #define USING_MINGW 1
249 #define USING_MINGW64 1
250 #endif
251 
252 #if defined(__MINGW32__) && !defined(__MINGW64__)
253 #define USING_MINGW 1
254 #define USING_MINGW32 1
255 #endif
256 
257 #if defined(_WIN32) && !defined(USING_MINGW64)
258 #define Windows 1
259 #define OS WINDOWS_OS
260 #define OS_s "WINDOWS"
261 #define OSTYPE WINDOWS_32
262 #define OSTYPE_S "WINDOWS_32"
263 #ifndef WIN32
264 #define WIN32
265 #endif // WIN32
266 #endif // _WIN32
267 
268 #if defined(USING_MINGW32)
269 #define Windows 1
270 #define OS WINDOWS_OS
271 #define OS_s "WINDOWS"
272 #define OSTYPE WINDOWS_32
273 #define OSTYPE_S "WINDOWS_32"
274 #ifndef WIN32
275 #define WIN32
276 #endif // WIN32
277 #endif // _WIN32
278 
279 #if defined(_WIN64) || defined(USING_MINGW64)
280 #define Windows 1
281 #define OS WINDOWS_OS
282 #define OS_s "WINDOWS"
283 #define OSTYPE WINDOWS_64
284 #define OSTYPE_S "WINDOWS_64"
285 #ifndef WIN64
286 #define WIN64
287 #endif // WIN64
288 #endif // _WIN64
289 
290 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
291 /* UNIX-style OS. ------------------------------------------- */
292 #ifndef OSTYPE
293 #define OSTYPE UNIX_OS
294 #define OSTYPE_s "UINX"
295 #endif // OSTYPE
296 #include <unistd.h>
297 #endif // OSTYPE
298 
299 #if defined(_POSIX_VERSION)
300 /* POSIX compliant */
301 #ifndef ISPOSIX
302 #define ISPOSIX
303 #endif // ISPOSIX
304 #endif // _POSIX_VERSION
305 
306 #ifndef _POSIX_IPV6
307 #ifndef HAS_IPV6
308 #define HAS_IPV6
309 #endif // HAS_IPV6
310 #endif // _POSIX_IPV6
311 
312 #ifdef _POSIX_MAPPED_FILES
313 #ifndef HAS_MMAP
314 #define HAS_MMAP
315 #endif // HAS_MMAP
316 #endif // _POSIX_MAPPED_FILES
317 
318 #ifdef _POSIX_SEMAPHORES
319 #ifndef HAS_SEMS
320 #define HAS_SEMS
321 #endif // HAS_SEMS
322 #endif // _POSIX_SEMAPHORES
323 
324 #ifdef _POSIX_THREADS
325 #ifndef HAS_PTHREADS
326 #define HAS_PTHREADS
327 #endif // HAS_PTHREDS
328 #endif // _POSIX_THREADS
329 
330 #if !defined(USING_MINGW)
331 #ifdef WIN32
332 #pragma warning (disable : 4251)
333 #endif
334 #endif
335 
336 #ifdef CYGWIN
337 #define NEED_PC_INCLUDES 1
338 #endif // CYGWIN
339 
340 #ifdef MINGW32
341 #define NEED_PC_INCLUDES 1
342 #define CYGWIN
343 #endif // MINGW23
344 
345 #ifdef __cplusplus
346 extern "C" {
347 #endif
348 
349  extern unsigned int getOsVersion();
350  extern const char * getProductGuid();
351  extern void setProductGuid(const char *);
352 
353  /*_____________START__LINUX_______________________________________*/
354 
355 #if defined(Linux) || defined(CYGWIN)
356 
357 #ifndef _POSIX_C_SOURCE
358 #ifndef _POSIX_C_SOURCE
359 #define _POSIX_C_SOURCE 200809L
360 #endif
361 #endif
362 
363 #ifndef __EXTENSIONS__
364 #define __EXTENSIONS__
365 #endif
366 
367 #ifndef _POSIX_PTHREAD_SEMANTICS
368 #define _POSIX_PTHREAD_SEMANTICS
369 #endif
370 
371 #define IS_UNIX OS
372 #if (__GNUC__ < 3)
373 #define _GNU_SOURCE
374 #endif
375 
376 #ifdef __USE_BSD
377 #undef __USE_BSD
378 #define __USE_BSD 1
379 #endif
380 
381 #include <string.h>
382 #define _SVID_SOURCE
383 #endif
384  /*--------------END---LINUX---------------------------------------*/
385 
386  /*______________START_SUNOS_______________________________________*/
387 
388 #if (OS == SunOS)
389 #ifndef _POSIX_C_SOURCE
390 #define _POSIX_C_SOURCE 199506L
391 #endif
392 
393 #ifndef __EXTENSIONS__
394 #define __EXTENSIONS__
395 #endif
396 
397 #ifndef _POSIX_PTHREAD_SEMANTICS
398 #define _POSIX_PTHREAD_SEMANTICS
399 #endif
400 
401 #ifndef XPG4_2
402 #define XPG4_2
403 #endif
404 
405 #ifndef XSH4_2
406 #define XSH4_2
407 #endif
408 
409 #if (OSVER < 56)
410  #pragma error "Only supported on OSVER version 5.6 (Solaris 2.6) and above"
411 #endif/*((OSVER < 56) */
412 
413 #define IS_UNIX OS
414 
419 #define PAM_APPDATA_PTR_BUG
420 
421 #if (OSVER <= 56)
422 
424 #ifndef _FILE_OFFSET_BITS
425 #define _FILE_OFFSET_BITS 32
426 #endif/*_FILE_OFFSET_BITS*/
427 
428 #define _LARGEFILE_SOURCE 1
429 
430 #if (OSVER == 56)
431 #define OSVERMAJOR 56
432 #else
433 #pragma error "Place an #ifdef in here so that the OS VER MAJOR is correct"
434 #endif/*(OSVER == 56)*/
435 
436 #endif/* (OSVER <= 56)*/
437 
438 #if ((OSVER > 55) && (OSVER < 56))
439 #include <sys/types.h>
440 #include <stdio.h>
441 
442 #ifdef DEBUG
443 #undef NDEBUG
444 #else
445 #define NDEBUG 1
446 #endif/*DEBUG*/
447 
448 #include <assert.h>
449  extern int snprintf(char *s, size_t n, const char *format, /* args */ ...);
450  extern int _doprnt(const char*, void*, FILE*);
451 #define OSVERMAJOR 55
452 #endif/*((OSVER > 55) && (OSVER < 56))*/
453 
465 #if ((OSVER > 55) && (OSVER < 56))
466  typedef int socklen_t;
467 #endif/*((OSVER > 55) && (OSVER < 56))*/
468 
469 
470 #endif/* OS == SunOS */
471  /*--------------END---SUNOS---------------------------------------*/
472 
473 
474  /*______________START_WIN32______________________________________*/
475 
476 
477 #if defined(WIN32) || defined(WIN32_POSIX) || defined(WIN64) || defined(USING_MINGW)
478 #include <pthread.h>
479 
480 #define _POSIX_C_SOURCE 199506L
481 #define __EXTENSIONS__
482 #define _POSIX_PTHREAD_SEMANTICS
483 
484 #define EXPORT_OUT __declspec(dllexport)
485 #define EXPORT_IN __declspec(dllimport)
486 
487 #ifndef strcasecmp
488 #define strcasecmp stricmp
489 #endif
490 
491 #else
492 #define EXPORT_OUT
493 #define EXPORT_IN
494 #endif
495 
496 #ifdef USING_MINGW
497 #define locale_t _locale_t
498 #endif
499 
500  /*--------------END---WIN32---------------------------------------*/
501 
502 
503 #ifdef NEED_PC_INCLUDES
504 
505 #include <strings.h>
506 #include <string.h>
507 
508  extern char * strdup(const char * ptr);
509  extern int strcasecmp(const char * s1, const char * s2);
510  extern int strncasecmp(const char * s1, const char * s2, unsigned int n);
511 
515 #undef _POSIX_PTHREAD_SEMANTICS
516 
517 #undef XPG4_2 /* No network _r functions */
518 #undef XSH4_2 /* No wide character support */
519 
520 #define IS_UNIX OS
521 #define _POSIX_SOURCE /* Pre 199506L or 199309L*/
522 #include <sys/types.h>
523 #include <stdio.h>
524 
525 #ifdef DEBUG
526 #undef NDEBUG
527 #else
528 #define NDEBUG 1
529 #endif/*DEBUG*/
530 
531 #include <assert.h>
532 
533 extern int snprintf(char *s, size_t n, const char *format, /* args */ ...);
534 extern int _doprnt(const char*, void*, FILE*);
535 
536 #ifndef _BSDTYPES_DEFINED
537 
542 typedef unsigned char u_char;
543 typedef unsigned short u_short;
544 typedef unsigned int u_int;
545 typedef unsigned long u_long;
546 
547 #define _BSDTYPES_DEFINED
548 #endif /*_BSDTYPES_DEFINED*/
549 
550 #endif /*OS == NEED_PC_INCLUDES*/
551  /*--------------END---CYGWIN---------------------------------------*/
552 
553 
554 #ifdef __cplusplus
555 }
556 #endif
557 
558 #endif // SOFTWARE_AND_SERVICES_LIBRARY_COMMON_OSVER_H_
559