1 /*****************************************************************************/
5 /* Configuration file scanner for the ld65 linker */
9 /* (C) 1998-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 /*****************************************************************************/
41 /*****************************************************************************/
43 /*****************************************************************************/
47 /* Config file tokens */
62 /* Special identifiers */
120 /* Mapping table entry, special identifier --> token */
121 typedef struct IdentTok_ IdentTok;
123 const char* Ident; /* Identifier */
124 cfgtok_t Tok; /* Token for identifier */
126 #define ENTRY_COUNT(s) (sizeof (s) / sizeof (s [0]))
130 /* Current token and attributes */
131 #define CFG_MAX_IDENT_LEN 255
132 extern cfgtok_t CfgTok;
133 extern char CfgSVal [CFG_MAX_IDENT_LEN+1];
134 extern unsigned long CfgIVal;
137 extern unsigned CfgErrorLine;
138 extern unsigned CfgErrorCol;
142 /*****************************************************************************/
144 /*****************************************************************************/
148 void CfgWarning (const char* Format, ...) attribute((format(printf,1,2)));
149 /* Print a warning message adding file name and line number of the config file */
151 void CfgError (const char* Format, ...) attribute((format(printf,1,2)));
152 /* Print an error message adding file name and line number of the config file */
154 void CfgNextTok (void);
155 /* Read the next token from the input stream */
157 void CfgConsume (cfgtok_t T, const char* Msg);
158 /* Skip a token, print an error message if not found */
160 void CfgConsumeSemi (void);
161 /* Consume a semicolon */
163 void CfgConsumeColon (void);
164 /* Consume a colon */
166 void CfgOptionalComma (void);
167 /* Consume a comma if there is one */
169 void CfgOptionalAssign (void);
170 /* Consume an equal sign if there is one */
172 void CfgAssureInt (void);
173 /* Make sure the next token is an integer */
175 void CfgAssureStr (void);
176 /* Make sure the next token is a string constant */
178 void CfgAssureIdent (void);
179 /* Make sure the next token is an identifier */
181 void CfgRangeCheck (unsigned long Lo, unsigned long Hi);
182 /* Check the range of CfgIVal */
184 void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
185 /* Map an identifier to one of the special tokens in the table */
187 void CfgBoolToken (void);
188 /* Map an identifier or integer to a boolean token */
190 void CfgSetName (const char* Name);
191 /* Set a name for a config file */
193 const char* CfgGetName (void);
194 /* Get the name of the config file */
196 void CfgSetBuf (const char* Buf);
197 /* Set a memory buffer for the config */
200 /* Return true if we have a configuration available */
202 void CfgOpenInput (void);
203 /* Open the input file if we have one */
205 void CfgCloseInput (void);
206 /* Close the input file if we have one */
210 /* End of scanner.h */