source: trunk/FACT++/dim_v19r19/dim/dim_common.h@ 10480

Last change on this file since 10480 was 10480, checked in by tbretz, 14 years ago
New version V19r19 with some important bug fixes.
File size: 7.8 KB
Line 
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
19typedef enum { SRC_NONE, SRC_DIS, SRC_DIC, SRC_DNS, SRC_DNA, SRC_USR }SRC_TYPES;
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#ifdef WIN32
46typedef __int64 longlong;
47#elif defined(__linux__)
48typedef long long int longlong;
49#else
50#include <sys/types.h>
51typedef int64_t longlong;
52#endif
53
54#endif
55
56#ifndef OSK
57# ifdef _OSK
58# define OSK
59# endif
60#endif
61
62
63#ifdef __VMS
64#define VMS
65#endif
66
67#ifndef _DIM_PROTO
68#ifndef OSK /* Temorary hack */
69# if defined(__cplusplus) /* || (__STDC__ == 1) || defined(_ANSI_EXT) || defined(ultrix) */
70# define _DIM_PROTO(func,param) func param
71# else
72# define _DIM_PROTO(func,param) func ()
73# endif
74#else
75# define _DIM_PROTO(func,param) func ()
76#endif
77#ifdef WIN32
78#ifdef DIMLIB
79# define _DIM_PROTOE(func,param) __declspec(dllexport) _DIM_PROTO(func,param)
80# define DllExp __declspec(dllexport)
81#else
82# define _DIM_PROTOE(func,param) __declspec(dllimport) _DIM_PROTO(func,param)
83# define DllExp __declspec(dllimport)
84#endif
85#else
86# define _DIM_PROTOE(func,param) _DIM_PROTO(func,param)
87# define DllExp
88#endif
89#endif
90
91#if defined (hpux) || defined (__osf__) || defined(_AIX) || defined(WIN32)
92#ifndef NOTHREADS
93#define NOTHREADS
94#endif
95#endif
96
97#ifndef VMS
98#ifndef WIN32
99#ifdef NOTHREADS
100#ifndef DIMLIB
101#ifndef sleep
102#define sleep(t) dtq_sleep(t)
103#endif
104#endif
105#endif
106#endif
107#endif
108
109#ifdef VMS
110#include <ssdef.h>
111#define DISABLE_AST long int ast_enable = sys$setast(0);
112#define ENABLE_AST if (ast_enable == SS$_WASSET) sys$setast(1);
113#define dim_enable() sys$setast(1);
114#endif
115
116#ifdef __unix__
117#include <signal.h>
118#include <unistd.h>
119
120#define DISABLE_AST sigset_t set, oset; sigemptyset(&set);\
121 sigaddset(&set,SIGIO);\
122 sigaddset(&set,SIGALRM);\
123 sigprocmask(SIG_BLOCK,&set,&oset);\
124 DIM_LOCK
125#define ENABLE_AST DIM_UNLOCK sigprocmask(SIG_SETMASK,&oset,0);
126
127#ifdef VxWorks
128#define DIM_LOCK taskLock();
129#define DIM_UNLOCK taskUnlock();
130#else
131
132#ifndef NOTHREADS
133#include <pthread.h>
134
135_DIM_PROTOE( void dim_lock, () );
136_DIM_PROTOE( void dim_unlock, () );
137_DIM_PROTOE( void dim_wait_cond, () );
138_DIM_PROTOE( void dim_signal_cond, () );
139
140#define DIM_LOCK dim_lock();
141#define DIM_UNLOCK dim_unlock();
142
143#else
144#define DIM_LOCK
145#define DIM_UNLOCK
146#endif
147#endif
148#endif
149#ifdef OSK
150#define INC_LEVEL 1
151#define DEC_LEVEL (-1)
152#define DISABLE_AST sigmask(INC_LEVEL);
153#define ENABLE_AST sigmask(DEC_LEVEL);
154#endif
155
156
157_DIM_PROTOE( int id_get, (void *ptr, int type) );
158_DIM_PROTOE( void id_free, (int id, int type) );
159_DIM_PROTOE( void *id_get_ptr, (int id, int type) );
160
161_DIM_PROTOE( unsigned int dtq_sleep, (unsigned int secs) );
162_DIM_PROTOE( void dtq_start_timer, (int secs, void(*rout)(void*), void *tag) );
163_DIM_PROTOE( int dtq_stop_timer, (void *tag) );
164_DIM_PROTOE( void dim_init, () );
165_DIM_PROTOE( void dim_no_threads, () );
166_DIM_PROTOE( void dna_set_test_write, (int conn_id, int time) );
167_DIM_PROTOE( void dna_rem_test_write, (int conn_id) );
168_DIM_PROTOE( int dim_set_dns_node, (char *node) );
169_DIM_PROTOE( int dim_get_dns_node, (char *node) );
170_DIM_PROTOE( int dim_set_dns_port, (int port) );
171_DIM_PROTOE( int dim_get_dns_port, () );
172_DIM_PROTOE( void dic_set_debug_on, () );
173_DIM_PROTOE( void dic_set_debug_off, () );
174_DIM_PROTOE( void dim_print_msg, (char *msg, int severity) );
175_DIM_PROTOE( void dim_print_date_time, () );
176_DIM_PROTOE( void dim_set_write_timeout, (int secs) );
177_DIM_PROTOE( int dim_get_write_timeout, () );
178_DIM_PROTOE( void dim_usleep, (unsigned int t) );
179_DIM_PROTOE( int dim_wait, (void) );
180_DIM_PROTOE( int dim_get_priority, (int dim_thread, int prio) );
181_DIM_PROTOE( int dim_set_priority, (int dim_thread, int *prio) );
182_DIM_PROTOE( int dim_set_scheduler_class, (int sched_class) );
183_DIM_PROTOE( int dim_get_scheduler_class, (int *sched_class) );
184_DIM_PROTOE( long dim_start_thread, (void(*rout)(void*), void *tag) );
185_DIM_PROTOE( int dic_set_dns_node, (char *node) );
186_DIM_PROTOE( int dic_get_dns_node, (char *node) );
187_DIM_PROTOE( int dic_set_dns_port, (int port) );
188_DIM_PROTOE( int dic_get_dns_port, () );
189_DIM_PROTOE( int dis_set_dns_node, (char *node) );
190_DIM_PROTOE( int dis_get_dns_node, (char *node) );
191_DIM_PROTOE( int dis_set_dns_port, (int port) );
192_DIM_PROTOE( int dis_get_dns_port, () );
193_DIM_PROTOE( void dim_stop, () );
194_DIM_PROTOE( int dim_stop_thread, (long tid) );
195_DIM_PROTOE( long dis_add_dns, (char *node, int port) );
196_DIM_PROTOE( long dic_add_dns, (char *node, int port) );
197_DIM_PROTOE( int dim_get_env_var, (char *env_var, char *value, int value_size) );
198_DIM_PROTOE( int dim_set_write_buffer_size, (int bytes) );
199_DIM_PROTOE( int dim_get_write_buffer_size, () );
200_DIM_PROTOE( int dim_set_read_buffer_size, (int bytes) );
201_DIM_PROTOE( int dim_get_read_buffer_size, () );
202_DIM_PROTOE( void dis_set_debug_on, () );
203_DIM_PROTOE( void dis_set_debug_off, () );
204
205#ifdef WIN32
206#define getpid _getpid
207_DIM_PROTOE( void dim_pause, () );
208_DIM_PROTOE( void dim_wake_up, () );
209_DIM_PROTOE( void dim_lock, () );
210_DIM_PROTOE( void dim_unlock, () );
211_DIM_PROTOE( void dim_sleep, (unsigned int t) );
212_DIM_PROTOE( void dim_win_usleep, (unsigned int t) );
213#define sleep(t) dim_sleep(t);
214#define usleep(t) dim_win_usleep(t);
215#define pause() dim_pause();
216#define wake_up() dim_wake_up();
217#define DIM_LOCK dim_lock();
218#define DIM_UNLOCK dim_unlock();
219#define DISABLE_AST DIM_LOCK
220#define ENABLE_AST DIM_UNLOCK
221#endif
222
223_DIM_PROTOE( void dim_print_date_time_millis, () );
224
225/* ctime usage */
226#if defined (solaris) || (defined (LYNXOS) && !defined (__Lynx__) )
227#define my_ctime(t,str,size) ctime_r(t,str,size)
228#else
229#if defined (__linux__) || defined (__Lynx__)
230#define my_ctime(t,str,size) ctime_r(t,str)
231#else
232#define my_ctime(t,str,size) strcpy(str,(const char *)ctime(t))
233#endif
234#endif
235
236/* DIM Error Severities*/
237typedef enum { DIM_INFO, DIM_WARNING, DIM_ERROR, DIM_FATAL }DIM_SEVERITIES;
238/* DIM Error codes */
239#define DIMDNSUNDEF 0x1 /* DIM_DNS_NODE undefined FATAL */
240#define DIMDNSREFUS 0x2 /* DIM_DNS refuses connection FATAL */
241#define DIMDNSDUPLC 0x3 /* Service already exists in DNS FATAL */
242#define DIMDNSEXIT 0x4 /* DNS requests server to EXIT FATAL */
243#define DIMDNSTMOUT 0x5 /* Server failed sending Watchdog WARNING */
244
245#define DIMSVCDUPLC 0x10 /* Service already exists in Server ERROR */
246#define DIMSVCFORMT 0x11 /* Bat format string for service ERROR */
247#define DIMSVCINVAL 0x12 /* Service ID invalid ERROR */
248#define DIMSVCTOOLG 0x13 /* Service name too long ERROR */
249
250#define DIMTCPRDERR 0x20 /* TCP/IP read error ERROR */
251#define DIMTCPWRRTY 0x21 /* TCP/IP write error - Retrying WARNING */
252#define DIMTCPWRTMO 0x22 /* TCP/IP write error - Disconnect ERROR */
253#define DIMTCPLNERR 0x23 /* TCP/IP listen error ERROR */
254#define DIMTCPOPERR 0x24 /* TCP/IP open server error ERROR */
255#define DIMTCPCNERR 0x25 /* TCP/IP connection error ERROR */
256#define DIMTCPCNEST 0x26 /* TCP/IP connection established INFO */
257
258#define DIMDNSCNERR 0x30 /* Connection to DNS failed ERROR */
259#define DIMDNSCNEST 0x31 /* Connection to DNS established INFO */
260
261#endif
262
263
264
265
266
267
268
Note: See TracBrowser for help on using the repository browser.