summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/COMMAND/TCMD2B.ASM
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/COMMAND/TCMD2B.ASM
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/COMMAND/TCMD2B.ASM')
-rw-r--r--v4.0/src/CMD/COMMAND/TCMD2B.ASM597
1 files changed, 597 insertions, 0 deletions
diff --git a/v4.0/src/CMD/COMMAND/TCMD2B.ASM b/v4.0/src/CMD/COMMAND/TCMD2B.ASM
new file mode 100644
index 0000000..4db1f11
--- /dev/null
+++ b/v4.0/src/CMD/COMMAND/TCMD2B.ASM
@@ -0,0 +1,597 @@
1 page 80,132
2; SCCSID = @(#)tcmd2b.asm 4.1 85/09/22
3; SCCSID = @(#)tcmd2b.asm 4.1 85/09/22
4TITLE PART5 COMMAND Transient routines.
5
6.xlist
7.xcref
8 INCLUDE comsw.asm
9 INCLUDE DOSSYM.INC
10 INCLUDE comseg.asm
11 INCLUDE comequ.asm
12.list
13.cref
14
15
16CODERES SEGMENT PUBLIC BYTE ;AC000;
17 EXTRN LODCOM1:NEAR
18CODERES ENDS
19
20DATARES SEGMENT PUBLIC BYTE ;AC000;
21 EXTRN crit_msg_off:word ;AC000;
22 EXTRN crit_msg_seg:word ;AC000;
23 EXTRN IO_SAVE:WORD
24 EXTRN OldTerm:DWORD
25 EXTRN PARENT:WORD
26;AD060; EXTRN pars_msg_off:word ;AC000;
27;AD060; EXTRN pars_msg_seg:word ;AC000;
28 EXTRN PERMCOM:BYTE ;AN045;
29 EXTRN RetCode:WORD
30DATARES ENDS
31
32TRANDATA SEGMENT PUBLIC BYTE ;AC000;
33 EXTRN ACRLF_PTR:WORD ;AN007;
34 EXTRN baddev_ptr:word
35 EXTRN CP_active_Ptr:word
36 EXTRN CP_not_all_Ptr:word
37 EXTRN CP_not_set_Ptr:word
38 EXTRN Extend_buf_ptr:word ;AN000;
39 EXTRN Extend_buf_sub:byte ;AN000;
40 EXTRN inv_code_page:word ;AC000;
41 EXTRN msg_disp_class:byte ;AN000;
42 EXTRN NLSFUNC_Ptr:word ;AC000;
43 EXTRN parse_chcp:byte ;AC000;
44 EXTRN parse_chdir:byte ;AC000;
45 EXTRN parse_ctty:byte ;AC000;
46 EXTRN string_buf_ptr:word ;AC000;
47
48TRANDATA ENDS
49
50TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
51 EXTRN COMBUF:BYTE
52 EXTRN parse_last:word ;AN018;
53 EXTRN parse1_addr:dword ;AC000;
54 EXTRN parse1_type:byte ;AC000;
55 EXTRN RESSEG:WORD
56 EXTRN srcbuf:byte
57 EXTRN srcxname:byte ;AC000;
58 EXTRN string_ptr_2:word
59 EXTRN system_cpage:word
60 EXTRN TRAN_TPA:WORD
61TRANSPACE ENDS
62
63TRANCODE SEGMENT PUBLIC BYTE
64
65ASSUME CS:TRANGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING
66
67;---------------
68
69TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
70 EXTRN arg:byte ; the arg structure!
71TRANSPACE ENDS
72;---------------
73
74 EXTRN cerror:near
75
76 PUBLIC $exit
77 PUBLIC chcp
78 PUBLIC ctty
79 PUBLIC parse_check_eol ;AN000;
80 PUBLIC parse_with_msg ;AN018;
81 PUBLIC setup_parse_error_msg ;AN018;
82 PUBLIC truename ;AN000;
83
84 break Ctty
85assume ds:trangroup,es:trangroup
86
87; ****************************************************************
88; *
89; * ROUTINE: CTTY - Change console
90; *
91; * SYNTAX: CTTY device
92; *
93; * FUNCTION: If a valid console device is specified, CTTY will
94; * duplicate the device handle to STDIN, STDOUT and
95; * STDERR. This routine returns to LODCOM1.
96; *
97; * INPUT: command line at offset 81H
98; *
99; * OUTPUT: none
100; *
101; ****************************************************************
102
103CTTY:
104 push ds ;AN000; Get local ES
105 pop es ;AN000;
106 mov si,81H ;AC000; Get command argument for CTTY
107
108 mov di,offset trangroup:parse_ctty ;AC000; Get adderss of PARSE_CTTY
109 xor cx,cx ;AC000; clear cx,dx
110 xor dx,dx ;AC000;
111 invoke cmd_parse ;AC000; call parser
112 cmp ax,end_of_line ;AN000; are we at end of line?
113 jz ctty_error ;AN000; yes - error
114 cmp ax,result_no_error ;AN000; did an error occur
115 jnz ctty_error ;AN000; YES -ERROR
116
117 push si ;AN000; save position in line
118 lds si,parse1_addr ;AN000; get address of filespec
119 mov di,offset trangroup:srcbuf ;AN000; get address of srcbuf
120
121ctty_move_filename: ;AN000; put filespec in srcbuf
122 lodsb ;AN000; get a char from buffer
123 stosb ;AN000; store in srcbuf
124 cmp al,end_of_line_out ;AN000; it char a terminator?
125 jnz ctty_move_filename ;AN000; no - keep moving
126 pop si ;AN000; get line position back
127 mov di,offset trangroup:parse_ctty ;AC000; Get adderss of PARSE_CTTY
128 call parse_check_eol ;AN000; are we at end of line?
129 jz nocolon ;AN000; yes - continue
130
131ctty_error:
132 jmp isbaddev ;AC000; yes - exit
133
134nocolon:
135 mov dx,offset trangroup:srcbuf ;AN000; get address of srcbuf
136 MOV AX,(OPEN SHL 8) OR 2 ; Read and write
137 INT int_command ; Open new device
138 JC ISBADDEV
139 MOV BX,AX
140 MOV AX,IOCTL SHL 8
141 INT int_command
142 TEST DL,80H
143 JNZ DEVISOK
144
145CLOSEDEV: ;AN007;
146 MOV AH,CLOSE ; Close initial handle
147 INT int_command
148
149ISBADDEV:
150 MOV DX,OFFSET TRANGROUP:BADDEV_ptr
151 invoke std_printf
152 JMP RESRET
153
154DEVISOK:
155 push dx ;AN007; save device info
156 mov ax,acrlf_ptr ;AN021; get message number for 0d, 0a
157 mov dh,util_msg_class ;AN021; this is a utility message
158 push bx ;AN021; save handle
159 invoke Tsysgetmsg ;AN021; get the address of the message
160 mov dx,si ;AN021; get address into dx
161 mov ax,(write shl 8) ;AN007; write to device
162 mov cx,2 ;AN007; write two bytes
163 int int_command ;AN007;
164 pop bx ;AN021; get back handle
165 pop dx ;AN007; get back device info
166 jc closedev ;AN007; if error, quit
167 XOR DH,DH
168 OR DL,3 ; Make sure has CON attributes
169 MOV AX,(IOCTL SHL 8) OR 1
170 INT int_command
171 PUSH BX ; Save handle
172 MOV CX,3
173 XOR BX,BX
174
175ICLLOOP: ; Close basic handles
176 MOV AH,CLOSE
177 INT int_command
178 INC BX
179 LOOP ICLLOOP
180 POP BX ; Get handle
181 MOV AH,XDUP
182 INT int_command ; Dup it to 0
183 MOV AH,XDUP
184 INT int_command ; Dup to 1
185 MOV AH,XDUP
186 INT int_command ; Dup to 2
187 MOV AH,CLOSE ; Close initial handle
188 INT int_command
189
190RESRET:
191 MOV DS,[RESSEG]
192ASSUME DS:RESGROUP
193 PUSH DS
194 MOV AX,WORD PTR DS:[PDB_JFN_Table] ; Get new 0 and 1
195 MOV [IO_SAVE],AX
196 MOV AX,OFFSET RESGROUP:LODCOM1
197 PUSH AX
198
199ZMMMM PROC FAR
200 RET ; Force header to be checked
201ZMMMM ENDP
202
203 break Chcp
204
205;****************************************************************
206;*
207;* ROUTINE: CHCP - Change code page internal command
208;* (added DOS 3.30 07/21/86)
209;*
210;* SYNTAX: CHCP [xxx]
211;* where xxx is a valid code page
212;*
213;* FUNCTION: If xxx is specified, CHCP will use INT 21H function
214;* 6402H to set the code page to xxxx. If no parameters
215;* are specified, CHCP will use INT 21H function 6401H
216;* to get global code page and display it to the user.
217;*
218;* INPUT: command line at offset 81H
219;*
220;* OUTPUT: none
221;*
222;****************************************************************
223
224NLSFUNC_installed equ 0ffh
225set_global_cp equ 2
226get_global_cp equ 1
227
228assume ds:trangroup,es:trangroup
229
230CHCP:
231 push ds ;AN000; Get local ES
232 pop es ;AN000;
233 mov si,81H ;AC000; Get command argument for CHCP
234
235 mov di,offset trangroup:parse_chcp ;AN000; Get adderss of PARSE_CHCP
236 xor cx,cx ;AC000; clear cx,dx
237 xor dx,dx ;AC000;
238 call parse_with_msg ;AC018; call parser
239 cmp ax,end_of_line ;AN000; are we at end of line?
240
241 jnz setcp ;AC000; no go get number & set code page
242 jmp getcp ;AC000; yes - no parm - get code page
243
244setcp:
245 cmp ax,result_no_error ;AN000; did we have an error?
246 jne cp_error ;AC018; yes - go issue message
247
248 push cx ;AN000; save positional count
249 mov bx,offset trangroup:parse1_addr ;AN000; get number returned
250 mov cx,word ptr [bx] ;AN000; into cx
251 mov system_cpage,cx ;AN000; save user input number
252 pop cx ;AC000; restore positional count
253 mov di,offset trangroup:parse_chcp ;AN000; Get adderss of PARSE_CHCP
254 call parse_check_eol ;AN000; are we at end of line?
255 jnz cp_error ;AC000; no - exit
256
257okset:
258 mov ah,NLSFUNC ;AN000; see if NLSFUNC installed
259 mov al,0 ;AN000;
260 int 2fh ;AN000;
261 cmp al,NLSFUNC_installed ;AN000;
262 jz got_NLS ;AN000; Yes - continue
263 mov dx,offset trangroup:NLSFUNC_ptr ;AN000; no - set up error message
264 jmp short cp_error ;AN000; error exit
265
266got_NLS:
267 mov bx,system_cpage ;AN000; get user input code page
268 mov ah,getsetcdpg ;get/set global code page function
269 mov al,set_global_cp ;minor - set
270 int int_command
271 jnc chcp_return ;no error - exit
272;
273;added for p716
274;
275 cmp ax,error_file_not_found ;p716 was the error file not found?
276 jnz chcp_other_error ;no - country.sys was found
277
278 mov ah,GetExtendedError ;p850 see if error is invalid data
279 xor bx,bx ; which is file was found but CP
280 int int_command ; information was not found.
281 cmp ax,error_invalid_data ;AC000; invalid code page
282 jnz no_countrysys ;no - use file not found
283 mov dx,offset trangroup:inv_code_page ;AN000; get message
284 jmp short cp_error ;AC000; error exit
285
286no_countrysys:
287 mov msg_disp_class,ext_msg_class ;AN000; set up extended error msg class
288 mov dx,offset TranGroup:Extend_Buf_ptr ;AC000; get extended message pointer
289 mov Extend_Buf_ptr,error_file_not_found ;AN000; get message number in control block
290 jmp short cp_error ;AC000; error exit
291
292chcp_other_error:
293;
294; end of p716
295;
296 mov ah,GetExtendedError ;error - see what it is
297 xor bx,bx
298 int int_command
299 cmp ax,65 ;was it access denied?
300 jnz none_set ;no - assume all failed
301 mov dx,offset trangroup:cp_not_all_ptr ;set up message
302 jmp short cp_error ;AC000; error exit
303
304none_set:
305 mov dx,offset trangroup:cp_not_set_ptr ;set up message
306cp_error: ;AN000;
307 jmp cerror ;exit
308
309getcp:
310 mov ah,getsetcdpg ;get/set global code page function
311 mov al,get_global_cp ;minor - get
312 int int_command
313 mov system_cpage,bx ;get active cp for output
314 mov dx,offset trangroup:cp_active_ptr
315 invoke std_printf ;print it out
316
317chcp_return:
318
319 RET
320
321 break TRUENAME ;AN000;
322
323
324; ****************************************************************
325; *
326; * ROUTINE: TRUENAME
327; *
328; * FUNCTION: Entry point for the internal TRUENAME command.
329; * Parses the command line. If a path is found, set
330; * SRCXNAME to path. If only a drive letter is
331; * found, set SRCXNAME to the drive letter. If
332; * no path is found, set the path of SRCXNAME to
333; * dot (.) for current directory. Use the NAME
334; * TRANSLATE system call to get the real name and
335; * then display the real name. If an error occurs
336; * issue an error message and transfer control to
337; * CERROR.
338; *
339; * INPUT: command line at offset 81H
340; *
341; * OUTPUT: none
342; *
343; ****************************************************************
344
345assume ds:trangroup,es:trangroup ;AN000;
346
347TRUENAME: ;AN000; TRUENAME entry point
348 push ds ;AN000; Get local ES
349 pop es ;AN000;
350 mov si,81H ;AN000; Get command line
351 mov di,offset trangroup:parse_chdir ;AN000; Get adderss of PARSE_CHDIR
352 xor cx,cx ;AN000; clear cx,dx
353 xor dx,dx ;AN000;
354 call parse_with_msg ;AC018; call parser
355
356 mov di,offset trangroup:srcxname ;AN000; get address of srcxname
357 cmp ax,end_of_line ;AN000; are we at end of line?
358 je tn_eol ;AN000; yes - go process
359 cmp ax,result_no_error ;AN000; did we have an error?
360 jne tn_parse_error ;AN000; yes - go issue message
361 cmp parse1_type,result_drive ;AN000; was a drive entered?
362 je tn_drive ;AN000; yes - go process
363 jmp short tn_filespec ;AN000; nothing else - must be filespec
364
365tn_eol: ;AN000; no parameters on line
366 mov ah,end_of_line_out ;AN000; set buffer to .
367 mov al,dot_chr ;AN000; for current dir
368 stosw ;AN000; store in srcxname
369 jmp short tn_doit ;AN000; go do command
370
371tn_drive: ;AN000; a drive was entered
372 push si ;AN000; save position in line
373 mov si,offset trangroup:parse1_addr ;AN000; get address of drive
374 lodsb ;AN000; get the drive number
375 add al,"A"-1 ;AN000; convert it to char
376 stosb ;AN000; store it in srcxname
377 mov ax,dot_colon ;AN000; get colon and . and
378 stosw ;AN000; store in srcxname
379 mov al,end_of_line_out ;AN000; put a terminator char
380 stosb ;AN000;
381 pop si ;AN000; get line position back
382 jmp short tn_check_eol ;AN000; check to make sure eol
383
384tn_filespec: ;AN000; a filespec was entered
385 push si ;AN000; save position in line
386 lds si,parse1_addr ;AN000; get address of filespec
387
388tn_move_filename: ;AN000; put filespec in srcxname
389 lodsb ;AN000; get a char from buffer
390 stosb ;AN000; store in srcxname
391 cmp al,end_of_line_out ;AN000; it char a terminator?
392 jnz tn_move_filename ;AN000; no - keep moving
393 pop si ;AN000; get line position back
394
395tn_check_eol: ;AN000; make sure no extra parms
396 mov di,offset trangroup:parse_chdir ;AN000; get address of parse_chdir
397 call parse_check_eol ;AN000; are we at end of line?
398 je tn_doit ;AN000; Yes - do the command
399
400tn_parse_error: ;AN000; A parse error occurred
401 jmp cerror ;AN000; Go to error routine
402
403tn_doit: ;AN000;
404 mov si,offset trangroup:srcxname ;AN000; set up srcxname as source
405 mov di,offset trangroup:combuf ;AN000; set up combuf as target (need big target)
406 mov ah,xnametrans ;AN000; do name translate call
407 int int_command ;AN000;
408 jnc tn_print_xname ;AN000; If no error - print result
409
410 invoke Set_ext_error_msg ;AN000; get extended message
411 mov string_ptr_2,offset trangroup:srcxname ;AN000; get address of failed string
412 mov Extend_buf_sub,one_subst ;AN000; put number of subst in control block
413 jmp cerror ;AN000; Go to error routine
414
415tn_print_xname: ;AN000;
416 mov string_ptr_2,offset Trangroup:combuf ;AN000; Set up address of combuf
417 mov dx,offset trangroup:string_buf_ptr ;AN000; Set up address of print control block
418 invoke crlf2 ;AN000; print a crlf
419 invoke printf_crlf ;AN000; print it out
420
421 ret ;AN000;
422
423 break $Exit
424
425assume ds:trangroup,es:trangroup
426
427$EXIT:
428 push ds ;AN000; save data segment
429 mov ds,[resseg] ;AN000; get resident data segment
430
431assume ds:resgroup ;AN000;
432
433 cmp [permcom],0 ;AN045; is this a permanent COMMAND?
434 jnz no_reset ;AN045; Yes - don't do anything
435;AD060; mov ah,multdos ;AN000; reset parse message pointers
436;AD060; mov al,message_2f ;AN000; call for message retriever
437;AD060; mov dl,set_parse_msg ;AN000; set up parse message address
438;AD060; mov di,pars_msg_off ;AN000; old offset of parse messages
439;AD060; mov es,pars_msg_seg ;AN000; old segment of parse messages
440;AD060; int 2fh ;AN000; go set it
441
442;AD060; mov ah,multdos ;AN000; set up to call DOS through int 2fh
443;AD060; mov al,message_2f ;AN000; call for message retriever
444 mov ax,(multdos shl 8 or message_2f);AN060; reset parse message pointers
445 mov dl,set_critical_msg ;AN000; set up critical error message address
446 mov di,crit_msg_off ;AN000; old offset of critical messages
447 mov es,crit_msg_seg ;AN000; old segment of critical messages
448 int 2fh ;AN000; go set it
449no_reset: ;AN045;
450 pop ds ;AN000; restore local data segment
451
452assume ds:trangroup ;AN000;
453
454 MOV ES,[RESSEG]
455
456assume es:resgroup
457
458 MOV AX,[PARENT]
459 MOV WORD PTR ES:[PDB_Parent_PID],AX
460 MOV AX,WORD PTR OldTerm
461 MOV WORD PTR ES:[PDB_Exit],AX
462 MOV AX,WORD PTR OldTerm+2
463 MOV WORD PTR ES:[PDB_Exit+2],AX
464
465 PUSH ES
466 MOV ES,[TRAN_TPA]
467 MOV AH,DEALLOC
468 INT int_command ; Now running in "free" space
469 POP ES
470
471 MOV AH,Exit
472 MOV AL,BYTE PTR RetCode
473 INT int_command
474
475
476; ****************************************************************
477; *
478; * ROUTINE: PARSE_CHECK_EOL
479; *
480; * FUNCTION: Calls parser to see if end of line occurred.
481; * If not end of line, set up to print parse
482; * error message. ASSUMES NO MORE PARAMETERS ARE
483; * EXPECTED!
484; *
485; * INPUT: DS:SI last output from parser
486; * ES:DI points to parse block
487; * CX last output from parser
488; *
489; * OUTPUT: AX parser return code
490; *
491; * if end of line found
492; * zero flag set
493; * else
494; * MSG_DISPLAY_CLASS set to parse error
495; *
496; ****************************************************************
497
498ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:NOTHING ;AN000;
499
500parse_check_eol Proc near ;AN000;
501
502 xor dx,dx ;AN000;
503 mov [parse_last],si ;AN018; save start of parameter
504 invoke cmd_parse ;AN000; call parser
505 cmp al,end_of_line ;AN000; Are we at end of line?
506 jz parse_good_eol ;AN000; yes - no problem
507
508 cmp ax,result_no_error ;AN018; was any error found?
509 jnz ok_to_setup_pmsg ;AN018; yes - continue
510 inc ax ;AN018; set AX to 1 and turn off zero flag
511
512ok_to_setup_pmsg:
513 call setup_parse_error_msg ;AN018; go set up error message
514
515parse_good_eol:
516 ret ;AN000;
517
518parse_check_eol endp ;AN000;
519
520; ****************************************************************
521; *
522; * ROUTINE: PARSE_WITH_MSG
523; *
524; * FUNCTION: Calls parser. If an error occurred, the error
525; * message is set up.
526; *
527; * INPUT: DS:SI last output from parser
528; * ES:DI points to parse block
529; * CX last output from parser
530; *
531; * OUTPUT: AX parser return code
532; *
533; * if no error
534; * outputs from parser
535; * else
536; * MSG_DISPLAY_CLASS set to parse error
537; * error message set up for STD_PRINTF
538; *
539; ****************************************************************
540
541ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:NOTHING ;AN018;
542
543parse_with_msg Proc near ;AN018;
544
545 mov [parse_last],si ;AN018; save start of parameter
546 invoke cmd_parse ;AN018; call parser
547 cmp al,end_of_line ;AN018; Are we at end of line?
548 jz parse_msg_good ;AN018; yes - no problem
549 cmp ax,result_no_error ;AN018; did an error occur
550 jz parse_msg_good ;AN018; yes - no problem
551
552 call setup_parse_error_msg ;AN018; go set up error message
553
554parse_msg_good:
555 ret ;AN018;
556
557parse_with_msg endp ;AN018;
558
559; ****************************************************************
560; *
561; * ROUTINE: SETUP_PARSE_ERROR_MSG
562; *
563; * FUNCTION: Calls parser. If an error occurred, the error
564; * message is set up.
565; *
566; * INPUT: AX Parse error number
567; * SI Set to past last parameter
568; * Parse_last Set to start of last parameter
569; *
570; * OUTPUT: MSG_DISPLAY_CLASS set to parse error
571; * error message set up for STD_PRINTF
572; *
573; ****************************************************************
574
575ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:NOTHING ;AN018;
576
577SETUP_PARSE_ERROR_MSG Proc near ;AN018;
578
579 mov msg_disp_class,parse_msg_class ;AC018; Set up parse message class
580 mov dx,offset TranGroup:Extend_Buf_ptr ;AC018; get extended message pointer
581 mov byte ptr [si],end_of_line_out ;AC018; terminate the parameter string
582 mov Extend_Buf_ptr,ax ;AC018; get message number in control block
583 cmp ax,lessargs_ptr ;AC018; if required parameter missing
584 jz Setup_parse_msg_ret ;AN018; no subst
585 mov si,[parse_last] ;AC018; get start of parameter
586 mov string_ptr_2,si ;AC018; get address of failed string
587 mov Extend_buf_sub,one_subst ;AC018; put number of subst in control block
588
589setup_parse_msg_ret:
590 inc si ;AN018; make sure zero flag not set
591
592 ret ;AC018;
593
594SETUP_PARSE_ERROR_MSG Endp ;AN018;
595
596trancode ends
597 end