-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
drm2txt.c
90 lines (73 loc) · 1.82 KB
/
drm2txt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* drm2txt.c
*
* Converts DosDream source files (*.DRM) to plain text format
*
* Graham E. Kinns <gekinns@iee.org> Apr '97
*
* $Log: drm2txt.c $
* Revision 1.0 1997/04/15 17:00:58 Graham
* Initial revision
*
*/
#include <stdio.h>
#include "global.h"
#if defined (__BORLANDC__) && (__BORLANDC__ >= 0x0450 && __BORLANDC__ <= 0x0452)
void
_ExceptInit (void)
{
}
#endif /* BC++ v4.0x */
#define PROG_NAME "drm2txt"
#define VERSION "1.0"
#ifdef RCS
static const char rcs_id[] = "$Id: drm2txt.c 1.0 1997/04/15 17:00:58 Graham Exp $";
#endif /* RCS */
int
main (int argc, char *argv[])
{
FILE *ipfile;
FILE *opfile;
Byte buf[256];
uint bytes_read;
/* Opening banner */
fputs (PROG_NAME " v" VERSION " -- Converts Dragon DOS Dream files to text\n"
"Graham E. Kinns <gekinns@iee.org> " __DATE__ "\n"
"\n", stderr);
if (argc != 3)
{
fprintf (stderr, "Usage: %s input_file output_file\n", argv[0]);
return (1);
}
ipfile = fopen (argv[1], "rb");
if (ipfile == NULL)
{
fprintf (stderr, "Error: Unable to open '%s'\n", argv[1]);
return (1);
}
opfile = fopen (argv[2], "wt");
if (opfile == NULL)
{
fprintf (stderr, "Error: Unable to create '%s'\n", argv[2]);
return (1);
}
while ((bytes_read = fread (buf, 1, 256, ipfile)) == 256)
{
uint buf_idx = 0;
while (buf_idx < 256)
{
Byte byte_count;
byte_count = buf[buf_idx++];
if (byte_count == 0x00)
break; /* next block */
/* Write out next byte_count bytes */
fwrite (&buf[buf_idx], 1, byte_count, opfile);
buf_idx += byte_count;
/* Add CR/LF */
putc ('\n', opfile);
}
}
if (bytes_read != 0)
fputs ("Warning: Dream file corrupt (size not a multiple of 256 bytes)\n", stderr);
return (0);
}