1 /*****************************************************************************/
5 /* Input file table for ca65 */
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 /*****************************************************************************/
47 /*****************************************************************************/
49 /*****************************************************************************/
53 /* List of input files */
55 unsigned long MTime; /* Time of last modification */
56 unsigned long Size; /* Size of file */
57 const char* Name; /* Name of file */
58 } Files [MAX_INPUT_FILES];
59 static unsigned FileCount = 0;
63 /*****************************************************************************/
65 /*****************************************************************************/
69 const char* GetFileName (unsigned Name)
70 /* Get the name of a file where the name index is known */
72 PRECONDITION (Name <= FileCount);
74 /* Name was defined outside any file scope, use the name of the first
75 * file instead. Errors are then reported with a file position of
76 * line zero in the first file.
79 /* No files defined until now */
80 return "(outside file scope)";
82 return Files [0].Name;
85 return Files [Name-1].Name;
91 unsigned AddFile (const char* Name, unsigned long Size, unsigned long MTime)
92 /* Add a new file to the list of input files. Return the index of the file in
96 /* Check for a table overflow */
97 if (FileCount >= MAX_INPUT_FILES) {
99 Fatal (FAT_MAX_INPUT_FILES);
102 /* Add the file to the table */
103 Files [FileCount].Name = xstrdup (Name);
104 Files [FileCount].Size = Size;
105 Files [FileCount].MTime = MTime;
113 void WriteFiles (void)
114 /* Write the list of input files to the object file */
118 /* Tell the obj file module that we're about to start the file list */
121 /* Write the file count */
122 ObjWriteVar (FileCount);
124 /* Write the file data */
125 for (I = 0; I < FileCount; ++I) {
126 ObjWrite32 (Files [I].MTime);
127 ObjWrite32 (Files [I].Size);
128 ObjWriteStr (Files [I].Name);
131 /* Done writing files */