changed txt to tex
authorBradley Bell <btb@icculus.org>
Mon, 26 Aug 2002 07:51:01 +0000 (07:51 +0000)
committerBradley Bell <btb@icculus.org>
Mon, 26 Aug 2002 07:51:01 +0000 (07:51 +0000)
utilities/tex2txb.c [new file with mode: 0755]
utilities/txb2tex.c [new file with mode: 0755]

diff --git a/utilities/tex2txb.c b/utilities/tex2txb.c
new file mode 100755 (executable)
index 0000000..87be8f0
--- /dev/null
@@ -0,0 +1,49 @@
+#include <stdio.h>
+
+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 <text file name> <txb file name>\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 (executable)
index 0000000..037a558
--- /dev/null
@@ -0,0 +1,45 @@
+#include <stdio.h>
+
+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 <txb file name> <text file name>\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;
+}