|
|
1.1 root 1: /* startup.h */
2:
3: /* Synchronet main/telnet server thread startup structure */
4:
5: /* $Id: startup.h,v 1.61 2006/12/31 11:15:25 rswindell Exp $ */
6:
7: /****************************************************************************
8: * @format.tab-size 4 (Plain Text/Source Code File Header) *
9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
10: * *
11: * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html *
12: * *
13: * This program is free software; you can redistribute it and/or *
14: * modify it under the terms of the GNU General Public License *
15: * as published by the Free Software Foundation; either version 2 *
16: * of the License, or (at your option) any later version. *
17: * See the GNU General Public License for more details: gpl.txt or *
18: * http://www.fsf.org/copyleft/gpl.html *
19: * *
20: * Anonymous FTP access to the most recent released source is available at *
21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
22: * *
23: * Anonymous CVS access to the development source and modification history *
24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: *
25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login *
26: * (just hit return, no password is necessary) *
27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src *
28: * *
29: * For Synchronet coding style and modification guidelines, see *
30: * http://www.synchro.net/source.html *
31: * *
32: * You are encouraged to submit any modifications (preferably in Unix diff *
33: * format) via e-mail to [email protected] *
34: * *
35: * Note: If this box doesn't appear square, then you need to fix your tabs. *
36: ****************************************************************************/
37:
38: #ifndef _STARTUP_H_
39: #define _STARTUP_H_
40:
41: #include <stddef.h> /* offsetof */
42: #include "client.h"
43: #include "ringbuf.h"
44: #include "semwrap.h" /* sem_t */
45: #include "ini_file.h" /* INI_MAX_VALUE_LEN */
46: #include "sbbsdefs.h" /* LOG_* (syslog.h) values */
47:
48: typedef struct {
49: ulong max_bytes; /* max allocated bytes before garbage collection */
50: ulong cx_stack; /* bytes for script execution stack */
51: ulong thread_stack; /* limit of stack size for native execution thread */
52: ulong branch_limit; /* maximum number of branches (for infinite loop detection) */
53: ulong gc_interval; /* number of branches between garbage collection attempts */
54: ulong yield_interval; /* number of branches between time-slice yields */
55: } js_startup_t;
56:
57: typedef struct {
58:
59: char ctrl_dir[INI_MAX_VALUE_LEN];
60: char temp_dir[INI_MAX_VALUE_LEN];
61: char host_name[INI_MAX_VALUE_LEN];
62: ushort sem_chk_freq;
63: ulong interface_addr;
64: int log_level;
65: js_startup_t js;
66: uint bind_retry_count; /* Number of times to retry bind() calls */
67: uint bind_retry_delay; /* Time to wait between each bind() retry */
68:
69: } global_startup_t;
70:
71: typedef struct {
72:
73: DWORD size; /* sizeof(bbs_struct_t) */
74: WORD first_node;
75: WORD last_node;
76: WORD telnet_port;
77: WORD rlogin_port;
78: WORD ssh_port;
79: WORD outbuf_highwater_mark; /* output block size control */
80: WORD outbuf_drain_timeout;
81: WORD sem_chk_freq; /* semaphore file checking frequency (in seconds) */
82: DWORD telnet_interface;
83: DWORD options; /* See BBS_OPT definitions */
84: DWORD rlogin_interface;
85: DWORD ssh_interface;
86: RingBuf** node_spybuf; /* Spy output buffer (each node) */
87: RingBuf** node_inbuf; /* User input buffer (each node) */
88: sem_t** node_spysem; /* Spy output semaphore (each node) */
89:
90: void* cbdata; /* Private data passed to callbacks */
91:
92: /* Callbacks (NULL if unused) */
93: int (*lputs)(void*, int, char*); /* Log - put string */
94: int (*event_lputs)(int, char*); /* Event log - put string */
95: void (*status)(void*, char*);
96: void (*started)(void*);
97: void (*recycle)(void*);
98: void (*terminated)(void*, int code);
99: void (*clients)(void*, int active);
100: void (*thread_up)(void*, BOOL up, BOOL setuid);
101: void (*socket_open)(void*, BOOL open);
102: void (*client_on)(void*, BOOL on, int sock, client_t*, BOOL update);
103: BOOL (*seteuid)(BOOL user); /* Set Unix uid for thread (bind) */
104: BOOL (*setuid)(BOOL force);
105:
106: /* Paths */
107: char ctrl_dir[128];
108: char dosemu_path[128];
109: char temp_dir[128];
110: char answer_sound[128];
111: char hangup_sound[128];
112:
113: /* Miscellaneous */
114: char xtrn_term_ansi[32]; /* external ANSI terminal type (e.g. "ansi-bbs") */
115: char xtrn_term_dumb[32]; /* external dumb terminal type (e.g. "dumb") */
116: char host_name[128];
117: BOOL recycle_now;
118: BOOL shutdown_now;
119: int log_level;
120: uint bind_retry_count; /* Number of times to retry bind() calls */
121: uint bind_retry_delay; /* Time to wait between each bind() retry */
122:
123: /* JavaScript operating parameters */
124: js_startup_t js;
125:
126: } bbs_startup_t;
127:
128: /* startup options that requires re-initialization/recycle when changed */
129: #define OFFSET_AND_SIZE(s, f) { offsetof(s,f), sizeof(((s *)0)->f) }
130:
131: #if defined(STARTUP_INIT_FIELD_TABLES)
132: static struct init_field {
133: size_t offset;
134: size_t size;
135: } bbs_init_fields[] = {
136: OFFSET_AND_SIZE(bbs_startup_t,first_node)
137: ,OFFSET_AND_SIZE(bbs_startup_t,last_node)
138: ,OFFSET_AND_SIZE(bbs_startup_t,telnet_port)
139: ,OFFSET_AND_SIZE(bbs_startup_t,rlogin_port)
140: ,OFFSET_AND_SIZE(bbs_startup_t,telnet_interface)
141: ,OFFSET_AND_SIZE(bbs_startup_t,rlogin_interface)
142: ,OFFSET_AND_SIZE(bbs_startup_t,ctrl_dir)
143: ,OFFSET_AND_SIZE(bbs_startup_t,temp_dir)
144: ,{ 0,0 } /* terminator */
145: };
146: #endif
147:
148: #define BBS_OPT_XTRN_MINIMIZED (1<<1) /* Run externals minimized */
149: #define BBS_OPT_AUTO_LOGON (1<<2) /* Auto-logon via IP */
150: #define BBS_OPT_DEBUG_TELNET (1<<3) /* Debug telnet commands */
151: #define BBS_OPT_SYSOP_AVAILABLE (1<<4) /* Available for chat */
152: #define BBS_OPT_ALLOW_RLOGIN (1<<5) /* Allow logins via BSD RLogin */
153: #define BBS_OPT_USE_2ND_RLOGIN (1<<6) /* Use 2nd username in BSD RLogin */
154: #define BBS_OPT_NO_QWK_EVENTS (1<<7) /* Don't run QWK-related events */
155: #define BBS_OPT_NO_TELNET_GA (1<<8) /* Don't send periodic Telnet GAs */
156: #define BBS_OPT_NO_EVENTS (1<<9) /* Don't run event thread */
157: #define BBS_OPT_NO_SPY_SOCKETS (1<<10) /* Don't create spy sockets */
158: #define BBS_OPT_NO_HOST_LOOKUP (1<<11)
159: #define BBS_OPT_ALLOW_SSH (1<<12) /* Allow logins via BSD SSH */
160: #define BBS_OPT_NO_RECYCLE (1<<27) /* Disable recycling of server */
161: #define BBS_OPT_GET_IDENT (1<<28) /* Get Identity (RFC 1413) */
162: #define BBS_OPT_NO_JAVASCRIPT (1<<29) /* JavaScript disabled */
163: #define BBS_OPT_LOCAL_TIMEZONE (1<<30) /* Don't force UTC/GMT */
164: #define BBS_OPT_MUTE (1<<31) /* Mute sounds */
165:
166: /* bbs_startup_t.options bits that require re-init/recycle when changed */
167: #define BBS_INIT_OPTS (BBS_OPT_ALLOW_RLOGIN|BBS_OPT_ALLOW_SSH|BBS_OPT_NO_EVENTS|BBS_OPT_NO_SPY_SOCKETS \
168: |BBS_OPT_NO_JAVASCRIPT|BBS_OPT_LOCAL_TIMEZONE)
169:
170: #if defined(STARTUP_INI_BITDESC_TABLES)
171: static ini_bitdesc_t bbs_options[] = {
172:
173: { BBS_OPT_XTRN_MINIMIZED ,"XTRN_MINIMIZED" },
174: { BBS_OPT_AUTO_LOGON ,"AUTO_LOGON" },
175: { BBS_OPT_DEBUG_TELNET ,"DEBUG_TELNET" },
176: { BBS_OPT_SYSOP_AVAILABLE ,"SYSOP_AVAILABLE" },
177: { BBS_OPT_ALLOW_RLOGIN ,"ALLOW_RLOGIN" },
178: { BBS_OPT_USE_2ND_RLOGIN ,"USE_2ND_RLOGIN" },
179: { BBS_OPT_NO_QWK_EVENTS ,"NO_QWK_EVENTS" },
180: { BBS_OPT_NO_TELNET_GA ,"NO_TELNET_GA" },
181: { BBS_OPT_NO_EVENTS ,"NO_EVENTS" },
182: { BBS_OPT_NO_HOST_LOOKUP ,"NO_HOST_LOOKUP" },
183: { BBS_OPT_NO_SPY_SOCKETS ,"NO_SPY_SOCKETS" },
184: { BBS_OPT_ALLOW_SSH ,"ALLOW_SSH" },
185: { BBS_OPT_NO_RECYCLE ,"NO_RECYCLE" },
186: { BBS_OPT_GET_IDENT ,"GET_IDENT" },
187: { BBS_OPT_NO_JAVASCRIPT ,"NO_JAVASCRIPT" },
188: { BBS_OPT_LOCAL_TIMEZONE ,"LOCAL_TIMEZONE" },
189: { BBS_OPT_MUTE ,"MUTE" },
190: /* terminator */
191: { 0 ,NULL }
192: };
193:
194: #endif
195:
196: #ifdef __cplusplus
197: extern "C" {
198: #endif
199:
200: #ifdef DLLEXPORT
201: #undef DLLEXPORT
202: #endif
203: #ifdef DLLCALL
204: #undef DLLCALL
205: #endif
206:
207: #ifdef _WIN32
208: #ifdef SBBS_EXPORTS
209: #define DLLEXPORT __declspec(dllexport)
210: #else
211: #define DLLEXPORT __declspec(dllimport)
212: #endif
213: #ifdef __BORLANDC__
214: #define DLLCALL __stdcall
215: #else
216: #define DLLCALL
217: #endif
218: #else
219: #define DLLEXPORT
220: #define DLLCALL
221: #endif
222:
223: /* arg is pointer to static bbs_startup_t* */
224: DLLEXPORT void DLLCALL bbs_thread(void* arg);
225: DLLEXPORT void DLLCALL bbs_terminate(void);
226: DLLEXPORT const char* DLLCALL js_ver(void);
227: DLLEXPORT const char* DLLCALL bbs_ver(void);
228: DLLEXPORT long DLLCALL bbs_ver_num(void);
229:
230: #ifdef __cplusplus
231: }
232: #endif
233:
234: #endif /* Don't add anything after this line */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.