-
Notifications
You must be signed in to change notification settings - Fork 1
/
rolib.h
391 lines (345 loc) · 8.49 KB
/
rolib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
/**********************************************************************
R O L I B
Remote Operations Library
Datei: rolib.h
Version: 1.12
Datum: 96/11/28 11:45:12
(c) CR by Herlitz AG
**********************************************************************
Funktion: Globale Header-Definitionen fuer die ROLIB
Autor: Destailleur, Lubitz
*/
#ifndef _RO_ROLIB_H
#define _RO_ROLIB_H
#ifdef TANDEM
#include "unixincl.system"
#else
#include "system.h"
#endif
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#ifdef BS2000
#include <sys.types.h>
#include <netdb.h>
#include <sys.socket.h>
#include <netinet.in.h>
#include <arpa.inet.h>
#else
#ifdef TANDEM
#include <types.h>
#include <fcntl.h>
#include <talh>
#include <cextdecs(AWAITIOX)>
#include <cextdecs(SETMODE)>
#include <cextdecs(CANCELREQ)>
#include <cextdecs(CLOSE)>
#include <cextdecs(DELAY)>
#include <cextdecs(FILE_GETINFO_)>
#include "$system.ztcpip.inh"
#include "$system.ztcpip.netdbh"
#include "$system.ztcpip.socketh"
#else
#ifdef WINNT
#include <winsock.h>
#include <malloc.h>
#include <sys/types.h>
#include <fcntl.h>
#else
#include <netdb.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#endif
#endif
#endif
#define RO_MAXLISTENQUEUE 5
#define RO_MAXCONNECTIONS 120
#define SOC_ACCEPT accept
#define SOC_BIND bind
#define SOC_CONNECT connect
#define SOC_LISTEN listen
#define SOC_SELECT select
#define SOC_SHUTDOWN shutdown
#define SOC_SOCKET socket
#define SOC_RECV recv
#define SOC_SEND send
#ifdef BS2000
#define SOC_CLOSE soc_close
#define SOC_IOCTL soc_ioctl
#define SOC_READ soc_read
#define SOC_WRITE soc_write
#else
#ifdef TANDEM
#define SOC_CLOSE CLOSE
#else
#ifdef WINNT
#define SOC_CLOSE closesocket
#else
#define SOC_CLOSE close
#endif
#endif
#ifdef WINNT
#define SOC_IOCTL ioctlsocket
#else
#define SOC_IOCTL ioctl
#endif
#define SOC_READ read
#define SOC_WRITE write
#endif
#ifdef WINNT
#define sleep(s) Sleep(s*1000)
#endif
/*
* Strukturdefinitionen
*/
struct ro_application_info
{
FILE *logfile;
char providerdir[255];
char servicedir[255];
int debuglevel;
unsigned short port;
#define RO_ASCII 0
#define RO_EBCDIC 1
int charset;
#ifdef TANDEM
int status2; /* TANDEM: accept_nw pending ? */
#endif
};
struct ro_connparams {
int mode;
#define RO_MODE_TRANSPARENT 1
#define RO_MODE_NONTRANSPARENT 0
char escape;
#define RO_DEFAULT_ESC '^'
};
struct ro_connection
{
int sock;
int status;
#define RO_CONNECTION_CLOSED 0
#define RO_CONNECTION_CLOSE_REQUESTED 1
#define RO_CONNECTION_REQUESTED 2
#define RO_CONNECTION_ESTABLISHED 3
unsigned long message_nr;
char providername[16];
char servicename[16];
int remote_port;
int level;
struct ro_connparams params;
#ifdef TANDEM
int status2; /* TANDEM: recv_nw pending ? */
#define RO_RECV_PENDING 1
#define RO_PORT_CLEAR 2
#endif
};
struct ro_connect_rq {
char myprovidername[15];
char myservicename[15];
char providername[15];
char servicename[15];
int level;
#define RO_APPLICATION_LEVEL 0
#define RO_ADMIN_LEVEL 1
struct ro_connparams roc;
unsigned long id;
};
struct ro_connect_cf {
unsigned long id;
};
struct ro_connect_rj {
int reason;
char *errtext;
unsigned long id;
};
struct ro_disconn_rq {
unsigned long id;
};
struct ro_disconn_cf {
unsigned long id;
};
struct ro_disconn_im {
int reason;
};
struct ro_invoke_rq {
int op;
int version;
unsigned long id;
char *in;
unsigned long inlen;
};
struct ro_invoke_rs {
int op;
int version;
unsigned long id;
char *result;
unsigned long resultlen;
};
struct ro_invoke_rj {
int op;
int version;
int reason;
unsigned long id;
char *data;
unsigned long datalen;
};
struct ro_event {
unsigned short event_typ;
#define RO_CONNECT_REQUEST 1
#define RO_CONNECT_CONFIRMATION 2
#define RO_CONNECT_REJECT 3
#define RO_DISCONNECT_REQUEST 4
#define RO_DISCONNECT_CONFIRMATION 5
#define RO_DISCONNECT_IMMEDIATE 6
#define RO_INVOKE_REQUEST 7
#define RO_INVOKE_RESULT 8
#define RO_INVOKE_REJECT 9
#define RO_TIMEOUT 97
#define RO_SHUTDOWN 98
#define RO_INTERNAL_EVENT 99
int cd;
union {
struct ro_connect_rq rocrq;
struct ro_connect_cf roccf;
struct ro_connect_rj rocrj;
struct ro_disconn_rq rodrq;
struct ro_disconn_cf rodcf;
struct ro_disconn_im rodim;
struct ro_invoke_rq roirq;
struct ro_invoke_rs roirs;
struct ro_invoke_rj roirj;
} event;
};
struct ro_indication {
int code;
char text[255];
};
struct ro_error {
int status;
char *text;
};
#define RO_ERR_INITMESS 1
#define RO_ERR_PORTINVALID 2
#define RO_ERR_PORTRESERVED 3
#define RO_ERR_INITSOCK 4
#define RO_ERR_GETPROVIDER 5
#define RO_ERR_CREATESOCK 6
#define RO_ERR_BINDSOCK 7
#define RO_ERR_LISTENSOCK 8
#define RO_ERR_ACCEPTSOCK 9
#define RO_ERR_RECVSOCK 10
#define RO_ERR_SENDMESS 11
#define RO_ERR_SELECTSOCK 12
#define RO_ERR_WAITEVENT 13
#define RO_ERR_TOOMANYCON 14
#define RO_ERR_CONNSOCK 15
#define RO_ERR_CONNALLOC 16
#define RO_ERR_CONNDIRSERV 17
#define RO_ERR_QRYDIRSERV 18
extern struct ro_error ro_errors[];
struct ro_provider {
char name[16];
struct sockaddr_in sin;
char charset[7];
};
struct ro_service {
char name[16];
unsigned short port;
};
/*
* Allgemeine Definitionen
*/
#ifndef WINNT
typedef enum { FALSE = 0, TRUE = 1 } BOOLEAN;
#endif
/*
* Symbolische Konstanten fuer mask bei ro_setconnparams,
* ggf. durch | verbinden
*/
#define RO_CP_SETMODE 0x0001 /* Verbindungs-Modus setzen */
#define RO_CP_SETESCAPE 0x0002 /* Escape-Character setzen */
/*
* Symbolische Konstanten fuer die Return-Codes der ROLIB-Funktionen
*/
enum { RO_ERROR = 0, RO_OK = 1, RO_WARNING = 2 };
/*
* Symbolische Konstanten fuer die OP-Codes von reservierten Operationen
*/
#define RO_STD_OP_PING 2
#define RO_STD_VERSION_PING 1
#define RO_STD_OP_SHUTDOWN 5
#define RO_STD_VERSION_SHUTDOWN 1
#define RO_STD_OP_SERVICEQUERY 512
#define RO_STD_VERSION_SERVICEQUERY 1
#define RO_STD_OP_WRITE 520
#define RO_STD_VERSION_WRITE 1
/*
* Funktionsprototypen
*/
int ro_init(char *myprovidername, char *providerdir, char *servicedir,
char *logfilename, int debuglevel, int port,
struct ro_indication *roi);
int ro_release(struct ro_indication *roi);
int ro_nw1_wait_event(int cd,
#ifndef TANDEM
fd_set *fdread,
int *maxfd,
#endif
struct ro_indication *roi);
int ro_nw2_wait_event(
#ifdef TANDEM
unsigned short ret_socket,
#else
int fdcount, fd_set *fdread,
#endif
long maxlen,
struct ro_event *roe,
struct ro_indication *roi);
int ro_wait_event(int secs, int cd, long maxlen, struct ro_event *roe,
struct ro_indication *roi);
int ro_direct_connect(struct sockaddr_in *netaddr,
struct ro_connect_rq *rocrq, int *cd,
struct ro_indication *roi);
int ro_connect(struct ro_connect_rq *rocrq, int *cd, struct ro_indication *roi);
int ro_co_confirm(int cd, struct ro_connect_cf *roccf,
struct ro_indication *roi);
int ro_co_reject(int cd, struct ro_connect_rj *rocrj,
struct ro_indication *roi);
int ro_disconnect(int cd, struct ro_disconn_rq *rodrq,
struct ro_indication *roi);
int ro_dc_immediate(int cd, struct ro_disconn_im *rodim,
struct ro_indication *roi);
int ro_dc_confirm(int cd, struct ro_disconn_cf *rodcf,
struct ro_indication *roi);
int ro_setconnparams(int cd, struct ro_connparams *roc, int mask,
struct ro_indication *roi);
int ro_request(int cd, struct ro_invoke_rq *roirq, struct ro_indication *roi);
int ro_result(int cd, struct ro_invoke_rs *roirs, struct ro_indication *roi);
int ro_reject(int cd, struct ro_invoke_rj *roirj, struct ro_indication *roi);
struct ro_connection *ro_getconnection(int cd);
int ro_enterconnection(int cd, struct ro_connection *roc);
struct ro_service *ro_getservicebyname(char *name);
struct ro_provider *ro_getproviderbyname(char *name);
void ro_setdebuglevel(int lvl);
int ro_getdebuglevel(void);
#ifndef HAS_BSTRING
void bzero(char *p, int len);
void bcopy(char *s, char *d, int len);
#endif
#ifndef HAS_GETOPT
int getopt(int nargc, char **nargv, char *ostr);
#endif
void dprintf(int lvl, char *format, ...);
void lbzero(char *p, unsigned long len);
void lbcopy(char *s, char *d, unsigned long len);
#endif
/******************************* EOF ********************************/