-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADIBM.C
50 lines (47 loc) · 1 KB
/
READIBM.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
/* @(#)readibm.c 2.5 */
/* readibm (12 Oct 84) - read an IBM PC file to CP/M file */
#include "portab.h"
#include "ibmdisk.h"
iread(argc,argv)
WORD argc;
BYTE *argv[];
{
WORD actual,fd;
BYTE *cpmfile;
BYTE buffer[MAXCLSIZE];/* used to store one cluster of file data */
if (argc != 2 && argc != 3)
{
printf("Usage: readibm <ibm filename> [<cpm filename>]\n");
return;
}
cpmfile = (argc == 2 ? argv[1] : argv[2]);
if (openibm(argv[1]) == -1)
{
printf("Unable to find IBM PC file %s\n",argv[1]);
return;
}
if (strcmp(argv[0],"Read") == 0)
{
if ((fd = creata(argv[1],0666)) == -1)
{
printf("Unable to create CP/M file %s\n",argv[1]);
return;
}
}
else
if ((fd = creatb(cpmfile,0666)) == -1)
{
printf("Unable to create CP/M file %s\n",argv[1]);
return;
}
while ((actual = readibm(buffer)) > 0)
{
if (write(fd,buffer,actual) < actual)
{
printf("Unable to write to CP/M file\n");
break;
}
}
close(fd);
}