mirror of
https://github.com/brouhaha/tapeutils.git
synced 2026-01-11 23:53:18 +00:00
Support for SIMH tape image format.
Stored records are padded to even length.
This commit is contained in:
parent
64fb27d1ff
commit
fc69a9dff5
@ -288,6 +288,7 @@ int main (int argc, char *argv[])
|
||||
tape_handle_t src = NULL;
|
||||
uchar *buf;
|
||||
t_tape_type tape_type = generic;
|
||||
int tape_flags = TF_DEFAULT;
|
||||
|
||||
progname = argv [0];
|
||||
|
||||
@ -302,6 +303,9 @@ int main (int argc, char *argv[])
|
||||
tape_type = hp_2000_mcp;
|
||||
else
|
||||
#endif /* HP_2000_SUPPORT */
|
||||
if (argv [0][1] == 's')
|
||||
tape_flags |= TF_SIMH;
|
||||
else
|
||||
fatal (1, "unrecognized option '%s'\n", argv [0]);
|
||||
}
|
||||
else if (! srcfn)
|
||||
@ -321,6 +325,8 @@ int main (int argc, char *argv[])
|
||||
if (! src)
|
||||
fatal (3, "can't open source tape\n");
|
||||
|
||||
tapeflags (src, tape_flags);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
len = getrec (src, buf, MAX_REC_LEN);
|
||||
|
||||
9
tapeio.c
9
tapeio.c
@ -71,6 +71,7 @@ struct mtape_t
|
||||
int tape_type;
|
||||
int tapefd; /* tape drive, file, or socket file descriptor */
|
||||
int seek_ok;
|
||||
int flags;
|
||||
|
||||
unsigned long bpi; /* tape density (for tape length msg) */
|
||||
int waccess; /* NZ => tape opened for write access access */
|
||||
@ -423,7 +424,10 @@ int getrec (tape_handle_t mtape, void *buf, int len)
|
||||
goto toolong; /* don't read if too long for buf */
|
||||
if (l != 0)
|
||||
{ /* get data unless tape mark */
|
||||
char x;
|
||||
doread (mtape->tapefd, buf, l); /* read data */
|
||||
if ((l & 1) != 0 && (mtape->flags & TF_SIMH) != 0)
|
||||
doread (mtape->tapefd, &x, 1);
|
||||
doread (mtape->tapefd, byte, 4); /* get trailing record length */
|
||||
if((((unsigned long)byte[3]<<24L)|
|
||||
((unsigned long)byte[2]<<16L)|
|
||||
@ -647,3 +651,8 @@ void skipfile (tape_handle_t mtape, int count)
|
||||
}
|
||||
}
|
||||
|
||||
/* set tape flags */
|
||||
void tapeflags (tape_handle_t mtape, int flags)
|
||||
{
|
||||
mtape->flags = flags;
|
||||
}
|
||||
|
||||
7
tapeio.h
7
tapeio.h
@ -24,6 +24,11 @@
|
||||
typedef struct mtape_t *tape_handle_t; /* opaque type */
|
||||
|
||||
|
||||
/* tape flags */
|
||||
#define TF_DEFAULT 0x000
|
||||
#define TF_SIMH 0x001
|
||||
|
||||
|
||||
/* open a tape drive */
|
||||
tape_handle_t opentape (char *name, int create, int writable);
|
||||
|
||||
@ -51,3 +56,5 @@ void skiprec (tape_handle_t h, int count);
|
||||
/* skip files (negative for reverse) */
|
||||
void skipfile (tape_handle_t h, int count);
|
||||
|
||||
/* set tape flags */
|
||||
void tapeflags (tape_handle_t h, int flags);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user