Home > Support > Documentation

osSysTypes.h

00001 /*
00002  * Copyright (c) 1997-2008 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00024 
00025 #ifndef _OSSYSTYPES_H_
00026 #define _OSSYSTYPES_H_
00027 
00028 /* Ensure that the appropriate limits are active. */
00029 #define __STDC_LIMIT_MACROS
00030 #define __STDC_CONSTANT_MACROS
00031 
00032 #if (!defined(BREW_MODULE) && !defined(FLAT_BREW))
00033 #include <stdlib.h>
00034 #else
00035 /* Special include for Qualcomm BREW environment */
00036 /* #include "AEEStdLib.h" */
00037 #endif
00038 
00039 #if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__) \
00040    && !defined(__vxworks) && !defined(__SYMBIAN32__)
00041 #include <inttypes.h> /* does not exist in windows; use builtins instead */
00042 #endif /* not windows */
00043 
00044 #include <limits.h>
00045 
00046 #include <float.h>
00047 
00048 #ifndef FALSE
00049 #define FALSE   0
00050 #define TRUE    1
00051 #endif
00052 
00053 #define NumberOf(x)     (sizeof(x)/sizeof(x[0]))
00054 
00055 typedef void            OSVoid;
00056 typedef void*           OSVoidPtr;
00057 typedef unsigned char   OSBOOL;
00058 typedef signed char     OSINT8;
00059 typedef unsigned char   OSUINT8;
00060 typedef short           OSINT16;
00061 typedef unsigned short  OSUINT16;
00062 typedef OSUINT8         OSOCTET;
00063 typedef OSUINT8         OSUTF8CHAR;
00064 typedef OSUINT16        OSUNICHAR;
00065 typedef double          OSREAL;
00066 typedef double          OSDOUBLE;
00067 typedef float           OSFLOAT;
00068 #ifdef _16BIT
00069 typedef long            OSINT32;
00070 typedef unsigned long   OSUINT32;
00071 #define OSINTCONST(val)  val##L
00072 #define OSUINTCONST(val) val##UL
00073 #else
00074 typedef int             OSINT32;
00075 typedef unsigned int    OSUINT32;
00076 #define OSINTCONST(val)  val
00077 #define OSUINTCONST(val) val##u
00078 #endif /* _16BIT */
00079 typedef OSUINT32        OS32BITCHAR;
00080 
00081 #define OSUINT32_MAX    ((OSUINT32)4294967295UL)
00082 #define OSINT32_MAX     ((OSINT32)2147483647L)
00083 #define OSINT32_MIN     ((OSINT32)(-OSINT32_MAX-1))
00084 
00085 #define OSUINT16_MAX    ((OSUINT16)65535UL)
00086 #define OSINT16_MAX     ((OSINT16)32767L)
00087 #define OSINT16_MIN     ((OSINT16)(-OSINT16_MAX-1))
00088 
00089 #define OSUINT8_MAX     ((OSUINT8)255U)
00090 #define OSINT8_MAX      ((OSINT8)127L)
00091 #define OSINT8_MIN      ((OSINT8)(-OSINT8_MAX-1))
00092 
00093 #define OSREALMAX       ((OSREAL)DBL_MAX)
00094 #define OSREALMIN       ((OSREAL)-DBL_MAX)
00095 
00100 typedef struct OSNumDateTime {
00101    OSINT32      year;
00102    OSUINT8      mon;            /* 1 <=  mon    <= 12   */
00103    OSUINT8      day;            /* 1 <=  day    <= 31   */
00104    OSUINT8      hour;           /* 0 <=  hour   <= 23   */
00105    OSUINT8      min;            /* 0 <=  min    <= 59   */
00106    OSREAL       sec;
00107    OSBOOL       tz_flag;        /* is tzo explicitely set? */
00108    OSINT32      tzo;            /* -1440 <= tzo <= 1440 */
00109 } OSNumDateTime;
00110 
00111 /* 64-bit long integer type */
00112 
00113 #ifndef OSINT64_
00114 #if !defined(_NO_INT64_SUPPORT)
00115 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
00116 #define OSINT64_
00117 typedef __int64 OSINT64;
00118 typedef unsigned __int64 OSUINT64;
00119 #define OSINT64FMT  "%I64d"
00120 #define OSUINT64FMT "%I64u"
00121 #define OSINT64FMTX "%I64x"
00122 #define OSINT64MAX  _I64_MAX
00123 #define OSUINT64MAX _UI64_MAX
00124 #define OSINT64MIN  _I64_MIN
00125 #define OSI64CONST(val)  val##i64
00126 #define OSUI64CONST(val) val##ui64
00127 
00128 #elif defined(INT64_MAX) /* assume have ISO C99 standard types */
00129 #define OSINT64_
00130 typedef int64_t OSINT64;
00131 typedef uint64_t OSUINT64;
00132 #ifdef PRId64 /* have C99 format macros */
00133 #define OSINT64FMT  "%"PRId64
00134 #define OSUINT64FMT "%"PRIu64
00135 #define OSINT64FMTX "%"PRIx64
00136 #else /* have C99 types but not format macros, assume long long format */
00137 #define OSINT64FMT  "%lld"
00138 #define OSUINT64FMT "%llu"
00139 #define OSINT64FMTX "%llx"
00140 #endif /* PRId64 */
00141 #define OSINT64MAX  INT64_MAX
00142 #define OSUINT64MAX UINT64_MAX
00143 #define OSINT64MIN  INT64_MIN
00144 #define OSI64CONST(val)  INT64_C(val)
00145 #define OSUI64CONST(val) UINT64_C(val)
00146 
00147 #else /* ?? __WORDSIZE != 64 */
00148 #warning "Using long long for 64-bit integers."
00149 #define OSINT64_
00150 typedef long long OSINT64;
00151 typedef unsigned long long OSUINT64;
00152 #define OSINT64FMT  "%lld"
00153 #define OSUINT64FMT "%llu"
00154 #define OSINT64FMTX "%llx"
00155 #define OSI64CONST(val)  val##LL
00156 #define OSUI64CONST(val) val##ULL
00157 
00158 /* May throw an error if __STDC_LIMIT_MACROS is not defined */
00159 #ifdef LLONG_MAX
00160 #define OSINT64MAX  LLONG_MAX
00161 #define OSUINT64MAX ULLONG_MAX
00162 #define OSINT64MIN  LLONG_MIN
00163 #else
00164 #warning "Using LONG_MAX for 64-bit maximum."
00165 #define OSINT64MAX LONG_MAX
00166 #define OSUINT64MAX ULONG_MAX
00167 #define OSINT64MIN LONG_MIN
00168 #endif
00169 
00170 #endif /* _MSC_VER ... */
00171 #endif /* !defined(_NO_INT64_SUPPORT) */
00172 
00173 #ifndef OSINT64_
00174 /* if OSINT64 is still not defined - define it as long/unsigned long */
00175 #define OSINT64_
00176 typedef long OSINT64;
00177 typedef unsigned long OSUINT64;
00178 #define OSINT64FMT  "%ld"
00179 #define OSUINT64FMT "%lu"
00180 #define OSINT64FMTX "%lx"
00181 #define OSINT64MAX  LONG_MAX
00182 #define OSUINT64MAX ULONG_MAX
00183 #define OSINT64MIN  LONG_MIN
00184 #define OSI64CONST(val)  val##L  
00185 #define OSUI64CONST(val) val##UL  
00186 #endif /* OSINT64 ... */
00187 
00188 #endif /* OSINT64 */
00189 
00197 typedef struct OSDynOctStr {
00198    OSUINT32     numocts;
00199    const OSOCTET* data;
00200 } OSDynOctStr;
00201 
00202 typedef OSDynOctStr OSOpenType;
00203 
00208 typedef enum { OSXSDAny_binary, OSXSDAny_xmlText } OSXSDAnyAlt;
00209 typedef struct OSXSDAny {
00210    OSXSDAnyAlt t;
00211    union {
00212       OSOpenType* binary;
00213       const OSUTF8CHAR* xmlText;
00214    } u;
00215 } OSXSDAny;
00216 
00217 /* UTF-8 name/value pair */
00218 
00219 typedef struct OSUTF8NVP {
00220    const OSUTF8CHAR* name;
00221    const OSUTF8CHAR* value;
00222 } OSUTF8NVP;
00223 
00224 typedef OSUTF8NVP OSAnyAttr;
00225 typedef OSUTF8NVP OSAnyElement;
00226 
00227 /* XML string */
00228 
00235 typedef struct OSXMLSTRING {
00236    OSBOOL cdata;                /* encode as a CDATA section */
00237    const OSUTF8CHAR* value;
00238 } OSXMLSTRING;
00239 
00248 typedef OSNumDateTime OSXSDDateTime;
00249 
00256 typedef struct OSBitMapItem {
00257    const OSUTF8CHAR* name;
00258    OSUINT16          bitno;
00259    OSUINT16          namelen;
00260 } OSBitMapItem;
00261 
00262 #endif