-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathIBMMAIN.C
279 lines (262 loc) · 5.88 KB
/
IBMMAIN.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/* @(#)ibmmain.c 2.17 */
#include "portab.h"
#include <stdio.h>
static BYTE buf[128];
static BYTE buf0[64], buf1[64], buf2[64], buf3[64], buf4[64], buf5[64];
static WORD ac;
static BYTE *av[] =
{
buf0,
buf1,
buf2,
buf3,
buf4,
buf5
};
WORD debugflag = 0;
WORD configured = FALSE;
#define FORMATCMD 0
main()
{
printf("VMUTIL Version 2.0 (04 Nov 85)\n");
InitDisk();
help();
while(1)
{
printf("\nEnter command: ");
strcpy(av[0],"");
strcpy(av[1],"");
strcpy(av[2],"");
strcpy(av[3],"");
strcpy(av[4],"");
strcpy(av[5],"");
ac = myparse(av);
if( debugflag )
{
printf("ac = %d\n", ac);
printf("av[0] = %s\n", av[0]);
printf("av[1] = %s\n", av[1]);
printf("av[2] = %s\n", av[2]);
printf("av[3] = %s\n", av[3]);
}
if( configured == FALSE &&
(av[0][0] != 's' && av[0][0] != '+' &&
av[0][0] != 'x' && av[0][0] != 'u' &&
av[0][0] != 'h' && av[0][0] != '-' &&
av[0][0] != 'q' ) )
{
printf("You must select a drive first\n");
continue;
}
switch( av[0][0] )
{
case '+':
debugflag = 1;
break;
case '-':
debugflag = 0;
break;
case 'h':
help();
break;
case 'u':
usage();
break;
case 'x':
case 'q':
exit();
case 's':
if( ac == 1 )
{
printf(" 0 = internal hard disk\n");
printf(" 1 = external hard disk\n");
printf(" 2 = internal floppy disk\n");
printf(" 3 = internal floppy disk\n");
printf(" Select which drive? ");
gets(av[1]);
ac++;
}
dkconf(ac,av);
configured = TRUE;
break;
#if FORMATCMD
case 'f':
ibmformat();
break;
#endif
case 'R':
strcpy(av[0],"Read");
goto read;
case 'r':
strcpy(av[0],"read");
read:
if( ac == 1 )
{
printf("CDOS file name to read from: ");
gets(av[1]); ac++;
printf("cpm file name to write to: ");
gets(av[2]); ac++;
}
else if( ac == 2 ) /* automatically fill in the second arg */
{
if( av[1][1] == ':' ) /* strip off user # or drive spec */
strcpy(av[2],av[1]+2);
else if( av[1][2] == ':' )
strcpy(av[2],av[1]+3);
else
strcpy(av[2],av[1]);
ac += 1;
}
iread(ac,av);
break;
case 'W':
strcpy(av[0],"Write");
goto write;
case 'w':
strcpy(av[0],"write");
write:
if( ac == 1 )
{
printf("cpm file name to read from: ");
gets(av[1]); ac++;
printf("CDOS file name to write to: ");
gets(av[2]); ac++;
}
else if( ac == 2 ) /* automatically fill in the second arg */
{
if( av[1][1] == ':' ) /* strip off user # or drive spec */
strcpy(av[2],av[1]+2);
else if( av[1][2] == ':' )
strcpy(av[2],av[1]+3);
else
strcpy(av[2],av[1]);
ac += 1;
}
iwrite(ac,av);
break;
case 'i':
if( ac == 1 )
{
printf("Booter object to write: ");
strcpy(av[1],"");
ac++;
gets(av[1]);
}
initpcdos(ac,av);
putboot(ac,av);
break;
case 'p':
if( ac == 1 )
{
printf("Booter object to write: ");
strcpy(av[1],"");
ac++;
gets(av[1]);
}
putboot(ac,av);
break;
case 'd':
case 'D':
printf("\n");
diribm(ac,av);
break;
case 'e':
if( ac == 1 )
{
printf("Enter CDOS filename to ERASE: ");
ac++;
gets(av[1]);
}
ierase(ac,av);
break;
case 't':
if( ac == 1 )
{
printf("Enter CDOS filename to type: ");
ac++;
gets(av[1]);
}
typeibm(ac,av);
break;
case '\0': /* simply a carriage return */
break;
default:
printf("Invalid command\n");
break;
}
}
}
help()
{
printf("Available commands:\n");
printf(" d - print directory of CDOS disk\n");
printf(" e - erase a CDOS file\n");
#if FORMATCMD
printf(" f - format a CDOS disk\n");
#endif
printf(" h - print this help summary\n");
printf(" i - initialize a CDOS file system\n");
printf(" p - install a booter ONLY in the CDOS file system\n");
printf(" r - read from CDOS file to CP/M file\n");
printf(" w - write CP/M file to CDOS file\n");
printf(" R - read from CDOS file to ASCII CP/M file\n");
printf(" W - write ASCII CP/M file to CDOS file\n");
printf(" s - select a disk drive\n");
printf(" t - type a CDOS file\n");
printf(" q - exit to CP/M\n");
printf(" u - command forms and usage\n");
printf(" x - exit to CP/M\n");
}
usage()
{
printf("\nCommand usage:\n");
printf(" dir help\n");
printf(" usage initialize bootfile\n");
printf(" putboot bootfile select disknum [sizeMb -]\n");
printf(" read CDOSfile [CPMfile] write CPMfile [CDOSfile]\n");
printf(" Read CDOSfile [CPMfile] Write CPMfile [CDOSfile]\n");
printf(" erase CDOSfile type CDOSfile\n");
printf(" quit xit\n");
#if FORMATCMD
printf(" format\n");
#endif
printf("\nOnly the first letter of the COMMAND is required.\n");
printf("'[]' brackets delimit optional arguments\n");
printf("You will be prompted for missing required arguments.\n");
printf("For write calls, leading 'x:' will be removed from the\n");
printf("filename before writing to the CDOS file system\n");
printf("You must select a disk first before using other commands.\n");
}
myparse(av)
BYTE **av;
{
BYTE line[256];
BYTE c;
REG BYTE *lp, *ap;
WORD cnt;
gets(line);
lp = line;
cnt = 0;
while( c = *lp++ )
{
if( c == ' ' || c == '\t' )
continue;
if( c == '\0' )
break;
ap = av[cnt++];
*ap++ = c;
while( 1 )
{
c = *lp++;
if( c == ' ' || c == '\t' || c == '\0' )
{
lp--;
*ap = '\0';
break;
}
*ap++ = c;
}
}
return cnt;
}