1 /*****************************************************************************/
5 /* Disassembler configuration file handling */
9 /* (C) 2000 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
37 /* Microsoft compiler */
54 /*****************************************************************************/
56 /*****************************************************************************/
60 static void GlobalSection (void)
61 /* Parse a global section */
63 static const IdentTok GlobalDefs[] = {
64 { "INPUTNAME", CFGTOK_INPUTNAME },
65 { "OUTPUTNAME", CFGTOK_OUTPUTNAME },
66 { "PAGELENGTH", CFGTOK_PAGELENGTH },
72 /* Expect the opening curly brace */
75 /* Look for section tokens */
76 while (CfgTok != CFGTOK_RCURLY) {
78 /* Convert to special token */
79 CfgSpecialToken (GlobalDefs, ENTRY_COUNT (GlobalDefs), "Global directive");
81 /* Look at the token */
84 case CFGTOK_INPUTNAME:
88 CfgError ("Input file name already given");
90 InFile = xstrdup (CfgSVal);
94 case CFGTOK_OUTPUTNAME:
98 CfgError ("Output file name already given");
100 OutFile = xstrdup (CfgSVal);
104 case CFGTOK_PAGELENGTH:
108 CfgRangeCheck (MIN_PAGE_LEN, MAX_PAGE_LEN);
110 PageLength = CfgIVal;
115 /* Directive is followed by a semicolon */
120 /* Consume the closing brace */
126 static void RangeSection (void)
127 /* Parse a range section */
129 static const IdentTok RangeDefs[] = {
130 { "START", CFGTOK_START },
131 { "END", CFGTOK_END },
132 { "TYPE", CFGTOK_TYPE },
138 /* Expect the opening curly brace */
141 /* Look for section tokens */
142 while (CfgTok != CFGTOK_RCURLY) {
147 /* Consume the closing brace */
153 static void LabelSection (void)
154 /* Parse a label section */
156 static const IdentTok Globals[] = {
157 { "INPUTNAMEL", CFGTOK_INPUTNAME },
158 { "OUTPUTNAME", CFGTOK_OUTPUTNAME },
159 { "PAGELENGTH", CFGTOK_PAGELENGTH },
165 /* Expect the opening curly brace */
168 /* Look for section tokens */
169 while (CfgTok != CFGTOK_RCURLY) {
174 /* Consume the closing brace */
180 static void CfgParse (void)
181 /* Parse the config file */
183 static const IdentTok Globals[] = {
184 { "GLOBAL", CFGTOK_GLOBAL },
185 { "RANGE", CFGTOK_RANGE },
186 { "LABEL", CFGTOK_LABEL },
189 while (CfgTok != CFGTOK_EOF) {
191 /* Convert an identifier into a token */
192 CfgSpecialToken (Globals, ENTRY_COUNT (Globals), "Config directive");
194 /* Check the token */
211 /* Semicolon expected */
219 /* Read the configuration if a configuration file exists */
221 /* Check if we have a config file given */
222 if (!CfgAvail() || access (CfgGetName(), 0) != 0) {
223 /* No name given or file not found */
227 /* Open the config file */
230 /* Parse the config file */