From 03231a43373f52830007ec1ecb777b2a36de2b08 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Mon, 26 Aug 2002 07:51:01 +0000 Subject: [PATCH] changed txt to tex --- utilities/tex2txb.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ utilities/txb2tex.c | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100755 utilities/tex2txb.c create mode 100755 utilities/txb2tex.c diff --git a/utilities/tex2txb.c b/utilities/tex2txb.c new file mode 100755 index 00000000..87be8f07 --- /dev/null +++ b/utilities/tex2txb.c @@ -0,0 +1,49 @@ +#include + +int +main(int argc, char *argv[]) +{ + FILE *file, *outfile; + char ch; + int code; + + if (argc != 3) { + printf("TEX2TXB V1.0 Copyright (c) Bryan Aamot, 1995\n" + "Modified by Bradley Bell, 2002\n" + "Text to TXB converter for Descent HOG files.\n" + "Converts a ascii text files to *.txb descent hog file format.\n" + "Usage: TEX2TXB \n" + "Example: TEX2TXB briefing.tex briefing.txb\n"); + exit(1); + } + file = fopen(argv[1], "rb"); + if (!file) { + printf("Can't open file (%s)\n", argv[1]); + exit(2); + } + + outfile = fopen(argv[2], "wb"); + if (!outfile) { + printf("Can't open file (%s)\n", argv[2]); + fclose(file); + exit(2); + } + + for (;;) { + ch = getc(file); + if (feof(file)) break; + if (ch!=0x0d) { + if (ch==0x0a) { + fprintf(outfile, "\x0a"); + } else { + code = ( ( (ch &0xfC) >> 2) + ( (ch &0x03) << 6 ) ) ^ 0xe9; + fprintf(outfile, "%c", code); + } + } + } + + fclose(outfile); + fclose(file); + + return 0; +} diff --git a/utilities/txb2tex.c b/utilities/txb2tex.c new file mode 100755 index 00000000..037a5583 --- /dev/null +++ b/utilities/txb2tex.c @@ -0,0 +1,45 @@ +#include + +int +main(int argc, char *argv[]) +{ + FILE *file, *outfile; + char ch; + int code; + + if (argc != 3) { + printf("TXB2TEX V1.0 Copyright (c) Bryan Aamot, 1995\n" + "Modified by Bradley Bell, 2002\n" + "TXB to Text converter for Descent HOG files.\n" + "Converts a *.txb descent hog file to an ascii file.\n" + "Usage: TXB2TEX \n" + "Example: TEX2TXB briefing.txb briefing.tex\n"); + exit(1); + } + file = fopen(argv[1], "rb"); + if (!file) { + printf("Can't open txb file (%s)\n", argv[1]); + exit(2); + } + outfile = fopen(argv[2], "wb"); + if (!outfile) { + printf("Can't open file (%s)\n", argv[2]); + fclose(file); + exit(2); + } + for (;;) { + code = getc(file); + if (feof(file)) break; + if (code == 0x0a) { + fprintf(outfile, "\x0d\x0a"); + } else { + ch = ( ( (code&0x3f) << 2 ) + ( (code&0xc0) >> 6 ) ) ^ 0xa7; + fprintf(outfile, "%c", ch); + } + } + + fclose(outfile); + fclose(file); + + return 0; +} -- 2.39.2