2 ; SCCSID = @(#)tenv2.asm 1.1 85/05/14
3 ; SCCSID = @(#)tenv2.asm 1.1 85/05/14
4 TITLE Part6 COMMAND Transient routines
.
6 ; Environment utilities and misc. routines
19 DATARES
SEGMENT PUBLIC BYTE ;AC000;
23 TRANDATA
SEGMENT PUBLIC BYTE ;AC000;
28 EXTRN Extend_buf_ptr
:word ;AN000;
29 EXTRN Extend_buf_sub
:byte ;AN022;
30 EXTRN MD_exists_ptr
:word ;AN006;
31 EXTRN msg_disp_class
:byte ;AC000;
32 EXTRN NOSPACE_PTR
:WORD
33 EXTRN parse_chdir
:byte ;AC000;
34 EXTRN parse_mrdir
:byte ;AC000;
35 EXTRN PIPEEMES_PTR
:WORD
36 EXTRN string_buf_ptr
:word
39 TRANSPACE
SEGMENT PUBLIC BYTE ;AC000;
44 EXTRN dirflag
:byte ;AN015;
45 EXTRN KPARSE
:BYTE ;AC000; 3/3/KK
46 EXTRN msg_numb
:word ;AN022;
47 EXTRN parse1_addr
:dword ;AC000;
48 EXTRN parse1_type
:byte ;AC000;
51 EXTRN srcxname
:byte ;AC000;
52 EXTRN string_ptr_2
:word
57 TRANCODE
SEGMENT PUBLIC byte
59 ASSUME
CS:TRANGROUP
,DS:NOTHING
,ES:NOTHING
,SS:NOTHING
80 ; ****************************************************************
84 ; * FUNCTION: Entry point for CHDIR command. Parse the command
85 ; * line. If path is found, CHDIR to path. If a drive
86 ; * letter is found, get and display the current dir
87 ; * of the specified drive. If nothing is found, get
88 ; * and display the current dir of the default drive.
90 ; * INPUT: command line at offset 81H
94 ; ****************************************************************
96 assume
ds:trangroup
,es:trangroup
101 mov di,offset trangroup
:parse_chdir
;AN000; Get adderss of PARSE_CHDIR
102 xor cx,cx ;AN000; clear cx,dx
104 invoke parse_with_msg
;AC018; call parser
106 cmp ax,end_of_line
;AC000; are we at end of line?
108 cmp ax,result_no_error
;AC000; did we have an error?
109 jnz ChDirErr
;AC018; yes - exit
111 cmp parse1_type
,result_drive
;AC000; was a drive entered?
114 ; D: was found. See if there is anything more.
116 mov di,offset trangroup
:parse_chdir
;AC000; get address of parse_chdir
118 invoke parse_check_eol
;AC000; call parser
122 invoke build_dir_for_chdir
; Drive only specified
128 push si ;AN000; save position in line
129 lds si,parse1_addr
;AN000; get address of filespec
130 invoke move_to_srcbuf
;AN000; move to srcbuf
131 pop si ;AN000; restore position in line
132 mov di,offset trangroup
:parse_chdir
;AC000; get address of parse_chdir
134 invoke parse_check_eol
;AC000; call parser
144 invoke get_ext_error_number
;AN022; get the extended error
145 cmp ax,error_path_not_found
;AN022; see if path not found
146 jz BadChDir
;AN022; yes - issue old message
147 call Set_Ext_Error_Subst
;AN022;
148 jmp short chdirerr
;AN022;
151 MOV DX,OFFSET TRANGROUP
:BADCD_ptr
159 assume
ds:trangroup
,es:trangroup
168 invoke get_ext_error_number
;AN022; get the extended error
169 cmp ax,error_path_not_found
;AN022; see if path not found
170 jz MD_other_err
;AN022; yes - issue old message
171 cmp ax,error_access_denied
;AN022; access denied?
172 jz badmderr
;AN022; yes - see if file exists
174 call Set_Ext_Error_Subst
;AN022;
175 jmp short MkDirerr
;AC022; yes - go print it
178 mov dx,offset trangroup
:srcxname
;AN006; Set Disk transfer address
179 mov ah,Set_DMA
;AN006;
180 int int_command
;AN006;
181 MOV AH,Find_First
;AN006; see if file/dir exists
182 mov cx,attr_directory
;AN006; search for directory
183 INT int_command
;AN006;
184 jc MD_other_err
;AN006; doesn't exist - must be something else
185 mov dl,srcxname
.find_buf_attr
;AN006; we found a file/dir
186 test dl,attr_directory
;AN006; was it a directory?
187 jz MD_other_err
;AN006; no - must have been a file
188 mov dx,offset trangroup
:MD_exists_ptr
;AN006; set up already exists error
189 jmp short MkDirErr
;AN006; make sure we didn't have network error
190 MD_other_err: ;AN006;
191 MOV DX,OFFSET TRANGROUP
:BADMKD_ptr
196 Break <Common MkDir
/RmDir set up
code>
198 ;****************************************************************
202 ;* FUNCTION: Parse routine for the internal MKDIR and RMDIR
203 ;* commands. Parses the command line for a required
206 ;* INPUT: command line at offset 81H
208 ;* OUTPUT: carry clear
209 ;* DS:DX points to ASCIIZ argument
211 ;* DS:DX has error message pointer
213 ;****************************************************************
217 mov di,offset trangroup
:parse_mrdir
;AN000; Get adderss of PARSE_MRDIR
218 xor cx,cx ;AN000; clear cx,dx
220 invoke parse_with_msg
;AC000; call parser
221 cmp ax,result_no_error
;AC000; did we have an error?
222 jnz NOARGERR
;AC000; yes - exit
224 mov di,offset trangroup
:srcxname
;AN000; get address of srcxname
225 push di ;AN000; save address
226 push si ;AN000; save position in line
227 lds si,parse1_addr
;AN000; get address of path
229 mrdir_move_filename: ;AN000; put filespec in srcxname
230 lodsb ;get a char from buffer
231 stosb ;AN000; store in srcxname
232 cmp al,end_of_line_out
;AC000; it char a terminator?
233 jnz mrdir_move_filename
;AC000; no - keep moving
234 pop si ;AN000; get line position back
237 ; we have scanned an argument. See if any args beyond.
240 mov di,offset trangroup
:parse_mrdir
;AC000; get address of parse_mrdir
241 invoke parse_check_eol
;AC000; are we at end of line?
242 pop dx ;AC000; get address of SRCXNAME
243 retz
;yes - return no error
245 mov dx,offset TranGroup
:Extend_Buf_ptr
;AC000; get extended message pointer
252 assume
ds:trangroup
,es:trangroup
262 invoke get_ext_error_number
;AN022; get the extended error
263 cmp ax,error_path_not_found
;AN022; see if path not found
264 jz badrderr
;AN022; yes - issue old message
265 cmp ax,error_access_denied
;AN022; access denied?
266 jz badrderr
;AN022; yes - issue old message
268 call Set_Ext_Error_Subst
;AN022;
269 jmp short RmDirerr
;AC022; yes - go print it
272 MOV DX,OFFSET TRANGROUP
:BADRMD_ptr
278 ;****************************************************************
280 ;* ROUTINE: Set_ext_error_subst
282 ;* FUNCTION: Sets up substitution for extended error
284 ;* INPUT: AX - extended error number
285 ;* DX - offset of string
287 ;* OUTPUT: Extend_Buf_Ptr set up for STD_EPRINTF
289 ;****************************************************************
291 Set_ext_error_subst proc
near ;AN022;
293 mov msg_disp_class
,ext_msg_class
;AN022; set up extended error msg class
294 mov string_ptr_2
,dx ;AN022; get address of failed string
295 mov Extend_buf_sub
,one_subst
;AN022; put number of subst in control block
296 mov dx,offset TranGroup
:Extend_Buf_ptr
;AN022; get extended message pointer
297 mov Extend_Buf_ptr
,ax ;AN022; get message number in control block
301 Set_ext_error_subst endp
;AN022;
307 Break <SavUDir
- preserve the users current directory
on a particular drive
>
310 ; SavUDir - move the user's current directory on a drive into UserDir1
311 ; SavUDir1 - move the user's current directory on a drive into a specified
314 ; Inputs: DL has 1-based drive number
315 ; ES:DI has destination buffer (SavUDir1 only)
316 ; Outputs: Carry Clear
320 ; Registers Modified: AX, SI
324 MOV DI,OFFSET TRANGROUP
:USERDIR1
344 MOV AH,CURRENT_DIR
; Get the Directory Text
356 MOV DX,OFFSET TRANGROUP
:ACRLF_ptr
369 ; These routines (SCANOFF, DELIM) are called in batch processing when DS
370 ; may NOT be TRANGROUP
372 ASSUME
DS:NOTHING
,ES:NOTHING
378 DEC SI ; Point to first non-delimiter
382 ; Input: AL is character to classify
383 ; Output: Z set if delimiter
385 ; Registers modified: none
397 CMP AL,9 ; Check for TAB character
399 CMP AL,0ah ; Check for line feed character - BAS
403 ASSUME
DS:TRANGROUP
,ES:TRANGROUP
406 FCB_TO_ASCZ: ; Convert DS:SI to ASCIZ ES:DI
441 ; Compare ASCIZ DS:SI with ES:DI.
445 retnz
; Strings not equal
446 cmp byte ptr [SI-1],0 ; Hit NUL terminator?
447 retz
; Yes, strings equal
448 jmp short STRCOMP
; Equal so far, keep going
462 REPNZ SCASB ; LOOK FOR TERMINATOR
463 mov byte ptr [di-1],0 ; nul terminate the string
466 mov dx,offset trangroup
:string_buf_ptr
468 mov ds:byte ptr [di-1],13 ; now put the CR back
484 MOV DX,OFFSET TRANGROUP
:NOSPACE_ptr
489 MOV DX,OFFSET TRANGROUP
:PIPEEMES_ptr
493 ASSUME
DS:TRANGROUP
,ES:TRANGROUP
496 ;---- Mod for path invocation ----
514 ; Drive taken from FCB
515 ; User dir saved in userdir1
517 ; Zero set if path dir, CHDIR to this dir, FCB filled with ?
518 ; NZ set if path/file, CHDIR to file, FCB has file (parsed fill ' ')
519 ; [DESTTAIL] points to parse point
520 ; Carry set if no CHDIRs worked, FCB not altered.
521 ; DESTISDIR set non zero if PATHCHRs in path (via SETPATH)
524 mov [msg_numb],0 ;AN022; Set up message flag
527 jc pcrunch_cderrJ ;AN022; if error on current dir - report
531 JNZ TRYPEEL ; If ? or * cannot be pure dir
535 jnc chdir_worked ;AN022; no error - continue
537 invoke get_ext_error_number ;AN022; get the extended error
538 cmp ax,error_path_not_found ;AN022; if path not found
539 jz trypeel ;AC022; keep trying
540 cmp ax,error_access_denied ;AN022; if access denied
541 jz trypeel ;AC022; keep trying
542 mov [msg_numb],ax ;AN022; set up message flag
543 jmp peelfail ;AN022; exit with other error
547 MOV AL,'?
' ; *.* is default file spec if pure dir
554 pcrunch_cderrj: ;AN022; need this for long jmp
555 jmp pcrunch_cderr ;AN022;
559 DEC SI ; Point at NUL
563 JNZ DELSTRT ; Last char is second KANJI byte, might be '\'
566 JZ PEELFAIL
; Trailing '/'
595 DELLOOP2: ; Set value of KPARSE
609 CMP BYTE PTR [SI+1],al
611 JZ PEELFAIL
; If . or .., pure cd should have worked
613 CMP al,':' ; Special case d:\file
617 JNZ NOTDOUBLESL
; Last char is second KANJI byte, might be '\'
630 invoke get_ext_error_number
;AN022; get the extended error
631 mov [msg_numb
],ax ;AN022; set up message flag
632 or si,si ;AN022; set up zero flag to not zero
633 stc ;AN022; set up carry flag
638 CALL PATHCHRCMP
; Special case 'DIRCHAR'file
645 jc pcrunch_cderr
;AN022; go to error exit
651 pushf ;AN015; save flags
652 cmp dirflag
,-1 ;AN015; don't do parse if in DIR
653 jz pcrunch_end
;AN015;
655 MOV AX,(PARSE_FILE_DESCRIPTOR
SHL 8) OR 02H ; Parse with default drive
658 popf ;AN015; get flags back