Added dump of the file list
git-svn-id: svn://svn.cc65.org/cc65/trunk@238 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
697f6e1cfa
commit
a63d35278c
3 changed files with 86 additions and 8 deletions
|
@ -65,6 +65,25 @@ static void DumpObjHeaderSection (const char* Name,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static char* TimeToStr (unsigned long Time)
|
||||||
|
/* Convert the time into a string and return it */
|
||||||
|
{
|
||||||
|
/* Get the time and convert to string */
|
||||||
|
time_t T = (time_t) Time;
|
||||||
|
char* S = asctime (localtime (&T));
|
||||||
|
|
||||||
|
/* Remove the trailing newline */
|
||||||
|
unsigned Len = strlen (S);
|
||||||
|
if (Len > 0 && S[Len-1] == '\n') {
|
||||||
|
S[Len-1 ] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the time string */
|
||||||
|
return S;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DumpObjHeader (FILE* F, unsigned long Offset)
|
void DumpObjHeader (FILE* F, unsigned long Offset)
|
||||||
/* Dump the header of the given object file */
|
/* Dump the header of the given object file */
|
||||||
{
|
{
|
||||||
|
@ -119,7 +138,6 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
|
||||||
/* Dump the file options */
|
/* Dump the file options */
|
||||||
{
|
{
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
long Size;
|
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
|
@ -137,7 +155,7 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
|
||||||
|
|
||||||
/* Read the number of options and print it */
|
/* Read the number of options and print it */
|
||||||
Count = Read16 (F);
|
Count = Read16 (F);
|
||||||
printf (" Count: %5u\n", Count);
|
printf (" Count:%27u\n", Count);
|
||||||
|
|
||||||
/* Read and print all options */
|
/* Read and print all options */
|
||||||
for (I = 0; I < Count; ++I) {
|
for (I = 0; I < Count; ++I) {
|
||||||
|
@ -175,7 +193,6 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
|
||||||
ArgStr = ReadMallocedStr (F);
|
ArgStr = ReadMallocedStr (F);
|
||||||
ArgLen = strlen (ArgStr);
|
ArgLen = strlen (ArgStr);
|
||||||
printf (" Data:%*s\"%s\"\n", 24-ArgLen, "", ArgStr);
|
printf (" Data:%*s\"%s\"\n", 24-ArgLen, "", ArgStr);
|
||||||
Size -= 1 + ArgLen + 1;
|
|
||||||
xfree (ArgStr);
|
xfree (ArgStr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -184,11 +201,9 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
|
||||||
printf (" Data:%26lu", ArgNum);
|
printf (" Data:%26lu", ArgNum);
|
||||||
if (Type == OPT_DATETIME) {
|
if (Type == OPT_DATETIME) {
|
||||||
/* Print the time as a string */
|
/* Print the time as a string */
|
||||||
time_t T = (time_t) ArgNum;
|
printf (" (%s)", TimeToStr (ArgNum));
|
||||||
printf (" (%.24s)", asctime (localtime (&T)));
|
|
||||||
}
|
}
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
Size -= 1 + 4;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -203,3 +218,50 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void DumpObjFiles (FILE* F, unsigned long Offset)
|
||||||
|
/* Dump the source files */
|
||||||
|
{
|
||||||
|
ObjHeader H;
|
||||||
|
unsigned Count;
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
/* Seek to the header position */
|
||||||
|
FileSeek (F, Offset);
|
||||||
|
|
||||||
|
/* Read the header */
|
||||||
|
ReadObjHeader (F, &H);
|
||||||
|
|
||||||
|
/* Seek to the start of the options */
|
||||||
|
FileSeek (F, Offset + H.FileOffs);
|
||||||
|
|
||||||
|
/* Output a header */
|
||||||
|
printf (" Files:\n");
|
||||||
|
|
||||||
|
/* Read the number of files and print it */
|
||||||
|
Count = Read8 (F);
|
||||||
|
printf (" Count:%27u\n", Count);
|
||||||
|
|
||||||
|
/* Read and print all options */
|
||||||
|
for (I = 0; I < Count; ++I) {
|
||||||
|
|
||||||
|
/* Read the data for one file */
|
||||||
|
unsigned long MTime = Read32 (F);
|
||||||
|
unsigned long Size = Read32 (F);
|
||||||
|
char* Name = ReadMallocedStr (F);
|
||||||
|
unsigned Len = strlen (Name);
|
||||||
|
|
||||||
|
/* Print the header */
|
||||||
|
printf (" File %u:\n", I);
|
||||||
|
|
||||||
|
/* Print the data */
|
||||||
|
printf (" Name:%*s\"%s\"\n", 24-Len, "", Name);
|
||||||
|
printf (" Size:%26lu\n", Size);
|
||||||
|
printf (" Modification time:%13lu (%s)\n", MTime, TimeToStr (MTime));
|
||||||
|
|
||||||
|
/* Free the Name */
|
||||||
|
xfree (Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,13 @@
|
||||||
|
|
||||||
void DumpObjHeader (FILE* F, unsigned long Offset);
|
void DumpObjHeader (FILE* F, unsigned long Offset);
|
||||||
/* Dump the header of the given object file */
|
/* Dump the header of the given object file */
|
||||||
|
|
||||||
void DumpObjOptions (FILE* F, unsigned long Offset);
|
void DumpObjOptions (FILE* F, unsigned long Offset);
|
||||||
/* Dump the file options */
|
/* Dump the file options */
|
||||||
|
|
||||||
|
void DumpObjFiles (FILE* F, unsigned long Offset);
|
||||||
|
/* Dump the source files */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of dump.h */
|
/* End of dump.h */
|
||||||
|
|
|
@ -77,7 +77,8 @@ static void Usage (void)
|
||||||
" -V\t\t\tPrint the version number and exit\n"
|
" -V\t\t\tPrint the version number and exit\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Long options:\n"
|
"Long options:\n"
|
||||||
" --dump-header\t\tDump the object file header\n"
|
" --dump-files\t\tDump the source files\n"
|
||||||
|
" --dump-header\t\tDump the object file header\n"
|
||||||
" --dump-options\t\tDump object file options\n"
|
" --dump-options\t\tDump object file options\n"
|
||||||
" --help\t\tHelp (this text)\n"
|
" --help\t\tHelp (this text)\n"
|
||||||
" --version\t\tPrint the version number and exit\n",
|
" --version\t\tPrint the version number and exit\n",
|
||||||
|
@ -86,6 +87,14 @@ static void Usage (void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptDumpFiles (const char* Opt, const char* Arg)
|
||||||
|
/* Dump the source files */
|
||||||
|
{
|
||||||
|
What |= D_FILES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void OptDumpHeader (const char* Opt, const char* Arg)
|
static void OptDumpHeader (const char* Opt, const char* Arg)
|
||||||
/* Dump the object file header */
|
/* Dump the object file header */
|
||||||
{
|
{
|
||||||
|
@ -158,6 +167,9 @@ static void DumpFile (const char* Name)
|
||||||
if (What & D_OPTIONS) {
|
if (What & D_OPTIONS) {
|
||||||
DumpObjOptions (F, 0);
|
DumpObjOptions (F, 0);
|
||||||
}
|
}
|
||||||
|
if (What & D_FILES) {
|
||||||
|
DumpObjFiles (F, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the file */
|
/* Close the file */
|
||||||
|
@ -171,6 +183,7 @@ int main (int argc, char* argv [])
|
||||||
{
|
{
|
||||||
/* Program long options */
|
/* Program long options */
|
||||||
static const LongOpt OptTab[] = {
|
static const LongOpt OptTab[] = {
|
||||||
|
{ "--dump-files", 0, OptDumpFiles },
|
||||||
{ "--dump-header", 0, OptDumpHeader },
|
{ "--dump-header", 0, OptDumpHeader },
|
||||||
{ "--dump-options", 0, OptDumpOptions },
|
{ "--dump-options", 0, OptDumpOptions },
|
||||||
{ "--help", 0, OptHelp },
|
{ "--help", 0, OptHelp },
|
||||||
|
|
Loading…
Add table
Reference in a new issue