Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | pmbaty | 1 | /* |
| 2 | * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>. |
||
| 3 | * It is copyright by its individual contributors, as recorded in the |
||
| 4 | * project's Git history. See COPYING.txt at the top level for license |
||
| 5 | * terms and a link to the Git history. |
||
| 6 | */ |
||
| 7 | /* |
||
| 8 | * Modified by Bradley Bell, 2002, 2003 |
||
| 9 | * This program is licensed under the terms of the GPL, version 2 or later |
||
| 10 | */ |
||
| 11 | |||
| 12 | #include <stdio.h> |
||
| 13 | #include <string.h> |
||
| 14 | |||
| 15 | int |
||
| 16 | main(int argc, char *argv[]) |
||
| 17 | { |
||
| 18 | FILE *file, *outfile; |
||
| 19 | char outfilename[64]; |
||
| 20 | char ch; |
||
| 21 | int code; |
||
| 22 | |||
| 23 | if (argc < 2) { |
||
| 24 | printf("TXB2TEX V1.0 Copyright (c) Bryan Aamot, 1995\n" |
||
| 25 | "Modified by Bradley Bell, 2002, 2003\n" |
||
| 26 | "TXB to Text converter for Descent HOG files.\n" |
||
| 27 | "Converts a *.txb descent hog file to an ascii file.\n" |
||
| 28 | "Usage: TXB2TEX <txb file name> <text file name>\n" |
||
| 29 | "Example: TXB2TEX briefing.txb briefing.tex\n"); |
||
| 30 | return 1; |
||
| 31 | } |
||
| 32 | file = fopen(argv[1], "rb"); |
||
| 33 | if (!file) { |
||
| 34 | printf("Can't open txb file (%s)\n", argv[1]); |
||
| 35 | return 2; |
||
| 36 | } |
||
| 37 | |||
| 38 | if (argc > 2) |
||
| 39 | strcpy(outfilename, argv[2]); |
||
| 40 | else { |
||
| 41 | strcpy(outfilename, argv[1]); |
||
| 42 | strcpy(strrchr(outfilename, '.'), ".tex"); |
||
| 43 | } |
||
| 44 | |||
| 45 | outfile = fopen(outfilename, "wb"); |
||
| 46 | if (!outfile) { |
||
| 47 | printf("Can't open file (%s)\n", outfilename); |
||
| 48 | fclose(file); |
||
| 49 | return 2; |
||
| 50 | } |
||
| 51 | for (;;) { |
||
| 52 | code = getc(file); |
||
| 53 | if (feof(file)) break; |
||
| 54 | if (code == 0x0a) { |
||
| 55 | fprintf(outfile, "\x0d\x0a"); |
||
| 56 | } else { |
||
| 57 | ch = ( ( (code&0x3f) << 2 ) + ( (code&0xc0) >> 6 ) ) ^ 0xa7; |
||
| 58 | fprintf(outfile, "%c", ch); |
||
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 62 | fclose(outfile); |
||
| 63 | fclose(file); |
||
| 64 | |||
| 65 | return 0; |
||
| 66 | } |