--- /dev/null
+/*****************************************************************************/
+/* */
+/* fileinfo.c */
+/* */
+/* sOURCE FILE INFO STRUCTURE */
+/* */
+/* */
+/* */
+/* (C) 2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+/* common */
+#include "xmalloc.h"
+
+/* ld65 */
+#include "fileio.h"
+#include "fileinfo.h"
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+static FileInfo* NewFileInfo (void)
+/* Allocate and initialize a new FileInfo struct and return it */
+{
+ /* Allocate memory */
+ FileInfo* FI = xmalloc (sizeof (FileInfo));
+
+ /* Return the new struct */
+ return FI;
+}
+
+
+
+FileInfo* ReadFileInfo (FILE* F, ObjData* O)
+/* Read a file info from a file and return it */
+{
+ /* Allocate a new FileInfo structure */
+ FileInfo* FI = NewFileInfo ();
+
+ /* Read the fields from the file */
+ FI->MTime = Read32 (F);
+ FI->Size = Read32 (F);
+ FI->Name = ReadStr (F);
+
+ /* Return the new struct */
+ return FI;
+}
+
+
+
--- /dev/null
+/*****************************************************************************/
+/* */
+/* fileinfo.h */
+/* */
+/* Source file info structure */
+/* */
+/* */
+/* */
+/* (C) 2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef FILEINFO_H
+#define FILEINFO_H
+
+
+
+#include <stdio.h>
+
+/* common */
+#include "coll.h"
+#include "filepos.h"
+
+/* ld65 */
+#include "objdata.h"
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+typedef struct FileInfo FileInfo;
+struct FileInfo {
+ unsigned long MTime; /* Time of last modification */
+ unsigned long Size; /* Size of the file */
+ char* Name; /* File name */
+};
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+FileInfo* ReadFileInfo (FILE* F, ObjData* O);
+/* Read a file info from a file and return it */
+
+
+
+/* End of fileinfo.h */
+#endif
+
+
+
/* common */
+#include "check.h"
#include "xmalloc.h"
/* ld65 */
LineInfo* LI = xmalloc (sizeof (LineInfo));
/* Initialize the fields */
+ LI->File = 0;
InitFilePos (&LI->Pos);
InitCollection (&LI->Fragments);
/* Read the file position */
ReadFilePos (F, &LI->Pos);
+ /* Resolve the file index to a pointer to FileInfo struct */
+ CHECK (LI->Pos.Name < O->FileCount);
+ LI->File = O->Files[LI->Pos.Name];
+
/* Return the new LineInfo */
return LI;
}
typedef struct LineInfo LineInfo;
struct LineInfo {
- FilePos Pos; /* File position */
- Collection Fragments; /* Fragments for this line */
+ struct FileInfo* File; /* File struct for this line */
+ FilePos Pos; /* File position */
+ Collection Fragments; /* Fragments for this line */
};
exports.o \
expr.o \
extsyms.o \
+ fileinfo.o \
fileio.o \
fragment.o \
global.o \
exports.obj \
expr.obj \
extsyms.obj \
+ fileinfo.obj \
fileio.obj \
fragment.obj \
global.obj \
library.obj \
+ lineinfo.obj \
main.obj \
mapfile.obj \
o65.obj \
/* ld65 */
#include "error.h"
+#include "fileinfo.h"
#include "objdata.h"
xfree (O->Name);
xfree (O->Imports);
xfree (O->Exports);
- xfree (O->DbgSyms);
+ xfree (O->DbgSyms);
xfree (O->LineInfos);
xfree (O);
}
PRECONDITION (Index < O->FileCount);
/* Return the name */
- return O->Files[Index];
+ return O->Files[Index]->Name;
}
}
unsigned long Start; /* Start offset of data in library */
unsigned Flags;
unsigned FileCount; /* Input file count */
- char** Files; /* List of input files */
+ struct FileInfo** Files; /* List of input files */
unsigned SectionCount; /* Count of sections in this object */
struct Section** Sections; /* List of all sections */
unsigned ExportCount; /* Count of exports */
#include "dbgsyms.h"
#include "error.h"
#include "exports.h"
+#include "fileinfo.h"
#include "fileio.h"
#include "lineinfo.h"
#include "objdata.h"
unsigned I;
O->FileCount = ReadVar (F);
- O->Files = xmalloc (O->FileCount * sizeof (char*));
+ O->Files = xmalloc (O->FileCount * sizeof (FileInfo*));
for (I = 0; I < O->FileCount; ++I) {
- /* Skip MTime and size */
- Read32 (F);
- Read32 (F);
- /* Read the filename */
- O->Files [I] = ReadStr (F);
+ O->Files[I] = ReadFileInfo (F, O);
}
}
/* Read the debug symbols from a file at the current position */
{
unsigned I;
-
+
O->DbgSymCount = ReadVar (F);
O->DbgSyms = xmalloc (O->DbgSymCount * sizeof (DbgSym*));
for (I = 0; I < O->DbgSymCount; ++I) {