1 TITLE COMMAND COPY routines
.
15 DATARES
SEGMENT PUBLIC
19 TRANDATA
SEGMENT PUBLIC
20 EXTRN BADARGS
:BYTE,BADCD
:BYTE,BADSWT
:BYTE,COPIED_PRE
:BYTE
21 EXTRN COPIED_POST
:BYTE
22 EXTRN INBDEV
:BYTE,OVERWR
:BYTE,FULDIR
:BYTE,LOSTERR
:BYTE
23 EXTRN NOSPACE
:BYTE,DEVWMES
:BYTE,NOTFND
:BYTE
26 TRANSPACE
SEGMENT PUBLIC
27 EXTRN MELCOPY
:BYTE,SRCPT
:WORD,MELSTART
:WORD,SCANBUF
:BYTE
28 EXTRN DESTFCB2
:BYTE,SDIRBUF
:BYTE,SRCTAIL
:WORD,CFLAG
:BYTE
29 EXTRN NXTADD
:WORD,DESTCLOSED
:BYTE,ALLSWITCH
:WORD,ARGC
:BYTE
30 EXTRN PLUS
:BYTE,BINARY:BYTE,ASCII
:BYTE,FILECNT
:WORD
31 EXTRN WRITTEN
:BYTE,CONCAT
:BYTE,DESTBUF
:BYTE,SRCBUF
:BYTE
32 EXTRN SDIRBUF
:BYTE,DIRBUF
:BYTE,DESTFCB
:BYTE,FRSTSRCH
:BYTE
33 EXTRN FIRSTDEST
:BYTE,DESTISDIR
:BYTE,DESTSWITCH
:WORD,STARTEL
:WORD
34 EXTRN DESTTAIL
:WORD,DESTSIZ
:BYTE,DESTINFO
:BYTE,INEXACT
:BYTE
35 EXTRN CURDRV
:BYTE,DESTVARS
:BYTE,RESSEG
:WORD,SRCSIZ
:BYTE
36 EXTRN SRCINFO
:BYTE,SRCVARS
:BYTE,USERDIR1
:BYTE,NOWRITE
:BYTE
37 EXTRN RDEOF
:BYTE,SRCHAND
:WORD,CPDATE
:WORD,CPTIME
:WORD
38 EXTRN SRCISDEV
:BYTE,BYTCNT
:WORD,TPA
:WORD,TERMREAD
:BYTE
39 EXTRN DESTHAND
:WORD,DESTISDEV
:BYTE,DIRCHAR
:BYTE
43 ; **************************************************
47 TRANCODE
SEGMENT PUBLIC BYTE
49 EXTRN RESTUDIR
:NEAR,CERROR
:NEAR,SWITCH
:NEAR,DISP32BITS
:NEAR
50 EXTRN PRINT
:NEAR,TCOMMAND
:NEAR,ZPRINT
:NEAR,ONESPC
:NEAR
51 EXTRN RESTUDIR1
:NEAR,FCB_TO_ASCZ
:NEAR,CRLF2
:NEAR,SAVUDIR1
:NEAR
52 EXTRN SETREST1
:NEAR,BADCDERR
:NEAR,STRCOMP
:NEAR,DELIM
:NEAR
53 EXTRN UPCONV
:NEAR,PATHCHRCMP
:NEAR,SCANOFF
:NEAR
57 EXTRN SEARCH
:NEAR,SEARCHNEXT
:NEAR,DOCOPY
:NEAR,CLOSEDEST
:NEAR
58 EXTRN FLSHFIL
:NEAR,SETASC
:NEAR,BUILDNAME
:NEAR,COPERR
:NEAR
60 PUBLIC COPY
,BUILDPATH
,COMPNAME
,ENDCOPY
63 ASSUME
CS:TRANGROUP
,DS:TRANGROUP
,ES:TRANGROUP
,SS:NOTHING
76 mov di,OFFSET TRANGROUP
:SCANBUF
79 jz NEXTMEL
; Go back to start
84 mov di,OFFSET TRANGROUP
:DESTFCB2
85 mov ax,PARSE_FILE_DESCRIPTOR
SHL 8
87 mov bx,OFFSET TRANGROUP
:SDIRBUF
+ 1
88 mov si,OFFSET TRANGROUP
:DESTFCB2
+ 1
109 ; First order of buisness is to find out about the destination
110 ASSUME
DS:TRANGROUP
,ES:TRANGROUP
112 mov [ALLSWITCH
],AX ; no switches
113 mov [ARGC
],al ; no arguments
114 mov [PLUS
],al ; no concatination
115 mov [BINARY],al ; Binary not specifically specified
116 mov [ASCII
],al ; ASCII not specifically specified
117 mov [FILECNT
],ax ; No files yet
118 mov [WRITTEN
],al ; Nothing written yet
119 mov [CONCAT
],al ; No concatination
120 mov [MELCOPY
],al ; Not a Mel Hallerman copy
121 mov word ptr [SCANBUF
],ax ; Init buffer
122 mov word ptr [DESTBUF
],ax ; Init buffer
123 mov word ptr [SRCBUF
],ax ; Init buffer
124 mov word ptr [SDIRBUF
],ax ; Init buffer
125 mov word ptr [DIRBUF
],ax ; Init buffer
126 mov word ptr [DESTFCB
],ax ; Init buffer
128 mov [FRSTSRCH
],al ; First search call
129 mov [FIRSTDEST
],al ; First time
130 mov [DESTISDIR
],al ; Don't know about dest
132 mov bl,'+' ; include '+' as a delimiter
134 xor bp,bp ; no switches
135 mov di,offset trangroup
:SCANBUF
138 test bh,80H
; A '+' argument?
142 POPF ; get flags back
143 jc CHECKDONE
; Hit CR?
146 or [DESTSWITCH
],BP ; Yes, assume destination
147 or [ALLSWITCH
],BP ; keep tabs on all switches
152 jnz GOTPLUS
; Yes, not a separate arg
153 inc [ARGC
] ; found a real arg
157 mov SI,offset trangroup
:SCANBUF
; Adjust to copy
159 mov DI,offset trangroup
:DESTBUF
162 mov [DESTSIZ
],cl ; Save its size
163 inc cx ; Include the NUL
164 rep movsb ; Save potential destination
165 mov [DESTINFO
],bh ; Save info about it
166 mov [DESTSWITCH
],0 ; reset switches
168 jmp short DESTSCAN
; keep going
172 mov [CONCAT
],al ; PLUS -> Concatination
175 mov [INEXACT
],al ; CONCAT -> inexact copy
176 mov dx,offset trangroup
:BADARGS
178 or al,al ; Good number of args?
179 jz CERROR4J
; no, not enough
183 jmp CERROR
; no, too many
185 mov bp,offset trangroup
:DESTVARS
188 mov al,[CURDRV
] ; Dest is default drive:*.*
192 mov di,offset trangroup
:DESTBUF
194 mov [DESTSWITCH
],0 ; no switches on dest
195 mov [bp.INFO
],2 ; Flag dest is ambig
196 mov [bp.ISDIR
],0 ; Know destination specs file
202 jnz NOTSHORTDEST
; Two char file name
203 or [bp.INFO
],2 ; Know dest is d:
204 mov di,offset trangroup
:DESTBUF
+ 2
205 mov [bp.ISDIR
],0 ; Know destination specs file
211 mov dx,offset trangroup
:BADCD
212 cmp byte ptr [DI-2],':'
213 jnz CERROR4J
; Trailing '/' error
214 mov [bp.ISDIR
],2 ; Know destination is d:/
218 mov dx,offset trangroup
:BADSWT
221 jz CERROR4J
; Switch specified which is not known
223 ; Now know most of the information needed about the destination
225 TEST AX,VSWITCH
; Verify requested?
227 MOV AH,GET_VERIFY_ON_WRITE
228 INT int_command
; Get current setting
233 MOV [VERVAL
],AX ; Save current setting
236 MOV AX,(SET_VERIFY_ON_WRITE
SHL 8) OR 1 ; Set verify
239 xor bp,bp ; no switches
241 mov bl,'+' ; include '+' as a delimiter
243 mov di,offset trangroup
:SCANBUF
244 call CPARSE
; Parse first source name
246 jnz SCANFSRC
; Yes, try again
247 or [DESTSWITCH
],bp ; Include copy wide switches on DEST
249 jnz NOSETCASC
; Binary explicit
251 JZ NOSETCASC
; Not Concat
252 mov [ASCII
],ASWITCH
; Concat -> ASCII copy if no B switch
256 mov SI,offset trangroup
:SCANBUF
; Adjust to copy
258 mov DI,offset trangroup
:SRCBUF
261 mov [SRCSIZ
],cl ; Save its size
262 inc cx ; Include the NUL
263 rep movsb ; Save this source
264 mov [SRCINFO
],bh ; Save info about it
266 mov ax,bp ; Switches so far
267 call SETASC
; Set A,B switches accordingly
268 call SWITCH
; Get any more switches on this arg
276 MOV DX,OFFSET TRANGROUP
:COPIED_PRE
281 MOV DX,OFFSET TRANGROUP
:COPIED_POST
283 JMP TCOMMAND
; Stack could be messed up
287 jnz NEXTSRC
; If in concat mode, ignore error
288 mov dx,offset trangroup
:SRCBUF
291 mov dx,offset trangroup
:NOTFND
297 mov SI,offset trangroup
:SCANBUF
; Adjust to copy
299 mov DI,offset trangroup
:SRCBUF
302 mov [SRCSIZ
],cl ; Save its size
303 inc cx ; Include the NUL
304 rep movsb ; Save this sorce
305 mov [SRCINFO
],bh ; Save info about it
307 mov ax,bp ; Switches so far
308 call SETASC
; Set A,B switches accordingly
309 call SWITCH
; Get any more switches on this arg
312 jnz LEAVECFLAG
; Leave CFLAG if concatination
315 mov [CFLAG
],al ; Flag destination not created
316 mov [NXTADD
],ax ; Zero out buffer
317 mov [DESTCLOSED
],al ; Not created -> not closed
319 mov [SRCPT
],SI ; remember where we are
320 mov di,offset trangroup
:USERDIR1
321 mov bp,offset trangroup
:SRCVARS
322 call BUILDPATH
; Figure out everything about the source
323 mov si,[SRCTAIL
] ; Create the search FCB
332 xor bp,bp ; no switches
334 mov bl,'+' ; include '+' as a delimiter
336 mov di,offset trangroup
:SCANBUF
337 call CPARSE
; Parse first source name
338 JC EndCopyJ2
; if error, then end (trailing + case)
340 jz ENDCOPYJ2
; If no '+' we're done
342 jnz SCANSRC
; Yes, try again
346 mov ax,PARSE_FILE_DESCRIPTOR
SHL 8
348 mov ax,word ptr [SRCBUF
] ; Get drive
355 mov ah,DIR_SEARCH_FIRST
357 pushf ; Save result of search
358 call RESTUDIR1
; Restore users dir
361 jmp SRCNONEXIST
; Failed
369 mov di,OFFSET TRANGROUP
:SDIRBUF
370 mov si,OFFSET TRANGROUP
:DIRBUF
371 rep movsb ; Save very first source name
374 mov [NOWRITE
],al ; Turn off NOWRITE
376 mov si,offset trangroup
:DIRBUF
+ 1
377 call FCB_TO_ASCZ
; SRCBUF has complete name
380 jnz SHOWCPNAM
; Show name if concat
381 test [SRCINFO
],2 ; Show name if multi
384 mov dx,offset trangroup
:SRCBUF
390 jnz NODCLOSE
; If concat, do not close
391 call CLOSEDEST
; else close current destination
392 jc NODCLOSE
; Concat flag got set, close didn't really happen
393 mov [CFLAG
],0 ; Flag destination not created
395 cmp [CONCAT
],0 ; Check CONCAT again
397 CALL FLSHFIL
; Flush output between source files on CONCAT
398 ; so LOSTERR stuff works correctly
404 call SEARCHNEXT
; Try next match
405 jnz NEXTSRCJ
; Finished with this source spec
406 mov [DESTCLOSED
],0 ; Not created or concat -> not closed
407 jmp NEXTAMBIG
; Do next ambig
416 jnz NOTPFILE
; If ambig don't bother with open
418 add dx,BUF
; Set DX to spec
422 mov bx,ax ; Is pure file
428 jnz ISADEV
; If device, done
430 jz ISSIMPFILE
; If no path seps, done
432 mov dx,word ptr [BP.BUF
]
440 add dx,BUF
; Set DX for upcomming CHDIRs
443 cmp bh,6 ; Ambig and path ?
444 jnz CHECKAMB
; jmp if no
446 cmp byte ptr [si-2],':'
448 mov [BP.ISDIR
],2 ; Know is d:/file
452 mov [BP.ISDIR
],1 ; Know is path/file
453 dec si ; Point to the /
462 mov [BP.ISDIR
],0 ; Know is file since ambig but no path
477 mov [bp.ISDIR
],2 ; assume d:/file
481 mov [bp.ISDIR
],1 ; know path/file
489 mov [bp.ISDIR
],0 ; assume pure file
492 retz
; Know pure file, no path seps
493 mov [bp.ISDIR
],2 ; assume d:/file
496 jz BADCDERRJ2
; Trailing '/'
497 cmp byte ptr [si],'.'
498 jz BADCDERRJ2
; If . or .. pure cd should have worked
499 cmp byte ptr [si-2],':'
500 jz DOPCD
; Know d:/file
501 mov [bp.ISDIR
],1 ; Know path/file
502 dec si ; Point at last '/'
505 xchg bl,[SI] ; Stick in a NUL
517 mov ax,('.' SHL 8) OR '?'
533 MOV si,offset trangroup
:SRCBUF
534 MOV di,offset trangroup
:DESTBUF
537 CMP BYTE PTR [SI+1],':'
543 CMP BYTE PTR [DI+1],':'
560 jnz RET81P
; Niether of the mismatch chars was a NUL
561 ; Know one of the mismatch chars is a NUL
562 ; Check for ".NUL" compared with NUL
566 jmp short RET81P
; If NUL return match, else no match
569 jnz RET81P
; Mismatch
570 or ch,ch ; If NUL return match, else no match