1 /************************************************************ 2 definitions and constants for all Swiss Ephemeris source files, 3 only required for compiling the libraries, not for the external 4 interface of the libraries. 5 6 The definitions are a subset of Astrodienst's ourdef.h content 7 and must be kept compatible. Everything not used in SwissEph 8 has been deleted. 9 10 Does auto-detection of MSDOS (TURBO_C or MS_C), HPUNIX, Linux. 11 Must be extended for more portability; there should be a way 12 to detect byte order and file system type. 13 14 ************************************************************/ 15 16 /* Copyright (C) 1997 - 2021 Astrodienst AG, Switzerland. All rights reserved. 17 18 License conditions 19 ------------------ 20 21 This file is part of Swiss Ephemeris. 22 23 Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author 24 or distributor accepts any responsibility for the consequences of using it, 25 or for whether it serves any particular purpose or works at all, unless he 26 or she says so in writing. 27 28 Swiss Ephemeris is made available by its authors under a dual licensing 29 system. The software developer, who uses any part of Swiss Ephemeris 30 in his or her software, must choose between one of the two license models, 31 which are 32 a) GNU Affero General Public License (AGPL) 33 b) Swiss Ephemeris Professional License 34 35 The choice must be made before the software developer distributes software 36 containing parts of Swiss Ephemeris to others, and before any public 37 service using the developed software is activated. 38 39 If the developer choses the AGPL software license, he or she must fulfill 40 the conditions of that license, which includes the obligation to place his 41 or her whole software project under the AGPL or a compatible license. 42 See https://www.gnu.org/licenses/agpl-3.0.html 43 44 If the developer choses the Swiss Ephemeris Professional license, 45 he must follow the instructions as found in http://www.astro.com/swisseph/ 46 and purchase the Swiss Ephemeris Professional Edition from Astrodienst 47 and sign the corresponding license contract. 48 49 The License grants you the right to use, copy, modify and redistribute 50 Swiss Ephemeris, but only under certain conditions described in the License. 51 Among other things, the License requires that the copyright notices and 52 this notice be preserved on all copies. 53 54 Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl 55 56 The authors of Swiss Ephemeris have no control or influence over any of 57 the derived works, i.e. over software or services created by other 58 programmers which use Swiss Ephemeris functions. 59 60 The names of the authors or of the copyright holder (Astrodienst) must not 61 be used for promoting any software, product or service which uses or contains 62 the Swiss Ephemeris. This copyright notice is the ONLY place where the 63 names of the authors can legally appear, except in cases where they have 64 given special permission in writing. 65 66 The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used 67 for promoting such software, products or services. 68 */ 69 70 #ifndef _OURDEF_INCLUDED /* ourdef.h is a superset of sweodef.h */ 71 #ifndef _SWEODEF_INCLUDED /* allow multiple #includes */ 72 #define _SWEODEF_INCLUDED 73 74 # define MY_TRUE 1 /* for use in other defines, before TRUE is defined */ 75 # define MY_FALSE 0 /* for use in other defines, before TRUE is defined */ 76 77 /* TLS support 78 * 79 * Sun Studio C/C++, IBM XL C/C++, GNU C and Intel C/C++ (Linux systems) -> __thread 80 * Borland, VC++ -> __declspec(thread) 81 */ 82 #if !defined(TLSOFF) && !defined( __APPLE__ ) && !defined(WIN32) && !defined(DOS32) 83 #if defined( __GNUC__ ) 84 #define TLS __thread 85 #else 86 #define TLS __declspec(thread) 87 #endif 88 #else 89 #define TLS 90 #endif 91 92 #ifdef _WIN32 /* Microsoft VC 5.0 does not define MSDOS anymore */ 93 # undef MSDOS 94 # define MSDOS MY_TRUE 95 #include <wtypes.h> 96 #include <objbase.h> 97 #include <wincon.h> 98 #include <winbase.h> 99 #include <io.h> 100 #include <windows.h> 101 # define sleep(x) Sleep((x) * 1000) 102 #endif 103 104 #ifdef _MSC_VER 105 # define MS_VC 106 #endif 107 108 #ifdef WIN32 /* Microsoft VC 5.0 does not define MSDOS anymore */ 109 # define MSDOS MY_TRUE 110 #endif 111 112 #ifdef MSDOS /* already defined by some DOS compilers */ 113 # undef MSDOS 114 # define MSDOS MY_TRUE 115 #endif 116 117 #ifdef __TURBOC__ /* defined by turboc */ 118 # ifndef MSDOS 119 # define MSDOS MY_TRUE 120 # endif 121 # define TURBO_C 122 #endif 123 124 #ifdef __SC__ /* defined by Symantec C */ 125 # ifndef MSDOS 126 # define MSDOS MY_TRUE 127 # endif 128 # define SYMANTEC_C 129 #endif 130 131 #ifdef __WATCOMC__ /* defined by WatcomC */ 132 # ifndef MSDOS 133 # define MSDOS MY_TRUE 134 # endif 135 # define WATCOMC 136 #endif 137 138 #ifdef __MWERKS__ /* defined on Macintosh CodeWarrior */ 139 # if macintosh && powerc 140 # define MACOS MY_TRUE /* let it undefined otherwise */ 141 # define MSDOS MY_FALSE /* in case one above fired falsely */ 142 # endif 143 #endif 144 145 #ifdef MSDOS 146 # define HPUNIX MY_FALSE 147 # define INTEL_BYTE_ORDER 1 148 # ifndef TURBO_C 149 # define MS_C /* assume Microsoft C compiler */ 150 # endif 151 # define UNIX_FS MY_FALSE 152 #else 153 # ifdef MACOS 154 # define HPUNIX MY_FALSE 155 # define UNIX_FS MY_FALSE 156 # else 157 # define MSDOS MY_FALSE 158 # define HPUNIX MY_TRUE 159 # ifndef _HPUX_SOURCE 160 # define _HPUX_SOURCE 161 # endif 162 # define UNIX_FS MY_TRUE 163 # endif 164 #endif 165 166 #include <math.h> 167 #include <stdlib.h> 168 #ifndef FILE 169 # include <stdio.h> 170 #endif 171 172 #if HPUNIX 173 # include <unistd.h> 174 #endif 175 176 /* 177 * if we have 16-bit ints, we define INT_16; we will need %ld to printf an int32 178 * if we have 64-bit long, we define LONG_64 179 * If none is defined, we have int = long = 32 bit, and use %d to printf an int32 180 */ 181 #include <limits.h> 182 #if INT_MAX < 40000 183 # define INT_16 184 #else 185 # if LONG_MAX > INT_MAX 186 # define LONG_64 187 # endif 188 #endif 189 190 #ifdef BYTE_ORDER 191 #ifdef LITTLE_ENDIAN 192 # if BYTE_ORDER == LITTLE_ENDIAN 193 # define INTEL_BYTE_ORDER 194 # endif 195 #endif 196 #endif 197 198 #ifdef INT_16 199 typedef long int32; 200 typedef unsigned long uint32; 201 typedef int int16; 202 typedef double REAL8; /* real with at least 64 bit precision */ 203 typedef long INT4; /* signed integer with at least 32 bit precision */ 204 typedef unsigned long UINT4; 205 /* unsigned integer with at least 32 bit precision */ 206 typedef int AS_BOOL; 207 typedef unsigned int UINT2; /* unsigned 16 bits */ 208 # define ABS4 labs /* abs function for long */ 209 #else 210 typedef int int32; 211 typedef long long int64; 212 typedef unsigned int uint32; 213 typedef short int16; 214 typedef double REAL8; /* real with at least 64 bit precision */ 215 typedef int INT4; /* signed integer with at least 32 bit precision */ 216 typedef unsigned int UINT4; 217 /* unsigned integer with at least 32 bit precision */ 218 typedef int AS_BOOL; 219 typedef unsigned short UINT2; /* unsigned 16 bits */ 220 # define ABS4 abs /* abs function for long */ 221 #endif 222 223 #if MSDOS 224 # ifdef TURBO_C 225 # include <alloc.h> /* MSC needs malloc ! */ 226 # else 227 # include <malloc.h> 228 # endif 229 # define SIGALRM SIGINT 230 #endif 231 232 #ifndef TRUE 233 # define TRUE 1 234 # define FALSE 0 235 #endif 236 237 #ifndef OK 238 # define OK (0) 239 # define ERR (-1) 240 #endif 241 242 /* hack because UCHAR is already used by mingw gcc */ 243 #ifdef __GNUC__ 244 #ifdef _WIN32 245 #define UCHAR SWE_UCHAR 246 #endif 247 #endif 248 249 typedef unsigned char UCHAR; 250 #define UCP (UCHAR*) 251 #define SCP (char*) 252 253 # define ODEGREE_STRING "°" /* degree as string, utf8 encoding */ 254 255 256 257 #ifndef HUGE 258 # define HUGE 1.7E+308 /* biggest value for REAL8 */ 259 #endif 260 #ifndef M_PI 261 # define M_PI 3.14159265358979323846 262 #endif 263 264 /* #define forward static obsolete */ 265 266 #define AS_MAXCH 256 /* used for string declarations, allowing 255 char+\0 */ 267 268 /* 269 #define DEGTORAD 0.0174532925199433 270 #define RADTODEG 57.2957795130823 271 */ 272 #define RADTODEG (180.0 / M_PI) 273 #define DEGTORAD (M_PI / 180.0) 274 275 typedef int32 centisec; /* centiseconds used for angles and times */ 276 #define CS (centisec) /* use for casting */ 277 #define CSEC centisec /* use for typing */ 278 279 #define DEG 360000 /* degree expressed in centiseconds */ 280 #define DEG7_30 (2700000) /* 7.5 degrees */ 281 #define DEG15 (15 * DEG) 282 #define DEG24 (24 * DEG) 283 #define DEG30 (30 * DEG) 284 #define DEG60 (60 * DEG) 285 #define DEG90 (90 * DEG) 286 #define DEG120 (120 * DEG) 287 #define DEG150 (150 * DEG) 288 #define DEG180 (180 * DEG) 289 #define DEG270 (270 * DEG) 290 #define DEG360 (360 * DEG) 291 292 /* #define CSTORAD 4.84813681109536E-08 centisec to rad: pi / 180 /3600/100 */ 293 /* #define RADTOCS 2.06264806247096E+07 rad to centisec 180*3600*100/pi */ 294 #define CSTORAD (DEGTORAD / 360000.0) 295 #define RADTOCS (RADTODEG * 360000.0) 296 297 #define CS2DEG (1.0/360000.0) /* centisec to degree */ 298 299 /* control strings for fopen() */ 300 #if UNIX_FS 301 # define BFILE_R_ACCESS "r" /* open binary file for reading */ 302 # define BFILE_RW_ACCESS "r+" /* open binary file for writing and reading */ 303 # define BFILE_W_CREATE "w" /* create/open binary file for write*/ 304 # define BFILE_A_ACCESS "a+" /* create/open binary file for append*/ 305 # define FILE_R_ACCESS "r" /* open text file for reading */ 306 # define FILE_RW_ACCESS "r+" /* open text file for writing and reading */ 307 # define FILE_W_CREATE "w" /* create/open text file for write*/ 308 # define FILE_A_ACCESS "a+" /* create/open text file for append*/ 309 # define O_BINARY 0 /* for open(), not defined in Unix */ 310 # define OPEN_MODE 0666 /* default file creation mode */ 311 # define DIR_GLUE "/" /* glue string for directory/file */ 312 # define PATH_SEPARATOR ";:" /* semicolon or colon may be used */ 313 #else 314 # define BFILE_R_ACCESS "rb" /* open binary file for reading */ 315 # define BFILE_RW_ACCESS "r+b" /* open binary file for writing and reading */ 316 # define BFILE_W_CREATE "wb" /* create/open binary file for write*/ 317 # define BFILE_A_ACCESS "a+b" /* create/open binary file for append*/ 318 # define PATH_SEPARATOR ";" /* semicolon as PATH separator */ 319 # define OPEN_MODE 0666 /* default file creation mode */ 320 # ifdef MACOS 321 # define FILE_R_ACCESS "r" /* open text file for reading */ 322 # define FILE_RW_ACCESS "r+" /* open text file for writing and reading */ 323 # define FILE_W_CREATE "w" /* create/open text file for write*/ 324 # define FILE_A_ACCESS "a+" /* create/open text file for append*/ 325 # define DIR_GLUE ":" /* glue string for directory/file */ 326 # else 327 # define FILE_R_ACCESS "rt" /* open text file for reading */ 328 # define FILE_RW_ACCESS "r+t" /* open text file for writing and reading */ 329 # define FILE_W_CREATE "wt" /* create/open text file for write*/ 330 # define FILE_A_ACCESS "a+t" /* create/open text file for append*/ 331 /* attention, all backslashes for msdos directry names must be written as \\, 332 because it is the C escape character */ 333 # define DIR_GLUE "\\" /* glue string for directory/file */ 334 # endif 335 #endif 336 337 #include <string.h> 338 #include <ctype.h> 339 340 #endif /* _SWEODEF_INCLUDED */ 341 #endif /* _OURDEF_INCLUDED */ 342