diff options
Diffstat (limited to 'v4.0/src/CMD/COMMAND/COPYPR2.ASM')
| -rw-r--r-- | v4.0/src/CMD/COMMAND/COPYPR2.ASM | 450 |
1 files changed, 450 insertions, 0 deletions
diff --git a/v4.0/src/CMD/COMMAND/COPYPR2.ASM b/v4.0/src/CMD/COMMAND/COPYPR2.ASM new file mode 100644 index 0000000..2913cab --- /dev/null +++ b/v4.0/src/CMD/COMMAND/COPYPR2.ASM | |||
| @@ -0,0 +1,450 @@ | |||
| 1 | page 80,132 | ||
| 2 | ; SCCSID = @(#)copypr2.asm 1.1 85/05/14 | ||
| 3 | ; SCCSID = @(#)copypr2.asm 1.1 85/05/14 | ||
| 4 | INCLUDE comsw.asm | ||
| 5 | |||
| 6 | .xlist | ||
| 7 | .xcref | ||
| 8 | INCLUDE DOSSYM.INC | ||
| 9 | INCLUDE comseg.asm | ||
| 10 | INCLUDE comequ.asm | ||
| 11 | .list | ||
| 12 | .cref | ||
| 13 | |||
| 14 | |||
| 15 | TRANDATA SEGMENT PUBLIC BYTE ;AC000; | ||
| 16 | EXTRN FulDir_ptr:word ;AN052; | ||
| 17 | TRANDATA ENDS | ||
| 18 | |||
| 19 | TRANSPACE SEGMENT PUBLIC BYTE ;AC000; | ||
| 20 | EXTRN ASCII:BYTE | ||
| 21 | EXTRN BINARY:BYTE | ||
| 22 | EXTRN CONCAT:BYTE | ||
| 23 | EXTRN DESTBUF:BYTE | ||
| 24 | EXTRN DESTFCB:BYTE | ||
| 25 | EXTRN DESTINFO:BYTE | ||
| 26 | EXTRN DESTISDIR:BYTE | ||
| 27 | EXTRN DESTTAIL:WORD | ||
| 28 | EXTRN DESTVARS:BYTE | ||
| 29 | EXTRN DIRBUF:BYTE | ||
| 30 | EXTRN DIRCHAR:BYTE | ||
| 31 | EXTRN FIRSTDEST:BYTE | ||
| 32 | EXTRN INEXACT:BYTE | ||
| 33 | EXTRN MELCOPY:BYTE | ||
| 34 | EXTRN NXTADD:WORD | ||
| 35 | EXTRN PLUS:BYTE | ||
| 36 | EXTRN SDIRBUF:BYTE | ||
| 37 | EXTRN SRCINFO:BYTE | ||
| 38 | EXTRN srcxname:byte | ||
| 39 | EXTRN TPA:WORD | ||
| 40 | EXTRN trgxname:byte | ||
| 41 | EXTRN USERDIR1:BYTE | ||
| 42 | TRANSPACE ENDS | ||
| 43 | |||
| 44 | TRANCODE SEGMENT PUBLIC BYTE | ||
| 45 | |||
| 46 | EXTRN BADPATH_ERR:NEAR ;AN022; | ||
| 47 | EXTRN COPERR:NEAR ;AN052; | ||
| 48 | EXTRN EXTEND_SETUP:NEAR ;AN022; | ||
| 49 | |||
| 50 | PUBLIC BUILDPATH | ||
| 51 | PUBLIC SETSTARS | ||
| 52 | PUBLIC SETASC | ||
| 53 | |||
| 54 | ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:TRANGROUP,SS:NOTHING | ||
| 55 | |||
| 56 | SETASC: | ||
| 57 | ; | ||
| 58 | ; Given switch vector in AX, | ||
| 59 | ; Set ASCII switch if A is set | ||
| 60 | ; Clear ASCII switch if B is set | ||
| 61 | ; BINARY set if B specified | ||
| 62 | ; Leave ASCII unchanged if neither or both are set | ||
| 63 | ; Also sets INEXACT if ASCII is ever set. AL = ASCII on exit, flags set | ||
| 64 | ; | ||
| 65 | AND AL,SwitchA+SwitchB | ||
| 66 | JPE LOADSW ; PE means both or neither are set | ||
| 67 | PUSH AX | ||
| 68 | AND AL,SwitchB | ||
| 69 | MOV [BINARY],AL | ||
| 70 | POP AX | ||
| 71 | AND AL,SwitchA | ||
| 72 | MOV [ASCII],AL | ||
| 73 | OR [INEXACT],AL | ||
| 74 | |||
| 75 | LOADSW: | ||
| 76 | MOV AL,[ASCII] | ||
| 77 | OR AL,AL | ||
| 78 | return | ||
| 79 | |||
| 80 | public builddest | ||
| 81 | BUILDDEST: | ||
| 82 | cmp [DESTISDIR],-1 | ||
| 83 | jnz KNOWABOUTDEST ; Already done the figuring | ||
| 84 | MOV DI,OFFSET TRANGROUP:USERDIR1 | ||
| 85 | mov bp,offset trangroup:DESTVARS | ||
| 86 | call BUILDPATH | ||
| 87 | invoke RESTUDIR1 | ||
| 88 | |||
| 89 | ; Now know all about the destination | ||
| 90 | |||
| 91 | KNOWABOUTDEST: | ||
| 92 | xor al,al | ||
| 93 | xchg al,[FIRSTDEST] | ||
| 94 | or al,al | ||
| 95 | jnz FIRSTDST | ||
| 96 | jmp NOTFIRSTDEST | ||
| 97 | |||
| 98 | FIRSTDST: | ||
| 99 | mov si,[DESTTAIL] ; Create an FCB of the original DEST | ||
| 100 | mov di,offset trangroup:DESTFCB | ||
| 101 | mov ax,PARSE_FILE_DESCRIPTOR SHL 8 | ||
| 102 | INT int_command | ||
| 103 | CMP BYTE PTR [SI],0 | ||
| 104 | JZ GoodParse | ||
| 105 | ;AD052; MOV BYTE PTR [DI+1],"|" ; must be illegal file name character | ||
| 106 | mov dx,offset trangroup:fuldir_ptr ;AN052; Issue "File creation error" | ||
| 107 | jmp coperr ;AN052; | ||
| 108 | |||
| 109 | GoodParse: | ||
| 110 | mov ax,word ptr [DESTBUF] ; Get drive | ||
| 111 | cmp ah,':' | ||
| 112 | jz DRVSPEC4 | ||
| 113 | mov al,'@' | ||
| 114 | |||
| 115 | DRVSPEC4: | ||
| 116 | MOV CL,[ASCII] ; Save current ASCII setting | ||
| 117 | or al,20h | ||
| 118 | sub al,60h | ||
| 119 | mov [DESTFCB],al | ||
| 120 | mov al,[DESTINFO] | ||
| 121 | mov ah,[SRCINFO] | ||
| 122 | and ax,0202H | ||
| 123 | or al,al | ||
| 124 | jz NOTMELCOPY | ||
| 125 | cmp al,ah | ||
| 126 | jnz NOTMELCOPY | ||
| 127 | cmp [PLUS],0 | ||
| 128 | jz NOTMELCOPY | ||
| 129 | inc [MELCOPY] ; ambig source, ambig dest, and pluses | ||
| 130 | xor al,al | ||
| 131 | jmp short SETCONC | ||
| 132 | |||
| 133 | NOTMELCOPY: | ||
| 134 | xor al,2 ; al=2 if unambig dest, =0 if ambig dest | ||
| 135 | and al,ah | ||
| 136 | shr al,1 ; al=1 if unambig dest AND ambig sorce | ||
| 137 | ; Implies concatenation | ||
| 138 | SETCONC: | ||
| 139 | or al,[PLUS] ; al=1 if concat | ||
| 140 | mov [CONCAT],al | ||
| 141 | shl al,1 | ||
| 142 | shl al,1 | ||
| 143 | mov [INEXACT],al ; Concat -> inexact copy | ||
| 144 | cmp [BINARY],0 | ||
| 145 | jnz NOTFIRSTDEST ; Binary explicitly given, all OK | ||
| 146 | mov [ASCII],al ; Concat -> ASCII | ||
| 147 | or cl,cl | ||
| 148 | jnz NOTFIRSTDEST ; ASCII flag set before, DATA read correctly | ||
| 149 | or al,al | ||
| 150 | JZ NOTFIRSTDEST ; ASCII flag did not change states | ||
| 151 | ; | ||
| 152 | ; At this point there may already be binary read data in the read buffer. | ||
| 153 | ; We need to find the first ^Z (if there is one) and trim the amount | ||
| 154 | ; of data in the buffer correctly. | ||
| 155 | ; | ||
| 156 | MOV CX,[NXTADD] | ||
| 157 | JCXZ NOTFIRSTDEST ; No data, everything OK | ||
| 158 | MOV AL,1AH | ||
| 159 | PUSH ES | ||
| 160 | XOR DI,DI | ||
| 161 | MOV ES,[TPA] | ||
| 162 | REPNE SCASB ; Scan for EOF | ||
| 163 | POP ES | ||
| 164 | JNZ NOTFIRSTDEST ; No ^Z in buffer, everything OK | ||
| 165 | DEC DI ; Point at ^Z | ||
| 166 | MOV [NXTADD],DI ; New buffer | ||
| 167 | |||
| 168 | NOTFIRSTDEST: | ||
| 169 | mov bx,offset trangroup:DIRBUF+1 ; Source of replacement chars | ||
| 170 | cmp [CONCAT],0 | ||
| 171 | jz GOTCHRSRC ; Not a concat | ||
| 172 | mov bx,offset trangroup:SDIRBUF+1 ; Source of replacement chars | ||
| 173 | |||
| 174 | GOTCHRSRC: | ||
| 175 | mov si,offset trangroup:DESTFCB+1 ; Original dest name | ||
| 176 | mov di,[DESTTAIL] ; Where to put result | ||
| 177 | |||
| 178 | public buildname | ||
| 179 | BUILDNAME: | ||
| 180 | mov cx,8 | ||
| 181 | |||
| 182 | BUILDMAIN: | ||
| 183 | lodsb | ||
| 184 | cmp al,'?' | ||
| 185 | jnz NOTAMBIG | ||
| 186 | mov al,byte ptr [BX] | ||
| 187 | |||
| 188 | NOTAMBIG: | ||
| 189 | cmp al,' ' | ||
| 190 | jz NOSTORE | ||
| 191 | stosb | ||
| 192 | |||
| 193 | NOSTORE: | ||
| 194 | inc bx | ||
| 195 | loop BUILDMAIN | ||
| 196 | mov cl,3 | ||
| 197 | mov al,' ' | ||
| 198 | cmp byte ptr [SI],al | ||
| 199 | jz ENDDEST ; No extension | ||
| 200 | mov al,dot_chr | ||
| 201 | stosb | ||
| 202 | |||
| 203 | BUILDEXT: | ||
| 204 | lodsb | ||
| 205 | cmp al,'?' | ||
| 206 | jnz NOTAMBIGE | ||
| 207 | mov al,byte ptr [BX] | ||
| 208 | |||
| 209 | NOTAMBIGE: | ||
| 210 | cmp al,' ' | ||
| 211 | jz NOSTOREE | ||
| 212 | stosb | ||
| 213 | |||
| 214 | NOSTOREE: | ||
| 215 | inc bx | ||
| 216 | loop BUILDEXT | ||
| 217 | ENDDEST: | ||
| 218 | xor al,al | ||
| 219 | stosb ; NUL terminate | ||
| 220 | return | ||
| 221 | |||
| 222 | BUILDPATH: | ||
| 223 | test [BP.INFO],2 | ||
| 224 | jnz NOTPFILE ; If ambig don't bother with open | ||
| 225 | mov dx,bp | ||
| 226 | add dx,BUF ; Set DX to spec | ||
| 227 | |||
| 228 | push di ;AN000; | ||
| 229 | MOV AX,EXTOPEN SHL 8 ;AC000; open the file | ||
| 230 | mov bx,read_open_mode ;AN000; get open mode for COPY | ||
| 231 | xor cx,cx ;AN000; no special files | ||
| 232 | mov si,dx ;AN030; get file name offset | ||
| 233 | mov di,-1 ;AN030; no parm list | ||
| 234 | mov dx,read_open_flag ;AN000; set up open flags | ||
| 235 | INT int_command | ||
| 236 | pop di ;AN000; | ||
| 237 | jnc pure_file ;AN022; is pure file | ||
| 238 | invoke get_ext_error_number ;AN022; get the extended error | ||
| 239 | cmp ax,error_file_not_found ;AN022; if file not found - okay | ||
| 240 | jz notpfile ;AN022; | ||
| 241 | cmp ax,error_path_not_found ;AN022; if path not found - okay | ||
| 242 | jz notpfile ;AN022; | ||
| 243 | cmp ax,error_access_denied ;AN022; if access denied - okay | ||
| 244 | jz notpfile ;AN022; | ||
| 245 | jmp extend_setup ;AN022; exit with error | ||
| 246 | |||
| 247 | pure_file: | ||
| 248 | mov bx,ax ; Is pure file | ||
| 249 | mov ax,IOCTL SHL 8 | ||
| 250 | INT int_command | ||
| 251 | mov ah,CLOSE | ||
| 252 | INT int_command | ||
| 253 | test dl,devid_ISDEV | ||
| 254 | jnz ISADEV ; If device, done | ||
| 255 | test [BP.INFO],4 | ||
| 256 | jz ISSIMPFILE ; If no path seps, done | ||
| 257 | |||
| 258 | NOTPFILE: | ||
| 259 | mov dx,word ptr [BP.BUF] | ||
| 260 | cmp dl,0 ;AN034; If no drive specified, get | ||
| 261 | jz set_drive_spec ;AN034; default drive dir | ||
| 262 | cmp dh,':' | ||
| 263 | jz DRVSPEC5 | ||
| 264 | |||
| 265 | set_drive_spec: ;AN034; | ||
| 266 | mov dl,'@' | ||
| 267 | |||
| 268 | DRVSPEC5: | ||
| 269 | or dl,20h | ||
| 270 | sub dl,60h ; A = 1 | ||
| 271 | invoke SAVUDIR1 | ||
| 272 | jnc curdir_ok ;AN022; if error - exit | ||
| 273 | invoke get_ext_error_number ;AN022; get the extended error | ||
| 274 | jmp extend_setup ;AN022; exit with error | ||
| 275 | |||
| 276 | curdir_ok: ;AN022; | ||
| 277 | mov dx,bp | ||
| 278 | add dx,BUF ; Set DX for upcomming CHDIRs | ||
| 279 | mov bh,[BP.INFO] | ||
| 280 | and bh,6 | ||
| 281 | cmp bh,6 ; Ambig and path ? | ||
| 282 | jnz CHECKAMB ; jmp if no | ||
| 283 | mov si,[BP.TTAIL] | ||
| 284 | mov bl,':' | ||
| 285 | cmp byte ptr [si-2],bl | ||
| 286 | jnz KNOWNOTSPEC | ||
| 287 | mov [BP.ISDIR],2 ; Know is d:/file | ||
| 288 | jmp short DOPCDJ | ||
| 289 | |||
| 290 | KNOWNOTSPEC: | ||
| 291 | mov [BP.ISDIR],1 ; Know is path/file | ||
| 292 | dec si ; Point to the / | ||
| 293 | |||
| 294 | DOPCDJ: | ||
| 295 | jmp DOPCD ;AC022; need long jump | ||
| 296 | |||
| 297 | CHECKAMB: | ||
| 298 | cmp bh,2 | ||
| 299 | jnz CHECKCD | ||
| 300 | |||
| 301 | ISSIMPFILE: | ||
| 302 | ISADEV: | ||
| 303 | mov [BP.ISDIR],0 ; Know is file since ambig but no path | ||
| 304 | return | ||
| 305 | |||
| 306 | CHECKCD: | ||
| 307 | invoke SETREST1 | ||
| 308 | mov ah,CHDIR | ||
| 309 | INT int_command | ||
| 310 | jc NOTPDIR | ||
| 311 | mov di,dx | ||
| 312 | xor ax,ax | ||
| 313 | mov cx,ax | ||
| 314 | dec cx | ||
| 315 | |||
| 316 | Kloop: ;AN000; 3/3/KK | ||
| 317 | MOV AL,ES:[DI] ;AN000; 3/3/KK | ||
| 318 | INC DI ;AN000; 3/3/KK | ||
| 319 | OR AL,AL ;AN000; 3/3/KK | ||
| 320 | JZ Done ;AN000; 3/3/KK | ||
| 321 | xor ah,ah ;AN000; 3/3/KK | ||
| 322 | invoke Testkanj ;AN000; 3/3/KK | ||
| 323 | JZ Kloop ;AN000; 3/3/KK | ||
| 324 | INC DI ;AN000; 3/3/KK | ||
| 325 | INC AH ;AN000; 3/3/KK | ||
| 326 | jmp Kloop ;AN000; 3/3/KK | ||
| 327 | |||
| 328 | Done: ;AN000; 3/3/KK | ||
| 329 | dec di | ||
| 330 | mov al,[DIRCHAR] | ||
| 331 | mov [bp.ISDIR],2 ; assume d:/file | ||
| 332 | OR AH, AH ;AN000; 3/3/KK | ||
| 333 | JNZ Store_pchar ;AN000; 3/3/KK this is the trailing byte of ECS code | ||
| 334 | cmp al,[di-1] | ||
| 335 | jz GOTSRCSLSH | ||
| 336 | |||
| 337 | Store_pchar: ;AN000; 3/3/KK | ||
| 338 | stosb | ||
| 339 | mov [bp.ISDIR],1 ; know path/file | ||
| 340 | |||
| 341 | GOTSRCSLSH: | ||
| 342 | or [bp.INFO],6 | ||
| 343 | call SETSTARS | ||
| 344 | return | ||
| 345 | |||
| 346 | |||
| 347 | NOTPDIR: | ||
| 348 | invoke get_ext_error_number ;AN022; get the extended error | ||
| 349 | cmp ax,error_path_not_found ;AN022; if path not found - okay | ||
| 350 | jz notpdir_try ;AN022; | ||
| 351 | cmp ax,error_access_denied ;AN022; if access denied - okay | ||
| 352 | jnz extend_setupj ;AN022; otherwise - exit error | ||
| 353 | |||
| 354 | notpdir_try: ;AN022; | ||
| 355 | mov [bp.ISDIR],0 ; assume pure file | ||
| 356 | mov bh,[bp.INFO] | ||
| 357 | test bh,4 | ||
| 358 | retz ; Know pure file, no path seps | ||
| 359 | mov [bp.ISDIR],2 ; assume d:/file | ||
| 360 | mov si,[bp.TTAIL] | ||
| 361 | cmp byte ptr [si],0 | ||
| 362 | jz BADCDERRJ2 ; Trailing '/' | ||
| 363 | mov bl,dot_chr | ||
| 364 | cmp byte ptr [si],bl | ||
| 365 | jz BADCDERRJ2 ; If . or .. pure cd should have worked | ||
| 366 | mov bl,':' | ||
| 367 | cmp byte ptr [si-2],bl | ||
| 368 | jz DOPCD ; Know d:/file | ||
| 369 | mov [bp.ISDIR],1 ; Know path/file | ||
| 370 | dec si ; Point at last '/' | ||
| 371 | |||
| 372 | DOPCD: | ||
| 373 | xor bl,bl | ||
| 374 | xchg bl,[SI] ; Stick in a NUL | ||
| 375 | invoke SETREST1 | ||
| 376 | CMP DX,SI ;AN000; 3/3/KK | ||
| 377 | JAE LookBack ;AN000; 3/3/KK | ||
| 378 | PUSH SI ;AN000; 3/3/KK | ||
| 379 | PUSH CX ;AN000; 3/3/KK | ||
| 380 | MOV CX,SI ;AN000; 3/3/KK | ||
| 381 | MOV SI,DX ;AN000; 3/3/KK | ||
| 382 | |||
| 383 | Kloop2: ;AN000; 3/3/KK | ||
| 384 | LODSB ;AN000; 3/3/KK | ||
| 385 | invoke TestKanj ;AN000; 3/3/KK | ||
| 386 | jz NotKanj4 ;AN000; 3/3/KK | ||
| 387 | LODSB ;AN000; 3/3/KK | ||
| 388 | CMP SI,CX ;AN000; 3/3/KK | ||
| 389 | JB Kloop2 ;AN000; 3/3/KK | ||
| 390 | POP CX ;AN000; 3/3/KK | ||
| 391 | POP SI ;AN000; 3/3/KK | ||
| 392 | JMP SHORT DoCdr ;AN000; 3/3/KK Last char is ECS code, don't check for | ||
| 393 | ; trailing path sep | ||
| 394 | NotKanj4: ;AN000; 3/3/KK | ||
| 395 | CMP SI,CX ;AN000; 3/3/KK | ||
| 396 | JB Kloop2 ;AN000; 3/3/KK | ||
| 397 | POP CX ;AN000; 3/3/KK | ||
| 398 | POP SI ;AN000; 3/3/KK | ||
| 399 | |||
| 400 | LookBack: ;AN000; 3/3/KK | ||
| 401 | CMP BL,[SI-1] ; if double slash, then complain. | ||
| 402 | JZ BadCDErrJ2 | ||
| 403 | |||
| 404 | DoCdr: ;AN000; 3/3/KK | ||
| 405 | mov ah,CHDIR | ||
| 406 | INT int_command | ||
| 407 | xchg bl,[SI] | ||
| 408 | retnc | ||
| 409 | invoke get_ext_error_number ;AN022; get the extended error | ||
| 410 | |||
| 411 | EXTEND_SETUPJ: ;AN022; | ||
| 412 | JMP EXTEND_SETUP ;AN022; go issue the error message | ||
| 413 | |||
| 414 | BADCDERRJ2: | ||
| 415 | jmp badpath_err ;AC022; go issue path not found message | ||
| 416 | |||
| 417 | SETSTARS: | ||
| 418 | mov [bp.TTAIL],DI | ||
| 419 | add [bp.SIZ],12 | ||
| 420 | mov ax,dot_qmark | ||
| 421 | mov cx,8 | ||
| 422 | rep stosb | ||
| 423 | xchg al,ah | ||
| 424 | stosb | ||
| 425 | xchg al,ah | ||
| 426 | mov cl,3 | ||
| 427 | rep stosb | ||
| 428 | xor al,al | ||
| 429 | stosb | ||
| 430 | return | ||
| 431 | |||
| 432 | PUBLIC CompName | ||
| 433 | COMPNAME: | ||
| 434 | |||
| 435 | mov si,offset trangroup:DESTBUF ;g do name translate of target | ||
| 436 | mov di,offset trangroup:TRGXNAME ;g save for name comparison | ||
| 437 | mov ah,xnametrans ;g | ||
| 438 | int int_command ;g | ||
| 439 | |||
| 440 | MOV si,offset trangroup:SRCXNAME ;g get name translate of source | ||
| 441 | MOV di,offset trangroup:TRGXNAME ;g get name translate of target | ||
| 442 | |||
| 443 | |||
| 444 | invoke STRCOMP | ||
| 445 | |||
| 446 | return | ||
| 447 | |||
| 448 | TRANCODE ENDS | ||
| 449 | END | ||
| 450 | \ No newline at end of file | ||