XBinder  Version 2.9.x
osSysTypes.h
1 /*
2  * Copyright (c) 1997-2022 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
24 
25 #ifndef _OSSYSTYPES_H_
26 #define _OSSYSTYPES_H_
27 
28 /* Ensure that the appropriate limits are active. */
29 #ifndef __STDC_LIMIT_MACROS
30 #define __STDC_LIMIT_MACROS
31 #endif
32 #ifndef __STDC_CONSTANT_MACROS
33 #define __STDC_CONSTANT_MACROS
34 #endif
35 #ifndef __STDC_FORMAT_MACROS
36 #define __STDC_FORMAT_MACROS
37 #endif
38 
39 #if defined(__sun) || defined(NOCPP11)
40 #define nullptr NULL
41 #endif
42 
43 #if (!defined(BREW_MODULE) && !defined(FLAT_BREW))
44 #include <stdlib.h>
45 #else
46 /* Special include for Qualcomm BREW environment */
47 /* #include "AEEStdLib.h" */
48 #endif
49 
50 #if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__) \
51  && !defined(__vxworks) && !defined(__SYMBIAN32__) && !defined(NIOS2)
52 #include <inttypes.h> /* does not exist in windows; use builtins instead */
53 #endif /* not windows */
54 
55 #include <limits.h>
56 
57 #include <float.h>
58 
59 #ifndef FALSE
60 #define FALSE 0
61 #define TRUE 1
62 #endif
63 
64 #define NumberOf(x) (sizeof(x)/sizeof(x[0]))
65 
66 /* This macro is for prototypes of argumentless functions. For actual
67  variables of type void, use OSVoid, defined below. This OSVOIDARG
68  macro can be #ifdef'd for compilers that don't like seeing "void"
69  in prototypes. */
70 #define OSVOIDARG void
71 
72 typedef void OSVoid;
73 typedef void* OSVoidPtr;
74 typedef unsigned char OSBOOL;
75 typedef signed char OSINT8;
76 typedef unsigned char OSUINT8;
77 typedef short OSINT16;
78 typedef unsigned short OSUINT16;
79 typedef OSUINT8 OSOCTET;
80 typedef OSUINT8 OSUTF8CHAR;
81 typedef OSUINT16 OSUNICHAR;
82 typedef double OSREAL;
83 typedef double OSDOUBLE;
84 typedef float OSFLOAT;
85 #ifdef _16BIT
86 typedef long OSINT32;
87 typedef unsigned long OSUINT32;
88 #define OSINTCONST(val) val##L
89 #define OSUINTCONST(val) val##UL
90 #define OSUINT32_MAX ULONG_MAX
91 #else
92 typedef int OSINT32;
93 typedef unsigned int OSUINT32;
94 #define OSINTCONST(val) val
95 #define OSUINTCONST(val) val##u
96 #define OSUINT32_MAX UINT_MAX
97 #endif /* _16BIT */
98 typedef OSUINT32 OS32BITCHAR;
99 typedef size_t OSSIZE;
100 
101 #define OSINT32_MAX ((OSINT32)2147483647L)
102 #define OSINT32_MIN ((OSINT32)(-OSINT32_MAX-1))
103 
104 #define OSUINT16_MAX ((OSUINT16)65535UL)
105 #define OSINT16_MAX ((OSINT16)32767L)
106 #define OSINT16_MIN ((OSINT16)(-OSINT16_MAX-1))
107 
108 #define OSUINT8_MAX ((OSUINT8)255U)
109 #define OSINT8_MAX ((OSINT8)127L)
110 #define OSINT8_MIN ((OSINT8)(-OSINT8_MAX-1))
111 
112 #define OSREALMAX ((OSREAL)DBL_MAX)
113 #define OSREALMIN ((OSREAL)-DBL_MAX)
114 
115 #define OSU32NULLIDX OSUINT32_MAX
116 #define OSNULLINDEX ((OSSIZE)-1)
117 
118 /* Note: OSSIZE_MAX as defined here should NOT be used in preprocessor
119  conditional expressions (e.g. #if).
120 
121  C99 says that conditional expressions in preprocessor diretives shall not
122  contain casts, which it does (but evidently Visual Studio ignores this).
123  C99 also says that the preprocessor treats signed/unsigned integer values as
124  intmax_t/uintmax_t, which means the preprocessor sees 64-bit values and sees
125  OSSIZE_MAX == 0xFFFFFFFFFFFFFFFFULL.
126 */
127 #define OSSIZE_MAX OSNULLINDEX
128 
129 #if SIZE_MAX == 0xFFFFFFFFUL
130  #define OSSIZE_IS_32BITS
131 #elif SIZE_MAX == 0xFFFFFFFFFFFFFFFFULL
132  #define OSSIZE_IS_64BITS
133 #endif
134 
135 
140 typedef struct OSNumDateTime {
141  OSINT32 year;
142  OSUINT8 mon; /* 1 <= mon <= 12 */
143  OSUINT8 day; /* 1 <= day <= 31 */
144  OSUINT8 hour; /* 0 <= hour <= 23 */
145  OSUINT8 min; /* 0 <= min <= 59 */
146  OSREAL sec;
147  OSBOOL tz_flag; /* is tzo explicitely set? */
148  OSINT32 tzo; /* -840 <= tzo <= 840 */
149 } OSNumDateTime;
150 
151 /* Size type print format string */
152 
153 #if defined(_MSC_VER)
154 #if _MSC_VER < 1300
155 //Visual C++ 6.0 is 32 bit only. No size specifier required.
156 #define OSSIZEFMT "%u"
157 #else
158 //Visual Studio 2003+ supports I for size_t
159 #define OSSIZEFMT "%Iu"
160 #endif
161 #elif defined(__hpux) || defined(VMS) || defined(_VMS)
162 //HP-UX and VMS use %u for size_t.
163 #define OSSIZEFMT "%u"
164 #else
165 //GNU compilers support z for size_t. It is C99 standard.
166 #define OSSIZEFMT "%zu"
167 #endif
168 
169 /* 64-bit long integer type */
170 
171 #ifndef OSINT64_
172 #if !defined(_NO_INT64_SUPPORT)
173 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
174 #define OSINT64_
175 typedef __int64 OSINT64;
176 typedef unsigned __int64 OSUINT64;
177 
178 /* OSINT64FMT_TS is the type specifier for 64-bit (signed) integers. */
179 #define OSINT64FMT_TS "I64d"
180 #define OSINT64FMT "%I64d"
181 #define OSUINT64FMT "%I64u"
182 #define OSINT64FMTX "%I64x"
183 #define OSINT64MAX _I64_MAX
184 #define OSUINT64MAX _UI64_MAX
185 #define OSINT64MIN _I64_MIN
186 #define OSI64CONST(val) val##i64
187 #define OSUI64CONST(val) val##ui64
188 
189 #elif defined(INT64_MAX) /* assume have ISO C99 standard types */
190 #define OSINT64_
191 typedef int64_t OSINT64;
192 typedef uint64_t OSUINT64;
193 #ifdef PRId64 /* have C99 format macros */
194 /* C++ 2011 requires spaces here */
195 #define OSINT64FMT_TS PRId64
196 #define OSINT64FMT "%" PRId64
197 #define OSUINT64FMT "%" PRIu64
198 #define OSINT64FMTX "%" PRIx64
199 #else /* have C99 types but not format macros, assume long long format */
200 #define OSINT64FMT_TS "lld"
201 #define OSINT64FMT "%lld"
202 #define OSUINT64FMT "%llu"
203 #define OSINT64FMTX "%llx"
204 #endif /* PRId64 */
205 #define OSINT64MAX INT64_MAX
206 #define OSUINT64MAX UINT64_MAX
207 #define OSINT64MIN INT64_MIN
208 #define OSI64CONST(val) INT64_C(val)
209 #define OSUI64CONST(val) UINT64_C(val)
210 
211 #else /* ?? __WORDSIZE != 64 */
212 #define OSINT64_
213 typedef long long OSINT64;
214 typedef unsigned long long OSUINT64;
215 #define OSINT64FMT_TS "lld"
216 #define OSINT64FMT "%lld"
217 #define OSUINT64FMT "%llu"
218 #define OSINT64FMTX "%llx"
219 #define OSI64CONST(val) val##LL
220 #define OSUI64CONST(val) val##ULL
221 
222 /* May throw an error if __STDC_LIMIT_MACROS is not defined */
223 #ifdef LLONG_MAX
224 #define OSINT64MAX LLONG_MAX
225 #define OSUINT64MAX ULLONG_MAX
226 #define OSINT64MIN LLONG_MIN
227 #elif defined LONG_LONG_MAX /* special code for gcc 3.3.3 */
228 #define OSINT64MAX LONG_LONG_MAX
229 #define OSUINT64MAX ULONG_LONG_MAX
230 #define OSINT64MIN LONG_LONG_MIN
231 #elif defined __INT64_MAX /* VMS */
232 #define OSINT64MAX __INT64_MAX
233 #define OSUINT64MAX __UINT64_MAX
234 #define OSINT64MIN __INT64_MIN
235 #else
236 #warning "Using LONG_MAX for 64-bit maximum."
237 #define OSINT64MAX LONG_MAX
238 #define OSUINT64MAX ULONG_MAX
239 #define OSINT64MIN LONG_MIN
240 #endif
241 
242 #endif /* _MSC_VER ... */
243 #endif /* !defined(_NO_INT64_SUPPORT) */
244 
245 #ifndef OSINT64_
246 /* if OSINT64 is still not defined - define it as long/unsigned long */
247 #define OSINT64_
248 typedef long OSINT64;
249 typedef unsigned long OSUINT64;
250 #define OSINT64FMT_TS "ld"
251 #define OSINT64FMT "%ld"
252 #define OSUINT64FMT "%lu"
253 #define OSINT64FMTX "%lx"
254 #define OSINT64MAX LONG_MAX
255 #define OSUINT64MAX ULONG_MAX
256 #define OSINT64MIN LONG_MIN
257 #define OSI64CONST(val) val##L
258 #define OSUI64CONST(val) val##UL
259 #endif /* OSINT64 ... */
260 
261 #define OSU64NULLIDX OSUINT64MAX
262 
263 #endif /* OSINT64 */
264 
272 typedef struct OSDynOctStr {
273  OSUINT32 numocts;
274  const OSOCTET* data;
275 } OSDynOctStr;
276 
277 typedef struct OSDynOctStr64 {
278  OSSIZE numocts;
279  OSOCTET* data;
280 } OSDynOctStr64;
281 
282 typedef OSDynOctStr OSOpenType;
283 
284 typedef OSDynOctStr64 OSOpenType64;
285 
286 /* UTF-8 name/value pair */
287 
288 typedef struct OSUTF8NVP {
289  const OSUTF8CHAR* name;
290  const OSUTF8CHAR* value;
291 } OSUTF8NVP;
292 
293 typedef OSUTF8NVP OSAnyAttr;
294 typedef OSUTF8NVP OSAnyElement;
295 
296 /* XML string */
297 
304 typedef struct OSXMLSTRING {
305  OSBOOL cdata; /* encode as a CDATA section */
306  const OSUTF8CHAR* value;
307 } OSXMLSTRING;
308 
318 
325 typedef struct OSBitMapItem {
326  const OSUTF8CHAR* name;
327  OSUINT16 bitno;
328  OSUINT16 namelen;
329 } OSBitMapItem;
330 
340 typedef struct OSUTF8NameAndLen {
341  const OSUTF8CHAR* name;
342  OSSIZE len;
344 
345 
346 typedef struct OSDecimalFmt {
347  OSINT8 totalDigits; /* total significiant digits */
348  OSINT8 fractionDigits; /* maximum signficiant digits in fraction,
349  precision */
350  OSINT8 fractionMinDigits; /* minimum digits in fraction, if
351  fraction digits less than this value
352  trailing zeros will be added. */
353  OSINT8 integerMaxDigits; /* Maximum digits in integer part; if it is 0
354  and integer part is 0 then integer part
355  will be omitted, like .3, or -.3 */
356  OSINT8 integerMinDigits; /* Minimum digits in integer part, leading zeros
357  will be added if necessary. */
358  OSBOOL signPresent; /* Indicates, sign must present, even if value
359  is positive. */
360  OSBOOL pointPresent; /* Indicates, decimal point must present, even
361  if value's fraction is 0 */
362  OSUINT8 nPatterns; /* number of patterns stored in 'patterns' */
363  const char* const* patterns; /* patterns, used to verify value format is
364  correct */
365 } OSDecimalFmt;
366 
367 
368 
369 typedef struct OSDoubleFmt {
370  OSINT8 totalDigits; /* total significiant digits */
371  OSINT8 fractionDigits; /* maximum signficiant digits in fraction,
372  precision */
373  OSINT8 fractionMinDigits; /* minimum digits in fraction, if
374  fraction digits less than this value
375  trailing zeros will be added. */
376  OSINT8 integerMaxDigits; /* Maximum digits in integer part; if it is 0
377  and integer part is 0 then integer part
378  will be omitted, like .3, or -.3 */
379  OSINT8 integerMinDigits; /* Minimum digits in integer part, leading zeros
380  will be added if necessary. */
381  OSINT8 expSymbol; /* 'E' or 'e' only; 0 if no exp is expected,
382  -1 - default ('E') */
383  OSINT16 expMinValue; /* Minimum exponent value. By default - -infinity */
384  OSINT16 expMaxValue; /* Maximum exponent value. By default - infinity */
385  OSINT8 expDigits; /* Total digits in exponent part; if exponent's
386  value is not enough, trailing zeros will be
387  added */
388  OSBOOL signPresent; /* Indicates, sign must present, even if value
389  is positive. */
390  OSBOOL pointPresent; /* Indicates, decimal point must present, even
391  if value's fraction is 0 */
392  OSBOOL expPresent; /* Indicates, exponent must present, even
393  if its value is 0 */
394  OSBOOL expSignPresent; /* Indicates, exponent sign must present, even
395  if its value is > 0 */
396 } OSDoubleFmt;
397 
398 #if defined(_MSC_VER)
399 /* this disables 'unreferenced formal parameter' warning */
400 #pragma warning(disable: 4100)
401 /* this disables 'assignment operator could not be generated' warning */
402 #pragma warning(disable: 4512)
403 #endif
404 
405 #endif
UTF-8 name and length structure.
Definition: osSysTypes.h:340
XML UTF-8 character string structure.
Definition: osSysTypes.h:304
Dynamic binary string structure.
Definition: osSysTypes.h:272
Named bit in a bit map.
Definition: osSysTypes.h:325
Numeric date/time structure.
Numeric date/time structure.
Definition: osSysTypes.h:140