1 /*
2  * This file is part of DGD, https://github.com/dworkin/dgd
3  * Copyright (C) 1993-2010 Dworkin B.V.
4  * Copyright (C) 2010,2012-2013 DGD Authors (see the commit log for details)
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as
8  * published by the Free Software Foundation, either version 3 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 /* these may be changed, but sizeof(type) <= sizeof(int) */
21 typedef unsigned short uindex;
22 # define UINDEX_MAX	USHRT_MAX
23 
24 typedef uindex sector;
25 # define SW_UNUSED	UINDEX_MAX
26 
27 /* sizeof(ssizet) <= sizeof(uindex) */
28 typedef unsigned short ssizet;
29 # define SSIZET_MAX	USHRT_MAX
30 
31 /* eindex can be anything */
32 typedef unsigned char eindex;
33 # define EINDEX_MAX	UCHAR_MAX
34 # define EINDEX(e)	UCHAR(e)
35 
36 typedef unsigned char kfindex;
37 # define KFTAB_SIZE	256
38 # define KFCRYPT_SIZE	128
39 
40 
41 /*
42  * Gamedriver configuration.  Hash table sizes should be powers of two.
43  */
44 
45 /* general */
46 # define BUF_SIZE	FS_BLOCK_SIZE	/* I/O buffer size */
47 # define MAX_LINE_SIZE	1024	/* max. line size in ed and lex (power of 2) */
48 # define STRINGSZ	256	/* general (internal) string size */
49 # define STRMAPHASHSZ	20	/* # characters to hash of map string indices */
50 # define STRMERGETABSZ	1024	/* general string merge table size */
51 # define STRMERGEHASHSZ	20	/* # characters in merge strings to hash */
52 # define ARRMERGETABSZ	1024	/* general array merge table size */
53 # define OBJHASHSZ	256	/* # characters in object names to hash */
54 # define COPATCHHTABSZ	64	/* callout patch hash table size */
55 # define OBJPATCHHTABSZ	128	/* object patch hash table size */
56 # define CMPLIMIT	2048	/* compress strings if >= CMPLIMIT */
57 # define SWAPCHUNKSZ	10	/* # objects reconstructed in main loop */
58 
59 /* comm */
60 # define INBUF_SIZE	2048	/* telnet input buffer size */
61 # define OUTBUF_SIZE	8192	/* telnet output buffer size */
62 # define BINBUF_SIZE	8192	/* binary/UDP input buffer size */
63 # define UDPHASHSZ	10	/* # characters in UDP challenge to hash */
64 
65 /* interpreter */
66 # define MIN_STACK	5	/* minimal stack, # arguments in driver calls */
67 # define EXTRA_STACK	32	/* extra space in stack frames */
68 # define MAX_STRLEN	SSIZET_MAX	/* max string length, >= 65535 */
69 # define INHASHSZ	4096	/* instanceof hashtable size */
70 
71 /* parser */
72 # define MAX_AUTOMSZ	6	/* DFA/PDA storage size, in strings */
73 # define PARSERULTABSZ	256	/* size of parse rule hash table */
74 # define PARSERULHASHSZ	10	/* # characters in parse rule symbols to hash */
75 
76 /* editor */
77 # define NR_EDBUFS	3	/* # buffers in editor cache (>= 3) */
78 /*# define TMPFILE_SIZE	2097152 */ /* max. editor tmpfile size */
79 
80 /* lexical scanner */
81 # define MACTABSZ	1024	/* macro hash table size */
82 # define MACHASHSZ	10	/* # characters in macros to hash */
83 
84 /* compiler */
85 # define YYMAXDEPTH	500	/* parser stack size */
86 # define MAX_ERRORS	5	/* max. number of errors during compilation */
87 # define MAX_LOCALS	127	/* max. number of parameters + local vars */
88 # define OMERGETABSZ	128	/* inherit object merge table size */
89 # define VFMERGETABSZ	256	/* variable/function merge table sizes */
90 # define VFMERGEHASHSZ	10	/* # characters in function/variables to hash */
91 # define NTMPVAL	32	/* # of temporary values for LPC->C code */
92 
93 /* builtin type prefix */
94 # define BIPREFIX	"builtin/"
95 # define BIPREFIXLEN	8
96 
97 extern bool		conf_init	(char*, char*, char*, char*, sector*);
98 extern char	       *conf_base_dir	(void);
99 extern char	       *conf_driver	(void);
100 extern char	      **conf_hotboot	(void);
101 extern int		conf_typechecking (void);
102 extern unsigned short	conf_array_size	(void);
103 
104 extern void   conf_dump		(bool, bool);
105 extern Uint   conf_dsize	(char*);
106 extern Uint   conf_dconv	(char*, char*, char*, Uint);
107 extern void   conf_dread	(int, char*, char*, Uint);
108 
109 extern bool   conf_statusi	(frame*, Int, value*);
110 extern array *conf_status	(frame*);
111 extern bool   conf_objecti	(dataspace*, object*, Int, value*);
112 extern array *conf_object	(dataspace*, object*);
113 
114 /* utility functions */
115 extern Int strtoint		(char**);
116