1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 1996, 2003 - 3D Realms Entertainment
4 
5 This file is NOT part of Duke Nukem 3D version 1.5 - Atomic Edition
6 However, it is either an older version of a file that is, or is
7 some test code written during the development of Duke Nukem 3D.
8 This file is provided purely for educational interest.
9 
10 Duke Nukem 3D is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14 
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 See the GNU General Public License for more details.
20 
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24 
25 Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
26 Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
27 */
28 //-------------------------------------------------------------------------
29 
30 // scrplib.h
31 
32 #ifndef _scriplib_private
33 #define _scriplib_private
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define SCRIPTSECTIONSTART ('[')
39 #define SCRIPTSECTIONEND   (']')
40 #define SCRIPTENTRYSEPARATOR ('=')
41 #define SCRIPTCOMMENT      (';')
42 #define SCRIPTEOL          ('\n')
43 #define SCRIPTNULL         ('\0')
44 #define SCRIPTSTRINGSEPARATOR ('"')
45 #define SCRIPTHEXFIRST ('0')
46 #define SCRIPTHEXSECOND ('x')
47 #define SCRIPTSPACE     (' ')
48 #define SCRIPTDEFAULTVALUE ('~')
49 #define MAXSCRIPTFILES 20
50 #define SCRIPT(scripthandle,item) (scriptfiles[(scripthandle)]->item)
51 
52 typedef enum
53    {
54    linetype_comment,
55    linetype_section,
56    linetype_entry
57    } linetype_t;
58 
59 typedef struct scriptline
60    {
61    int32  type;
62    void * ptr;
63    struct scriptline *nextline;
64    struct scriptline *prevline;
65    } ScriptLineType;
66 
67 typedef struct scriptentry
68    {
69    char * name;
70    char * value;
71    struct scriptentry *nextentry;
72    struct scriptentry *preventry;
73    } ScriptEntryType;
74 
75 typedef struct scriptsection
76    {
77    char * name;
78    ScriptEntryType      *entries;
79    ScriptLineType       *lastline;
80    struct scriptsection *nextsection;
81    struct scriptsection *prevsection;
82    } ScriptSectionType;
83 
84 typedef struct
85    {
86    ScriptSectionType * script;
87    ScriptSectionType * lastsection;
88    ScriptLineType * scriptlines;
89    char scriptfilename[128];
90    } script_t;
91 
92 /*
93 ==============
94 =
95 = SCRIPT_New
96 =
97 ==============
98 */
99 
100 int32 SCRIPT_New( void );
101 
102 /*
103 ==============
104 =
105 = SCRIPT_Delete
106 =
107 ==============
108 */
109 void SCRIPT_Delete( int32 scripthandle );
110 
111 /*
112 ==============
113 =
114 = SCRIPT_FreeSection
115 =
116 ==============
117 */
118 void SCRIPT_FreeSection( ScriptSectionType * section );
119 
120 /*
121 ==============
122 =
123 = SafeWriteString
124 =
125 ==============
126 */
127 void SafeWriteString (int32 handle, char * string);
128 
129 /*
130 ==============
131 =
132 = SCRIPT_AddLine
133 =
134 ==============
135 */
136 
137 
138 ScriptLineType * SCRIPT_AddLine
139    (
140    ScriptLineType * root,
141    int32 type,
142    void * ptr
143    );
144 
145 /*
146 ==============
147 =
148 = SCRIPT_SectionExists
149 =
150 ==============
151 */
152 ScriptSectionType * SCRIPT_SectionExists
153    (
154    int32 scripthandle,
155    const char * sectionname
156    );
157 
158 /*
159 ==============
160 =
161 = SCRIPT_AddSection
162 =
163 ==============
164 */
165 ScriptSectionType * SCRIPT_AddSection( int32 scripthandle, const char * sectionname );
166 
167 /*
168 ==============
169 =
170 = SCRIPT_EntryExists
171 =
172 ==============
173 */
174 ScriptEntryType * SCRIPT_EntryExists
175    (
176    ScriptSectionType * section,
177    const char * entryname
178    );
179 
180 /*
181 ==============
182 =
183 = SCRIPT_AddEntry
184 =
185 ==============
186 */
187 void SCRIPT_AddEntry
188    (
189    int32 scripthandle,
190    const char * sectionname,
191    const char * entryname,
192    const char * entryvalue
193    );
194 
195 /*
196 ==============
197 =
198 = SCRIPT_DecodeToken
199 =
200 ==============
201 */
202 
203 void SCRIPT_DecodeToken ( int32 scripthandle, const char * str );
204 
205 
206 #ifdef __cplusplus
207 };
208 #endif
209 #endif
210