OpenFAST
Wind turbine multiphysics simulator
modules
map
src
mapsys.h
1
/****************************************************************
2
* Copyright (C) 2014 mdm *
3
* map[dot]plus[dot]plus[dot]help[at]gmail *
4
* *
5
* Licensed to the Apache Software Foundation (ASF) under one *
6
* or more contributor license agreements. See the NOTICE file *
7
* distributed with this work for additional information *
8
* regarding copyright ownership. The ASF licenses this file *
9
* to you under the Apache License, Version 2.0 (the *
10
* "License"); you may not use this file except in compliance *
11
* with the License. You may obtain a copy of the License at *
12
* *
13
* http://www.apache.org/licenses/LICENSE-2.0 *
14
* *
15
* Unless required by applicable law or agreed to in writing, *
16
* software distributed under the License is distributed on an *
17
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
18
* KIND, either express or implied. See the License for the *
19
* specific language governing permissions and limitations *
20
* under the License. *
21
****************************************************************/
22
23
24
#ifndef _MAPSYS_H
25
#define _MAPSYS_H
26
27
#include <stdio.h>
28
#include <stdlib.h>
29
#include <assert.h>
30
#include <string.h>
31
#include <ctype.h>
32
#include <math.h>
33
34
35
#if defined(_WIN32) || defined(_WIN64)
36
# include <Windows.h>
37
# include <tchar.h>
38
#else
39
# include <unistd.h>
40
#endif
41
42
43
44
#if defined _WIN32 || defined __CYGWIN__ || defined _WINDOWS
45
# ifdef BUILD_SHARED_LIC_LIBS
46
# ifdef __GNUC__
47
# define DLL_PUBLIC __attribute__ ((dllexport))
48
# else
49
# define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
50
# endif
51
# else
52
# define DLL_PUBLIC
53
# endif
54
#else
55
# if __GNUC__ >= 4
56
# define DLL_PUBLIC __attribute__ ((visibility ("default")))
57
# else
58
# define DLL_PUBLIC
59
# endif
60
#endif
61
62
#define MAP_EXTERNCALL DLL_PUBLIC
63
64
#if defined(_MSC_VER)
65
typedef
int
bool;
66
#define false 0
67
#define true 1
68
//# include "stdbool.h"
69
# define map_snprintf _snprintf
70
# define map_strcat(a,b,c) strcat_s(a,b,c)
71
# define MAP_STRCPY(a,b,c) strcpy_s(a,b,c)
72
#else
73
# include <stdbool.h>
74
# define map_snprintf snprintf
75
# define map_strcat(a,b,c) strncat(a,c,b)
76
# define MAP_STRCPY(a,b,c) strcpy(a,c)
77
#endif
78
79
80
#ifndef BUILD_DEFS_H
81
# define BUILD_DEFS_H
82
# define BUILD_YEAR_CH0 (__DATE__[ 7])
83
# define BUILD_YEAR_CH1 (__DATE__[ 8])
84
# define BUILD_YEAR_CH2 (__DATE__[ 9])
85
# define BUILD_YEAR_CH3 (__DATE__[10])
86
# define BUILD_MONTH_IS_JAN (__DATE__[0] == 'J' && __DATE__[1] == 'a' && __DATE__[2] == 'n')
87
# define BUILD_MONTH_IS_FEB (__DATE__[0] == 'F')
88
# define BUILD_MONTH_IS_MAR (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r')
89
# define BUILD_MONTH_IS_APR (__DATE__[0] == 'A' && __DATE__[1] == 'p')
90
# define BUILD_MONTH_IS_MAY (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y')
91
# define BUILD_MONTH_IS_JUN (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n')
92
# define BUILD_MONTH_IS_JUL (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l')
93
# define BUILD_MONTH_IS_AUG (__DATE__[0] == 'A' && __DATE__[1] == 'u')
94
# define BUILD_MONTH_IS_SEP (__DATE__[0] == 'S')
95
# define BUILD_MONTH_IS_OCT (__DATE__[0] == 'O')
96
# define BUILD_MONTH_IS_NOV (__DATE__[0] == 'N')
97
# define BUILD_MONTH_IS_DEC (__DATE__[0] == 'D')
98
# define BUILD_MONTH_CH0 (__DATE__[ 0])
99
# define BUILD_MONTH_CH1 (__DATE__[ 1])
100
# define BUILD_MONTH_CH2 (__DATE__[ 2])
101
# define BUILD_DAY_CH0 ((__DATE__[4] >= '0') ? (__DATE__[4]) : '0')
102
# define BUILD_DAY_CH1 (__DATE__[ 5])
103
#endif // BUILD_DEFS_H
104
105
106
#ifdef DEBUG
107
# define checkpoint() printf("Checkpoint: Line %d in file %s\n",__LINE__,__FILE__);
108
#else
109
# define checkpoint()
110
#endif // DEBUG
111
112
113
#define MAX_INIT_TYPE_STRING_LENGTH 255
114
#define TIME_BUFFER_SIZE 64
115
#define MAX_INIT_VERSION_STRING_LENGTH 99
116
#define MAX_INIT_COMPILING_DATA_STRING_LENGTH 25
117
#define MAP_ERROR_STRING_LENGTH 1024
118
#define MAP_HORIZONTAL_TOL 1E-2
119
120
#define PROGNAME "MAP++ (Mooring Analysis Program++)"
121
#define PROGVERSION "1.20.10"
122
#define CHECKERRQ(code) if(success!=MAP_SAFE) {set_universal_error(map_msg, ierr, code); break;}
123
#define CHECKERRK(code) if(success!=MAP_SAFE) {set_universal_error(map_msg, ierr, code);}
124
#define MAPFREE(obj) if(obj!=NULL) {free(obj); obj=NULL;}
125
#define DEG2RAD 0.01745329251
/* pi/180 */
126
#define RAD2DEG 57.2957795131
/* 180/pi */
127
#define ARCSINH(x) log(x+sqrt(1+x*x))
128
#define SPACE_LENGTH 12
129
#define MACHINE_EPSILON 1e-16
130
#define MAP_BEGIN_ERROR_LOG do{ \
131
;
132
#define MAP_END_ERROR_LOG } while(0);
133
#define MAP_RETURN_STATUS(x) \
134
if (x==MAP_SAFE) { \
135
return MAP_SAFE; \
136
} else if (x==MAP_ERROR) { \
137
return MAP_ERROR; \
138
} else { \
139
return MAP_FATAL; \
140
};
141
142
143
/* Text Coloring (OS dependant)
144
*
145
* Not used any longer, but can color text at the terminal. If we are on a non-Unix OS, then:
146
* -- set the strings to "" (empty) so that garbage is not printed
147
*/
148
#ifdef __posix
149
# define MAP_COLOR_RED "\033[1;31m"
150
# define MAP_COLOR_YELLOW "\033[1;33m"
151
# define MAP_COLOR_BLUE "\033[1;34m"
152
# define MAP_COLOR_END "\033[0m"
153
#elif __linux
154
# define MAP_COLOR_RED "\033[1;31m"
155
# define MAP_COLOR_YELLOW "\033[1;33m"
156
# define MAP_COLOR_BLUE "\033[1;34m"
157
# define MAP_COLOR_END "\033[0m"
158
#elif __unix
159
# define MAP_COLOR_RED "\033[1;31m"
160
# define MAP_COLOR_YELLOW "\033[1;33m"
161
# define MAP_COLOR_BLUE "\033[1;34m"
162
# define MAP_COLOR_END "\033[0m"
163
#elif __APPLE__
164
# define MAP_COLOR_RED "\033[1;31m"
165
# define MAP_COLOR_YELLOW "\033[1;33m"
166
# define MAP_COLOR_BLUE "\033[1;34m"
167
# define MAP_COLOR_END "\033[0m"
168
#else
169
# define MAP_COLOR_RED ""
170
# define MAP_COLOR_YELLOW ""
171
# define MAP_COLOR_BLUE ""
172
# define MAP_COLOR_END ""
173
#endif
174
175
void
__get_machine_name(
char
* machineName );
176
177
#endif
/* _MAPSYS_H */
Generated by
1.8.13