1 /*****************************************************************************/
5 /* Object file options for the ca65 macroassembler */
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 /*****************************************************************************/
49 /*****************************************************************************/
51 /*****************************************************************************/
56 static Option* OptRoot = 0;
57 static Option* OptLast = 0;
58 static unsigned OptCount = 0;
62 /*****************************************************************************/
64 /*****************************************************************************/
68 static Option* NewOption (unsigned char Type)
69 /* Create a new option, insert it into the list and return it */
74 Opt = xmalloc (sizeof (*Opt));
76 /* Initialize fields */
81 /* Insert it into the list */
89 /* One more option now */
92 /* Return the new struct */
98 void OptStr (unsigned char Type, const char* Text)
99 /* Add a string option */
103 /* String must have less than 255 bytes */
104 if (strlen (Text) > 255) {
105 Fatal (FAT_STRING_TOO_LONG);
107 O = NewOption (Type);
108 O->V.Str = xstrdup (Text);
113 void OptComment (const char* Comment)
116 OptStr (OPT_COMMENT, Comment);
121 void OptAuthor (const char* Author)
122 /* Add an author statement */
124 OptStr (OPT_AUTHOR, Author);
129 void OptTranslator (const char* Translator)
130 /* Add a translator option */
132 OptStr (OPT_TRANSLATOR, Translator);
137 void OptCompiler (const char* Compiler)
138 /* Add a compiler option */
140 OptStr (OPT_COMPILER, Compiler);
145 void OptOS (const char* OS)
146 /* Add an operating system option */
153 void OptDateTime (unsigned long DateTime)
154 /* Add a date/time option */
156 Option* O = NewOption (OPT_DATETIME);
162 void WriteOptions (void)
163 /* Write the options to the object file */
167 /* Tell the object file module that we're about to start the options */
170 /* Write the option count */
171 ObjWriteVar (OptCount);
173 /* Walk through the list and write the options */
177 /* Write the type of the option */
180 /* Write the argument */
181 switch (O->Type & OPT_ARGMASK) {
184 ObjWriteStr (O->V.Str);
188 ObjWrite32 (O->V.Val);
192 Internal ("Invalid option type: $%02X", O->Type & 0xFF);
201 /* Done writing options */