-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnetlib.h
More file actions
executable file
·215 lines (194 loc) · 6.03 KB
/
netlib.h
File metadata and controls
executable file
·215 lines (194 loc) · 6.03 KB
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
/*[[ CMS REPLACEMENT HISTORY, Element NETLIB.H]]*/
/*[[ *2 7-NOV-2004 15:37:57 MADISON ""]]*/
/*[[ *1 12-MAR-1998 16:41:05 MADISON "Initial CMS population"]]*/
/*[[ CMS REPLACEMENT HISTORY, Element NETLIB.H]]*/
#ifndef NETLIB_H_LOADED
#define NETLIB_H_LOADED
/*
** NETLIB.H
**
** Main #include file for NETLIB.
**
** COPYRIGHT © 1993,1997,2004 MADGOAT SOFTWARE. ALL RIGHTS RESERVED.
**
** MODIFICATION HISTORY:
**
** 29-Sep-1993 Madison Initial commenting.
** 31-May-1997 Madison Fix queue access.
** 07-Nov-2004 Madison IA64 support.
*/
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <varargs.h>
#include <socket.h>
#include <in.h>
#include <netdb.h>
#include <descrip.h>
#include <stsdef.h>
#include <ssdef.h>
#include <lib$routines.h>
#include <str$routines.h>
#include <starlet.h>
#ifdef __DECC
#include <builtins.h>
#else
#pragma builtins
#endif
#ifndef __NETLIB_BUILD__
#define __NETLIB_BUILD__
#endif
#include "netlibdef.h"
#if defined(__ALPHA) || defined(__ia64__)
#pragma member_alignment save
#pragma nomember_alignment
#endif
typedef struct { void *head, *tail; } QUEUE;
typedef struct { unsigned int long1, long2; } TIME;
typedef struct dsc$descriptor DESCRIP;
typedef struct { unsigned short bufsiz, itmcod; void *bufadr, *retlen; } ITMLST;
#if defined(__ALPHA) || defined(__ia64__)
#pragma member_alignment restore
#endif
/*
** Handy macros
*/
#define OK(s) $VMS_STATUS_SUCCESS(s)
#define INIT_DYNDSCPTR(str) {str->dsc$w_length = 0; str->dsc$a_pointer = (void *) 0;\
str->dsc$b_class = DSC$K_CLASS_D; str->dsc$b_dtype = DSC$K_DTYPE_T;}
#define INIT_DYNDESC(str) {str.dsc$w_length = 0; str.dsc$a_pointer = (void *) 0;\
str.dsc$b_class = DSC$K_CLASS_D; str.dsc$b_dtype = DSC$K_DTYPE_T;}
#define INIT_SDESC(str,len,ptr) {str.dsc$w_length=(len);str.dsc$a_pointer=(void *)(ptr);\
str.dsc$b_class=DSC$K_CLASS_S; str.dsc$b_dtype=DSC$K_DTYPE_T;}
#define ITMLST_INIT(itm,c,s,a,r) {itm.bufsiz=(s); itm.itmcod=(c);\
itm.bufadr=(a); itm.retlen=(r);}
#define INIT_QUEUE(que) {que.head = que.tail = &que;}
#define SETARGCOUNT(x) va_count(x)
#define VERIFY_CTX(x,c) {if ((x) == 0) return SS$_BADPARAM; c = *x;}
#define GET_IOR(x, _ctx, _iosb, _astadr, _astprm) {unsigned int status;\
status = netlib___alloc_ior(&x);\
if (!OK(status)) return status; (x)->ctx = (_ctx);\
(x)->iosbp=(_iosb); (x)->astadr=(_astadr); (x)->astprm=(_astprm);}
#define FREE_IOR(x) netlib___free_ior(x);
#define GET_DNSREQ(x, _ctx, _iosb, _astadr, _astprm) {unsigned int status;\
status = netlib___alloc_dnsreq(&x);\
if (!OK(status)) return status;\
status = netlib___alloc_ior(&((x)->ior));\
if (!OK(status)) {netlib___free_dnsreq(x); return status;}\
(x)->ior->ctx = (_ctx);\
(x)->ior->iosbp=(_iosb); (x)->ior->astadr=(_astadr);\
(x)->ior->astprm=(_astprm);}
#define FREE_DNSREQ(x) {netlib___free_ior(((x)->ior));netlib___free_dnsreq(x);}
#if defined(__ALPHA) || defined(__ia64__)
#define queue_insert(item,pred) __PAL_INSQUEL((void *)(pred),(void *)(item))
#define queue_remove(entry,addr) (__PAL_REMQUEL((void *)(entry),(void *)(addr)) >= 0)
#else
#define queue_insert(item,pred) _INSQUE(item,pred)
#define queue_remove(entry,addr) (_REMQUE(entry,addr) != 2)
#endif
/*
** Generic context structure
*/
#ifndef __SPECCTX
#define __SPECCTX void
#endif
struct NAMESERVER {
struct NAMESERVER *flink, *blink;
struct INADDRDEF addr;
};
struct DOMAIN {
struct DOMAIN *flink, *blink;
int length;
char name[1];
};
struct DNSCTX {
QUEUE nsq;
QUEUE domq;
TIME timeout;
int retry_count;
unsigned int flags;
unsigned short queryid;
};
#define CTX_S_LINEBUF 32768
struct CTX {
struct CTX *flink, *blink;
TIME exptime;
unsigned int flags;
#define CTX_M_USER_SET_REUSEADDR (1<<0)
#define CTX_M_LINE_FOUND_CR (1<<1)
#define CTX_M_NO_DNS (1<<2)
unsigned short chan;
__SPECCTX *specctx;
unsigned int specctx_size;
unsigned char *linebuf, *linebufp, *lineanchor;
struct dsc$descriptor *line_dsc;
unsigned short *line_retlen;
unsigned int line_flags;
int line_remain;
TIME *line_tmo;
unsigned char *wlinebuf;
int wlinesize;
struct DNSCTX *dnsctx;
};
#define SPECIOR_SPACE 64
#ifndef __SPECIOR
#define __SPECIOR void *
#endif
#pragma nostandard
struct IOR {
struct IOR *flink, *blink;
struct NETLIBIOSBDEF iosb;
TIME timeout;
struct CTX *ctx;
struct NETLIBIOSBDEF *iosbp;
unsigned int iorflags;
#define IOR_M_IO_COMPLETED (1<<0)
#define IOR_M_IO_TIMED (1<<1)
#define IOR_M_IO_TIMEOUT (1<<2)
void (*astadr)();
void *astprm;
union {
void *address;
unsigned int longword;
unsigned short word;
} arg[8];
variant_union {
unsigned char specior_space[SPECIOR_SPACE];
__SPECIOR specior;
} specior_overlay;
};
#pragma standard
struct DNSREQ {
struct DNSREQ *flink, *blink;
struct IOR *ior;
struct CTX *ctx;
struct NAMESERVER *curns;
struct DOMAIN *curdom;
char *query_name;
unsigned short query_namlen;
unsigned int query_flags;
unsigned char *query_rbuf;
unsigned int query_rbufsize;
unsigned int query_class;
unsigned int query_type;
unsigned int buflen, replylen;
int retries;
struct SINDEF sin;
struct SINDEF rsin;
unsigned char buf[1024];
};
#ifndef __NETLIB_MODULE_MEM__
#pragma nostandard
globalref unsigned int netlib_synch_efn;
globalref unsigned int netlib_asynch_efn;
#pragma standard
unsigned int netlib___alloc_ctx(struct CTX **, unsigned int);
unsigned int netlib___free_ctx(struct CTX *);
unsigned int netlib___alloc_ior(struct IOR **);
unsigned int netlib___free_ior(struct IOR *);
unsigned int netlib___alloc_dnsreq(struct DNSREQ **);
unsigned int netlib___free_dnsreq(struct DNSREQ *);
#endif
#endif /* NETLIB_H_LOADED */