2 ; SCCSID = @(#)copypr1.asm 1.1 85/05/14
3 ; SCCSID = @(#)copypr1.asm 1.1 85/05/14
16 TRANDATA
SEGMENT PUBLIC BYTE ;AC000;
17 EXTRN DEVWMES_ptr
:word
18 EXTRN ext_open_parms
:byte ;AN000;
19 EXTRN ext_open_seg
:word ;AN000;
20 EXTRN ext_open_off
:word ;AN000;
21 EXTRN Extend_buf_sub
:byte ;AN000;
22 EXTRN LOSTERR_ptr
:word
23 EXTRN NOSPACE_ptr
:word
27 TRANSPACE
SEGMENT PUBLIC BYTE ;AC000;
32 EXTRN concat_xa
:byte ;AC000;
41 EXTRN plus_comma
:byte ;AN000;
43 EXTRN src_xa_seg
:word ;AN000;
45 EXTRN string_ptr_2
:word ;AN000;
51 TRANCODE
SEGMENT PUBLIC BYTE
58 ASSUME
CS:TRANGROUP
,DS:TRANGROUP
,ES:TRANGROUP
,SS:NOTHING
70 ; Write out any data remaining in memory.
72 ; [NXTADD] = No. of bytes to write
73 ; [CFLAG] <> 0 if file has been created
83 invoke BUILDDEST
; Find out all about the destination
84 invoke COMPNAME
; Source and dest. the same?
85 JNZ PROCDEST
; If not, go ahead
87 JNZ PROCDEST
; Same name on device OK
88 CMP [CONCAT
],0 ; Concatenation?
89 MOV DX,OFFSET TRANGROUP
:OVERWR_ptr
90 JNZ NO_CONCAT_ERR
;AC000; If not, overwrite error
93 NO_CONCAT_ERR: ;AC000;
94 MOV [NOWRITE
],1 ; Flag not writting (just seeking)
97 MOV AX,EXTOPEN
SHL 8 ;AC000; open the file
98 mov si,offset trangroup
:destbuf
;AN030; get file name
99 mov di,-1 ;AN030; indicate no parameters
100 cmp src_xa_seg
,no_xa_seg
;AN030; is there an XA segment?
101 jz cont_no_xa
;AN030; no - no parameters
102 mov di,offset trangroup
:Ext_open_parms
;AN030; get parameters
103 mov bx,src_xa_seg
;AN030; get extended attribute segment
104 mov ext_open_seg
,bx ;AN030; put it in parameter list
105 mov ext_open_off
,0 ;AN030; offset is 0
108 mov bx,write_open_mode
;AN000; get open mode for COPY
109 xor cx,cx ;AN000; no special files
110 mov dx,write_open_flag
;AN000; set up open flags
113 JNZ DODESTOPEN
; Don't actually create if NOWRITE set
114 mov dx,creat_open_flag
;AC000; set up create flags
119 ; We assume that the error is normal. TriageError will correct the DX value
122 JNC dest_open_okay
;AC030;
124 xa_set_error: ;AN030; error occurred on XA
125 invoke set_ext_error_msg
;AN030; get extended error
128 mov string_ptr_2
,offset trangroup
:destbuf
;AN000; get address of failed string
129 mov Extend_buf_sub
,one_subst
;AN030; put number of subst in control block
132 jmp COPERR
;AN030; go issue message
134 dest_open_okay: ;AC030
135 mov [DESTHAND
],ax ; Save handle
136 mov [CFLAG
],1 ; Destination now exists
138 mov cx,bx ;AN030; get handle into CX
139 invoke set_file_code_page
;AN030; set the code page for the target
140 jc ext_err_set
;AN030; if no error, continue
142 mov [concat_xa
],0 ;AN000; set first file flag off
144 INT int_command
; Get device stuff
145 mov [DESTISDEV
],dl ; Set dest info
147 jz exists
;AC030; Dest a device
149 mov al,BYTE PTR [DESTSWITCH
]
150 AND AL,SwitchA
+SwitchB
152 MOV AL,[ASCII
] ; Neither set, use current setting
154 JZ EXSETA
; Neither set, default to ASCII
157 JPE EXISTS
; Both are set, ignore
159 jz EXISTS
; Leave in cooked mode
160 mov ax,(IOCTL
SHL 8) OR 1
163 mov [DESTISDEV
],dl ; New value
164 INT int_command
; Set device to RAW mode
172 ; What we read in may have been in binary mode, flag zapped write OK
174 mov [ASCII
],SwitchA
; Set ASCII mode
175 or [INEXACT
],SwitchA
; ASCII -> INEXACT
179 jnz NOCHECKING
; If nowrite don't bother with name check
180 cmp plus_comma
,1 ;g don't check if just doing +,,
182 invoke COMPNAME
; Source and dest. the same?
183 JNZ NOCHECKING
; If not, go ahead
185 JNZ NOCHECKING
; Same name on device OK
187 ; At this point we know in append (would have gotten overwrite error on first
188 ; destination create otherwise), and user trying to specify destination which
189 ; has been scribbled already (if dest had been named first, NOWRITE would
192 MOV DX,OFFSET TRANGROUP
:LOSTERR_ptr
; Tell him he's not going to get it
193 invoke std_Eprintf
;AC022;
194 MOV [NXTADD
],0 ; Set return
195 INC [TERMREAD
] ; Tell Read to give up
201 mov bx,[DESTHAND
] ; Get handle
204 JCXZ RET60
; If Nothing to write, forget it
205 INC [WRITTEN
] ; Flag that we wrote something
206 CMP [NOWRITE
],0 ; If NOWRITE set, just seek CX bytes
216 MOV DX,OFFSET TRANGROUP
:NOSPACE_ptr
217 JC xa_set_error_Jmp
;AC022; Failure
219 retz
; Wrote all supposed to
220 test [DESTISDEV
],devid_ISDEV
221 jz COPERR
; Is a file, error
222 test [DESTISDEV
],devid_RAW
223 jnz DEVWRTERR
; Is a raw device, error
225 retnz
; INEXACT so OK
227 retz
; Wrote one byte less (the ^Z)
230 MOV DX,OFFSET TRANGROUP
:DEVWMES_ptr
234 INVOKE std_Eprintf
;AC022;
239 jz ENDCOPYJ
; Never actually got it open
243 MOV AH,CLOSE
; Close the file
247 MOV DX,OFFSET TRANGROUP
:DESTBUF
249 INT int_command
; And delete it
255 XA_SET_ERROR_JMP: ;AN022; Go set up error message
256 jmp xa_set_error
;AN022;
259 xor dx,dx ; Zero high half of offset
260 xchg dx,cx ; cx:dx is seek location
261 mov ax,(LSEEK
SHL 8) OR 1
262 INT int_command
; Seek ahead in the file
266 ; If a ^Z has been read we must set the file size to the current
267 ; file pointer location
270 INT int_command
; CX is zero, truncates file
271 jc xa_set_error_Jmp
;AC022; Failure