home *** CD-ROM | disk | FTP | other *** search
/ PC Direkt 1995 March / PCD_395.iso / starview / pm2csci / german / solar._ / SOLAR.H
Encoding:
C/C++ Source or Header  |  1994-10-24  |  5.6 KB  |  183 lines

  1. /*************************************************************************
  2. * SOLAR.H
  3. * Sat Oct 24  3:23:43 1992
  4. * (c) 1992-1994 STAR DIVISION
  5. *************************************************************************/
  6.  
  7. #ifndef _SOLAR_H
  8. #define _SOLAR_H
  9.  
  10. #ifndef TRUE
  11. #define TRUE        1
  12. #endif
  13. #ifndef FALSE
  14. #define FALSE       0
  15. #endif
  16.  
  17. #undef NULL
  18. #define NULL        0
  19.  
  20. typedef unsigned char       BOOL;
  21. typedef unsigned char       BYTE;
  22. typedef unsigned short      USHORT;
  23. typedef unsigned long       ULONG;
  24.  
  25. #ifndef _SOLAR_NOUINT
  26.  
  27. #if defined( ALPHA ) && !defined( WNT )
  28. typedef long                INT64;
  29. typedef unsigned long       UINT64;
  30. typedef int                 INT32;
  31. typedef unsigned int        UINT32;
  32. typedef short               INT16;
  33. typedef unsigned short      UINT16;
  34. typedef char                INT8;
  35. typedef unsigned char       UINT8;
  36. #else
  37. typedef void                INT64;
  38. typedef void                UINT64;
  39. typedef long                INT32;
  40. typedef unsigned long       UINT32;
  41. typedef short               INT16;
  42. typedef unsigned short      UINT16;
  43. #ifdef AViiON
  44. typedef signed char         INT8;
  45. #else
  46. typedef char                INT8;
  47. #endif
  48. typedef unsigned char       UINT8;
  49. #endif
  50. #endif 
  51.  
  52. #ifndef _SOLAR_NOSVBT
  53.  
  54. typedef BYTE                SVBT8[1];
  55. typedef BYTE                SVBT16[2];
  56. typedef BYTE                SVBT32[4];
  57. typedef BYTE                SVBT64[8];
  58. #endif  
  59.  
  60. #ifndef _SOLAR_NODESCRIPTION
  61.  
  62. #if defined( ALPHA ) && !defined( WNT )
  63. #define __LITTLEENDIAN
  64. #define __ALIGNMENT2        2 
  65. #define __ALIGNMENT4        4 
  66. #define __ALIGNMENT8        8 
  67. #define __STACKALIGNMENT    8
  68. #define __STACKDIRECTION   -1
  69. #define __SIZEOFCHAR        1
  70. #define __SIZEOFSHORT       2
  71. #define __SIZEOFINT         4
  72. #define __SIZEOFLONG        8
  73. #define __SIZEOFPOINTER     8
  74. #elif defined( SUN ) || defined( AViiON )
  75. #define __BIGENDIAN
  76. #define __ALIGNMENT2        2
  77. #define __ALIGNMENT4        4
  78. #define __ALIGNMENT8        4
  79. #define __STACKALIGNMENT    4
  80. #define __STACKDIRECTION   -1
  81. #define __SIZEOFCHAR        1
  82. #define __SIZEOFSHORT       2
  83. #define __SIZEOFINT         4
  84. #define __SIZEOFLONG        4
  85. #define __SIZEOFPOINTER     4
  86. #elif defined( HP9000 )
  87. #define __BIGENDIAN
  88. #define __ALIGNMENT2        2
  89. #define __ALIGNMENT4        4
  90. #define __ALIGNMENT8        4
  91. #define __STACKALIGNMENT    4
  92. #define __STACKDIRECTION    1
  93. #define __SIZEOFCHAR        1
  94. #define __SIZEOFSHORT       2
  95. #define __SIZEOFINT         4
  96. #define __SIZEOFLONG        4
  97. #define __SIZEOFPOINTER     4
  98. #elif defined( RS6000 ) || defined( MAC )
  99. #define __BIGENDIAN
  100. #define __ALIGNMENT2        1
  101. #define __ALIGNMENT4        1
  102. #define __ALIGNMENT8        1
  103. #define __STACKALIGNMENT    4
  104. #define __STACKDIRECTION   -1
  105. #define __SIZEOFCHAR        1
  106. #define __SIZEOFSHORT       2
  107. #define __SIZEOFINT         4
  108. #define __SIZEOFLONG        4
  109. #define __SIZEOFPOINTER     4
  110. #elif defined( PM2 ) || defined( WNT ) 
  111. #define __LITTLEENDIAN
  112. #define __ALIGNMENT2        1
  113. #define __ALIGNMENT4        1
  114. #define __ALIGNMENT8        1
  115. #define __STACKALIGNMENT    4
  116. #define __STACKDIRECTION   -1
  117. #define __SIZEOFCHAR        1
  118. #define __SIZEOFSHORT       2
  119. #define __SIZEOFINT         4
  120. #define __SIZEOFLONG        4
  121. #define __SIZEOFPOINTER     4
  122. #else 
  123. #define __LITTLEENDIAN
  124. #define __ALIGNMENT2        1
  125. #define __ALIGNMENT4        1
  126. #define __ALIGNMENT8        1
  127. #define __STACKALIGNMENT    2
  128. #define __STACKDIRECTION   -1
  129. #define __SIZEOFCHAR        1
  130. #define __SIZEOFSHORT       2
  131. #define __SIZEOFINT         2
  132. #define __SIZEOFLONG        4
  133. #define __SIZEOFPOINTER     4
  134. #endif
  135. #endif 
  136.  
  137. #define SWAPSHORT(x) ((((x) >> 8) & 0x00FF) | (((x) & 0x00FF) << 8))
  138. #define SWAPLONG(x)  ((((x) >> 24) & 0x000000FF) | (((x) & 0x00FF0000) >> 8) | \
  139.                       (((x) & 0x0000FF00) <<  8) | (((x) & 0x000000FF) << 24))
  140.  
  141. #ifndef min
  142. #define min(a,b)    (((a) < (b)) ? (a) : (b))
  143. #endif
  144. #ifndef max
  145. #define max(a,b)    (((a) > (b)) ? (a) : (b))
  146. #endif
  147.  
  148. #if !defined( _SOLAR_NOSVBT ) && !defined( _SOLAR_NODESCRIPTION )
  149. inline BYTE     SVBT8ToByte  ( SVBT8  p ) { return p[0]; }
  150. #if defined( __LITTLEENDIAN ) && __ALLIGNMENT2 == 1
  151. inline USHORT   SVBT16ToShort( SVBT16 p ) { return *(USHORT*)p; }
  152. #else
  153. inline USHORT   SVBT16ToShort( SVBT16 p ) { return (USHORT)p[0]
  154.                                                    + ((USHORT)p[1] <<  8); }
  155. #endif
  156. #if defined( __LITTLEENDIAN ) && __ALLIGNMENT4 == 1
  157. inline ULONG    SVBT32ToLong ( SVBT32 p ) { return *(ULONG*)p; }
  158. #else
  159. inline ULONG    SVBT32ToLong ( SVBT32 p ) { return (ULONG)p[0]
  160.                                                    + ((ULONG)p[1] <<  8)
  161.                                                    + ((ULONG)p[2] << 16)
  162.                                                    + ((ULONG)p[3] << 24); }
  163. #endif
  164.  
  165. inline void     ByteToSVBT8  ( BYTE   n, SVBT8  p ) { p[0] = n; }
  166. #if defined( __LITTLEENDIAN ) && __ALLIGNMENT2 == 1
  167. inline void     ShortToSVBT16( USHORT n, SVBT16 p ) { *(USHORT*)p = n; }
  168. #else
  169. inline void     ShortToSVBT16( USHORT n, SVBT16 p ) { p[0] = (BYTE) n;
  170.                                                       p[1] = (BYTE)(n >>  8); }
  171. #endif
  172. #if defined( __LITTLEENDIAN ) && __ALLIGNMENT4 == 1
  173. inline void     LongToSVBT32 ( ULONG  n, SVBT32 p ) { *(ULONG*)p = n; }
  174. #else
  175. inline void     LongToSVBT32 ( ULONG  n, SVBT32 p ) { p[0] = (BYTE) n;
  176.                                                       p[1] = (BYTE)(n >>  8);
  177.                                                       p[2] = (BYTE)(n >> 16);
  178.                                                       p[3] = (BYTE)(n >> 24); }
  179. #endif
  180. #endif  
  181.  
  182. #endif  
  183.