/* */
/* */
/* */
-/* (C) 1998-2000 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
-void FileSeek (FILE* F, unsigned long Pos)
+void FileSetPos (FILE* F, unsigned long Pos)
/* Seek to the given absolute position, fail on errors */
-{
+{
if (fseek (F, Pos, SEEK_SET) != 0) {
Error ("Cannot seek: %s", strerror (errno));
}
+unsigned long FileGetPos (FILE* F)
+/* Return the current file position, fail on errors */
+{
+ long Pos = ftell (F);
+ if (Pos < 0) {
+ Error ("Error in ftell: %s", strerror (errno));
+ }
+ return Pos;
+}
+
+
+
unsigned Read8 (FILE* F)
/* Read an 8 bit value from the file */
{
if (Size > 0) {
if (fread (Data, 1, Size, F) != Size) {
Error ("Read error (file corrupt?)");
- }
+ }
}
return Data;
}
H->ExportSize = Read32 (F);
H->DbgSymOffs = Read32 (F);
H->DbgSymSize = Read32 (F);
+ H->LineInfoOffs = Read32 (F);
+ H->LineInfoSize = Read32 (F);
+ H->StrPoolOffs = Read32 (F);
+ H->StrPoolSize = Read32 (F);
+ H->AssertOffs = Read32 (F);
+ H->AssertSize = Read32 (F);
+ H->ScopeOffs = Read32 (F);
+ H->ScopeSize = Read32 (F);
+ H->SpanOffs = Read32 (F);
+ H->SpanSize = Read32 (F);
+}
+
+
+
+void ReadStrPool (FILE* F, Collection* C)
+/* Read a string pool from the current position into C. */
+{
+ /* The number of strings is the first item */
+ unsigned long Count = ReadVar (F);
+
+ /* Read all the strings into C */
+ while (Count--) {
+ CollAppend (C, ReadStr (F));
+ }
}