2 ; SCCSID = @(#)tpipe.asm 1.1 85/05/14
3 ; SCCSID = @(#)tpipe.asm 1.1 85/05/14
4 TITLE PART8 COMMAND Transient routines
.
17 DATARES
SEGMENT PUBLIC BYTE ;AC000;
33 TRANDATA
SEGMENT PUBLIC BYTE ;AC000;
36 EXTRN curdat_mo_day
:word ;AN000;
38 EXTRN curdat_yr
:word ;AN000;
39 EXTRN curtim_hr_min
:word ;AN000;
41 EXTRN curtim_sec_hn
:word ;AN000;
44 EXTRN newdat_format
:word ;AN000;
47 EXTRN parse_date
:byte ;AN000;
48 EXTRN parse_time
:byte ;AN000;
49 EXTRN PIPEEMES_PTR
:WORD
50 EXTRN promtim_hr_min
:word ;AN000;
51 EXTRN promtim_ptr
:word ;AN000;
52 EXTRN promtim_sec_hn
:word ;AN000;
53 EXTRN STRING_BUF_PTR
:WORD ;AC000;
54 EXTRN SYNTMES_PTR
:WORD
59 TRANSPACE
SEGMENT PUBLIC BYTE ;AC000;
61 EXTRN date_day
:byte ;AN000;
62 EXTRN date_month
:byte ;AN000;
63 EXTRN date_year
:word ;AN000;
64 EXTRN INTERNATVARS
:BYTE
66 EXTRN time_fraction
:byte ;AN000;
67 EXTRN time_hour
:byte ;AN000;
68 EXTRN time_minutes
:byte ;AN000;
69 EXTRN time_seconds
:byte ;AN000;
72 TRANCODE
SEGMENT PUBLIC BYTE
73 ASSUME
CS:TRANGROUP
,DS:NOTHING
,ES:NOTHING
,SS:NOTHING
80 EXTRN TESTDOREOUT
:NEAR
81 EXTRN TESTKANJ
:NEAR ;AN000;3/3/KK
82 EXTRN TSYSGETMSG
:NEAR ;AN000;
103 CMP [SINGLECOM
],0EFFFH
124 ; Note that we need to handle the same thing that RestDir handles: the
125 ; requirement that we try only once to restore the user's environment after
126 ; and INT 24 or the like. If the condition that causes the INT 24 does not
127 ; disappear, we just give up.
136 mov DX,OFFSET RESGROUP
:PIPE1
; Clean up in case ^C
139 MOV DX,OFFSET RESGROUP
:PIPE2
149 MOV DX,OFFSET TRANGROUP
:SYNTMES_ptr
157 SaveReg
<AX,DX> ; Save results from TriageError
158 MOV DX,OFFSET TRANGROUP
:PIPEEMES_ptr
163 RestoreReg
<DX,AX> ; Restore results from TriageError
172 ASSUME
DS:TRANGROUP
,ES:TRANGROUP
175 INC [PIPEFILES
] ; Flag that the pipe files exist
176 MOV AH,Get_Default_Drive
; Get current drive
179 MOV [PIPE2
],AL ; Make pipe files in root of def drv
180 MOV BX,OFFSET RESGROUP
:PIPE1
182 xor ah,ah ; nul terminate path names
187 mov ah,CreateTempFile
; the CreateTemp call
189 JC PIPEERR
; Couldn't create
191 MOV AH,CLOSE
; Don't proliferate handles
194 MOV DX,OFFSET RESGROUP
:PIPE2
195 mov ah,createTempFile
; the CreateTemp call
202 CALL TESTDOREIN
; Set up a redirection if specified
206 MOV [SINGLECOM
],0F000H ; Flag single command pipe
212 AND [ECHOFLAG
],0FEh ; force current echo to be off
215 CMP AL,AltPipeChr
; Alternate pipe char?
219 jmp PIPEEND
; Pipe done
221 MOV DX,[INPIPEPTR
] ; Get the input file name
226 JMP PIPEERR
; Lost the pipe file
230 XCHG AL,[BX.PDB_JFN_Table
]
231 MOV DS:[PDB_JFN_Table
],AL ; Redirect
234 MOV DI,OFFSET TRANGROUP
:COMBUF
+ 2
236 CMP BYTE PTR [SI],0DH ; '|<CR>'
242 CMP BYTE PTR [SI],al ; '||'
244 CMP BYTE PTR [SI],AltPipeChr
; '##' or '|#'?
245 JZ PipeErrSynJ
; Yes, Error
255 ; Added following 2 commands to the fix pipe bug.
257 inc cx ;AN000; 3/3/KK
258 inc cx ;AN000; 3/3/KK
273 MOV BYTE PTR ES:[DI-1],0DH
277 MOV [PIPEPTR
],SI ; On to next pipe element
284 JC PIPEERRJ
; Lost the file
287 XCHG AL,[BX.PDB_JFN_Table
]
288 MOV DS:[PDB_JFN_Table
+1],AL
289 XCHG DX,[INPIPEPTR
] ; Swap for next element of pipe
296 MOV [PIPEPTR
],SI ; Point at the CR (anything not '|' will do)
297 CALL TESTDOREOUT
; Set up the redirection if specified
301 JMP NOPIPEPROC
; Process the pipe element
305 CMP [SINGLECOM
],0F000H
307 MOV [SINGLECOM
],-1 ; Make it return
311 ASSUME
DS:TRANGROUP
,ES:TRANGROUP
313 ; Date and time are set during initialization and use
314 ; this routines since they need to do a long return
317 mov cs:[resseg
],ds ; SetInitFlag needs resseg initialized
319 PUSH DS ; Going to use the previous stack
320 MOV AX,CS ; Set up the appropriate segment registers
323 invoke TSYSLOADMSG
;AN000; preload messages
324 invoke SETSTDINON
;AN026; turn on critical error on STDIN
325 invoke SETSTDOUTOFF
;AN026; turn off critical error on STDOUT
326 MOV DX,OFFSET TRANGROUP
:INTERNATVARS
;Set up internat vars
327 MOV AX,INTERNATIONAL
SHL 8
329 MOV WORD PTR DS:[81H
],13 ; Want to prompt for date during initialization
330 MOV [COMBUF
],COMBUFLEN
; Init COMBUF
331 MOV WORD PTR [COMBUF
+1],0D01H
339 ; DATE - Gets and sets the time
345 ; ****************************************************************
347 ; * ROUTINE: DATE - Set system date
349 ; * FUNCTION: If a date is specified, set the system date,
350 ; * otherwise display the current system date and
351 ; * prompt the user for a new date. If an invalid
352 ; * date is specified, issue an error message and
353 ; * prompt for a new date. If the user enters
354 ; * nothing when prompted for a date, terminate.
356 ; * INPUT: command line at offset 81H
360 ; ****************************************************************
362 assume
ds:trangroup
,es:trangroup
365 MOV SI,81H
; Accepting argument for date inline
366 mov di,offset trangroup
:parse_date
;AN000; Get adderss of PARSE_DATE
367 xor cx,cx ;AN000; clear counter for positionals
369 invoke cmd_parse
;AC000; call parser
370 cmp ax,end_of_line
;AC000; are we at end of line?
371 JZ PRMTDAT
;AC000; yes - go ask for date
372 cmp ax,result_no_error
;AN000; did we have an error?
373 jne daterr
;AN000; yes - go issue message
374 JMP COMDAT
;AC000; we have a date
377 ; Print "Current date is
379 invoke GetDate
;AN000; get date for output
380 xchg dh,dl ;AN000; switch month & day
381 mov CurDat_yr
,cx ;AC000; put year into message control block
382 mov CurDat_mo_day
,dx ;AC000; put month and day into message control block
383 mov dx,offset trangroup
:CurDat_ptr
;AC000; set up message for output
385 ;AD061; mov CurDat_yr,0 ;AC000; reset year, month and day
386 ;AD061; mov CurDat_mo_day,0 ;AC000; pointers in control block
388 GET_NEW_DATE: ;AN000;
389 call getdat
;AC000; prompt user for date
390 cmp ax,end_of_line
;AC000; are we at end of line?
391 jz date_end
;AC000; yes - exit
392 cmp ax,result_no_error
;AN000; did we have an error?
393 jne daterr
;AN000; yes - go issue message
395 mov cx,date_year
;AC000; get parts of date in
396 mov dh,date_month
;AC000; cx and dx for set
397 mov dl,date_day
;AC000; date function call.
398 push cx ;AC000; save date
400 mov cx,1 ;AC000; set 1 positional entered
402 invoke cmd_parse
;AN029; call parser
403 cmp al,end_of_line
;AN029; Are we at end of line?
404 pop dx ;AC000; retrieve date
406 jnz daterr
;AC000; extra stuff on line - try again
407 MOV AH,SET_DATE
;yes - set date
415 invoke crlf2
;AN028; print out a blank line
416 MOV DX,OFFSET TRANGROUP
:BADDAT_ptr
418 JMP GET_NEW_DATE
;AC000; get date again
421 ; TIME gets and sets the time
425 ; ****************************************************************
427 ; * ROUTINE: TIME - Set system time
429 ; * FUNCTION: If a time is specified, set the system time,
430 ; * otherwise display the current system time and
431 ; * prompt the user for a new time. If an invalid
432 ; * time is specified, issue an error message and
433 ; * prompt for a new time. If the user enters
434 ; * nothing when prompted for a time, terminate.
436 ; * INPUT: command line at offset 81H
440 ; ****************************************************************
442 assume
ds:trangroup
,es:trangroup
445 MOV SI,81H
; Accepting argument for time inline
446 mov di,offset trangroup
:parse_time
;AN000; Get adderss of PARSE_time
447 xor cx,cx ;AN000; clear counter for positionals
449 invoke cmd_parse
;AC000; call parser
450 cmp ax,end_of_line
;AC000; are we at end of line?
451 JZ PRMTTIM
;AC000; yes - prompt for time
452 cmp ax,result_no_error
;AN000; did we have an error?
453 jne timerr
;AN000; yes - go issue message
454 JMP COMTIM
;AC000; we have a time
457 ;Printf "Current time is ... "
459 MOV AH,GET_TIME
;AC000; get the current time
460 INT int_command
;AC000; Get time in CX:DX
461 xchg ch,cl ;AN000; switch hours & minutes
462 xchg dh,dl ;AN000; switch seconds & hundredths
463 mov CurTim_hr_min
,cx ;AC000; put hours and minutes into message subst block
464 mov CurTim_sec_hn
,dx ;AC000; put seconds and hundredths into message subst block
465 mov dx,offset trangroup
:CurTim_ptr
;AC000; set up message for output
467 ;AD061; mov CurTim_hr_min,0 ;AC000; reset hour, minutes, seconds, and hundredths
468 ;AD061; mov CurTim_sec_hn,0 ;AC000; pointers in control block
472 cmp ax,end_of_line
;AC000; are we at end of line?
474 cmp ax,result_no_error
;AN000; did we have an error?
475 jne timerr
;AN000; yes - go issue message
478 mov ch,time_hour
;AC000; get parts of time in
479 mov cl,time_minutes
;AC000; cx and dx for set
480 mov dh,time_seconds
;AC000; time function call
481 mov dl,time_fraction
;AC000;
482 push cx ;AC000; save time
484 mov cx,1 ;AC000; set 1 positional parm entered
486 invoke cmd_parse
;AN029; call parser
487 cmp al,end_of_line
;AN029; Are we at end of line?
488 pop dx ;AC000; retieve time
490 jnz timerr
;AC000; extra stuff on line - try again
496 JNZ TIMERR
;AC000; if an error occured, try again
503 invoke crlf2
;AN028; print out a blank line
504 MOV DX,OFFSET TRANGROUP
:BADTIM_ptr
505 invoke std_printf
; Print error message
506 JMP GET_NEW_TIME
;AC000; Try again
510 ; Set the special flag in the INIT flag to the value in CX.
515 and InitFlag
,NOT initSpecial
523 ASSUME
DS:NOTHING
,ES:NOTHING
540 INT int_command
; Get time in CX:DX
545 xchg ch,cl ;AN000; switch hours & minutes
546 xchg dh,dl ;AN000; switch seconds & hundredths
547 mov promTim_hr_min
,cx ;AC000; put hours and minutes into message subst block
548 mov promTim_sec_hn
,dx ;AC000; put seconds and hundredths into message subst block
549 mov dx,offset trangroup
:promTim_ptr
;AC000; set up message for output
551 ;AD061; mov promTim_hr_min,0 ;AC000; reset hour, minutes, seconds, and hundredths
552 ;AD061; mov promTim_sec_hn,0 ;AC000; pointers in control block
558 ; ****************************************************************
560 ; * ROUTINE: GETDAT - Prompt user for date
562 ; * FUNCTION: Gets the date format from the COUNTRY DEPENDENT
563 ; * INFORMATION and issues the "Enter new date"
564 ; * message with the proper date format. COMBUF
565 ; * is reset to get a date from the command line.
566 ; * The PARSE_DATE blocks are then reset and the
567 ; * PARSE function call is issued.
572 ; * PARSER RETURN CODES
574 ; ****************************************************************
577 GETDAT proc
near ;AC000;
579 mov ax,(International
SHL 8) ; Determine what format the date
580 mov dx,5
ch ; should be entered in and
581 int int_command
; print a message describing it
584 mov dx,usadat_ptr
;AC000; get mm-dd-yy
587 mov dx,eurdat_ptr
;AC000; get dd-mm-yy
589 mov dx,japdat_ptr
;AC000; get yy-mm-dd
591 mov ax,dx ;AN000; get message number of format
592 mov dh,util_msg_class
;AN000; this is a utility message
593 call Tsysgetmsg
;AN000; get the address of the message
594 mov newdat_format
,si ;AN000; put the address in subst block
595 MOV DX,OFFSET TRANGROUP
:NEWDAT_ptr
;AC000; get address of message to print
597 mov newdat_format
,no_subst
;AN000; reset subst block
599 MOV AH,STD_CON_STRING_INPUT
600 MOV DX,OFFSET TRANGROUP
:COMBUF
601 mov cx,initSpecial
; Set bit in InitFlag that indicates
602 call SetInitFlag
; prompting for date.
603 INT int_command
; Get input line
604 xor cx,cx ; Reset bit in InitFlag that indicates
605 call SetInitFlag
; prompting for date.
607 MOV SI,OFFSET TRANGROUP
:COMBUF
+2
608 mov di,offset trangroup
:parse_date
;AN000; Get adderss of PARSE_DATE
609 xor cx,cx ;AN000; clear counter for positionals
611 invoke cmd_parse
;AC000; call parser
618 ; ****************************************************************
620 ; * ROUTINE: GETTIME - Prompt user for time
622 ; * FUNCTION: Gets the time format from the COUNTRY DEPENDENT
623 ; * INFORMATION and issues the "Enter new time"
624 ; * message. COMBUF is reset to get a time from the
625 ; * command line. The PARSE_TIME blocks are then
626 ; * reset and the PARSE function call is issued.
631 ; * PARSER RETURN CODES
633 ; ****************************************************************
636 GETTIM proc
near ;AC000;
638 XOR CX,CX ; Initialize hours and minutes to zero
639 MOV DX,OFFSET TRANGROUP
:NEWTIM_ptr
641 MOV AH,STD_CON_STRING_INPUT
642 MOV DX,OFFSET TRANGROUP
:COMBUF
643 mov cx,initSpecial
; Set bit in InitFlag that indicates
644 call SetInitFlag
; prompting for time.
645 INT int_command
; Get input line
646 xor cx,cx ; Reset bit in InitFlag that indicates
647 call SetInitFlag
; prompting for time.
649 MOV SI,OFFSET TRANGROUP
:COMBUF
+2
650 mov di,offset trangroup
:parse_time
;AN000; Get adderss of PARSE_TIME
651 xor cx,cx ;AN000; clear counter for positionals
653 invoke cmd_parse
;AC000; call parser