1 /******************************************************************************
2   Copyright (c) 1992, 1995, 1996 Xerox Corporation.  All rights reserved.
3   Portions of this code were written by Stephen White, aka ghond.
4   Use and copying of this software and preparation of derivative works based
5   upon this software are permitted.  Any distribution of this software or
6   derivative works must comply with all applicable United States export
7   control laws.  This software is made available AS IS, and Xerox Corporation
8   makes no warranty about the software, its performance or its conformity to
9   any specification.  Any person obtaining a copy of this software is requested
10   to send their name and post office or electronic mail address to:
11     Pavel Curtis
12     Xerox PARC
13     3333 Coyote Hill Rd.
14     Palo Alto, CA 94304
15     Pavel@Xerox.Com
16  *****************************************************************************/
17 
18 #ifndef Options_h
19 #define Options_h 1
20 
21 /******************************************************************************
22  * The server is prepared to keep a log of every command entered by players
23  * since the last checkpoint.  The log is flushed whenever a checkpoint is
24  * successfully begun and is dumped into the server log when and if the server
25  * panics.  Define LOG_COMMANDS to enable this logging.
26  */
27 
28 /* #define LOG_COMMANDS */
29 
30 /******************************************************************************
31  * The server normally forks a separate process to make database checkpoints;
32  * the original process continues to service user commands as usual while the
33  * new process writes out the contents of its copy of memory to a disk file.
34  * This checkpointing process can take quite a while, depending on how big your
35  * database is, so it's usually quite convenient that the server can continue
36  * to be responsive while this is taking place.  On some systems, however,
37  * there may not be enough memory to support two simultaneously running server
38  * processes.  Define UNFORKED_CHECKPOINTS to disable server forking for
39  * checkpoints.
40  */
41 
42 /* #define UNFORKED_CHECKPOINTS */
43 
44 /******************************************************************************
45  * If OUT_OF_BAND_PREFIX is defined as a non-empty string, then any lines of
46  * input from any player that begin with that prefix will bypass both normal
47  * command parsing and any pending read()ing task, instead spawning a server
48  * task invoking #0:do_out_of_band_command(word-list).  This is intended for
49  * use by fancy clients that need to send reliably-understood messages to the
50  * server.
51  */
52 
53 #define OUT_OF_BAND_PREFIX "#$#"
54 
55 /******************************************************************************
56  * The following constants define the execution limits placed on all MOO tasks.
57  *
58  * DEFAULT_MAX_STACK_DEPTH is the default maximum depth allowed for the MOO
59  *	verb-call stack, the maximum number of dynamically-nested calls at any
60  *	given time.  If defined in the database and larger than this default,
61  *	$server_options.max_stack_depth overrides this default.
62  * DEFAULT_FG_TICKS and DEFAULT_BG_TICKS are the default maximum numbers of
63  *	`ticks' (basic operations) any task is allowed to use without
64  *	suspending.  If defined in the database, $server_options.fg_ticks and
65  *	$server_options.bg_ticks override these defaults.
66  * DEFAULT_FG_SECONDS and DEFAULT_BG_SECONDS are the default maximum numbers of
67  *	real-time seconds any task is allowed to use without suspending.  If
68  *	defined in the database, $server_options.fg_seconds and
69  *	$server_options.bg_seconds override these defaults.
70  *
71  * The *FG* constants are used only for `foreground' tasks (those started by
72  * either player input or the server's initiative and that have never
73  * suspended); the *BG* constants are used only for `background' tasks (forked
74  * tasks and those of any kind that have suspended).
75  *
76  * The values given below are documented in the LambdaMOO Programmer's Manual,
77  * so they should either be left as they are or else the manual should be
78  * updated.
79  */
80 
81 #define DEFAULT_MAX_STACK_DEPTH	50
82 
83 #define DEFAULT_FG_TICKS	30000
84 #define DEFAULT_BG_TICKS	15000
85 
86 #define DEFAULT_FG_SECONDS	5
87 #define DEFAULT_BG_SECONDS	3
88 
89 /******************************************************************************
90  * NETWORK_PROTOCOL must be defined as one of the following:
91  *
92  * NP_SINGLE	The server will accept only one user at a time, communicating
93  *		with them using the standard input and output streams of the
94  *		server itself.
95  * NP_TCP	The server will use TCP/IP protocols, such as are used by the
96  *		Internet `telnet' command.
97  * NP_LOCAL	The server will use a non-networking mechanism, entirely local
98  *		to the machine on which the server is running.  Depending on
99  *		the value of NETWORK_STYLE, below, this will be either UNIX-
100  *		domain sockets (NS_BSD) or named pipes (NS_SYSV).
101  *
102  * If NP_TCP is selected, then DEFAULT_PORT is the TCP port number on which the
103  * server listens when no port argument is given on the command line.
104  *
105  * If NP_LOCAL is selected, then DEFAULT_CONNECT_FILE is the name of the UNIX
106  * pseudo-file through which the server will listen for connections when no
107  * file name is given on the command line.
108  */
109 
110 #define NETWORK_PROTOCOL 	NP_TCP
111 
112 #define DEFAULT_PORT 		7777
113 #define DEFAULT_CONNECT_FILE	"/tmp/.MOO-server"
114 
115 /******************************************************************************
116  * If NETWORK_PROTOCOL is not defined as NP_SINGLE, then NETWORK_STYLE must be
117  * defined as one of the following:
118  *
119  * NS_BSD	The server will use implementation techniques appropriate to a
120  *		BSD-style UNIX system.
121  * NS_SYSV	The server will use implementation techniques appropriate to an
122  *		AT&T UNIX System V system.
123  */
124 
125 #define NETWORK_STYLE NS_BSD
126 
127 /******************************************************************************
128  * If NETWORK_PROTOCOL is not defined as NP_SINGLE, then MPLEX_STYLE must be
129  * defined as one of the following:
130  *
131  * MP_SELECT	The server will assume that the select() system call exists.
132  * MP_POLL	The server will assume that the poll() system call exists and
133  *		that, if NETWORK_PROTOCOL is NP_LOCAL above, it works for
134  *		named pipes (FIFOs).
135  * MP_FAKE	The server will use a nasty trick that works only if you've
136  *		defined NETWORK_PROTOCOL as NP_LOCAL and NETWORK_STYLE as
137  *		NS_SYSV above.
138  *
139  * Usually, it works best to leave MPLEX_STYLE undefined and let the code at
140  * the bottom of this file pick the right value.
141  */
142 
143 /* #define MPLEX_STYLE MP_POLL */
144 
145 /******************************************************************************
146  * Define OUTBOUND_NETWORK to enable the built-in MOO function
147  * open_network_connection(), which allows (only) wizard-owned MOO code to make
148  * outbound network connections from the server.
149  * *** THINK VERY HARD BEFORE ENABLING THIS FUNCTION ***
150  * In some contexts, this could represent a serious breach of security.  By
151  * default, the open_network_connection() function is disabled, always raising
152  * E_PERM when called.
153  *
154  * Note: OUTBOUND_NETWORK may not be defined if NETWORK_PROTOCOL is either
155  *	 NP_SINGLE or NP_LOCAL.
156  */
157 
158 /* #define OUTBOUND_NETWORK */
159 
160 /******************************************************************************
161  * The following constants define certain aspects of the server's network
162  * behavior if NETWORK_PROTOCOL is not defined as NP_SINGLE.
163  *
164  * MAX_QUEUED_OUTPUT is the maximum number of output characters the server is
165  *		     willing to buffer for any given network connection before
166  *		     discarding old output to make way for new.  The server
167  *		     only discards output after attempting to send as much as
168  *		     possible on the connection without blocking.
169  * MAX_QUEUED_INPUT is the maximum number of input characters the server is
170  *		    willing to buffer from any given network connection before
171  *		    it stops reading from the connection at all.  The server
172  *		    starts reading from the connection again once most of the
173  *		    buffered input is consumed.
174  * DEFAULT_CONNECT_TIMEOUT is the default number of seconds an un-logged-in
175  *			   connection is allowed to remain idle without being
176  *			   forcibly closed by the server; this can be
177  *			   overridden by defining the `connect_timeout'
178  *			   property on $server_options or on L, for connections
179  *			   accepted by a given listener L.
180  */
181 
182 #define MAX_QUEUED_OUTPUT	65536
183 #define MAX_QUEUED_INPUT	MAX_QUEUED_OUTPUT
184 #define DEFAULT_CONNECT_TIMEOUT	300
185 
186 /******************************************************************************
187  * The server maintains a cache of the most recently used patterns from calls
188  * to the match() and rmatch() built-in functions.  PATTERN_CACHE_SIZE controls
189  * how many past patterns are remembered by the server.  Do not set it to a
190  * number less than 1.
191  */
192 
193 #define PATTERN_CACHE_SIZE	20
194 
195 /******************************************************************************
196  * If you don't plan on using protecting built-in properties (like
197  * .name and .location), define IGNORE_PROP_PROTECTED.  The extra
198  * property lookups on every reference to a built-in property are
199  * expensive.
200  ******************************************************************************
201  */
202 
203 #define IGNORE_PROP_PROTECTED
204 
205 /******************************************************************************
206  * The code generator can now recognize situations where the code will not
207  * refer to the value of a variable again and generate opcodes that will
208  * keep the interpreter from holding references to the value in the runtime
209  * environment variable slot.  Before, when doing something like x=f(x), the
210  * interpreter was guaranteed to have a reference to the value of x while f()
211  * was running, meaning that f() always had to copy x to modify it.  With
212  * BYTECODE_REDUCE_REF enabled, f() could be called with the last reference
213  * to the value of x.  So for example, x={@x,y} can (if there are no other
214  * references to the value of x in variables or properties) just append to
215  * x rather than make a copy and append to that.  If it *does* have to copy,
216  * the next time (if it's in a loop) it will have the only reference to the
217  * copy and then it can take advantage.
218  *
219  * NOTE WELL    NOTE WELL    NOTE WELL    NOTE WELL    NOTE WELL
220  *
221  * This option affects the length of certain bytecode sequences.
222  * Suspended tasks in a database from a server built with this option
223  * are not guaranteed to work with a server built without this option,
224  * and vice versa.  It is safe to flip this switch only if there are
225  * no suspended tasks in the database you are loading.  (It might work
226  * anyway, but hey, it's your database.)  This restriction will be
227  * lifted in a future version of the server software.  Consider this
228  * option as being BETA QUALITY until then.
229  *
230  * NOTE WELL    NOTE WELL    NOTE WELL    NOTE WELL    NOTE WELL
231  *
232  ****************************************************************************** */
233 /* #define BYTECODE_REDUCE_REF */
234 
235 #ifdef BYTECODE_REDUCE_REF
236 #error Think carefully before enabling BYTECODE_REDUCE_REF.  This feature is still beta.  Comment out this line if you are sure.
237 #endif
238 
239 /******************************************************************************
240  * This package comes with a copy of the implementation of malloc() from GNU
241  * Emacs.  This is a very nice and reasonably portable implementation, but some
242  * systems, notably the NeXT machine, won't allow programs to provide their own
243  * implementations of standard C functions.  Also, the GNU malloc()
244  * implementation uses a fair amount more memory than some system-supplied
245  * ones, though it does allow for better debugging support.  Define
246  * USE_GNU_MALLOC to enable the use of the GNU malloc() implementation.
247  ******************************************************************************
248  * NOTE: This switch is now officially deprecated; it is recommended that you
249  *	 avoid its use.  The GNU code is no longer as portable as once it might
250  *	 have been, and it causes compilation errors on many systems.  If you
251  *	 do enable it, and then experience compilation problems in the file
252  *	 `gnu_malloc.c', your first step should be to re-disable its use.  This
253  *	 option may be completely removed in a later release of the server.
254  ******************************************************************************
255  */
256 
257 /* #define USE_GNU_MALLOC */
258 
259 /*****************************************************************************
260  ********** You shouldn't need to change anything below this point. **********
261  *****************************************************************************/
262 
263 #ifndef OUT_OF_BAND_PREFIX
264 #define OUT_OF_BAND_PREFIX ""
265 #endif
266 
267 #if PATTERN_CACHE_SIZE < 1
268 #  error Illegal match() pattern cache size!
269 #endif
270 
271 #define NP_SINGLE	1
272 #define NP_TCP		2
273 #define NP_LOCAL	3
274 
275 #define NS_BSD		1
276 #define NS_SYSV		2
277 
278 #define MP_SELECT	1
279 #define MP_POLL		2
280 #define MP_FAKE		3
281 
282 #include "config.h"
283 
284 #if NETWORK_PROTOCOL != NP_SINGLE  &&  !defined(MPLEX_STYLE)
285 #  if NETWORK_STYLE == NS_BSD
286 #    if HAVE_SELECT
287 #      define MPLEX_STYLE MP_SELECT
288 #    else
289        #error You cannot use BSD sockets without having select()!
290 #    endif
291 #  else				/* NETWORK_STYLE == NS_SYSV */
292 #    if NETWORK_PROTOCOL == NP_LOCAL
293 #      if SELECT_WORKS_ON_FIFOS
294 #        define MPLEX_STYLE MP_SELECT
295 #      else
296 #        if POLL_WORKS_ON_FIFOS
297 #	   define MPLEX_STYLE MP_POLL
298 #	 else
299 #	   if FSTAT_WORKS_ON_FIFOS
300 #	     define MPLEX_STYLE MP_FAKE
301 #	   else
302 	     #error I need to be able to do a multiplexing wait on FIFOs!
303 #	   endif
304 #	 endif
305 #      endif
306 #    else			/* It's a TLI-based networking protocol */
307 #      if HAVE_POLL
308 #        define MPLEX_STYLE MP_POLL
309 #      else
310          #error You cannot use TLI without having poll()!
311 #      endif
312 #    endif
313 #  endif
314 #endif
315 
316 #if (NETWORK_PROTOCOL == NP_LOCAL || NETWORK_PROTOCOL == NP_SINGLE) && defined(OUTBOUND_NETWORK)
317 #  error You cannot define "OUTBOUND_NETWORK" with that "NETWORK_PROTOCOL"
318 #endif
319 
320 #if NETWORK_PROTOCOL != NP_LOCAL && NETWORK_PROTOCOL != NP_SINGLE && NETWORK_PROTOCOL != NP_TCP
321 #  error Illegal value for "NETWORK_PROTOCOL"
322 #endif
323 
324 #if NETWORK_STYLE != NS_BSD && NETWORK_STYLE != NS_SYSV
325 #  error Illegal value for "NETWORK_STYLE"
326 #endif
327 
328 #if defined(MPLEX_STYLE) 	\
329     && MPLEX_STYLE != MP_SELECT \
330     && MPLEX_STYLE != MP_POLL \
331     && MPLEX_STYLE != MP_FAKE
332 #  error Illegal value for "MPLEX_STYLE"
333 #endif
334 
335 #endif				/* !Options_h */
336 
337 /*
338  * $Log: options.h,v $
339  * Revision 1.7  2000/01/11 02:05:27  nop
340  * More doc tweaking, really warn about BYTECODE_REDUCE_REF.
341  *
342  * Revision 1.6  2000/01/09 22:20:15  nop
343  * Round one of doc cleanup.
344  *
345  * Revision 1.5  1999/08/09 04:09:54  nop
346  * Turn up the buffer sizes a notch.  They're still really too small...
347  *
348  * Revision 1.4  1998/12/14 13:18:41  nop
349  * Merge UNSAFE_OPTS (ref fixups); fix Log tag placement to fit CVS whims
350  *
351  * Revision 1.3.2.1  1997/09/09 07:01:17  bjj
352  * Change bytecode generation so that x=f(x) calls f() without holding a ref
353  * to the value of x in the variable slot.  See the options.h comment for
354  * BYTECODE_REDUCE_REF for more details.
355  *
356  * This checkin also makes x[y]=z (OP_INDEXSET) take advantage of that (that
357  * new code is not conditional and still works either way).
358  *
359  * Revision 1.3  1997/03/03 06:14:45  nop
360  * Nobody actually uses protected properties.  Make IGNORE_PROP_PROTECTED
361  * the default.
362  *
363  * Revision 1.2  1997/03/03 04:19:13  nop
364  * GNU Indent normalization
365  *
366  * Revision 1.1.1.1  1997/03/03 03:45:04  nop
367  * LambdaMOO 1.8.0p5
368  *
369  * Revision 2.5  1996/03/19  07:13:35  pavel
370  * Changed CONNECT_TIMEOUT into DEFAULT_CONNECT_TIMEOUT.  Release 1.8.0p2.
371  *
372  * Revision 2.4  1996/03/10  01:12:55  pavel
373  * Added definitions of DEFAULT_PORT and DEFAULT_CONNECT_FILE, moved here
374  * from elsewhere.  Release 1.8.0.
375  *
376  * Revision 2.3  1996/02/08  06:15:51  pavel
377  * Updated copyright notice for 1996.  Release 1.8.0beta1.
378  *
379  * Revision 2.2  1995/12/31  00:06:58  pavel
380  * Clarified that OUTBOUND_NETWORK may not be defined for non-TCP
381  * configurations.  Release 1.8.0alpha4.
382  *
383  * Revision 2.1  1995/12/11  08:07:02  pavel
384  * Moved USE_GNU_MALLOC to a less prominent place in the file.
385  * Release 1.8.0alpha2.
386  *
387  * Revision 2.0  1995/11/30  04:53:59  pavel
388  * New baseline version, corresponding to release 1.8.0alpha1.
389  *
390  * Revision 1.11  1992/10/23  23:03:47  pavel
391  * Added copyright notice.
392  *
393  * Revision 1.10  1992/10/23  22:21:10  pavel
394  * Fixed MPLEX_STYLE-defaulting code to avoid assuming that select() always
395  * works on FIFOs by conditionalizing on SELECT_WORKS_ON_FIFOS rather than
396  * HAVE_SELECT.
397  *
398  * Revision 1.9  1992/10/21  03:02:35  pavel
399  * Converted to use new automatic configuration system.
400  *
401  * Revision 1.8  1992/10/17  20:20:16  pavel
402  * Generalize treatment of system-dependent replacements for rand().
403  * Allow for systems that don't have rename() and/or remove().
404  *
405  * Revision 1.7  1992/10/06  18:23:07  pavel
406  * Dyked out useless XNS support and fixed a bug in the default definition of
407  * MPLEX_STYLE.
408  *
409  * Revision 1.6  1992/09/23  17:16:25  pavel
410  * Added definitions of NETWORK_PROTOCOL etc. to support new networking
411  * architecture.
412  *
413  * Revision 1.5  1992/09/11  21:17:54  pavel
414  * Reset to refrain from defining SINGLE_USER in the distribution.
415  *
416  * Revision 1.4  1992/09/03  23:52:45  pavel
417  * Added support for multiple complete network implementations.
418  *
419  * Revision 1.3  1992/08/21  01:01:22  pavel
420  * Radically reorganized and verbosely commented to make it easy for people to
421  * understand what all of the configuration options mean.
422  *
423  * Moved all of the -DFOO options out of the Makefile and into here.
424  *
425  * Revision 1.2  1992/08/20  17:33:54  pavel
426  * Added #define for OUT_OF_BAND_PREFIX.
427  *
428  * Revision 1.1  1992/07/20  23:23:12  pavel
429  * Initial RCS-controlled version.
430  */
431