Subversion Repositories SvarDOS

Rev

Rev 548 | Rev 580 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 548 Rev 576
Line 50... Line 50...
50
 
50
 
51
; File where stdin and stdout should be redirected (0 = no redirection)
51
; File where stdin and stdout should be redirected (0 = no redirection)
52
REDIR_INFIL:     times 128 db 0     ; +EAh
52
REDIR_INFIL:     times 128 db 0     ; +EAh
53
REDIR_OUTFIL:    times 128 db 0     ; +16Ah
53
REDIR_OUTFIL:    times 128 db 0     ; +16Ah
54
REDIR_OUTAPPEND: dw 0               ; +1EAh
54
REDIR_OUTAPPEND: dw 0               ; +1EAh
-
 
55
REDIR_DEL_STDIN: db 0               ; +1ECh  indicates that the stdin file
-
 
56
                                    ;        should be deleted (pipes). This
-
 
57
                                    ;        MUST contain the 1st char of
-
 
58
                                    ;        REDIR_INFIL!
55
 
59
 
56
; CTRL+BREAK (int 23h) handler
60
; CTRL+BREAK (int 23h) handler
57
; According to the TechHelp! Manual: "If you want to abort (exit to the parent
61
; According to the TechHelp! Manual: "If you want to abort (exit to the parent
58
; process), then set the carry flag and return via a FAR RET. This causes DOS
62
; process), then set the carry flag and return via a FAR RET. This causes DOS
59
; to perform normal cleanup and exit to the parent." (otherwise use iret)
63
; to perform normal cleanup and exit to the parent." (otherwise use iret)
60
BREAK_HANDLER:            ; +1ECh
64
BREAK_HANDLER:            ; +1EDh
61
stc
65
stc
62
retf
66
retf
63
 
67
 
64
 
68
 
65
skipsig:                  ; +1EEh
69
skipsig:                  ; +1EFh
66
 
70
 
67
; set up CS=DS=SS and point SP to my private stack buffer
71
; set up CS=DS=SS and point SP to my private stack buffer
68
mov ax, cs
72
mov ax, cs
69
mov ds, ax
73
mov ds, ax
70
mov es, ax
74
mov es, ax
Line 77... Line 81...
77
int 0x21
81
int 0x21
78
 
82
 
79
; revert stdin/stdout redirections (if any) to their initial state
83
; revert stdin/stdout redirections (if any) to their initial state
80
call REVERT_REDIR_IF_ANY
84
call REVERT_REDIR_IF_ANY
81
 
85
 
82
; redirect stdout if required
86
; redirect stdin and/or stdout if required
83
call REDIR_INOUTFILE_IF_REQUIRED
87
call REDIR_INOUTFILE_IF_REQUIRED
84
 
88
 
85
; should I executed command.com or a pre-set application?
89
; should I executed command.com or a pre-set application?
86
or [EXECPROG], byte 0
90
or [EXECPROG], byte 0
87
jz EXEC_COMMAND_COM
91
jz EXEC_COMMAND_COM
Line 182... Line 186...
182
; *** ROUTINES ***************************************************************
186
; *** ROUTINES ***************************************************************
183
; ****************************************************************************
187
; ****************************************************************************
184
 
188
 
185
; ----------------------------------------------------------------------------
189
; ----------------------------------------------------------------------------
186
; revert stdin/stdout redirections (if any) to their initial state
190
; revert stdin/stdout redirections (if any) to their initial state
187
; all memory accesses are CS-prefixes because this code may be called at
-
 
188
; times when DS is out of whack.
-
 
189
REVERT_REDIR_IF_ANY:
191
REVERT_REDIR_IF_ANY:
190
; is stdout redirected?
192
; is stdout redirected?
191
mov bx, [OLD_STDOUT]
193
mov bx, [OLD_STDOUT]
192
cmp bx, 0xffff
194
cmp bx, 0xffff
193
je STDOUT_DONE
195
je STDOUT_DONE
Line 211... Line 213...
211
int 0x21
213
int 0x21
212
; close the old handle (still in bx)
214
; close the old handle (still in bx)
213
mov ah, 0x3e
215
mov ah, 0x3e
214
int 0x21
216
int 0x21
215
mov [OLD_STDIN], word 0xffff ; mark stdin as "not redirected"
217
mov [OLD_STDIN], word 0xffff ; mark stdin as "not redirected"
-
 
218
 
-
 
219
; delete stdin file if required
-
 
220
cmp [REDIR_DEL_STDIN], byte 0
-
 
221
je STDIN_DONE
-
 
222
; revert the original file and delete it
-
 
223
mov ah, [REDIR_DEL_STDIN]
-
 
224
mov [REDIR_INFIL], ah
-
 
225
mov ah, 0x41     ; DOS 2+ - delete file pointed at by DS:DX
-
 
226
mov dx, REDIR_INFIL
-
 
227
int 0x21
-
 
228
mov [REDIR_INFIL], byte 0
-
 
229
mov [REDIR_DEL_STDIN], byte 0
-
 
230
 
216
STDIN_DONE:
231
STDIN_DONE:
217
 
232
 
218
ret
233
ret
219
; ----------------------------------------------------------------------------
234
; ----------------------------------------------------------------------------
220
 
235