1
0
mirror of synced 2026-02-07 16:52:26 +00:00
Files
lisper.cpus-pdp8/utils/skipz/skipz.c
brad e91720db24
2010-04-13 14:01:42 +00:00

50 lines
738 B
C
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* remove comment + ^Z from paper tape files
* brad@heeltoe.com
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
size_t binfile_size;
unsigned char binfile[64*1024];
main(int argc, char *argv[])
{
if (argc > 1) {
int f, ret;
char ch;
f = open(argv[1], O_RDONLY);
if (f < 0) {
perror(argv[1]);
return -1;
}
while (1) {
ret = read(f, &ch, 1);
if (ret != 1)
return -1;
if (ch == 'Z'-'@')
break;
}
binfile_size = read(f, binfile, sizeof(binfile));
ret = write(1, binfile, binfile_size);
close(f);
}
exit(0);
}
/*
* Local Variables:
* indent-tabs-mode:nil
* c-basic-offset:4
* End:
*/