-
Notifications
You must be signed in to change notification settings - Fork 0
/
readcfg.h
447 lines (412 loc) · 11.9 KB
/
readcfg.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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
/*
* readcfg.h -- read config
*
* readcfg.h is a part of binkd project
*
* Copyright (C) 1996-1997 Dima Maloff, 5047/13
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See COPYING.
*/
/*
* $Id: readcfg.h,v 2.42 2013/02/04 12:47:12 gul Exp $
*
* $Log: readcfg.h,v $
* Revision 2.42 2013/02/04 12:47:12 gul
* New config option "listen"
*
* Revision 2.41 2013/02/03 21:37:45 gul
* New option "rename-style [postfix|extension]"
*
* Revision 2.40 2012/01/08 17:34:58 green
* Avoid using MAXHOSTNAMELEN
*
* Revision 2.39 2012/01/03 17:52:32 green
* Implement FSP-1035 (SRV record usage)
* - add SRV enabled getaddrinfo() wrapper (srv_gai.[ch])
* - Unix (libresolv, autodetected) and Win32 support implemented
* - Port information is stored as string now, i.e. may be service name
*
* Revision 2.38 2009/05/31 07:16:17 gul
* Warning: many changes, may be unstable.
* Perl interpreter is now part of config and rerun on config reload.
* Perl 5.10 compatibility.
* Changes in outbound queue managing and sorting.
*
* Revision 2.37 2009/05/27 09:33:52 gul
* perl-var config keyword
* update $hosts by on_call() perl hook not only if it returns 2
*
* Revision 2.36 2009/05/26 13:04:35 gul
* New perl hooks:
* need_reload() - is it needed to reload config
* config_loaded() - after successful reading config
*
* Revision 2.35 2007/10/30 07:33:25 gul
* New config option dont-send-empty
*
* Revision 2.34 2004/11/07 13:52:40 stream
* Automatically rescan outbound after reload of configuration
*
* Revision 2.33 2004/11/07 07:26:36 gul
* New config options zlib-dll and bzlib2-dll
*
* Revision 2.32 2004/10/25 17:04:54 gul
* Process passwords file after all, independent of its place in config.
* Use first password for node if several specified.
*
* Revision 2.31 2004/09/06 10:47:06 val
* bandwidth limiting code advancements, `listed' session state fix
*
* Revision 2.30 2004/09/02 08:56:20 val
* bandwidth limiting config parameter 'limit-rate'
*
* Revision 2.29 2004/01/07 12:23:40 gul
* Remove zaccept keyword, receiving compressed files possibility
* is always on now if binkd was compiled with zlib/bzip2 support.
*
* Revision 2.28 2003/12/26 20:11:32 gul
* Add -d commandline switch - dump parsed config and exit;
* remove 'debugcfg' config token.
*
* Revision 2.27 2003/10/29 21:08:39 gul
* Change include-files structure, relax dependences
*
* Revision 2.26 2003/10/19 12:21:47 gul
* Stream compression
*
* Revision 2.25 2003/10/14 07:20:40 gul
* Fixed typo
*
* Revision 2.24 2003/09/24 07:32:17 val
* bzlib2 compression support, new compression keyword: zlevel
*
* Revision 2.23 2003/09/15 06:57:09 val
* compression support via zlib: config keywords, improvements, OS/2 code
*
* Revision 2.22 2003/09/12 07:37:58 val
* compression support via zlib (preliminary)
*
* Revision 2.21 2003/09/08 16:39:39 stream
* Fixed race conditions when accessing array of nodes in threaded environment
* ("jumpimg node structures")
*
* Revision 2.20 2003/08/26 16:06:27 stream
* Reload configuration on-the fly.
*
* Warning! Lot of code can be broken (Perl for sure).
* Compilation checked only under OS/2-Watcom and NT-MSVC (without Perl)
*
* Revision 2.19 2003/08/23 15:51:51 stream
* Implemented common list routines for all linked records in configuration
*
* Revision 2.18 2003/08/18 07:35:09 val
* multiple changes:
* - hide-aka/present-aka logic
* - address mask matching via pmatch
* - delay_ADR in STATE (define DELAY_ADR removed)
* - ftnaddress_to_str changed to xftnaddress_to_str (old version #define'd)
* - parse_ftnaddress now sets zone to domain default if it's omitted
*
* Revision 2.17 2003/08/14 07:39:36 val
* migrate from vfprintf() to vsnprintf() in Log(), new keyword `nolog'
*
* Revision 2.16 2003/08/11 08:33:16 val
* better error handling in perl hooks
*
* Revision 2.15 2003/07/30 11:01:37 val
* perl-dll keyword can be used even when PERLDL is not defined (does nothing)
*
* Revision 2.14 2003/07/28 10:23:33 val
* Perl DLL dynamic load for Win32, config keyword perl-dll, nmake PERLDL=1
*
* Revision 2.13 2003/07/07 08:33:25 val
* `perl-hooks' config keyword to specify perl script
*
* Revision 2.12 2003/06/12 08:30:57 val
* check pkt header feature, see keyword 'check-pkthdr'
*
* Revision 2.11 2003/06/12 08:21:43 val
* 'skipmask' is replaced with 'skip', which allows more skipping features
*
* Revision 2.10 2003/06/07 08:46:25 gul
* New feature added: shared aka
*
* Revision 2.9 2003/03/10 10:57:45 gul
* Extern declarations moved to header files
*
* Revision 2.8 2003/03/10 10:39:23 gul
* New include file common.h
*
* Revision 2.7 2003/03/01 18:52:49 gul
* use time_t for mtime
*
* Revision 2.6 2003/03/01 15:00:17 gul
* Join skipmask and overwrite into common maskchain
*
* Revision 2.5 2003/02/22 21:32:46 gul
* Amiga Style Outbound support
*
* Revision 2.4 2003/02/22 14:30:18 gul
* Make nNod var static
*
* Revision 2.3 2002/05/11 08:37:32 gul
* Added token deletedirs
*
* Revision 2.2 2002/05/06 19:25:40 gul
* new keyword inboundCase in config
*
* Revision 2.1 2001/08/24 13:23:28 da
* binkd/binkd.c
* binkd/readcfg.c
* binkd/readcfg.h
* binkd/server.c
* binkd/nt/service.c
*
* Revision 2.0 2001/01/10 12:12:39 gul
* Binkd is under CVS again
*
* Revision 1.7 1997/10/23 03:44:03 mff
* +fdinhist, +fdouthist, +root_domain
*
* 1997/07/11 11:51:17 maxb
* Added fdinhist and fdouthist keywords.
*
* Revision 1.6 1997/06/16 05:42:30 mff
* Added binlog and tzoff keywords.
*
* Revision 1.5 1997/03/28 06:36:28 mff
* Added "exec" keyword
*/
#ifndef _readcfg_h
#define _readcfg_h
#include <stdio.h>
#include "Config.h"
#include "btypes.h"
#include "iphdr.h"
typedef struct _BINKD_CONFIG BINKD_CONFIG;
#define MAXINCLUDELEVEL 8
#define MAXCFGLINE 1024
/* val: enum for checks */
typedef enum { A_ALL=-1, A_LST=1, A_UNLST=2, A_PROT=4, A_UNPROT=8 } addrtype;
/* val: use for overwrite and nolog */
struct maskchain
{
struct maskchain *next;
char *mask;
};
/* val: struct for skipmask */
struct skipchain
{
struct skipchain *next;
char *mask;
addrtype atype;
off_t size;
int destr;
};
/* val: struct for hide-aka, present-aka */
struct akachain
{
struct akachain *next;
FTN_ADDR fa;
char *mask;
enum { ACT_UNKNOWN=0, ACT_HIDE, ACT_PRESENT } type;
};
struct listenchain
{
struct listenchain *next;
char addr[42];
char port[MAXSERVNAME + 1];
};
#if defined(WITH_ZLIB) || defined(WITH_BZLIB2)
/* val: struct for zallow, zdeny */
struct zrule
{
struct zrule *next;
char *mask;
enum { ZRULE_ALLOW, ZRULE_DENY } type;
};
#endif
#ifdef BW_LIM
/* val: struct for limit-rate */
struct ratechain
{
struct ratechain *next;
char *mask;
addrtype atype;
long rate;
};
#endif
struct conflist_type
{
struct conflist_type *next;
char *path;
time_t mtime;
};
struct perl_var
{
struct perl_var *next;
char *name, *val;
};
struct _BINKD_CONFIG
{
int usageCount; /* when it reaches zero, config can be freed */
int nAddr; /* total addresses defined */
FTN_ADDR *pAddr; /* array of adresses */
int nNod; /* number of nodes */
FTN_NODE **pNodArray; /* array of pointers to nodes */
int nNodSorted; /* internal flag */
int q_present; /* BSO scan: queue not empty */
char iport[MAXSERVNAME + 1];
char oport[MAXSERVNAME + 1];
int oblksize;
#if defined(WITH_ZLIB) || defined(WITH_BZLIB2)
int zminsize;
int zlevel;
#endif
int nettimeout;
int connect_timeout;
int rescan_delay;
int call_delay;
int max_servers;
int max_clients;
int kill_dup_partial_files;
int kill_old_partial_files;
int kill_old_bsy;
int minfree;
int minfree_nonsecure;
int tries;
int hold;
int hold_skipped;
int backresolv;
int send_if_pwd;
int debugcfg;
int loglevel;
int conlog;
int printq;
int percents;
int tzoff;
int prescan;
enum inbcasetype inboundcase;
int deletedirs;
int havedefnode;
enum dontsendemptytype dontsendempty;
enum renamestyletype renamestyle;
#ifdef AMIGADOS_4D_OUTBOUND
int aso;
#endif
addrtype pkthdr_type;
char *pkthdr_bad;
DEFINE_LIST(conflist_type) config_list;
DEFINE_LIST(_FTN_DOMAIN) pDomains;
DEFINE_LIST(maskchain) overwrite, nolog;
DEFINE_LIST(skipchain) skipmask;
DEFINE_LIST(_RF_RULE) rf_rules;
DEFINE_LIST(_EVT_FLAG) evt_flags;
DEFINE_LIST(akachain) akamask;
DEFINE_LIST(listenchain) listen;
DEFINE_LIST(_SHARED_CHAIN) shares; /* Linked list for shared akas header */
#if defined(WITH_ZLIB) || defined(WITH_BZLIB2)
DEFINE_LIST(zrule) zrules;
#endif
#ifdef BW_LIM
DEFINE_LIST(ratechain) rates;
#endif
#ifdef WITH_PERL
DEFINE_LIST(perl_var) perl_vars;
#endif
/*
#ifdef HTTPS
struct simplelistheader proxylist;
#endif
*/
#ifdef HTTPS
char proxy[BINKD_FQDNLEN + 40];
char socks[BINKD_FQDNLEN + 40];
#endif
char root_domain[BINKD_FQDNLEN + 1];
char sysname[MAXSYSTEMNAME + 1];
char bindaddr[42];
char sysop[MAXSYSOPNAME + 1];
char location[MAXLOCATIONNAME + 1];
char nodeinfo[MAXNODEINFO + 1];
char inbound[MAXPATHLEN + 1];
char inbound_nonsecure[MAXPATHLEN + 1];
char temp_inbound[MAXPATHLEN + 1];
char logpath[MAXPATHLEN + 1];
char binlogpath[MAXPATHLEN + 1];
char fdinhist[MAXPATHLEN + 1];
char fdouthist[MAXPATHLEN + 1];
char pid_file[MAXPATHLEN + 1];
char passwords[MAXPATHLEN + 1];
#ifdef MAILBOX
char tfilebox[MAXPATHLEN + 1]; /* FileBoxes dir */
char bfilebox[MAXPATHLEN + 1]; /* BrakeBoxes dir */
int deleteablebox;
#endif
#if defined (WITH_ZLIB) && defined (ZLIBDL)
char zlib_dll[MAXPATHLEN + 1];
#endif
#if defined (WITH_BZLIB2) && defined (ZLIBDL)
char bzlib2_dll[MAXPATHLEN + 1];
#endif
#ifdef WITH_PERL
char perl_script[MAXPATHLEN + 1];
char perl_dll[MAXPATHLEN + 1];
int perl_strict;
void *perl;
int perl_ok;
#endif
};
extern BINKD_CONFIG *current_config;
#if defined (HAVE_VSYSLOG) && defined (HAVE_FACILITYNAMES)
extern int syslog_facility;
#endif
/*
* Parses and reads the path as a config
* Return 1 if config has been loaded Ok
*/
BINKD_CONFIG *readcfg (char *path);
/*
* Checking for changed config files and reloading if necessary.
* Return 1 if config has been reloaded Ok
*/
int checkcfg (void);
/*
* Dump parsed config
*/
void debug_readcfg (void);
/*
* Locks current config structure and return pointer to it in one
* thread-safe operation
*/
BINKD_CONFIG *lock_current_config(void);
/*
* Increment lock counter on specific config
*/
void lock_config_structure(BINKD_CONFIG *c);
/*
* Release config structure after usage
*/
void unlock_config_structure(BINKD_CONFIG *c, int on_exit);
/*
* Lists
*/
void simplelist_add(struct list_linkpoint *lp, void *data, int size);
void simplelist_free(struct list_linkpoint *lp, void (*destructor)(void *));
/*
* Popular destructors
*/
void destroy_maskchain(void *p);
int get_host_and_port (int n, char *host, char **port, char *src, FTN_ADDR *fa, BINKD_CONFIG *config);
char *mask_test(char *s, struct maskchain *chain);
#if defined(WITH_ZLIB) || defined(WITH_BZLIB2)
struct zrule *zrule_test(int type, char *s, struct zrule *root);
#endif
#ifdef BW_LIM
long parse_rate (char *w, char **err);
char *describe_rate(long rate);
#endif
#endif