2 ; SCCSID = @(#)tmisc2.asm 4.3 85/06/25
3 ; SCCSID = @(#)tmisc2.asm 4.3 85/06/25
4 TITLE Part7 COMMAND Transient Routines
20 CODERES
SEGMENT PUBLIC BYTE ;AC000;
23 DATARES
SEGMENT PUBLIC BYTE ;AC000;
30 TRANDATA
SEGMENT PUBLIC BYTE ;AC000;
32 EXTRN Extend_buf_ptr
:word ;AN000;
34 EXTRN msg_disp_class
:byte ;AN000;
37 TRANSPACE
SEGMENT PUBLIC BYTE ;AC000;
40 EXTRN KPARSE
:BYTE ;AC000;
41 EXTRN ONE_CHAR_VAL
:BYTE ;AN011;
58 TRANCODE
SEGMENT PUBLIC byte
60 ASSUME
CS:TRANGROUP
,DS:NOTHING
,ES:NOTHING
,SS:NOTHING
70 PUBLIC MOVE_TO_SRCBUF
;AN000;
81 ; Get an ASCIZ argument from the unformatted parms
82 ; DESTISDIR set if pathchars in string
83 ; DESTINFO set if ? or * in string
85 MOV AX,[PATHCNT
] ;AC000; get length of string
86 MOV SI,[PATHPOS
] ;AC000; get start of source buffer
157 MOV [SI],AL ;Don't loose the CR
178 JNZ PSCANOFF
; ';' is not a delimiter
181 DEC SI ; Point to first non-delimiter
186 ; ALL REGISTERS PRESERVED
188 ASSUME
DS:NOTHING
,ES:NOTHING
,SS:NOTHING
199 JNZ NOREDIR
; Don't muck up the pipe
223 MOV DX,OFFSET tranGROUP
:RE_INSTR
232 ; Mega sleaze!! We move the SFN from the new handle spot into the old stdin
233 ; spot. We invalidate the new JFN we got.
235 XCHG AL,[BX.PDB_JFN_Table
]
236 MOV DS:[PDB_JFN_Table
],AL
240 ; We had some kind of error on the redirection. Figure out what the
241 ; appropriate message should be; BX has the system call that failed
248 ; At this point, we have recognized the network-generated access denied error.
249 ; The correct message is in DX
252 JZ CERRORJ
;AC000; just issue message returned
256 ; The error was for a create operation. Report the error as a creation error.
258 MOV DX,OFFSET TranGroup
:FULDIR_PTR
263 ; The system call was an OPEN. Report either file not found or path not found.
267 mov msg_disp_class
,ext_msg_class
;AN000; set up extended error msg class
268 mov dx,offset TranGroup
:Extend_Buf_ptr
;AC000; get extended message pointer
269 mov Extend_Buf_ptr
,ax ;AN000; get message number in control block
277 JNZ REOUTEXISTS
;AN017; need long jump
284 ; The output redirection was for append. We open for write and seek to the
287 MOV DX,OFFSET RESGROUP
:RE_OUTSTR
288 MOV AX,(OPEN
SHL 8) OR 2 ;AC011; Open for read/write
295 MOV AX,IOCTL
SHL 8 ;AN035; Get attributes of handle
296 INT int_command
;AN035;
297 TEST DL,devid_ISDEV
;AN035; Is it a device?
298 JNZ SET_REOUT
;AN035; Yes, don't read from it
300 MOV AX,(LSEEK
SHL 8) OR 2
301 MOV CX,-1 ;AC011; MOVE TO EOF -1
304 PUSH CS ;AN011; Get transient seg to DS
306 assume
DS:Trangroup
;AN011;
307 MOV AX,(READ
SHL 8) ;AN011; Read one byte from the
308 MOV CX,1 ;AN011; file into one_char_val
309 MOV DX,OFFSET Trangroup
:ONE_CHAR_VAL
;AN011;
310 INT int_command
;AN011;
311 JC OpenWriteError
;AN011; If error, exit
312 cmp ax,cx ;AN017; Did we read 1 byte?
313 jnz reout_0_length
;AN017; No - file must be 0 length
315 cmp one_char_val
,01ah ;AN011; Was char an eof mark?
316 mov DS,[resseg
] ;AN011; Get resident segment back
317 assume
DS:Resgroup
;AN011;
318 JNZ SET_REOUT
;AN011; No, just continue
319 MOV AX,(LSEEK
SHL 8) OR 1 ;AN011; EOF mark found
320 MOV CX,-1 ;AN011; LSEEK back one byte
322 INT int_command
;AN011;
325 reout_0_length: ;AN017; We have a 0 length file
326 mov DS,[resseg
] ;AN017; Get resident segment back
327 assume
DS:Resgroup
;AN017;
328 MOV AX,(LSEEK
SHL 8) ;AN017; Move to beginning of file
329 XOR CX,CX ;AN017; Offset is 0
331 INT int_command
;AN017;
332 JMP SHORT SET_REOUT
;AN017; now finish setting up redirection
335 CMP AX,error_access_denied
337 JNZ REOUTCRT
;AN017; need long jump
341 MOV DX,OFFSET RESGROUP
:RE_OUTSTR
347 JNC NOREDIRERR
;AC011;
355 ; Mega sleaze!! We move the SFN from the new handle spot into the old stdout
356 ; spot. We invalidate the new JFN we got.
359 XCHG AL,[BX.PDB_JFN_Table
]
360 MOV DS:[PDB_JFN_Table
+1],AL
366 ; Compute length of string (including NUL) in DS:SI into CX. Change no other
369 Procedure DSTRLEN
,NEAR
385 Break <Extended error support
>
388 ; TriageError will examine the return from a carry-set system call and
389 ; return the correct error if applicable.
391 ; Inputs: outputs from a carry-settable system call
392 ; No system calls may be done in the interrim
393 ; Outputs: If carry was set on input
394 ; carry set on output
395 ; DX contains trangroup offset to printf message
397 ; No registers changed
400 Procedure TriageError
,NEAR
402 retnc
; no carry => do nothing...
404 SaveReg
<BX,CX,SI,DI,BP,ES,DS,AX,DX>
405 MOV AH,GetExtendedError
407 RestoreReg
<CX,BX> ; restore original AX
408 MOV DX,OFFSET TranGroup
:AccDen_PTR
409 CMP AX,65 ; network access denied?
410 JZ NoMove
; Yes, return it.
415 RestoreReg
<DS,ES,BP,DI,SI,CX,BX>
428 ; ****************************************************************
430 ; * ROUTINE: MOVE_TO_SRCBUF
432 ; * FUNCTION: Move ASCIIZ string from DS:SI to SRCBUF. Change
433 ; * terminating 0 to 0dH. Set PATHCNT to length of
434 ; * string. Set PATHPOS to start of SRCBUF.
436 ; * INPUT: DS:SI points to ASCIIZ string
437 ; * ES points to TRANGROUP
439 ; * OUTPUT: SRCBUF filled in with string terminated by 0dH
440 ; * PATHCNT set to length of string
441 ; * PATHPOS set to start of SRCBUF
444 ; ****************************************************************
446 assume
es:trangroup
,ds:nothing
;AN000;
448 MOVE_TO_SRCBUF PROC
NEAR ;AN000;
450 push si ;AN000; save si,di
453 mov di,offset TRANGROUP
:srcbuf
;AN000; set ES:DI to srcbuf
454 xor cx,cx ;AN000; clear cx for counint
455 mov ax,cx ;AN000; clear ax
456 push di ;AN000; save start of srcbuf
457 lodsb ;AN000; get a character from DS:SI
459 mts_get_chars: ;AN000;
460 cmp al,0 ;AN000; was it a null char?
461 jz mts_end_string
;AN000; yes - exit
462 stosb ;AN000; no - store it in srcbuf
463 inc cx ;AN000; increment length count
464 lodsb ;AN000; get a character from DS:SI
465 jmp short mts_get_chars
;AN000; go check it
467 mts_end_string: ;AN000; we've reached the end of line
468 mov al,end_of_line_in
;AN000; store 0dH in srcbuf
470 pop di ;AN000; restore start of srcbuf
472 push cs ;AN000; set DS to local segment
474 assume
ds:trangroup
;AN000;
475 mov [pathcnt
],cx ;AN000; set patchcnt to length count
476 mov [pathpos
],di ;AN000; set pathpos to start of srcbuf
477 pop cx ;AN000; restore cx,di,si
483 MOVE_TO_SRCBUF ENDP
;AN000;