MERLIN <-> text conversion utility

This commit is contained in:
dschmenk 2013-09-06 21:11:24 -07:00
parent d5daf6f970
commit 2eaf496d05
3 changed files with 56 additions and 1 deletions

View File

@ -1,4 +1,4 @@
BIN=a2serclk a2pid a2mon a2term dskread dskwrite bintomon bload brun
BIN=a2serclk a2pid a2mon a2term dskread dskwrite bintomon bload brun text2merlin merlin2text
all: $(BIN)
fusea2pi: fusea2pi.c a2lib.c

31
src/merlin2text.c Executable file
View File

@ -0,0 +1,31 @@
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int fin, comment, charpos;
char c;
if (argc > 1)
{
fin = open(argv[1], O_RDONLY, 0);
}
else
fin = 0;
comment = charpos = 0;
while (read(fin, &c, 1) == 1)
{
c &= 0x7f;
if ((charpos++ == 0 && c == '*') || c == ';')
comment = 1;
if (c == '\r')
{
comment = charpos = 0;
c = '\n';
}
if (c == ' ' && !comment)
c = '\t';
putc(c & 0x7f, stdout);
}
return (0);
}

24
src/text2merlin.c Executable file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int fout;
char c;
if (argc > 1)
fout = open(argv[1], O_WRONLY|O_CREAT, 0644);
else
fout = 1;
while ((c = getc(stdin)) != EOF)
{
if (c == '\n')
c = '\r';
if (c == '\t')
c = ' ';
c |= 0x80;
write(fout, &c, 1);
}
close(fout);
return (0);
}