Skip to content

Updates to DUMPER format. #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 59 additions & 42 deletions dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static int record_number;
static int format;
static int word_bytes;
static word_t file_bytes;
static word_t file_octets;

/*
Format:
Expand Down Expand Up @@ -434,70 +435,79 @@ static word_t
read_tape_header (FILE *f, word_t word)
{
char name[100];
int bfmsg;

word = read_record (f, word);

//fprintf (stderr, "006: %012llo format\n", data[0]);

read_asciz (name, &data[3]);
fprintf (stderr, "DUMPER tape #%d, %s, ", right (block[2]), name);
print_timestamp (stderr, data[2]);
if (format == 0)
bfmsg = 0;
else {
bfmsg = data[1];
if (bfmsg == 0)
bfsmsg = format > 4 ? 10 : 3;
}

read_asciz (name, &data[bfmsg]);
fprintf (stderr, "DUMPER tape #%d, %s", right (block[2]), name);
if (format > 0) {
fputs (", ", stderr);
print_timestamp (stderr, data[2]);
}
fputc ('\n', stderr);

return word;
}

static void
print_info (FILE *f, word_t *fdb)
{
int bits_per_byte, file_words;

print_timestamp (f, fdb[5]);
fprintf (f, " %4d", right (fdb[011]));
file_bytes = fdb[012];
bits_per_byte = (fdb[011] >> 24) & 077;
word_bytes = bits_per_byte ? 36 / bits_per_byte : 0;
file_words = file_bytes / word_bytes;
file_octets = 5 * file_words;
file_octets += ((file_bytes % word_bytes) * bits_per_byte + 7) / 8;
fprintf (f, " %lld(%d)\n",
file_bytes, bits_per_byte);
}

static void
read_file (int offset)
{
int bits_per_byte;
char *p;

if (offset != 0206)
{
if (format == 0)
print_info (stderr, block + offset);

if (output != NULL)
close_file ();
return;
}
else
{
read_asciz (file_path, &data[0]);

read_asciz (file_path, &data[0]);

p = strchr (file_path, ';');
if (format == 0 && p != NULL)
p = strchr (p + 1, ';');
if (p)
*p = 0;

fprintf (stderr, " %-40s", file_path);
print_timestamp (stderr, block[offset + 5]);
fprintf (stderr, " %4d", right (block[offset + 011]));
file_bytes = block[offset + 012];
bits_per_byte = (block[offset + 011] >> 24) & 077;
word_bytes = bits_per_byte ? 36 / bits_per_byte : 0;
fprintf (stderr, " %lld(%d)\n",
file_bytes, bits_per_byte);
p = strchr (file_path, ';');
if (format == 0 && p != NULL)
p = strchr (p + 1, ';');
if (p)
*p = 0;

if (extract)
open_file ();
fprintf (stderr, " %-40s", file_path);

#if 0
fprintf (stderr, "006: %012llo file file_path\n", data[0]);
fprintf (stderr, "Timestamp, last write: ");
print_timestamp (stderr, block[offset + 5]);
fputc ('\n', stderr);
fprintf (stderr, "Timestamp, creation: ");
print_timestamp (stderr, block[offset + 013]);
fputc ('\n', stderr);
fprintf (stderr, "Timestamp, user write: ");
print_timestamp (stderr, block[offset + 014]);
fputc ('\n', stderr);
fprintf (stderr, "Timestamp, last nonwrite: ");
print_timestamp (stderr, block[offset + 015]);
fputc ('\n', stderr);
if (format > 0)
print_info (stderr, block + offset);

for (i = offset; i < offset + 030; i++)
fprintf (stderr, "%03o: %012llo\n", i, block[i]);
#endif
if (extract)
open_file ();
}
}

static void
Expand Down Expand Up @@ -721,7 +731,7 @@ write_tape (FILE *f)
struct word_format *tmp = input_word_format;
input_word_format = output_word_format;
output_word_format = tmp;
int i, bfmsg = 0;
int i, bfmsg;

if (f == NULL)
f = stdout;
Expand All @@ -733,13 +743,20 @@ write_tape (FILE *f)
if (format == 0)
{
record_number = 2;
bfmsg = 0;
}
else
{
record_number = 1;
data[bfmsg++] = format;
bfmsg++;
bfmsg++; // Filled in below.
data[bfmsg++] = tops20_timestamp (time (NULL));
if (format > 4)
{
// Unknown fields for now.
memset(data + bfmsg, 0, 13 * sizeof (word_t));
bfmsg += 13;
}
data[1] = bfmsg;
}
write_asciz ("Saveset name", data + bfmsg);
Expand Down