FACT++  1.0
dim_common.h
Go to the documentation of this file.
1 #ifndef __COMMONDEFS
2 #define __COMMONDEFS
3 
4 /* Service type definition */
5 
6 #ifndef ONCE_ONLY
7 #define ONCE_ONLY 0x01
8 #define TIMED 0x02
9 #define MONITORED 0x04
10 #define COMMAND 0x08
11 #define DIM_DELETE 0x10
12 #define MONIT_ONLY 0x20
13 #define UPDATE 0x40
14 #define TIMED_ONLY 0x80
15 #define MONIT_FIRST 0x100
16 #define MAX_TYPE_DEF 0x100
17 #define STAMPED 0x1000
18 
20 
21 #ifdef __APPLE__
22 #ifndef unix
23 #define unix
24 #endif
25 #endif
26 
27 #ifdef __Lynx__
28 #ifndef unix
29 #define unix
30 #endif
31 #endif
32 
33 #ifdef unix
34 #ifndef __unix__
35 #define __unix__
36 #endif
37 #endif
38 
39 #ifdef linux
40 #ifndef __linux__
41 #define __linux__
42 #endif
43 #endif
44 
45 #if defined (_WIN64)
46 typedef __int64 longlong;
47 typedef longlong dim_long;
48 #elif defined(WIN32)
49 typedef __int64 longlong;
50 typedef long dim_long;
51 #elif defined(__linux__)
52 typedef long long int longlong;
53 typedef long dim_long;
54 #else
55 #include <sys/types.h>
56 typedef int64_t longlong;
57 typedef long dim_long;
58 #endif
59 
60 #endif
61 
62 #ifndef OSK
63 # ifdef _OSK
64 # define OSK
65 # endif
66 #endif
67 
68 
69 #ifdef __VMS
70 #define VMS
71 #endif
72 
73 #ifndef _DIM_PROTO
74 #ifndef OSK /* Temorary hack */
75 # if defined(__cplusplus) /* || (__STDC__ == 1) || defined(_ANSI_EXT) || defined(ultrix) */
76 # define _DIM_PROTO(func,param) func param
77 # else
78 # define _DIM_PROTO(func,param) func ()
79 # endif
80 #else
81 # define _DIM_PROTO(func,param) func ()
82 #endif
83 #ifdef WIN32
84 #ifdef DIMLIB
85 # define _DIM_PROTOE(func,param) __declspec(dllexport) _DIM_PROTO(func,param)
86 # define DllExp __declspec(dllexport)
87 #else
88 # define _DIM_PROTOE(func,param) __declspec(dllimport) _DIM_PROTO(func,param)
89 # define DllExp __declspec(dllimport)
90 #endif
91 #else
92 # define _DIM_PROTOE(func,param) _DIM_PROTO(func,param)
93 # define DllExp
94 #endif
95 #endif
96 
97 #if defined (hpux) || defined (__osf__) || defined(_AIX) || defined(WIN32)
98 #ifndef NOTHREADS
99 #define NOTHREADS
100 #endif
101 #endif
102 
103 #ifndef VMS
104 #ifndef WIN32
105 #ifdef NOTHREADS
106 #ifndef DIMLIB
107 #ifndef sleep
108 #define sleep(t) dtq_sleep(t)
109 #endif
110 #endif
111 #endif
112 #endif
113 #endif
114 
115 #ifdef VMS
116 #include <ssdef.h>
117 #define DISABLE_AST long int ast_enable = sys$setast(0);
118 #define ENABLE_AST if (ast_enable == SS$_WASSET) sys$setast(1);
119 #define dim_enable() sys$setast(1);
120 #endif
121 
122 #ifdef __unix__
123 #include <signal.h>
124 #include <unistd.h>
125 
126 extern int DIM_Threads_OFF;
127 
128 #define DISABLE_SIG sigset_t set, oset; if (DIM_Threads_OFF) {\
129  sigemptyset(&set);\
130  sigaddset(&set,SIGIO);\
131  sigaddset(&set,SIGALRM);\
132  sigprocmask(SIG_BLOCK,&set,&oset);}
133 #define ENABLE_SIG if (DIM_Threads_OFF) {\
134  sigprocmask(SIG_SETMASK,&oset,0);}
135 
136 /*
137 #define DISABLE_SIG sigset_t set, oset; sigemptyset(&set);\
138  sigaddset(&set,SIGIO);\
139  sigaddset(&set,SIGALRM);\
140  sigprocmask(SIG_BLOCK,&set,&oset);
141 #define ENABLE_SIG sigprocmask(SIG_SETMASK,&oset,0);
142 */
143 
144 #define DISABLE_AST DISABLE_SIG DIM_LOCK
145 #define ENABLE_AST DIM_UNLOCK ENABLE_SIG
146 
147 #ifdef VxWorks
148 #define DIM_LOCK taskLock();
149 #define DIM_UNLOCK taskUnlock();
150 #else
151 
152 #ifndef NOTHREADS
153 #include <pthread.h>
154 
155 #ifdef __cplusplus
156 extern "C" {
157 #endif
158 
159 _DIM_PROTOE( void dim_lock, () );
160 _DIM_PROTOE( void dim_unlock, () );
161 _DIM_PROTOE( void dim_wait_cond, () );
162 _DIM_PROTOE( void dim_signal_cond, () );
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #define DIM_LOCK dim_lock();
168 #define DIM_UNLOCK dim_unlock();
169 
170 #else
171 #include <time.h>
172 #define DIM_LOCK
173 #define DIM_UNLOCK
174 #endif
175 #endif
176 #endif
177 #ifdef OSK
178 #define INC_LEVEL 1
179 #define DEC_LEVEL (-1)
180 #define DISABLE_AST sigmask(INC_LEVEL);
181 #define ENABLE_AST sigmask(DEC_LEVEL);
182 #endif
183 
184 #ifdef __cplusplus
185 extern "C" {
186 #define __CXX_CONST const
187 #else
188 #define __CXX_CONST
189 #endif
190 
191 _DIM_PROTOE( int id_get, (void *ptr, int type) );
192 _DIM_PROTOE( void id_free, (int id, int type) );
193 _DIM_PROTOE( void *id_get_ptr, (int id, int type) );
194 
195 _DIM_PROTOE( unsigned int dtq_sleep, (unsigned int secs) );
196 _DIM_PROTOE( void dtq_start_timer, (int secs, void(*rout)(void*), void *tag) );
197 _DIM_PROTOE( int dtq_stop_timer, (void *tag) );
198 _DIM_PROTOE( void dim_init, () );
199 _DIM_PROTOE( void dim_no_threads, () );
200 _DIM_PROTOE( void dna_set_test_write, (int conn_id, int time) );
201 _DIM_PROTOE( void dna_rem_test_write, (int conn_id) );
203 _DIM_PROTOE( int dim_get_dns_node, (char *node) );
204 _DIM_PROTOE( int dim_set_dns_port, (int port) );
205 _DIM_PROTOE( int dim_get_dns_port, () );
206 _DIM_PROTOE( void dic_set_debug_on, () );
207 _DIM_PROTOE( void dic_set_debug_off, () );
208 _DIM_PROTOE( void dim_print_msg, (__CXX_CONST char *msg, int severity) );
209 _DIM_PROTOE( void dim_print_date_time, () );
210 _DIM_PROTOE( void dim_set_write_timeout, (int secs) );
212 _DIM_PROTOE( void dim_usleep, (unsigned int t) );
213 _DIM_PROTOE( int dim_wait, (void) );
214 _DIM_PROTOE( int dim_get_priority, (int dim_thread, int prio) );
215 _DIM_PROTOE( int dim_set_priority, (int dim_thread, int *prio) );
216 _DIM_PROTOE( int dim_set_scheduler_class, (int sched_class) );
217 _DIM_PROTOE( int dim_get_scheduler_class, (int *sched_class) );
218 _DIM_PROTOE( dim_long dim_start_thread, (void(*rout)(void*), void *tag) );
220 _DIM_PROTOE( int dic_get_dns_node, (char *node) );
221 _DIM_PROTOE( int dic_set_dns_port, (int port) );
222 _DIM_PROTOE( int dic_get_dns_port, () );
224 _DIM_PROTOE( int dis_get_dns_node, (char *node) );
225 _DIM_PROTOE( int dis_set_dns_port, (int port) );
226 _DIM_PROTOE( int dis_get_dns_port, () );
227 _DIM_PROTOE( void dim_stop, () );
228 _DIM_PROTOE( int dim_stop_thread, (dim_long tid) );
229 _DIM_PROTOE( dim_long dis_add_dns, (__CXX_CONST char *node, int port) );
230 _DIM_PROTOE( dim_long dic_add_dns, (__CXX_CONST char *node, int port) );
231 _DIM_PROTOE( int dim_get_env_var, (__CXX_CONST char *env_var, char *value, int value_size) );
232 _DIM_PROTOE( int dim_set_write_buffer_size, (int bytes) );
234 _DIM_PROTOE( int dim_set_read_buffer_size, (int bytes) );
236 _DIM_PROTOE( void dis_set_debug_on, () );
237 _DIM_PROTOE( void dis_set_debug_off, () );
238 _DIM_PROTOE( void dim_set_keepalive_timeout, (int secs) );
242 
243 #ifdef WIN32
244 #define getpid _getpid
245 _DIM_PROTOE( void dim_pause, () );
246 _DIM_PROTOE( void dim_wake_up, () );
247 _DIM_PROTOE( void dim_lock, () );
248 _DIM_PROTOE( void dim_unlock, () );
249 _DIM_PROTOE( void dim_sleep, (unsigned int t) );
250 _DIM_PROTOE( void dim_win_usleep, (unsigned int t) );
251 #define sleep(t) dim_sleep(t);
252 #define usleep(t) dim_win_usleep(t);
253 #define pause() dim_pause();
254 #define wake_up() dim_wake_up();
255 #define DIM_LOCK dim_lock();
256 #define DIM_UNLOCK dim_unlock();
257 #define DISABLE_AST DIM_LOCK
258 #define ENABLE_AST DIM_UNLOCK
259 #endif
260 
261 #ifdef __cplusplus
262 }
263 #undef __CXX_CONST
264 #endif
265 
267 
268 /* ctime usage */
269 #if defined (solaris) || (defined (LYNXOS) && !defined (__Lynx__) )
270 #define my_ctime(t,str,size) ctime_r(t,str,size)
271 #else
272 #if defined (__linux__) || defined (__Lynx__)
273 #define my_ctime(t,str,size) ctime_r(t,str)
274 #else
275 #define my_ctime(t,str,size) strcpy(str,(const char *)ctime(t))
276 #endif
277 #endif
278 
279 /* DIM Error Severities*/
281 /* DIM Error codes */
282 #define DIMDNSUNDEF 0x1 /* DIM_DNS_NODE undefined FATAL */
283 #define DIMDNSREFUS 0x2 /* DIM_DNS refuses connection FATAL */
284 #define DIMDNSDUPLC 0x3 /* Service already exists in DNS FATAL */
285 #define DIMDNSEXIT 0x4 /* DNS requests server to EXIT FATAL */
286 #define DIMDNSTMOUT 0x5 /* Server failed sending Watchdog WARNING */
287 
288 #define DIMSVCDUPLC 0x10 /* Service already exists in Server ERROR */
289 #define DIMSVCFORMT 0x11 /* Bat format string for service ERROR */
290 #define DIMSVCINVAL 0x12 /* Service ID invalid ERROR */
291 #define DIMSVCTOOLG 0x13 /* Service name too long ERROR */
292 
293 #define DIMTCPRDERR 0x20 /* TCP/IP read error ERROR */
294 #define DIMTCPWRRTY 0x21 /* TCP/IP write error - Retrying WARNING */
295 #define DIMTCPWRTMO 0x22 /* TCP/IP write error - Disconnect ERROR */
296 #define DIMTCPLNERR 0x23 /* TCP/IP listen error ERROR */
297 #define DIMTCPOPERR 0x24 /* TCP/IP open server error ERROR */
298 #define DIMTCPCNERR 0x25 /* TCP/IP connection error ERROR */
299 #define DIMTCPCNEST 0x26 /* TCP/IP connection established INFO */
300 
301 #define DIMDNSCNERR 0x30 /* Connection to DNS failed ERROR */
302 #define DIMDNSCNEST 0x31 /* Connection to DNS established INFO */
303 
304 #endif
305 
306 
307 
308 
309 
310 
311 
void dim_stop()
Definition: dim_thr.c:186
void dim_wait_cond()
Definition: dim_thr.c:486
Definition: dns.c:26
#define __CXX_CONST
Definition: dim_common.h:188
int dim_get_keepalive_timeout()
Definition: tcpip.c:128
int dis_get_dns_port()
Definition: open_dns.c:139
int dim_wait(void)
Definition: dim_thr.c:409
int dis_set_dns_port(int port)
Definition: open_dns.c:114
dim_long dis_add_dns(char *node_name, int port_number)
Definition: open_dns.c:237
int dim_set_dns_node(char *node)
Definition: open_dns.c:50
DIM_SEVERITIES
Definition: dim_common.h:280
int dim_get_listen_backlog()
Definition: tcpip.c:118
void dic_set_debug_on()
Definition: dic.c:97
dim_get_env_var("EXTRA_DNS_NODE", extra_dns, sizeof(extra_dns))
int dim_get_read_buffer_size()
Definition: tcpip.c:187
void * id_get_ptr(int id, SRC_TYPES type)
Definition: conn_handler.c:184
void dic_set_debug_off()
Definition: dic.c:102
void dim_usleep(int usecs)
Definition: dtq.c:293
dim_long dim_start_thread(void *(*thread_ast)(void *), dim_long tag)
Definition: dim_thr.c:231
int dic_set_dns_node(char *node)
Definition: open_dns.c:58
void dna_rem_test_write(int conn_id)
Definition: dna.c:613
SRC_TYPES
Definition: dim_common.h:19
int dic_get_dns_port()
Definition: open_dns.c:130
void dna_set_test_write(int conn_id, int time)
Definition: dna.c:606
void dim_signal_cond()
Definition: dim_thr.c:500
void dis_set_debug_off()
Definition: dis.c:186
unsigned int dtq_sleep(int secs)
Definition: dtq.c:837
int dic_set_dns_port(int port)
Definition: open_dns.c:107
int dim_get_scheduler_class(int *pclass)
Definition: dim_thr.c:296
#define _DIM_PROTOE(func, param)
Definition: dim_common.h:92
int dim_get_dns_node(char *node)
Definition: open_dns.c:72
void dim_set_listen_backlog(int size)
Definition: tcpip.c:113
void dtq_start_timer(int time, void(*user_routine)(), dim_long tag)
Definition: dtq.c:790
void dim_init()
Definition: dim_thr.c:111
int dic_get_dns_node(char *node)
Definition: open_dns.c:81
void dim_no_threads()
Definition: dtq.c:80
int type
int dtq_stop_timer(dim_long tag)
Definition: dtq.c:806
void dim_unlock()
Definition: dim_thr.c:472
int DIM_Threads_OFF
Definition: dtq.c:14
long dim_long
Definition: dim_common.h:57
dim_long dic_add_dns(char *node_name, int port_number)
Definition: open_dns.c:258
void dim_set_write_timeout(int secs)
Definition: tcpip.c:141
int dim_set_scheduler_class(int pclass)
Definition: dim_thr.c:255
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
int dim_get_dns_port()
Definition: open_dns.c:121
int dis_get_dns_node(char *node)
Definition: open_dns.c:90
void rout(int *tag, int *buff, int *size)
void dim_set_keepalive_timeout(int secs)
Definition: tcpip.c:123
void dim_lock()
Definition: dim_thr.c:455
int size
Definition: db_dim_server.c:17
void id_free(int id, SRC_TYPES type)
Definition: conn_handler.c:206
int dis_set_dns_node(char *node)
Definition: open_dns.c:65
int dim_set_dns_port(int port)
Definition: open_dns.c:99
int dim_stop_thread(dim_long t_id)
Definition: dim_thr.c:246
int dim_set_priority(int threadId, int prio)
Definition: dim_thr.c:309
int64_t longlong
Definition: dim_common.h:56
int id_get(void *ptr, SRC_TYPES type)
Definition: conn_handler.c:152
int dim_set_write_buffer_size(int size)
Definition: tcpip.c:160
void dim_print_date_time()
Definition: utilities.c:134
void dim_print_msg(char *msg, int severity)
Definition: utilities.c:180
TT t
Definition: test_client.c:26
int dim_get_write_timeout()
Definition: tcpip.c:147
int dim_get_priority(int threadId, int *prio)
Definition: dim_thr.c:333
int dim_get_write_buffer_size()
Definition: tcpip.c:171
void dis_set_debug_on()
Definition: dis.c:181
int dim_set_read_buffer_size(int size)
Definition: tcpip.c:176
void dim_print_date_time_millis()
Definition: utilities.c:157