summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/FDISK/FDPARSE.C
diff options
context:
space:
mode:
authorGravatar Mark Zbikowski2024-04-25 21:24:10 +0100
committerGravatar Microsoft Open Source2024-04-25 22:32:27 +0000
commit2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch)
tree80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/CMD/FDISK/FDPARSE.C
parentMerge pull request #430 from jpbaltazar/typoptbr (diff)
downloadms-dos-main.tar.gz
ms-dos-main.tar.xz
ms-dos-main.zip
MZ is back!HEADmain
Diffstat (limited to 'v4.0/src/CMD/FDISK/FDPARSE.C')
-rw-r--r--v4.0/src/CMD/FDISK/FDPARSE.C312
1 files changed, 312 insertions, 0 deletions
diff --git a/v4.0/src/CMD/FDISK/FDPARSE.C b/v4.0/src/CMD/FDISK/FDPARSE.C
new file mode 100644
index 0000000..7cf3143
--- /dev/null
+++ b/v4.0/src/CMD/FDISK/FDPARSE.C
@@ -0,0 +1,312 @@
1
2#include "dos.h" /* AN000 */
3#include "fdisk.h" /* AN000 */
4#include "extern.h" /* AN000 */
5#include "parse.h" /* AN000 */
6#include "string.h" /* AN000 */
7#include "subtype.h" /* AN000 */
8#include "msgret.h" /* AN000 */
9
10
11/* */
12/******************************************************************************/
13/*Routine name: PARSE_COMMAND_LINE */
14/******************************************************************************/
15/* */
16/*Description: Sets up flags, preloads messages, and parses the command */
17/* line for switchs. */
18/* */
19/*Called Procedures: */
20/* */
21/*Change History: Created 5/30/87 DRM */
22/* */
23/*Input: None */
24/* */
25/*Output: None */
26/* */
27/******************************************************************************/
28
29
30char parse_command_line(argc,argv) /* AN000 */
31
32char *argv[]; /* array of pointer arguments AN000 */
33int argc;
34
35BEGIN /* AN000 */
36
37
38 char cmd_line[128]; /* AN000 */
39 char finished; /* AN000 */
40 int i; /* AN000 */
41 char parse_good; /* AN000 */
42 char far *cmdline;
43
44 parse_init(); /* AN000 */
45
46 /* Initialize parse_flag to true and don't change unless error */
47 parse_good = TRUE; /* AN000 */
48
49 regs.h.ah = (unsigned char) 0x62;
50 intdosx(&regs, &regs, &segregs);
51
52 FP_OFF(cmdline) = 0x81;
53 FP_SEG(cmdline) = regs.x.bx;
54
55 i = 0;
56 while ( *cmdline != (char) '\x0d' ) cmd_line[i++] = *cmdline++;
57 cmd_line[i++] = (char) '\x0d';
58 cmd_line[i++] = (char) '\0';
59
60 regs.x.si = (unsigned)cmd_line; /* AN000 make DS:SI point to source */
61 regs.x.cx = u(0); /* AN000 operand ordinal (whatever that means) */
62 regs.x.dx = u(0); /* AN000 operand ordinal (whatever that means) */
63 regs.x.di = (unsigned)&p_p; /* AN000 address of parm list */
64 Parse_Ptr = (unsigned)cmd_line; /* AN010 */
65 regs.x.si = (unsigned)cmd_line; /* AN010 */
66
67 finished = FALSE;
68 while ( !finished ) /* AN000 */
69 BEGIN /* AN000 */
70
71 Parse_Ptr = regs.x.si; /* AN010 point to next parm */
72 parse(&regs,&regs); /* AN000 Call DOS PARSE service routines*/
73
74 if (regs.x.ax == u(NOERROR)) /* AN000 If there was an error*/
75 BEGIN
76 if (regs.x.dx == (unsigned)&p_buff) /* AN000 */
77 check_disk_validity(); /* AN000 It's a drive letter */
78
79 if (regs.x.dx == (unsigned)&sp_buff) /* AN000 */
80 process_switch(); /* AN000 It's a switch*/
81 END
82 else
83 BEGIN
84 if (regs.x.ax == u(0xffff))
85 finished = TRUE; /* AN000 Then we are done*/
86 else
87 BEGIN
88 Parse_msg(regs.x.ax,STDERR,Parse_err_class); /* AN010 */
89 parse_good = FALSE;
90 finished = TRUE; /* AN000 Then we are done*/
91 END
92 END
93 END /* End WHILE */ /* AN000 */
94
95 return(parse_good); /* AN000 Return to caller*/
96
97END /* end parser */ /* AN000 */
98
99
100/* */
101/******************************************************************************/
102/*Routine name: INIT_PARSE */
103/******************************************************************************/
104/* */
105/*Description: Sets up ALL VALUES AND STRUCTS FOR PARSER. */
106/* */
107/*Called Procedures: */
108/* */
109/*Change History: Created 6/15/87 DRM */
110/* */
111/*Input: None */
112/* */
113/*Output: None */
114/* */
115/******************************************************************************/
116
117
118void parse_init() /* AN000 */
119
120BEGIN /* AN000 */
121
122
123 primary_flag = FALSE; /* AN000 */
124 extended_flag = FALSE; /* AN000 */
125 logical_flag = FALSE; /* AN000 */
126 disk_flag = FALSE; /* AN000 */
127 quiet_flag = FALSE; /* AN000 */
128
129 p_p.p_parmsx_ptr = (unsigned)&p_px; /* AN000 Address of extended parm list */
130 p_p.p_num_extra = uc(1); /* AN000 */
131 p_p.p_len_extra_delim = uc(1); /* AN000 */
132 p_p.p_extra_delim = c(SEMICOLON); /* AN000 */
133
134 p_px.p_minp = uc(0); /* AN000 1 required positional */
135 p_px.p_maxp = uc(1); /* AN000 1 maximum positionals */
136 p_px.p_con1_ptr = (unsigned)&p_con; /* AN000 pointer to next control blk */
137 p_px.p_maxs = uc(2); /* AN000 number of switches */
138 p_px.p_swi1_ptr = (unsigned)&p_swi1; /* AN000 pointer to next control blk */
139 p_px.p_swi2_ptr = (unsigned)&p_swi2; /* AN000 pointer to next control blk */
140 p_px.p_maxk = uc(NOVAL); /* AN000 no keywords */
141
142 p_con.p_match_flag = u(0x8001); /* AN000 DRIVE NUMBER 1 OR 2 optional */
143 p_con.p_function_flag = u(0x0000); /* AN000 DO NOTHING FOR FUNCTION FLAG */
144 p_con.p_buff1_ptr = (unsigned)&p_buff; /* AN000 */
145 p_con.p_val1_ptr = (unsigned)&p_val; /* AN000 */
146 p_con.p_nid = uc(0); /* AN000 */
147
148 p_swi1.sp_match_flag = u(0x8000); /* AN000 Optional (switch) */
149 p_swi1.sp_function_flag = u(0x0000); /* AN000 DO NOTHING FOR FUNCTION FLAG */
150 p_swi1.sp_buff1_ptr = (unsigned)&sp_buff; /* AN000 */
151 p_swi1.sp_val1_ptr = (unsigned)&sp_val; /* AN000 */
152 p_swi1.sp_nid = uc(3); /* AN000 3 switches allowed */
153 strcpy((char *) p_swi1.sp_switch1,PRI); /* AN000 /a switch */
154 strcpy((char *) p_swi1.sp_switch2,EXT); /* AN000 /a switch */
155 strcpy((char *) p_swi1.sp_switch3,LOG); /* AN000 /a switch */
156
157 p_swi2.sp_match_flag = u(0x0001); /* AN000 Optional (switch) */
158 p_swi2.sp_function_flag = u(0x0000); /* AN000 DO NOTHING FOR FUNCTION FLAG */
159 p_swi2.sp_buff1_ptr = (unsigned)&sp_buff; /* AN000 */
160 p_swi2.sp_val1_ptr = (unsigned)NOVAL; /* AN000 */
161 p_swi2.sp_nid = uc(1); /* AN000 3 switches allowed */
162 strcpy((char *) p_swi2.sp_switch4,QUIET); /* AN000 /a switch */
163
164 p_val.p_values = uc(1); /* AN000 - Number of values items returned */
165 p_val.p_range = uc(1); /* AN000 - Number of ranges */
166 p_val.p_range_one = uc(1); /* AN000 - range number one */
167 p_val.p_low_range = ul(1); /* AN000 - low value for range */
168 p_val.p_high_range = ul(2); /* AN000 - high value for range */
169
170 sp_val.p_values = uc(1); /* AN000 - Number of values items returned */
171 sp_val.p_range = uc(1); /* AN000 - Number of ranges */
172 sp_val.p_range_one = uc(1); /* AN000 - range number one */
173 sp_val.p_low_range = ul(1); /* AN000 - low value for range */
174 sp_val.p_high_range = ul(4000); /* AN000 - high value for range */
175
176 return; /* AN000 */
177
178END
179 /* AN000 */
180/* */
181/******************************************************************************/
182/*Routine name: CHECK_DISK_VALIDITY */
183/******************************************************************************/
184/* */
185/*Description: Checks the return buffer from parse for the positional */
186/* value to be equal to 0 or 1. */
187/* */
188/*Called Procedures: */
189/* */
190/*Change History: Created 6/18/87 DRM */
191/* */
192/*Input: None */
193/* */
194/*Output: None */
195/* */
196/******************************************************************************/
197
198
199void check_disk_validity() /* AN000 */
200
201BEGIN /* AN000 */
202
203 disk_flag = (FLAG)TRUE; /* AN000 */
204 cur_disk_buff = ((char)p_buff.p_value - 1); /* AN000 */
205 return; /* AN000 */
206END /* AN000 */
207
208/* */
209/******************************************************************************/
210/*Routine name: PROCESS_SWITCH */
211/******************************************************************************/
212/* */
213/*Description: This function looks at the return buffer of the parse and */
214/* determins the switch, places value in buffer, and sets */
215/* flag for specific switch. */
216/* */
217/*Called Procedures: */
218/* */
219/*Change History: Created 6/18/87 DRM */
220/* */
221/*Input: None */
222/* */
223/*Output: None */
224/* */
225/******************************************************************************/
226
227
228void process_switch() /* AN000 */
229
230BEGIN /* AN000 */
231
232
233 BEGIN /* AN000 */
234 if (sp_buff.p_synonym == (unsigned)p_swi1.sp_switch1) /* AN000 */
235 BEGIN /* AN000 */
236 primary_flag = (FLAG)TRUE; /* AN000 */
237 primary_buff = (unsigned)sp_buff.p_value; /* AN000 */
238 END /* AN000 */
239
240 if (sp_buff.p_synonym == (unsigned)p_swi1.sp_switch2) /* AN000 */
241 BEGIN /* AN000 */
242 extended_flag = (FLAG)TRUE; /* AN000 */
243 extended_buff = (unsigned)sp_buff.p_value; /* AN000 */
244 END /* AN000 */
245
246 if (sp_buff.p_synonym == (unsigned)p_swi1.sp_switch3) /* AN000 */
247 BEGIN /* AN000 */
248 logical_flag = (FLAG)TRUE; /* AN000 */
249 logical_buff = (unsigned)sp_buff.p_value; /* AN000 */
250 END /* AN000 */
251
252 if (sp_buff.p_synonym == (unsigned)p_swi2.sp_switch4) /* AN000 */
253 BEGIN /* AN000 */
254 quiet_flag = (FLAG)TRUE; /* AN000 */
255 END /* AN000 */
256 END /* AN000 */
257 return; /* AN000 Return to caller*/
258END /* end parser */ /* AN000 */
259
260/************************************************************************/ /* ;an000; */
261/* Parse_Message - This routine will print only those */
262/* messages that require 1 replaceable */
263/* parm. */
264/* */
265/* Inputs : Msg_Num - number of applicable message */
266/* Handle - display type */
267/* Message_Type - type of message to display */
268/* Replace_Parm - pointer to parm to replace */
269/* */
270/* Outputs : message */
271/* */
272/* Date : 03/28/88 */
273/* Version : DOS 4.00 */
274/************************************************************************/
275
276void Parse_msg(Msg_Num,Handle,Message_Type) /* AN010 */
277 /* AN010 */
278int Msg_Num; /* AN010 */
279int Handle; /* AN010 */
280unsigned char Message_Type; /* AN010 */
281
282BEGIN /* AN010 */
283char far *Cmd_Ptr; /* AN010 */
284
285
286 BEGIN /* AN010 */
287 segread(&segregs); /* AN010 */
288 FP_SEG(Cmd_Ptr) = segregs.ds; /* AN010 */
289 FP_OFF(Cmd_Ptr) = regs.x.si; /* AN010 */
290 *Cmd_Ptr = '\0'; /* AN010 */
291
292 FP_SEG(sublistp[0].value) = segregs.ds; /* AN010 */
293 FP_OFF(sublistp[0].value) = Parse_Ptr; /* AN010 */
294 sublistp[0].size = Sublist_Length; /* AN010 */
295 sublistp[0].reserved = Reserved; /* AN010 */
296 sublistp[0].id = 0; /* AN010 */
297 sublistp[0].flags = Char_Field_ASCIIZ+Left_Align; /* AN010 */
298 sublistp[0].max_width = 80; /* AN010 */
299 sublistp[0].min_width = 01; /* AN010 */
300 sublistp[0].pad_char = Blank; /* AN010 */
301
302 regs.x.ax = Msg_Num; /* AN010 */
303 regs.x.bx = Handle; /* AN010 */
304 regs.x.cx = SubCnt1; /* AN010 */
305 regs.h.dl = No_Input; /* AN010 */
306 regs.h.dh = Message_Type; /* AN010 */
307 regs.x.si = (unsigned int)&sublistp[0]; /* AN010 */
308 sysdispmsg(&regs,&regs); /* AN010 */
309 END /* AN010 */
310 return; /* AN010 */
311END /* AN010 */
312