1 /* This program converts between the old 128 words/block DECtape images
2 and the new 129 words/block DECtape image format.
3 to run execute blkdectp infile outfile
4 It will convert the infile to the opposite format and write to outfile.
16 #include <sys/types.h>
19 main(int argc
, char *argv
[])
23 unsigned short buf
[129];
28 printf("Usage: %s infile outfile\n",argv
[0]);
31 fdin
= open(argv
[1],O_RDONLY
| O_BINARY
);
33 perror("Unable to open input file");
36 fdout
= open(argv
[2],O_WRONLY
| O_CREAT
| O_BINARY
, 0666);
38 perror("Unable to open output file");
41 if (fstat(fdin
, &statbuf
) < 0) {
42 perror("Unable to get size of input file");
45 if (statbuf
.st_size
% (129*2) == 0) {
48 } else if (statbuf
.st_size
% (128*2) == 0) {
52 printf("Input file is not a multiple of 128 or 129 words, can't convert\n");
56 memset(buf
, 0, sizeof(buf
));
58 rc
= read(fdin
, buf
, insize
*2);
60 if (write(fdout
, buf
, outsize
*2) != outsize
*2) {
61 perror("Error writing to output file");
65 perror("Error reading input file");
68 printf("Short read on input file %d\n",rc
);