1 ;********************************************************************************
4 ; Subroutine for scanning the SELECT command line, and if the appropriate
5 ; parameter is specified, additional information is read from the disk.
7 ;********************************************************************************
10 INCLUDE MACROS
.INC ;AN000;
11 INCLUDE STRUC.INC ;AN000;
12 INCLUDE EXT
.INC ;AN000;
16 PUBLIC SCAN_PARAMETERS_ROUTINE
;AN000;
17 EXTRN SYSPARSE
:FAR ;AN000;
18 EXTRN POS_ZERO
:FAR ;AN000;
19 EXTRN HOOK_INT_24
:FAR ;AN000;
20 EXTRN RESTORE_INT_24
:FAR ;AN000;
21 EXTRN CLOSE_FILE_ROUTINE
:FAR ;AN000;
24 DATA SEGMENT BYTE PUBLIC 'DATA';AN000;
26 PARMS
LABEL BYTE ;AN000;
27 PAR_EXTEN
DW PARMSX
;AN000; Offset of the PARMS EXTENSION BLOCK
28 PAR_NUM
DB 0 ;AN000; The number of further definitions
30 ; The PARMS EXTENSION BLOCK
31 PARMSX
LABEL BYTE ;AN000;
34 DW OFFSET CONTROL_P1
;AN000;
35 PAX_MAX_SW
DB 0 ;AN000;
36 PAX_MAX_K1
DB 0 ;AN000;
38 CONTROL_P1
LABEL BYTE ;AN000;
42 DW VALUE_LIST_P1
;AN000;
45 VALUE_LIST_P1
LABEL BYTE ;AN000;
46 DB 3 ;AN000; Number of value definitions
47 DB 0 ;AN000; Number of range definitions
48 DB 0 ;AN000; Number of actual value definitions
49 DB 2 ;AN000; Number of string definitions
50 DB 0 ;AN000; Value to be returned if this string is matched
51 DW OFFSET KEYWORD_MENU
;AN000;
52 DB 1 ;AN000; Value to be returned if this string is matched
53 DW OFFSET KEYWORD_FDISK
;AN000;
55 KEYWORD_MENU
DB 'MENU',0 ;AN000;
56 KEYWORD_FDISK
DB 'FDISK',0 ;AN000;
58 RESULT_P1
LABEL BYTE ;AN000;
59 DB 0 ;AN000; Type of operand returned
60 DB 0 ;AN000; Matched item tag
61 DW 0 ;AN000; Offset of synonym returned
62 DB 0,0,0,0 ;AN000; Unsure what this is...
69 OPTION_3
DW 0 ;AN033;SEH
70 FILE_HANDLE
DW 0 ;AN000;
74 CODE_FAR
SEGMENT BYTE PUBLIC 'CODE' ;AN000;
76 ASSUME
CS:CODE_FAR
, DS:DATA, ES:DATA ;AN000;
78 ;****************************************************************************
80 ; SCAN_PARAMETERS_ROUTINE: Scan SELECT command line for parameters.
82 ; SYNTAX: SCAN_PARAMETERS mode, option, path, filename, buffer, buff_size
85 ; DI = The name of the file which contains the FDISK parameters.
87 ; SI = A buffer where the data read from the file can be stored.
88 ; CX = The size of the buffer.
92 ; = 0: Parameter is MENU
93 ; = 1: Parameter is FDISK
94 ; = 0FFH: Parameter is invalid
98 ; = 0FFh: Parameter is invalid (not 0, 1, 2)
100 ; DI = Install path in ASCII-N format
102 ; OPERATION: The SELECT command line is scanned for parameters. The
103 ; return codes for the various parameters are provided in variables
104 ; defined above. If the parameter on the command line is FDISK, then
105 ; the file specified in FILENAME is opened and additional parameters
106 ; are read. If the parameters in the file are invalid, or if the file
107 ; cannot be found, then 0FFh is returned in MODE and OPTION, and the
108 ; path length is set to zero.
111 ; Before this macro is executed, there must be as ASSUME ES:DATA
112 ; statement. If not, the parser will not execute properly and
113 ; either the computer will hang or erroneous values will be returned.
115 ;****************************************************************************
116 PATH EQU
[BP+12] ;AN000;
117 FILENAME EQU
[BP+10] ;AN000;
118 BUFFER EQU
[BP+8] ;AN000;
119 BUFF_SIZE EQU
[BP+6] ;AN000;
121 SCAN_PARAMETERS_ROUTINE PROC
FAR ;AN000;
125 MOV OPTION_1
, E_SELECT_INV
;AN000;
126 MOV OPTION_2
, E_SELECT_INV
;AN000;
128 PUSH ES ;AN000; Save the extra register
129 MOV AX, DATA ;AN000; ES contain control block segment
131 MOV DI, OFFSET PARMS
;AN000; DI contains offset of control block
132 MOV SI, 0081H ;AN000; SI contains offset of command line
133 MOV DX, 0 ;AN000; DX and CX must be zero
135 MOV AH, 062H ;AN000; Get the PSP segment
138 PUSH BX ;AN000; Save for later reference
140 POP AX ;AN000; Get the PSP segment
141 PUSH AX ;AN000; Place on stack again
142 PUSH DS ;AN000; Save the current data segment
143 MOV DS, AX ;AN000; Load DS with the segment of the command line
144 CALL SYSPARSE
;AN000; Parse the command line
145 POP DS ;AN000; Restore the data segment
147 .IF < AX EQ 0 > ;AN000; Were there any errors?
148 MOV BX, DX ;AN000; No! Get the address of the result block
149 MOV AL, [BX]+1 ;AN000; Yes! Get the returned value
150 MOV AH, 0 ;AN000; Zero the high byte
151 MOV MODE
, AX ;AN000; Store the result
152 JMP NEXT_PARSE
;AN000; Parse the next parameter
153 .ELSEIF
< AX NE
-1 > ;AN000; If there was an error, indicate so.
154 MOV MODE
, E_SELECT_INV
;AN000; Return that the values are invalid
155 MOV OPTION_1
, E_SELECT_INV
;AN000;
156 MOV OPTION_2
, E_SELECT_INV
;AN000;
158 POP AX ;AN000; Take the PSP segment off the stack
159 MOV AX,MODE
;AN000; Store the result
163 SCAN_PARAMETERS_ROUTINE ENDP
;AN000;
164 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
166 ; SCAN_INFO_FILE_ROUTINE: Scan SELECT.TMP file for parameters.
169 ; The following variables have been passed to this routine from the
170 ; SCAN_INFO_FILE macro by pushing them on the stack:
172 ; FILENAME EQU [BP+10]
174 ; BUFF_SIZE EQU [BP+6]
178 ; = 0: Parameter is MENU
179 ; = 1: Parameter is FDISK
180 ; = 0FFH: Parameter is invalid
184 ; = 0FFh: Parameter is invalid (not 1, 2, 3)
187 ; = 0FFh: Parameter is invalid (not 1, 2)
190 ; = 0FFh: Parameter is invalid (not 1, 2)
192 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
193 PUBLIC SCAN_INFO_FILE_ROUTINE
;AN000;
194 SCAN_INFO_FILE_ROUTINE PROC
FAR ;AN000;
195 CALL HOOK_INT_24
;AN000;
199 MOV OPTION_0
, E_SELECT_INV
;AN000;
200 MOV OPTION_1
, E_SELECT_INV
;AN000;
201 MOV OPTION_2
, E_SELECT_INV
;AN000;
202 MOV OPTION_3
, E_SELECT_INV
;AN033;SEH
203 PUSH ES ;AN000; Save the extra register
205 .IF < MODE NE E_SELECT_INV
> AND NEAR ;AN000; If no error has occured yet,
206 .IF < MODE
EQ 1 > NEAR ;AN000; and if the parameter was FDISK...
207 MOV DI, FILENAME
;AN000; Get the offset of the filename
208 CALL POS_ZERO
;AN000; Make into an ASCII-Z string
209 MOV DX, DI ;AN000; Load filename offset again
210 ADD DX, 2 ;AN000; Adjust pointer past the length word
211 MOV AX, 3D00H
;AN000; Fn call for opening a file for reading
212 DOSCALL
;AN000; Open the file
213 .IF < C
> ;AN000; If there was as error, do not continue
214 JMP FILE_ERROR
;AN000; Return INVALID parameters to the caller
216 MOV FILE_HANDLE
, AX ;AN000; Save the returned file handle
217 MOV AH, 3FH
;AN000; DOS Fn for reading from a file
218 MOV DX, BUFFER
;AN000; Get the offset of the data buffer
219 MOV CX, BUFF_SIZE
;AN000; Get the number of bytes in the buffer
220 MOV BX, FILE_HANDLE
;AN000; Get the file handle for the opened file
221 DOSCALL
;AN000; Read from the file
222 .IF < C
> ;AN000; If there was an error, do not continue
223 JMP FILE_ERROR
;AN000; Return INVALID parameters to the caller
225 MOV SI, BUFFER
;AN000; Get the offset of the data buffer
226 MOV BH, 0 ;AN000; Zero the high byte
227 MOV BL, BYTE PTR [SI] ;AN000; Get the first byte from the file
228 SUB BL, '0' ;AN000; Turn into a binary number
229 MOV OPTION_0
, BX ;AN000; Save this as the first option
230 MOV BL, BYTE PTR [SI+3] ;AN000; Get the first byte from the file
231 SUB BL, '0' ;AN000; Turn into a binary number
232 MOV OPTION_1
, BX ;AN000; Save this as the first option
233 MOV BL, BYTE PTR [SI+6] ;AN000; Get the second option in the file
234 SUB BL, '0' ;AN000; Make into a binary value
235 MOV OPTION_2
, BX ;AN000; Save this second option
236 MOV BL, BYTE PTR [SI+9] ;AN033; SEH Get the third option in the file
237 SUB BL, '0' ;AN033; SEH Make into a binary value
238 MOV OPTION_3
, BX ;AN033; SEH Save this third option
239 MOV SI, BUFFER
;AN000; Get the offset of the data buffer
240 ADD SI, 12 ;AC033; SEH Point to the start of the path line
241 MOV DI, PATH
;AN000; Get the offset of the path storage
243 ADD DI, 2 ;AN000; Adjust pointer past the length word
244 ; AX contains the number of characters read from the file
245 SUB AX, 12 ;AC033; SEH Number of characters left in the buffer
246 MOV CX, 0 ;AN000; Number of characters in the path string
247 MOV WORD PTR [BX], 0 ;AN000; Zero the string length to begin
248 .WHILE < AX GT
0 > ;AN000; Continue while there are characters left
249 MOV DL, [SI] ;AN000; Get the character from the buffer
250 .IF < DL EQ E_CR
> OR ;AN000; See if this is the end of the line
251 .IF < DL EQ E_LF
> ;AN000;
252 MOV [BX], CX ;AN000; Store the length of path
255 MOV [DI], DL ;AN000; Store the byte in the path
256 INC DI ;AN000; Increment the path pointer
257 INC SI ;AN000; Increment the source pointer
258 INC CX ;AN000; Increment the count of characters
259 DEC AX ;AN000; Decrement the numbers of characters left
260 .IF < CX A M_INSTALL_PATH
> ;AN000; If more then 40 characters then an error
261 JMP FILE_ERROR
;AN000;
264 .IF < OPTION_1 AE
1 > AND ;AN000; If option is 1 or 2 then a path is needed
265 .IF < OPTION_1 BE
3 > ;AN000;
266 .IF < <WORD PTR [BX]> EQ 0 > ;AN000; If the path length was 0, return error
267 JMP FILE_ERROR
;AN000;
270 .IF < <WORD PTR [BX]> NE
0 > ;AN000; If option is 3 and there is a path, error
271 JMP FILE_ERROR
;AN000;
274 JMP CLOSE_THE_FILE
;AN000;
275 FILE_ERROR: ;AN000; Here if there has been an error
276 MOV MODE
, E_SELECT_INV
;AN000;
277 MOV OPTION_1
, E_SELECT_INV
;AN000;
278 MOV OPTION_2
, E_SELECT_INV
;AN000;
279 MOV OPTION_3
, E_SELECT_INV
;AN033; SEH
281 MOV WORD PTR [BX], 0 ;AN000;
282 CLOSE_THE_FILE: ;AN000; Close the file
283 MOV BX, FILE_HANDLE
;AN000; Get the file handle
284 CLOSE_FILE
BX ;AN000; Close the file
286 MOV AX, option_0
;AN000; Return the parameters
287 MOV BX, OPTION_1
;AN000;
288 MOV CX, OPTION_2
;AN000;
289 MOV DX, OPTION_3
;AN033; SEH
291 POP ES ;AN000; Restore the extra segment
293 CALL RESTORE_INT_24
;AN000;
295 SCAN_INFO_FILE_ROUTINE ENDP
;AN000;
296 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
297 CODE_FAR ENDS
;AN000;