diff options
Diffstat (limited to 'v4.0/src/CMD/COMP/COMP2.ASM')
| -rw-r--r-- | v4.0/src/CMD/COMP/COMP2.ASM | 1932 |
1 files changed, 1932 insertions, 0 deletions
diff --git a/v4.0/src/CMD/COMP/COMP2.ASM b/v4.0/src/CMD/COMP/COMP2.ASM new file mode 100644 index 0000000..e4e719a --- /dev/null +++ b/v4.0/src/CMD/COMP/COMP2.ASM | |||
| @@ -0,0 +1,1932 @@ | |||
| 1 | PAGE ,132 ; | ||
| 2 | title COMP2.SAL - COMPARES FILES | ||
| 3 | ;****************** START OF SPECIFICATIONS ***************************** | ||
| 4 | ; MODULE NAME: COMP2.ASM | ||
| 5 | ; | ||
| 6 | ; DESCRIPTIVE NAME: Compare two files to show they are identical or not. | ||
| 7 | ; | ||
| 8 | ; FUNCTION: The paths and names of each pair of files is | ||
| 9 | ; displayed as the comparing process proceeds. An | ||
| 10 | ; error message will follow the names if: | ||
| 11 | ; (1) a file matching the second filename can't be found, | ||
| 12 | ; (2) the files are different sizes, | ||
| 13 | ; (3) either path is invalid, or. | ||
| 14 | ; (4) CHCP=Yes (CODE PAGE active) and code page of files | ||
| 15 | ; do not match. | ||
| 16 | ; | ||
| 17 | ; During the comparison, an error message will appear for any | ||
| 18 | ; location that contains mismatching information in the 2 | ||
| 19 | ; files. The message indicates the offset into the files of | ||
| 20 | ; the mismatching bytes, and the contents of the 2 bytes | ||
| 21 | ; themselves (all in hex). This will occur for up to 10 | ||
| 22 | ; mismatching bytes - if more than 10 compare errors are | ||
| 23 | ; found, the program assumes that further comparison would be | ||
| 24 | ; useless, and ends its compare of the 2 files at that point. | ||
| 25 | ; | ||
| 26 | ; If all bytes in the 2 files match, a "Files compare OK" | ||
| 27 | ; message will appear. | ||
| 28 | ; | ||
| 29 | ; In all cases, after the comparing of 2 files ends, comparing | ||
| 30 | ; will proceed with the next pair of files that match the 2 | ||
| 31 | ; filenames, until no more files can be found that match the | ||
| 32 | ; first filename. You are then asked if you want to compare | ||
| 33 | ; any more files. Replying "N" returns you to the DOS prompt | ||
| 34 | ; (such as A>); a reply of "Y" results in prompts for new | ||
| 35 | ; primary and secondary filenames. | ||
| 36 | ; | ||
| 37 | ; In all compares, COMP looks at the last byte of one of the | ||
| 38 | ; files being compared to assure that it contains a valid | ||
| 39 | ; end-of-file mark (CTRL-Z, which is the hex character 1A). | ||
| 40 | ; If found, no action is taken by COMP. If the end-of-file | ||
| 41 | ; mark is NOT found, COMP produces the message "EOF mark not | ||
| 42 | ; found". This is done because some products produce files | ||
| 43 | ; whose sizes are always recorded in the directory as a | ||
| 44 | ; multiple of 128 bytes, even though the actual usable data in | ||
| 45 | ; the file will usually be a few bytes less than the directory | ||
| 46 | ; size. In this case, COMP may produce "Compare error" | ||
| 47 | ; messages when comparing the few bytes beyond the last real | ||
| 48 | ; data byte in the last block of 128 bytes (COMP always | ||
| 49 | ; compares the number of bytes reflected in the directory). | ||
| 50 | ; Thus, the "EOF mark not found" message indicates that the | ||
| 51 | ; compare errors may not have occurred in the usable data | ||
| 52 | ; portion of the file. | ||
| 53 | ; | ||
| 54 | ; Multiple compare operations may be performed with one load | ||
| 55 | ; of COMP. A prompt, "Compare more files (Y/N)?" permits additional | ||
| 56 | ; executions. | ||
| 57 | ; | ||
| 58 | ; ENTRY POINT: "INIT", jumped to by COMP1 at the DOS entry point. | ||
| 59 | ; | ||
| 60 | ; INPUT: (DOS command line parameters) | ||
| 61 | ; [d:][path] COMP [d:][path][filenam1[.ext]] [d:][path][filenam2[.ext]] | ||
| 62 | ; | ||
| 63 | ; Where | ||
| 64 | ; [d:][path] before COMP to specify the drive and path that | ||
| 65 | ; contains the COMP command file. | ||
| 66 | ; | ||
| 67 | ; [d:][path][filenam1[.ext]] - to specify the FIRST (or primary) | ||
| 68 | ; file or group of files to be compared | ||
| 69 | ; | ||
| 70 | ; [d:][path][filenam2[.ext]] - to specify the SECOND file or group | ||
| 71 | ; of files to be compared with the corresponding file | ||
| 72 | ; from the FIRST group | ||
| 73 | ; | ||
| 74 | ; Global filename characters are allowed in both filenames, | ||
| 75 | ; and will cause all of the files matching the first filename | ||
| 76 | ; to be compared with the corresponding files from the second | ||
| 77 | ; filename. Thus, entering COMP A:*.ASM B:*.BAK will cause | ||
| 78 | ; each file from drive A: that has an extension of .ASM to be | ||
| 79 | ; compared with a file of the same name (but with an extension | ||
| 80 | ; of .BAK) from drive B:. | ||
| 81 | ; | ||
| 82 | ; If you enter only a drive specification, COMP will assume | ||
| 83 | ; all files in the current directory of the specified drive. | ||
| 84 | ; If you enter a path without a filename, COMP assumes all | ||
| 85 | ; files in the specified directory. Thus, COMP A:\LEVEL1 | ||
| 86 | ; B:\LEVEL2 will compare all files in directory A:\LEVEL1 with | ||
| 87 | ; the files of the same names in directory B:\LEVEL2. | ||
| 88 | ; | ||
| 89 | ; If no parameters are entered with the COMP command, you will | ||
| 90 | ; be prompted for both. If the second parm is omitted, COMP | ||
| 91 | ; will prompt for it. If you simply press ENTER when prompted | ||
| 92 | ; for the second filename, COMP assumes *.* (all files | ||
| 93 | ; matching the primary filename), and will use the current | ||
| 94 | ; directory of the default drive. | ||
| 95 | ; | ||
| 96 | ; If no file matches the primary filename, COMP will prompt | ||
| 97 | ; again for both parameters. | ||
| 98 | ; | ||
| 99 | ; EXIT-NORMAL: Errorlevel = 0, Function completed successfully. | ||
| 100 | ; | ||
| 101 | ; EXIT-ERROR: Errorlevel = 1, Abnormal termination due to error, wrong DOS, | ||
| 102 | ; invalid parameters, unrecoverable I/O errors on the diskette. | ||
| 103 | ; | ||
| 104 | ; EFFECTS: Files are not altered. A Message will show result of compare. | ||
| 105 | ; | ||
| 106 | ; INTERNAL REFERENCES: | ||
| 107 | ; ROUTINES: | ||
| 108 | ; SENDMSG - passes parms to regs and invokes the system message routine. | ||
| 109 | ; EXTERR - get extended error and display message. | ||
| 110 | ; INIT_CP - record chcp switch then turn off. Allows COMP to open first | ||
| 111 | ; or second file regardless of the system code page. | ||
| 112 | ; RESTORE_CP - resets the chcp switch to the initial value. | ||
| 113 | ; COMP_CODEPAGE - verify matching code pages. | ||
| 114 | ; GET_CP - do an extended open, get code page, then close. | ||
| 115 | ; | ||
| 116 | ; DATA AREAS: | ||
| 117 | ; WORKAREA - Temporary storage | ||
| 118 | ; | ||
| 119 | ; EXTERNAL REFERENCES: | ||
| 120 | ; ROUTINES: | ||
| 121 | ; SYSDISPMSG - Uses the MSG parm lists to construct the messages | ||
| 122 | ; on STDOUT. | ||
| 123 | ; SYSLOADMSG - Loads messages, makes them accessable. | ||
| 124 | ; SYSPARSE - Processes the DOS Command line, finds parms. | ||
| 125 | ; | ||
| 126 | ; DATA AREAS: | ||
| 127 | ; PSP - Contains the DOS command line parameters. | ||
| 128 | ; COMPSM.SAL - Defines the control blocks that describe the messages | ||
| 129 | ; COMPPAR.SAL - Defines the control blocks that describe the | ||
| 130 | ; DOS Command line parameters. | ||
| 131 | ; | ||
| 132 | ; NOTES: | ||
| 133 | ; This module should be processed with the SALUT preprocessor | ||
| 134 | ; with the re-alignment not requested, as: | ||
| 135 | ; | ||
| 136 | ; SALUT COMP2,NUL | ||
| 137 | ; | ||
| 138 | ; To assemble these modules, the alphabetical or sequential | ||
| 139 | ; ordering of segments may be used. | ||
| 140 | ; | ||
| 141 | ; For LINK information, reference Prolog of COMP1.SAL. | ||
| 142 | ; | ||
| 143 | ; COPYRIGHT: The following notice is found in the OBJ code generated from | ||
| 144 | ; the "COMPSM.SAL" module: | ||
| 145 | ; | ||
| 146 | ; "The DOS COMP Utility" | ||
| 147 | ; "Version 4.0 (C) Copyright 1988 Microsoft" | ||
| 148 | ; "Licensed Material - Property of Microsoft" | ||
| 149 | ; | ||
| 150 | ; Modification History: | ||
| 151 | ; | ||
| 152 | ; Version Author date comment | ||
| 153 | ; ------- ------ ---- ------- | ||
| 154 | ; V0.0 Dave L. Original author | ||
| 155 | ; | ||
| 156 | ; V3.3 Russ W. | ||
| 157 | ; | ||
| 158 | ; V4.0 Edwin M. K. ;AN000; Extended attribute support, | ||
| 159 | ; Bill L. 7/10/87 parser, message retriever support | ||
| 160 | ; | ||
| 161 | ; V4.0 Bill L. 9/17/87 ;AN001; - DCR 201 enhancements to the | ||
| 162 | ; extended attribute support | ||
| 163 | ; | ||
| 164 | ; V4.0 Bill L. ;AN002; - PTM 708 | ||
| 165 | ; ;AN003; - PTM 728 | ||
| 166 | ; ;AN004; - PTM 1610 | ||
| 167 | ; ;AN005; - PTM 274 | ||
| 168 | ; ;AN006; - PTM 2205 (DBCS support) | ||
| 169 | ; ;AN007; - PTM 3056 (y/n -> STDERR) | ||
| 170 | ; ;AN008; - optimizations | ||
| 171 | ; ;AN009; - PTM 4076 network hang | ||
| 172 | ; | ||
| 173 | ;****************** END OF SPECIFICATIONS ***************************** | ||
| 174 | page | ||
| 175 | |||
| 176 | if1 | ||
| 177 | %OUT COMPONENT=COMP, MODULE=COMP2.SAL | ||
| 178 | endif | ||
| 179 | |||
| 180 | ;*********************************** | ||
| 181 | ; Macro definitions | ||
| 182 | ;*********************************** | ||
| 183 | |||
| 184 | fill_name1 macro pfcb ;AN000; | ||
| 185 | push dx ;AN000; | ||
| 186 | push di ;AN000; | ||
| 187 | push si ;AN000; | ||
| 188 | mov dx,offset name1 ;AN000; | ||
| 189 | mov si,offset path1 ;AN000; | ||
| 190 | mov di,offset pfcb ;AN000; | ||
| 191 | call fill_n ;AN000; | ||
| 192 | pop si ;AN000; | ||
| 193 | pop di ;AN000; | ||
| 194 | pop dx ;AN000; | ||
| 195 | endm ;AN000; | ||
| 196 | |||
| 197 | fill_name2 macro ;AN000; | ||
| 198 | push dx ;AN000; | ||
| 199 | push di ;AN000; | ||
| 200 | push si ;AN000; | ||
| 201 | mov dx,offset name2 ;AN000; | ||
| 202 | mov si,offset path2 ;AN000; | ||
| 203 | mov di,offset outfcb ;AN000; | ||
| 204 | call fill_n ;AN000; | ||
| 205 | pop si ;AN000; | ||
| 206 | pop di ;AN000; | ||
| 207 | pop dx ;AN000; | ||
| 208 | endm ;AN000; | ||
| 209 | |||
| 210 | print_msg macro msg,handle ;AC003; | ||
| 211 | push ax ;AN000; | ||
| 212 | mov dx,offset msg ;AN000; ;dx: ptr to msg descriptor | ||
| 213 | ifnb <handle> ;AN003; ;check if new handle given | ||
| 214 | push di ;AN003; ;put new handle in msg structure | ||
| 215 | mov di,dx ;AN003; | ||
| 216 | mov [di].msg_handle,handle ;AN003; | ||
| 217 | pop di ;AN003; | ||
| 218 | endif ;AN003; | ||
| 219 | call sendmsg ;AC000; | ||
| 220 | pop ax ;AN000; | ||
| 221 | endm ;AN000; | ||
| 222 | |||
| 223 | doscall macro func,subfunc ;AN000; | ||
| 224 | ifnb <func> ;AN000; ;are there any parms at all ? | ||
| 225 | ifnb <subfunc> ;AN000; ;is there a sub-function ? | ||
| 226 | mov ax,(func shl 8)+subfunc ;AN000; ;yes, ah=func, al=subfunc | ||
| 227 | else ;AN000; ;no sub-function | ||
| 228 | mov ah,func ;AN000; | ||
| 229 | endif ;AN000; | ||
| 230 | endif ;AN000; | ||
| 231 | int 21h ;AN000; | ||
| 232 | endm ;AN000; | ||
| 233 | |||
| 234 | ;*********************************** | ||
| 235 | ; Include equates | ||
| 236 | ;*********************************** | ||
| 237 | |||
| 238 | include compeq.inc ;AN000; ;include some equates | ||
| 239 | |||
| 240 | ;*********************************** | ||
| 241 | ; Extended attribute structures | ||
| 242 | ;*********************************** | ||
| 243 | |||
| 244 | ea struc ;AN001; ;extended attr. structure | ||
| 245 | ea_type db EAISBINARY ;AN001; | ||
| 246 | ea_flags dw EASYSTEM ;AN001; | ||
| 247 | ea_rc db ? ;AN001; | ||
| 248 | ea_namelen db 2 ;AN001; | ||
| 249 | ea_vallen dw 2 ;AN001; | ||
| 250 | ea_name db "CP" ;AN001; | ||
| 251 | ea_value dw ? ;AN001; | ||
| 252 | ea ends ;AN001; | ||
| 253 | |||
| 254 | qea struc ;AN001; ;query extended attr. name | ||
| 255 | qea_type db EAISBINARY ;AN001; | ||
| 256 | qea_flags dw EASYSTEM ;AN001; | ||
| 257 | qea_namelen db 2 ;AN001; | ||
| 258 | qea_name db "CP" ;AN001; | ||
| 259 | qea ends ;AN001; | ||
| 260 | |||
| 261 | ;*********************************** | ||
| 262 | ; Code Segment | ||
| 263 | ;*********************************** | ||
| 264 | |||
| 265 | cseg segment para public 'CODE' ;AC000; | ||
| 266 | assume cs:cseg,ds:cseg,es:cseg,ss:cseg ;as set by DOS loader | ||
| 267 | |||
| 268 | extrn parser:near ;AN000; | ||
| 269 | extrn sysloadmsg:near ;AN000; | ||
| 270 | extrn sysdispmsg:near ;AN000; | ||
| 271 | extrn memory_size:word | ||
| 272 | extrn fcb:byte | ||
| 273 | extrn parms:word ;AN000; | ||
| 274 | extrn parm_area:byte | ||
| 275 | extrn parm_count:word ;AN000; | ||
| 276 | extrn current_parm:word ;AN000; | ||
| 277 | extrn ordinal:word ;AN000; | ||
| 278 | extrn msgnum_mem:word ;AN000; | ||
| 279 | extrn msgnum_para:word ;AN000; | ||
| 280 | extrn msgnum_tenmsg:word ;AN000; | ||
| 281 | extrn msgnum_baddrv:word ;AN000; | ||
| 282 | extrn msgnum_bad:word ;AN000; | ||
| 283 | extrn msgnum_adr:word ;AN000; | ||
| 284 | extrn msgnum_bdr:word ;AN000; | ||
| 285 | extrn msgnum_eor:word ;AN000; | ||
| 286 | extrn msgnum_done:word ;AN000; | ||
| 287 | extrn msgnum_fnf:word ;AN000; | ||
| 288 | extrn msgnum_bad_path:word ;AN000; | ||
| 289 | extrn msgnum_share:word ;AN000; | ||
| 290 | extrn msgnum_too_many:word ;AN000; | ||
| 291 | extrn msgnum_prinam:word ;AN000; | ||
| 292 | extrn msgnum_secnam:word ;AN000; | ||
| 293 | extrn msgnum_badsiz:word ;AN000; | ||
| 294 | extrn msgnum_nother:word ;AN000; | ||
| 295 | extrn msgnum_and_msg:word ;AN000; | ||
| 296 | extrn msgnum_crlf:word ;AN000; | ||
| 297 | extrn msgnum_accessdenied:word ;AN000; | ||
| 298 | extrn msgnum_cp_mismatch:word ;AN000; | ||
| 299 | extrn msgnum_ok:word ;AN000; | ||
| 300 | extrn msgnum_exterr:word ;AN000; | ||
| 301 | extrn msgnum_pparse:word ;AN000; | ||
| 302 | extrn sublist_6:word ;AN000; | ||
| 303 | extrn sublist_7:word ;AN000; | ||
| 304 | extrn sublist_8:word ;AN000; | ||
| 305 | extrn sublist_11:word ;AN000; | ||
| 306 | extrn sublist_12:word ;AN000; | ||
| 307 | extrn sublist_13:word ;AN000; | ||
| 308 | extrn sublist_19a:word ;AN000; | ||
| 309 | extrn sublist_19b:word ;AN000; | ||
| 310 | extrn sublist_21:word ;AN000; | ||
| 311 | extrn sublist_exterr:word ;AN000; | ||
| 312 | extrn sublist_24:word ;AN000; | ||
| 313 | |||
| 314 | ;*********************************** | ||
| 315 | ; Data area in code segment | ||
| 316 | ;*********************************** | ||
| 317 | |||
| 318 | public path1 ;AN000; | ||
| 319 | public path2 ;AN000; | ||
| 320 | public name1 ;AN000; | ||
| 321 | public name2 ;AN000; | ||
| 322 | public cur_name ;AN000; | ||
| 323 | public exitfl ;AN000; | ||
| 324 | |||
| 325 | even ;AN000; ;align stack on word boundary | ||
| 326 | |||
| 327 | stack_area db 512 dup ("S") ;Added in DOS 3.20 to support hardware requiring | ||
| 328 | End_Stack_Area db 00h ;large stacks. DO NOT PUT DATA ABOVE THIS ! | ||
| 329 | |||
| 330 | clear db 00h ;AN000; ;clear path2 | ||
| 331 | cur_name dw 00h ;AN000; ;ptr to current filename | ||
| 332 | input_buf db 130 dup (0) ;AN000; ;input buffer for keyb input | ||
| 333 | name1 db 130 dup (0) ;AN000; ;source file name | ||
| 334 | name2 db 130 dup (0) ;AN000; ;target file name | ||
| 335 | byte1 db 00h ;AN000; ;on compare: bad byte for source | ||
| 336 | byte2 db 00h ;AN000; ;on compare: bad byte for target | ||
| 337 | fcb2 db 16 dup (0) ;entered target filespec | ||
| 338 | ;--------KEEP NEXT VARIABLes IN ORIGINAL ORDER------------- | ||
| 339 | oldp1 db 67 dup (0) ;original path for the first drive 1 KEEP IN ORDER | ||
| 340 | path1 db 130 dup (0) ;path we'll use for the first drive 2 | ||
| 341 | infcb db 37 dup (0) ;source fcb 3 | ||
| 342 | oldp2 db 67 dup (0) ;original path for second drive 4 | ||
| 343 | path2 db 130 dup (0) ;path we'll use for second drive 5 | ||
| 344 | outfcb db 37 dup (0) ;target fcb 6 | ||
| 345 | ;--------KEEP ABOVE VARIABLes IN ORIGINAL ORDER------------ | ||
| 346 | sav db 2 dup (0) | ||
| 347 | mem db 2 dup (0) ;size of large buffer in bytes | ||
| 348 | curfcb db 4 dup (0) ;first 2 bytes = addr of fcb for large buffer, | ||
| 349 | ;last 2 bytes = addr of fcb for small buffer | ||
| 350 | curpos dw 00h ;current byte offset in large buffer | ||
| 351 | buf2 dw 00h ;seg address of large buffer | ||
| 352 | siz dw 512 ;# bytes of data left to compare in large buffer | ||
| 353 | swt db 00h ;Bit switch: | ||
| 354 | ; 1 = read file to eof | ||
| 355 | ; 4 = had compare error | ||
| 356 | ; 8 = eof mark not found | ||
| 357 | ; 16 = secondary dir path has been found | ||
| 358 | ; 32 = primary file opened | ||
| 359 | ; 64 = secondary file opened | ||
| 360 | ; 128 = zero suppress switch | ||
| 361 | swt2 db 00h ;Bit switch: | ||
| 362 | ; 1 = oldp1 setup | ||
| 363 | ; 2 = oldp2 setup | ||
| 364 | offs db 00h,00h,00h,00h ;count of bytes compared | ||
| 365 | cnt db 00h ;# of bad compares | ||
| 366 | offp db 8 dup(0) ;AC000; ;offset of mis-compare between bytes | ||
| 367 | off_byte db 8 dup (0) ;AN000; ;same as offp, but the words are reversed | ||
| 368 | curdrv db 00h ;actual number of default drive | ||
| 369 | cdrv db " :" ;ascii letter of default drive | ||
| 370 | pathchar db "\",00h | ||
| 371 | tbl db "0123456789ABCDEF" | ||
| 372 | openpath db 15 dup (0) ;An fcb will be parsed into this path. | ||
| 373 | cpsw_orig db 00h ;AN000; ;save original cpsw value | ||
| 374 | exitfl db EXOK ;AN000; ;errorlevel return code | ||
| 375 | handle dw 00h ;AN000; | ||
| 376 | |||
| 377 | dbcs_off dw 0 ;AN006; | ||
| 378 | dbcs_seg dw 0 ;AN006; | ||
| 379 | dbcs_len dw 0 ;AN006; | ||
| 380 | string_off dw 0 ;AN006; | ||
| 381 | string_seg dw 0 ;AN006; | ||
| 382 | dstring db 128 dup(0) ;AN006; | ||
| 383 | |||
| 384 | parm_list label word ;AN001; | ||
| 385 | dd -1 ;AN001; | ||
| 386 | dw 1 ;AN001; | ||
| 387 | db 6 ;AN001; | ||
| 388 | dw 2 ;AN001; | ||
| 389 | |||
| 390 | querylist label byte ;AN001; ;query general list | ||
| 391 | dw 1 ;AN001; ;# of entries | ||
| 392 | querylist_qea qea <EAISBINARY,EASYSTEM,2,"CP"> ;AN001; | ||
| 393 | |||
| 394 | qlist label byte ;AN001; ;general get/set list | ||
| 395 | dw 1 ;AN001; ;count of attr entries | ||
| 396 | qlist_ea ea <EAISBINARY,EASYSTEM,?,2,2,"CP",?> ;AN001; ;return code page in this structure | ||
| 397 | |||
| 398 | ;*********************************** | ||
| 399 | ; Code area in code segment | ||
| 400 | ;*********************************** | ||
| 401 | |||
| 402 | |||
| 403 | ;----------------------------------------------------------------------------- | ||
| 404 | ; INIT - Fill in fill_seg, fill_off in all msg sublists with current seg_id | ||
| 405 | ; and offset. Also calls the system load massage function so it can | ||
| 406 | ; establish addressability to the system messages, and for it to verify | ||
| 407 | ; the DOS version | ||
| 408 | ;----------------------------------------------------------------------------- | ||
| 409 | init proc near ;AC000; | ||
| 410 | public init ;AN000; | ||
| 411 | |||
| 412 | mov sp,offset End_Stack_Area ;Big Stack | ||
| 413 | push ax ;AN000; ;on entry--ax (should) = valid drive parm | ||
| 414 | call setfill ;AN000; ;init fill_seg, fill_off in sublists | ||
| 415 | call sysloadmsg ;AN000; ;init sysmsg handler | ||
| 416 | |||
| 417 | ; $if c ;AN000; ;if there was a problem | ||
| 418 | JNC $$IF1 | ||
| 419 | call sysdispmsg ;AN000; ;let him say why we had a problem | ||
| 420 | mov exitfl,EXVER ;AN000; ;tell errorlevel bad DOS version | ||
| 421 | ; $else ;AN000; ;since sysdispmsg is happy | ||
| 422 | JMP SHORT $$EN1 | ||
| 423 | $$IF1: | ||
| 424 | call get_dbcs_vector ;AN006; ;get DOS DBCS table vector | ||
| 425 | ;;(deleted for AN009) call init_cp ;AN000; ;get current setting of CHCP | ||
| 426 | pop ax ;AN000; ;restore valid drive parm | ||
| 427 | call more_init ;AN000; ;do more init | ||
| 428 | call main ;AN000; ;do rest of utility as normal | ||
| 429 | ;;(deleted for AN009) call restore_cp ;AN000; ;set CHCP back to normal | ||
| 430 | ; $endif ;AN000; ;ok with sysdispmsg? | ||
| 431 | $$EN1: | ||
| 432 | mov al,exitfl ;AN000; ;pass back errorlevel ret code | ||
| 433 | doscall RET_FN ;AN000; ;return to DOS with ret code | ||
| 434 | int 20h ;AN000; ;if above not work, | ||
| 435 | ;AN000; ;take stick and kill it | ||
| 436 | init endp ;AN000; | ||
| 437 | |||
| 438 | |||
| 439 | ;------------------------------------------------------------------------------ | ||
| 440 | ; MAIN - Does the compare for two sets of files | ||
| 441 | ;------------------------------------------------------------------------------ | ||
| 442 | ; | ||
| 443 | main proc near ;AN000; | ||
| 444 | public main ;AN000; | ||
| 445 | |||
| 446 | mov clear,0 ;clear it | ||
| 447 | ; $do ;AN000; | ||
| 448 | $$DO4: | ||
| 449 | cmp byte ptr path1,0 ;was first parm given? | ||
| 450 | ; $leave ne ;AN000; ;Yes, LEAVE INPUT loop | ||
| 451 | JNE $$EN4 | ||
| 452 | mov byte ptr path2,0 ;AN000; ;make sure that we get the second file name | ||
| 453 | rpt: | ||
| 454 | mov dx,offset msgnum_prinam ;AC000; ;to ask user for first parm | ||
| 455 | mov parm_count,FIRST_PARM_CT ;AN000; ;THIS IS FIRST PARM (ONLY ONE ACTUALLY) | ||
| 456 | call getnam ;get first parm from user in path1 and fcb | ||
| 457 | mov di,offset fcb ;AN000; ;es:di=ptr TO UNOPENED fcb | ||
| 458 | mov si,offset path1 ;AN000; ;ds:si=ptr TO COMMAND LINE TO PARSE | ||
| 459 | ;AN000; ;AL-BIT VALUE CONTROLS PARsiNG | ||
| 460 | doscall PARSE_FILENAME,01H ;AN000; ;AND GO MAKE AN fcb, SCAN OFF LEAdiNG SEPARATORS | ||
| 461 | cmp AL,255 ;AN000; ;INVALID DRIVE? | ||
| 462 | ; $if e ;AN000; ;Yes | ||
| 463 | JNE $$IF6 | ||
| 464 | print_msg msgnum_baddrv,STDERR ;AN000; ;"Invalid drive spec." | ||
| 465 | mov byte ptr path1,00 ;AN000; ;BLANK FIRST CHAR. SO TO loop AGAIN | ||
| 466 | ; $endif ;AN000; | ||
| 467 | $$IF6: | ||
| 468 | ; $enddo ;AC000; ;REPEAT UNTIL FIRST PARM OK | ||
| 469 | JMP SHORT $$DO4 | ||
| 470 | $$EN4: | ||
| 471 | |||
| 472 | ;chek2: ;GET/SET SECOND FILENAME | ||
| 473 | cmp clear,1 | ||
| 474 | ; $if e | ||
| 475 | JNE $$IF9 | ||
| 476 | mov byte ptr path2,0 | ||
| 477 | mov clear,0 | ||
| 478 | ; $endif | ||
| 479 | $$IF9: | ||
| 480 | ; $do ;AN000; | ||
| 481 | $$DO11: | ||
| 482 | cmp byte ptr path2,0 ;was second parm given? | ||
| 483 | ; $leave ne ;AN000; ;Yes, LEAVE INPUT loop | ||
| 484 | JNE $$EN11 | ||
| 485 | mov dx,offset msgnum_secnam ;AC000; ;to ask for second parm | ||
| 486 | mov parm_count,TRICK_PARM_CT ;AN000; ;THIS IS FIRST PARM (ONLY ONE ACTUALLY) | ||
| 487 | ;AN000; ;BUT PUT FILENAME IN path2 INSTEAD OF path1 | ||
| 488 | call getnam ;get second parm in path2 and fcb2 | ||
| 489 | mov di,offset fcb2 ;AN000; ;es:di=ptr TO UNOPENED fcb | ||
| 490 | mov si,offset path2 ;AN000; ;ds:si=ptr TO COMMAND LINE TO PARSE | ||
| 491 | ;AN000; ;AL-BIT VALUE CONTROLS PARsiNG | ||
| 492 | doscall PARSE_FILENAME,01H ;AN000; ;AND GO MAKE AN fcb, SCAN OFF LEAdiNG SEPARATORS | ||
| 493 | cmp AL,255 ;AN000; ;INVALID DRIVE? | ||
| 494 | ; $if e ;AN000; ;Yes | ||
| 495 | JNE $$IF13 | ||
| 496 | print_msg msgnum_baddrv,STDERR ;AN000; ;"Invalid drive spec." | ||
| 497 | mov byte ptr path2, 00 ;AN000; ;BLANK FIRST CHAR. SO TO loop AGAIN | ||
| 498 | ; $endif ;AN000; | ||
| 499 | $$IF13: | ||
| 500 | ; $enddo ;AC000; ;SECOND PARM? | ||
| 501 | JMP SHORT $$DO11 | ||
| 502 | $$EN11: | ||
| 503 | mov si,offset path1 ;AN000; ;si = ptr TO PATH NAME TO FIND "\" IN | ||
| 504 | call findfs ;AN000; ;FIND LAST "\" AND SAVE ADDR | ||
| 505 | mov si,offset path2 ;AN000; ;si = ptr TO PATH NAME TO FIND "\" IN | ||
| 506 | call findfs ;AN000; ;FIND LAST "\" AND SAVE ADDR | ||
| 507 | mov al,curdrv ;get default drive | ||
| 508 | cmp byte ptr fcb,0 ;source on default? | ||
| 509 | ; $if e ;AC000; ;Yes | ||
| 510 | JNE $$IF16 | ||
| 511 | mov fcb,al ;yes, set to actual drive | ||
| 512 | ; $endif ;AC000; | ||
| 513 | $$IF16: | ||
| 514 | cmp byte ptr fcb2,0 ;target on default? | ||
| 515 | ; $if e ;AC000; ;Yes | ||
| 516 | JNE $$IF18 | ||
| 517 | mov fcb2,al ;yes, set to actual drive | ||
| 518 | ; $endif ;AC000; ;***** FIND PRI FILE | ||
| 519 | $$IF18: | ||
| 520 | mov si,offset path1 | ||
| 521 | mov di,offset fcb | ||
| 522 | call findpath ;locate primary's specified dir | ||
| 523 | ; $if ne ;AC000; | ||
| 524 | JE $$IF20 | ||
| 525 | fill_name1 fcb ;AN000; ;get full path name | ||
| 526 | mov sublist_12.sub_value,offset name1 ;AN000; ;SET UP %1 IN sublist OF "Invalid path - %0: | ||
| 527 | mov dx,offset msgnum_bad_path ;AC000; ;dx = ptr TO MSG DesCRIPTOR TO dispLAY | ||
| 528 | ;AN000; ;VALUE IN di,si,dx PAssED TO BADFIL CODE | ||
| 529 | jmp badfil ;dir not found - tell user | ||
| 530 | ; $endif ;AC000; | ||
| 531 | $$IF20: | ||
| 532 | mov dx,offset infcb | ||
| 533 | doscall SETDTA ;AC000; ;diR FOUND, SET DTA TO SOURCE fcb | ||
| 534 | mov dx,di ;fcb | ||
| 535 | doscall SEARCHF ;AC000; SEARCH FIRST SOURCE FILE | ||
| 536 | or al,al ;find one? | ||
| 537 | ; $if nz ;AC000; ;Yes | ||
| 538 | JZ $$IF22 | ||
| 539 | fill_name1 fcb ;AN000; ;get full path name | ||
| 540 | mov sublist_11.sub_value,offset name1 ;AN000; ;SET UP %1 IN sublist OF "File not found - %0" | ||
| 541 | mov dx,offset msgnum_fnf ;AC000; ;dx = ptr TO MSG DesCRIPTOR TO dispLAY | ||
| 542 | ;AN000; ;VALUE IN di,si,dx PAssED TO BADFIL CODE | ||
| 543 | jmp badfil | ||
| 544 | ; $endif ;AC000; | ||
| 545 | $$IF22: | ||
| 546 | f1ok: ;OPEN, PRIME PRIMARY FILE | ||
| 547 | and swt,09Fh ;clear file open flags | ||
| 548 | mov dx,offset infcb | ||
| 549 | doscall FCBOPEN ;AC000; OPEN SOURCE FILE | ||
| 550 | or al,al ;Error ? | ||
| 551 | |||
| 552 | ;Try to open the same file using a handle open with read access | ||
| 553 | ; $if nz ;AC000; ;IF fcb OPEN FAILED, THEN SHARING ERROR | ||
| 554 | JZ $$IF24 | ||
| 555 | jmp shrerr | ||
| 556 | ; $endif ;AC000; | ||
| 557 | $$IF24: | ||
| 558 | mov si,offset infcb ;Take this fcb... | ||
| 559 | mov di,offset OpenPath ; and in this area... | ||
| 560 | call MakePathFromfcb ; make an ASCIIZ path. | ||
| 561 | mov dx,offset OpenPath | ||
| 562 | doscall HANDLEOPEN,READONLYACCESS ;AC000; TRY TO OPEN IT WITH READONLY ACCEss | ||
| 563 | ; $if c ;AC000; | ||
| 564 | JNC $$IF26 | ||
| 565 | jmp accessdenied1 ;ERROR OPENING FILE. AssUME ACCEss DENIED. | ||
| 566 | ; $endif ;AC000; | ||
| 567 | $$IF26: | ||
| 568 | mov bx,ax ;Put the handle in bx... | ||
| 569 | doscall HANDLECLOSE ;AC000; AND CLOSE IT | ||
| 570 | cmp byte ptr path1,0 ;using current dir? | ||
| 571 | ; $if ne ;AC000; ;NO | ||
| 572 | JE $$IF28 | ||
| 573 | mov dx,offset oldp1 | ||
| 574 | doscall CHDIR ;AN000; change directory | ||
| 575 | ; $endif ;AC000; | ||
| 576 | $$IF28: | ||
| 577 | ;p1ok: | ||
| 578 | mov word ptr infcb+14,1 ;set record size | ||
| 579 | xor ax,ax | ||
| 580 | mov di,offset infcb+33 | ||
| 581 | stosw ;set rr fields | ||
| 582 | stosw | ||
| 583 | Mov dx,offset infcb | ||
| 584 | call get ;and prime big buffer from first file | ||
| 585 | print_msg msgnum_crlf,STDOUT ;AN000; ;dispLAY CRLF | ||
| 586 | print_msg msgnum_crlf,STDOUT ;AN000; ;dispLAY CRLF | ||
| 587 | fill_name1 infcb ;AN000; ;get full path name | ||
| 588 | mov sublist_19a.sub_value,offset name1 ;AN000; ;SET UP %1 IN sublist FOR "%1 AND %2" MSG | ||
| 589 | mov al,fcb2 ;target drive | ||
| 590 | mov outfcb,al ;to target fcb | ||
| 591 | |||
| 592 | ;****** FIND SECONDARY diR | ||
| 593 | mov si,offset path2 | ||
| 594 | test byte ptr swt,16 ;has secondary path already been found? | ||
| 595 | ; $if z ;AC000; ;NO | ||
| 596 | JNZ $$IF30 | ||
| 597 | mov di,offset fcb2 | ||
| 598 | call findpath ;no, find its path now | ||
| 599 | ; $else ;AC000; ;siNCE SECONDARY PATH ALREADY BEEN FOUND | ||
| 600 | JMP SHORT $$EN30 | ||
| 601 | $$IF30: | ||
| 602 | cmp byte ptr [si],0 ;is there a path? | ||
| 603 | ; $if ne ;AC000; ;Yes | ||
| 604 | JE $$IF32 | ||
| 605 | ; BUT IF NOT, WILL USE CURRENT DIR | ||
| 606 | mov dx,si | ||
| 607 | doscall CHDIR ;AC000; ;yes, set the secondary dir to proper node | ||
| 608 | |||
| 609 | cmp al,al ;force eq | ||
| 610 | ; $endif ;AC000; | ||
| 611 | $$IF32: | ||
| 612 | ; $endif ;AC000; | ||
| 613 | $$EN30: | ||
| 614 | pushf ;save status of secondary dir search | ||
| 615 | mov cx,11 | ||
| 616 | mov di,offset outfcb+1 ;target filename field | ||
| 617 | mov si,offset fcb2+1 ;current target filename | ||
| 618 | mov bx,offset infcb+1 ;current source filename | ||
| 619 | ; $do ;AC000; | ||
| 620 | $$DO35: | ||
| 621 | lodsb ;get target name char | ||
| 622 | cmp al,"?" ;is it ambiguous? | ||
| 623 | ; $if E ;AC000; ;Yes | ||
| 624 | JNE $$IF36 | ||
| 625 | mov al,[bx] ;yes, copy char from source | ||
| 626 | ; $endif ;AC000; | ||
| 627 | $$IF36: | ||
| 628 | stosb ;build target name | ||
| 629 | inc bx ;next source char | ||
| 630 | ; $enddo loop ;AC000; | ||
| 631 | LOOP $$DO35 | ||
| 632 | fill_name2 ;AN000; ;get full path name | ||
| 633 | mov sublist_19b.sub_value,offset name2 ;AN000; ;SET UP %2 IN sublist FOR "%1 AND %2" MSG | ||
| 634 | print_msg msgnum_and_msg,STDOUT ;AN000; ;dispLAY " AND " | ||
| 635 | print_msg msgnum_crlf,STDOUT ;AN000; ;dispLAY CRLF | ||
| 636 | popf ;return from getting secondary dir | ||
| 637 | ; $if ne ;AC000; ;diD NOT GET IT | ||
| 638 | JE $$IF39 | ||
| 639 | fill_name2 ;AN000; ;get full path name | ||
| 640 | mov sublist_12.sub_value,offset name2 ;AN000; ;SET UP %1 IN sublist FOR "%1 - INVALID PATH" ;AN000; | ||
| 641 | print_msg msgnum_bad_path,STDERR ;AN000; ;"Invalid path - %0" | ||
| 642 | mov dx,offset oldp2 ;Get back to current dir on sec drive | ||
| 643 | doscall CHDIR ;AC000; | ||
| 644 | jmp quit5 | ||
| 645 | |||
| 646 | ; $endif ;AC000; | ||
| 647 | $$IF39: | ||
| 648 | mov dx,offset outfcb | ||
| 649 | doscall SETDTA ;AC000; diR FOUND, SET DTA TO TARGET fcb | ||
| 650 | mov dx,offset outfcb | ||
| 651 | doscall SEARCHF ;AC000; FIND FIRST TARGET FILE | ||
| 652 | or al,al ;Find one? | ||
| 653 | ; $if NZ ;AC000; ;Yes | ||
| 654 | JZ $$IF41 | ||
| 655 | print_msg msgnum_crlf,STDERR ;AN000; ;dispLAY CRLF | ||
| 656 | fill_name2 ;AN000; ;get full path name | ||
| 657 | mov sublist_11.sub_value,offset name2 ;AN000; ;SET UP %1 IN sublist OF MSG | ||
| 658 | print_msg msgnum_fnf,STDERR ;AN000; ;"File not found - %0" | ||
| 659 | mov dx,offset oldp2 ;Get back to current dir on sec drive | ||
| 660 | doscall CHDIR ;AC000; | ||
| 661 | jmp quit3 ;and get the next source file | ||
| 662 | |||
| 663 | ; $endif ;AC000; | ||
| 664 | $$IF41: | ||
| 665 | mov dx,offset outfcb | ||
| 666 | doscall FCBOPEN ;AC000; OPEN TARGET FILE | ||
| 667 | or al,al ;Was the fcb open ok? | ||
| 668 | |||
| 669 | jnz ShrViolation ;If fcb open failed, then SHARING ERROR | ||
| 670 | mov si,offset outfcb ;Take this fcb... | ||
| 671 | mov di,offset OpenPath ; and in this area... | ||
| 672 | call MakePathFromfcb ; make an ASCIIZ path. | ||
| 673 | mov dx,offset OpenPath | ||
| 674 | doscall HANDLEOPEN,READONLYACCESS ;AC000; TRY TO OPEN IT WITH READONLY ACCEss | ||
| 675 | jc accessdenied2 | ||
| 676 | mov bx,ax ;Put the handle in bx... | ||
| 677 | doscall HANDLECLOSE ;AC000; AND CLOSE IT. | ||
| 678 | call RestoreDir | ||
| 679 | jmp filopn ;If successful then continue | ||
| 680 | accessdenied2: ;Oops, there was an error. AssUME it was Access Denied | ||
| 681 | call RestoreDir | ||
| 682 | print_msg msgnum_crlf,STDERR ;AN000; ;dispLAY CRLF | ||
| 683 | fill_name2 ;AN000; ;get full path name | ||
| 684 | mov sublist_21.sub_value,offset name2 ;AN000; ;SET UP %1 IN sublist OF "Access Denied - %0" | ||
| 685 | mov dx,offset oldp2 ;Get back to current dir on sec drive | ||
| 686 | doscall CHDIR ;AC000; | ||
| 687 | print_msg msgnum_accessdenied,STDERR ;AN000; ;"Access Denied - %0" | ||
| 688 | jmp quit3 ;and get the next source file | ||
| 689 | |||
| 690 | ShrViolation: | ||
| 691 | call RestoreDir | ||
| 692 | print_msg msgnum_crlf,STDERR ;AN000; ;dispLAY CRLF | ||
| 693 | fill_name2 ;AN000; ;get full path name | ||
| 694 | mov sublist_13.sub_value,offset name2 ;AN000; ;SET UP %1 IN sublist OF "Sharing violation - %0" | ||
| 695 | mov dx,offset oldp2 ;Get back to current dir on sec drive | ||
| 696 | doscall CHDIR ;AC000; | ||
| 697 | print_msg msgnum_share,STDERR ;AN000; ;"Sharing violation - %0" | ||
| 698 | jmp quit3 ;and get the next source file | ||
| 699 | filopn: | ||
| 700 | mov word ptr outfcb+14,1 ;record size | ||
| 701 | xor ax,ax | ||
| 702 | mov di,offset outfcb+33 | ||
| 703 | stosw | ||
| 704 | stosw | ||
| 705 | mov ax,word ptr infcb+16 ;low part of file size | ||
| 706 | mov dx,word ptr infcb+18 ;high part | ||
| 707 | cmp ax,word ptr outfcb+16 ;are files the same size? | ||
| 708 | jne invsiz ;no, error | ||
| 709 | cmp dx,word ptr outfcb+18 | ||
| 710 | je sizok ;yes, ok | ||
| 711 | invsiz: | ||
| 712 | print_msg msgnum_badsiz,STDOUT ;AN000; ;"Files are different sizes" | ||
| 713 | jmp quit3 ;tell user sizes are different and process next source file | ||
| 714 | sizok: | ||
| 715 | ;;(deleted for AN009) call comp_codepage ;AN000; ;VERIFY BOTH FILes HAVE THE SAME CODEPAGE | ||
| 716 | ;;(deleted for AN009) $if c ;AN000; ;ERROR WITH CODEPAGE | ||
| 717 | ;;(deleted for AN009) jmp quit3 ;AN000; ;go on to other files if any | ||
| 718 | ;;(deleted for AN009) $endif ;AN000; | ||
| 719 | mov dx,offset infcb | ||
| 720 | mov word ptr curfcb,dx ;get fcb's in proper order | ||
| 721 | mov dx,offset outfcb | ||
| 722 | mov word ptr curfcb+2,dx | ||
| 723 | mov word ptr offs,0 ;set constants | ||
| 724 | mov word ptr offs+2,0 | ||
| 725 | mov byte ptr cnt,0 ;and fall through to process | ||
| 726 | process: ;**** PREPARE TO COMPARE DATA | ||
| 727 | mov dx,word ptr curfcb+2 ;small buffer's file | ||
| 728 | cmp word ptr siz,0 ;any data left in large buffer? | ||
| 729 | jne getsec ;yes, use it | ||
| 730 | test byte ptr swt,1 ;no, have we reached eof yet? | ||
| 731 | jz large ;no - fill large buffer from other file | ||
| 732 | doscall FCBCLOSE ;AC000; CLOSE THE FILE FILLING SMALL BUFFER | ||
| 733 | test byte ptr swt,8 ;yes, files are done - did we find eof mark? | ||
| 734 | ; $if z ;AC000; ;NO | ||
| 735 | JNZ $$IF43 | ||
| 736 | print_msg msgnum_eor,STDOUT ;AN000; ;"Eof mark not found" | ||
| 737 | ; $endif ;AC000; | ||
| 738 | $$IF43: | ||
| 739 | test byte ptr swt,4 ;any compare errors? | ||
| 740 | ; $if Z ;AC000; | ||
| 741 | JNZ $$IF45 | ||
| 742 | print_msg msgnum_ok,STDOUT ;AN000; ;"FILes COMPARE OK" | ||
| 743 | ; $endif ;AC000; | ||
| 744 | $$IF45: | ||
| 745 | jmp quit3 ;had compare errors - no "ok" msg | ||
| 746 | |||
| 747 | large: ;Fill large buffer | ||
| 748 | xchg dx,word ptr curfcb ;AC000; ;switch fcbs' association with buffers | ||
| 749 | xchg dx,word ptr curfcb+2 | ||
| 750 | call get ;fill large buffer from currently mounted file | ||
| 751 | jmp process ;and now fill small buffer from other file | ||
| 752 | getsec: | ||
| 753 | call getf2 ;fill small buffer with 1024 bytes | ||
| 754 | sub siz,cx ;# bytes left in big buffer after this compare | ||
| 755 | mov bp,cx ;save # bytes of compare | ||
| 756 | les di,dword ptr curpos ;current byte in large buffer | ||
| 757 | mov si,offset buf ;current byte in small buffer | ||
| 758 | comp: | ||
| 759 | jcxz compok ;all done and equal | ||
| 760 | repe cmpsb | ||
| 761 | jne cmp1 ;bytes don't match | ||
| 762 | compok: | ||
| 763 | push ds | ||
| 764 | pop es ;get es back | ||
| 765 | mov curpos,di ;next byte to compare in large buffer | ||
| 766 | mov ax,word ptr offs+2 ;low part of bytes compared so far | ||
| 767 | add ax,bp ;increment count of bytes compared | ||
| 768 | adc word ptr offs,0 ;adjust high part | ||
| 769 | mov word ptr offs+2,ax ;save low part | ||
| 770 | jmp process ;and keep going | ||
| 771 | cmp1: ;***** FOUND UNEQUAL BYTes | ||
| 772 | or byte ptr swt,4 ;indicate had compare error | ||
| 773 | dec si ;point to the bad bytes | ||
| 774 | dec di | ||
| 775 | mov al,[si] ;bad byte from small buffer | ||
| 776 | mov ah,es:[di] ;bad byte from large buffer | ||
| 777 | mov dx,offset infcb ;AC000; ;FIND OUT WHICH byte CAME FROM WHICH FILE | ||
| 778 | ;AN000; ;SO THAT "File 1 = %1" AND "File 2 = %1" | ||
| 779 | ;AN000; ;MEssAGes WILL BE CORRECT. | ||
| 780 | cmp word ptr curfcb+2,dx ;is first file in small buffer? | ||
| 781 | ; $if ne ;AC000; ;NO | ||
| 782 | JE $$IF47 | ||
| 783 | xchg ah,al ;no, reverse the bad bytes | ||
| 784 | ; $endif ;AC000; | ||
| 785 | $$IF47: | ||
| 786 | mov byte1,al ;AN000; ;SAVE FIRST FILE BAD byte | ||
| 787 | mov byte2,ah ;AN000; ;SAVE SECOND FILE BAD byte | ||
| 788 | ;AN000; ;COMPUTE offset IN FILE OF BAD BYTes | ||
| 789 | mov bx,word ptr offs ;high part of byte count | ||
| 790 | mov ax,si ;addr of the bad byte in small buffer | ||
| 791 | sub ax,offset buf ;bad byte's offset in this buffer | ||
| 792 | add ax,word ptr offs+2 ;offset into file | ||
| 793 | adc bx,0 ;adjust high part if needed | ||
| 794 | mov word ptr offp,bx ;AC000; ;SAVE HIGH PART OF offset | ||
| 795 | mov word ptr off_byte+2,bx ;AN000; ;SAVE HIGH PART OF offset | ||
| 796 | mov word ptr offp+2,ax ;AN000; ;SAVE LOW PART OF offset | ||
| 797 | mov word ptr off_byte,ax ;AN000; ;SAVE LOW PART OF offset | ||
| 798 | inc si ;back to correct position | ||
| 799 | inc di | ||
| 800 | push cx ;save remaining byte count | ||
| 801 | push si ;save next data byte addr | ||
| 802 | |||
| 803 | mdone: | ||
| 804 | mov sublist_6.sub_value,offset OFF_byte ;AN000; ;sublist OF MSG DesC | ||
| 805 | print_msg msgnum_bad,STDOUT ;AN000; ;"Compare error at offset %1" | ||
| 806 | mov sublist_7.sub_value,offset byte1 ;AN000; ;sublist OF MSG DesC. (ptr TO BAD byte IN FIRST FILE) | ||
| 807 | print_msg msgnum_adr,STDOUT ;AN000; ;"File 1 = %1" | ||
| 808 | mov sublist_8.sub_value,offset byte2 ;AN000; ;sublist OF MSG DesC. (ptr TO BAD byte IN SECOND FILE) | ||
| 809 | print_msg msgnum_bdr,STDOUT ;AN000; ;"File 2 = %1" | ||
| 810 | pop si ;get regs back | ||
| 811 | pop cx | ||
| 812 | inc byte ptr cnt ;count errors | ||
| 813 | cmp byte ptr cnt,10 ;10 errors yet? | ||
| 814 | je gotten ;yes, further compare is useless | ||
| 815 | jmp comp ;no, go on with following byte | ||
| 816 | gotten: | ||
| 817 | push ds | ||
| 818 | pop es ;get es back | ||
| 819 | print_msg msgnum_tenmsg,STDOUT ;AN000; ;"10 Mismatches - ending compare" | ||
| 820 | |||
| 821 | quit3: ;terminate | ||
| 822 | mov byte ptr swt,16 ;say we've found the secondary dir | ||
| 823 | cmp byte ptr path1,0 ;is primary file in the drive's current dir? | ||
| 824 | ; $if ne ;AN000; NO | ||
| 825 | JE $$IF49 | ||
| 826 | mov dx,offset path1 ;no, | ||
| 827 | doscall CHDIR ;AC000; | ||
| 828 | ; $endif ;AC000; | ||
| 829 | $$IF49: | ||
| 830 | mov dx,offset infcb | ||
| 831 | doscall SETDTA ;AC000; ;DTA = SOURCE fcb | ||
| 832 | mov dx,offset fcb | ||
| 833 | doscall SEARCHN ;AC000; ;12H FIND NEXT SOURCE FILE | ||
| 834 | or al,al ;find one? | ||
| 835 | jnz quit4 ;no | ||
| 836 | jmp f1ok ;yes, go process it | ||
| 837 | AccessDenied1: ;Oops, there was an error. AssUME it was Access Denied | ||
| 838 | fill_name1 INfcb ;AN000; ;get full path name | ||
| 839 | mov sublist_21.sub_value,offset name1 ;AN000; ;SET UP %1 IN sublist OF "Access Denied - %0" | ||
| 840 | mov dx,offset msgnum_accessdenied ;AC000; ;dx = ptr TO MSG DesCRIPTOR TO dispLAY | ||
| 841 | ;AN000; ;VALUES IN dx,si,di PAssED TO BADFIL CODE | ||
| 842 | jmp short badfil | ||
| 843 | |||
| 844 | ShrErr: | ||
| 845 | fill_name1 INfcb ;AN000; ;get full path name | ||
| 846 | mov sublist_13.sub_value,offset name1 ;AN000; ;SET UP %1 IN sublist OF "Sharing violation - %0" | ||
| 847 | mov dx,offset msgnum_SHARE ;AC000; ;dx = ptr TO MSG DesCRIPTOR TO dispLAY | ||
| 848 | ;AN000; ;VALUes IN dx,si,di PAssED TO BADFIL CODE | ||
| 849 | badfil: ;assume si = path, di = fcb , dx = MSG DesCRIPTOR | ||
| 850 | push dx | ||
| 851 | push cx | ||
| 852 | print_msg msgnum_crlf,STDERR ;AN000; ;dispLAY CRLF | ||
| 853 | print_msg msgnum_crlf,STDERR ;AN000; ;dispLAY CRLF | ||
| 854 | pop cx | ||
| 855 | pop dx | ||
| 856 | ; DISPLAY MSG THAT WAS POINTED TO BY DX | ||
| 857 | push ax | ||
| 858 | push di ;AN003; | ||
| 859 | mov di,dx ;AN003; | ||
| 860 | mov [di].msg_handle,STDERR ;AN003; | ||
| 861 | pop di ;AN003; | ||
| 862 | call sendmsg ;AC000; ;dispLAY IT | ||
| 863 | pop ax ;AN000; | ||
| 864 | quit4: ;no more primary files | ||
| 865 | ;;;;;; cmp byte ptr path1,0 ;current dir on pri drive? | ||
| 866 | ;;;;;; je quit5 ;yes | ||
| 867 | mov dx,offset oldp1 | ||
| 868 | doscall CHDIR ;AC000; ;no, restore it now | ||
| 869 | quit5: | ||
| 870 | mov byte ptr path2,0 ;force get of second name - leave this here | ||
| 871 | mov byte ptr swt,0 | ||
| 872 | ; $do ;AC000; ;REPEAT UNTIL A VALID Y/N REspONSE | ||
| 873 | $$DO51: | ||
| 874 | mov dx,offset msgnum_nother ;AN000; ;dispLAY (Y/N) MEssAGE | ||
| 875 | push di ;AN007; save DI | ||
| 876 | mov di,dx ;AN007; DI -> message struct | ||
| 877 | mov [di].msg_handle,STDERR ;AN007; display to STDERR | ||
| 878 | pop di ;AN007; restore DI | ||
| 879 | call sendmsg ;AC000; ;dispLAY IT | ||
| 880 | push ax ;SAVE REspONSE | ||
| 881 | print_msg msgnum_crlf,STDERR ;AC003; ;dispLAY CRLF | ||
| 882 | print_msg msgnum_crlf,STDOUT ;AC009; ;dispLAY CRLF | ||
| 883 | pop dx ;AN000; ;GET REspONSE BACK | ||
| 884 | doscall GET_EXT_CNTRY_INFO,YESNO_CHECK ;AC000; ;CHECK REspONSE, dx=REspONSE | ||
| 885 | cmp al,YES ;AN000; ;Yes REspONSE | ||
| 886 | ; $leave e ;AN000; ;LEAVE loop | ||
| 887 | JE $$EN51 | ||
| 888 | cmp al,0 ;AN000; ;NO REspONSE | ||
| 889 | ; $leave e | ||
| 890 | JE $$EN51 | ||
| 891 | ; $enddo ;AN000; ;REPEAT UNTIL A VALID Y/N REspONSE | ||
| 892 | JMP SHORT $$DO51 | ||
| 893 | $$EN51: | ||
| 894 | cmp al,YES ;AC000; ;ax=0=NO, ax=1=Yes (CHECK REspONSE) | ||
| 895 | ; $if e ;AC000; ;GOT A Yes REspONSE, REPEAT COMP | ||
| 896 | JNE $$IF55 | ||
| 897 | xor ax,ax ;AN008; ;AN000; ;CHAR TO USE TO CLEAR BUFFER | ||
| 898 | mov di,offset path1 ;AN000; ;CLEAR OLD PATH, FILE NAMes TO START AGAIN | ||
| 899 | mov cx,129 ;AN000; ;LENGTH OF BUFFER | ||
| 900 | ; $do ;AN000; | ||
| 901 | $$DO56: | ||
| 902 | stosb ;AN000; | ||
| 903 | ; $enddo loop ;AN000; | ||
| 904 | LOOP $$DO56 | ||
| 905 | mov di,offset path2 ;AN000; ;CLEAR OLD PATH, FILE NAMes TO START AGAIN | ||
| 906 | mov cx,129 ;AN000; ;LENGTH OF BUFFER | ||
| 907 | ; $do ;AN000; | ||
| 908 | $$DO58: | ||
| 909 | stosb ;AN000; | ||
| 910 | ; $enddo loop ;AN000; | ||
| 911 | LOOP $$DO58 | ||
| 912 | mov clear,1 ;set clear | ||
| 913 | jmp rpt ;AC000; ;REPEAT COMP | ||
| 914 | ; $endif ;AC000; | ||
| 915 | $$IF55: | ||
| 916 | ret ;AN000; ;QUIT | ||
| 917 | |||
| 918 | |||
| 919 | ;-------------------------------------------- | ||
| 920 | ; CONTROL BREAK EXIT CODE (INTERRUPT HANDLER) | ||
| 921 | ;-------------------------------------------- | ||
| 922 | CBExit: | ||
| 923 | test swt2,2 ;oldp2 set? | ||
| 924 | ; $if nz ;AC000; ;no, restore it now | ||
| 925 | JZ $$IF61 | ||
| 926 | mov dx,offset oldp2 | ||
| 927 | doscall CHDIR ;AC000; ;no, restore it now | ||
| 928 | ; $endif ;AC000; | ||
| 929 | $$IF61: | ||
| 930 | |||
| 931 | test swt2,1 ;oldp1 set? | ||
| 932 | ; $if nz ;AC000; ;if it was | ||
| 933 | JZ $$IF63 | ||
| 934 | mov dx,offset oldp1 | ||
| 935 | doscall CHDIR ;AC000; ;no, restore it now | ||
| 936 | ; $endif ;AC000; | ||
| 937 | $$IF63: | ||
| 938 | |||
| 939 | ;;(deleted for AN009) call restore_cp ;AN000; ;restore the codepage | ||
| 940 | mov al,EXCB ;AN000; ;errorlevel: control break exit | ||
| 941 | doscall RET_FN ;AN000; ;return to DOS with ret code | ||
| 942 | |||
| 943 | int 20h ;AC000; ;if exit didn't work, kill it | ||
| 944 | main endp ;AN000; | ||
| 945 | |||
| 946 | ;------------------------------------------------------------------------------ | ||
| 947 | ; -----------------------------SUBROUTINES---------------------------------- | ||
| 948 | ;------------------------------------------------------------------------------ | ||
| 949 | |||
| 950 | |||
| 951 | ;------------------------------------------------------------------------------ | ||
| 952 | ; FINDFS - Finds the last "\" in the path name given. This is done so that the | ||
| 953 | ; path and not the filename can be derived from the path name. | ||
| 954 | ; | ||
| 955 | ; INPUT - SI = ptr to path name to work on | ||
| 956 | ; OUTPUT - saves address of last "\" at end of buffer that SI points to. | ||
| 957 | ; (this is tricky) | ||
| 958 | ;------------------------------------------------------------------------------ | ||
| 959 | findfs proc near ;AN000; | ||
| 960 | mov string_off,si ;AN006; save addr of string for Check_DBCS_slash | ||
| 961 | mov string_seg,cs ;AN006; | ||
| 962 | push dx ;AN000; | ||
| 963 | push si ;AN000; | ||
| 964 | xor dx,dx ;AN008; ;AN000; ;CLEAR dx IN THE CASE THAT NO "\" IS FOUND | ||
| 965 | ; $do ;AN000; | ||
| 966 | $$DO65: | ||
| 967 | lodsb ;AN000; ;GET A CHARACTER | ||
| 968 | cmp al,0 ;AN000; ;AT END OF STRING YET ? | ||
| 969 | ; $leave z ;AN000; ;Yes, LEAVE | ||
| 970 | JZ $$EN65 | ||
| 971 | push si ;AN006; Check the character in AL == '\' | ||
| 972 | dec si ;AN006; and the character in front of | ||
| 973 | call Check_DBCS_slash ;AN006; the '\' is not DBCS. | ||
| 974 | pop si ;AN006; | ||
| 975 | |||
| 976 | ; $if z ;AN000; ;Yes, SAVE ADDR OF IT IN dx | ||
| 977 | JNZ $$IF67 | ||
| 978 | mov dx,si ;AN000; | ||
| 979 | dec dx ;AN000; | ||
| 980 | ; $endif ;AN000; | ||
| 981 | $$IF67: | ||
| 982 | ; $enddo ;AN000; | ||
| 983 | JMP SHORT $$DO65 | ||
| 984 | $$EN65: | ||
| 985 | pop si ;AN000; | ||
| 986 | mov [si+128],dx ;AN000; ;SAVE ADDR OF LAST "\" IN THE LAST TWO BYTes OF PATH | ||
| 987 | pop dx ;AN000; | ||
| 988 | ret ;AN000; | ||
| 989 | findfs endp ;AN000; | ||
| 990 | |||
| 991 | |||
| 992 | ;------------------------------------------------------------------------------ | ||
| 993 | ; GETNAM - Inputs a filename from STDIN to be used as either the first or second | ||
| 994 | ; parameter for COMP. | ||
| 995 | ; | ||
| 996 | ; INPUT - PARM_COUNT = ordinal number for parser | ||
| 997 | ; DX = ptr to msg descriptor of message to display | ||
| 998 | ; BX = ptr to FCB of file | ||
| 999 | ; SI = ptr to FCB structure | ||
| 1000 | ;------------------------------------------------------------------------------ | ||
| 1001 | getnam proc near | ||
| 1002 | mov input_buf,INPUT_LEN ;AN000; ;PUT LENGTH OF BUFFER AS FIRST byte OF BUFFER | ||
| 1003 | mov di,dx ;AN000; ;FILL IN offset OF INPUT BUFFER IN MSG DesC. | ||
| 1004 | mov [di].msg_input, offset input_buf ;AN000; ;ptr TO INPUT BUFFER | ||
| 1005 | mov [di].msg_handle, STDERR | ||
| 1006 | push ax ;AN000; | ||
| 1007 | call sendmsg ;AC000; ;dispLAY MEssAGE, GET BUFFERED INPUT | ||
| 1008 | pop ax ;AN000; | ||
| 1009 | xor ch,ch ;AN000; ;CLEAR HIGH byte OF cx | ||
| 1010 | mov cl,input_len ;AN000; ;CL = LENGTH OF INPUT BUFFER | ||
| 1011 | ;get offset into input buffer (to skip length word) | ||
| 1012 | mov current_parm,offset INPUT_BUF+2 ;AN000; ;CURRENT_PARM = offset OF INPUT BUFFER | ||
| 1013 | mov ordinal,ZERO_PARM_CT ;AN000; ;TELL PARSER THAT THIS IS FIRST PARAMETER (ONLY ONE) | ||
| 1014 | call parser ;PUT NEW STRING AT WHERE di POINTS TO | ||
| 1015 | ret ;then go back | ||
| 1016 | getnam endp ;AC000; | ||
| 1017 | |||
| 1018 | |||
| 1019 | ;------------------------------------------------------------------------------ | ||
| 1020 | ; FINDPATH - Check if path is a directory. If yes, then CHDIR to it and set the | ||
| 1021 | ; FCB to ????????.???. If no, check for "\". If no "\", then assume | ||
| 1022 | ; we are in the correct directory and set FCB to ????????.??? if blank. | ||
| 1023 | ; If "\" is found, then strip last name off path into FCBYTE (?'s if | ||
| 1024 | ; nothing follows "\") and try to find the directory again. | ||
| 1025 | ; | ||
| 1026 | ; INPUT - SI = ptr to path string | ||
| 1027 | ; DI = ptr to FCB (drive byte is valid) | ||
| 1028 | ; OUTPUT - if path found then set ZERO flag and CHDIR to directory and FCB set. | ||
| 1029 | ; else FCB set and reset ZERO flag. | ||
| 1030 | ;------------------------------------------------------------------------------ | ||
| 1031 | findpath proc near | ||
| 1032 | mov dl,[di] ;drive number from fcb | ||
| 1033 | push di | ||
| 1034 | push si | ||
| 1035 | mov di,si | ||
| 1036 | sub di,67 ;where to put current dir for the drive | ||
| 1037 | mov al,dl ;AN005; ;get drive number | ||
| 1038 | add al,64 ;AN005; ;convert to ascii letter | ||
| 1039 | stosb ;AN005; | ||
| 1040 | mov al,':' ;AN005; | ||
| 1041 | stosb ;AN005; | ||
| 1042 | mov al,pathchar ;get path separator | ||
| 1043 | stosb ;and put in beginning of path | ||
| 1044 | mov si,di | ||
| 1045 | doscall CURDIR ;AC000; ;GET DRIVE'S CURRENT diR | ||
| 1046 | cmp di,offset oldp1+3 ;See if pri cur dir is set up | ||
| 1047 | ; $if e ;AC000; | ||
| 1048 | JNE $$IF70 | ||
| 1049 | or swt2,1 | ||
| 1050 | ; $endif ;AC000; | ||
| 1051 | $$IF70: | ||
| 1052 | cmp di,offset oldp2+3 ;See if sec cur dir is set up | ||
| 1053 | ; $if e ;AC000; | ||
| 1054 | JNE $$IF72 | ||
| 1055 | or swt2,2 | ||
| 1056 | ; $endif ;AC000; | ||
| 1057 | $$IF72: | ||
| 1058 | pop si ;path string | ||
| 1059 | pop di ;fcb | ||
| 1060 | cmp byte ptr [si],0 ;is there a path? | ||
| 1061 | jne fp3 ;yes | ||
| 1062 | fp0: | ||
| 1063 | cmp byte ptr [di+1]," " ;no, is there a name in the fcb? | ||
| 1064 | jne fp2 ;yes, use current dir | ||
| 1065 | fp1: | ||
| 1066 | call setq ;no, set it to ????????.??? | ||
| 1067 | fp2: | ||
| 1068 | cmp al,al ;force eq on return | ||
| 1069 | ret | ||
| 1070 | fp3: ;there's a path | ||
| 1071 | mov dx,si ;path | ||
| 1072 | doscall CHDIR ;AC000; ;see if it's a dir | ||
| 1073 | jnc fp1 ;yes, set fcb to ?'s - path found and set | ||
| 1074 | mov bx,[si+128] ;no - get last \ in string | ||
| 1075 | or bx,bx ;is there a \? | ||
| 1076 | jnz fp4 ;yes, go strip off last name | ||
| 1077 | mov byte ptr [si],0 ;no, there's only 1 name in path - must be filename | ||
| 1078 | jmp short fp0 ;go use current dir | ||
| 1079 | fp4: | ||
| 1080 | call backoff ;strip last name off line into fcb | ||
| 1081 | mov dx,si | ||
| 1082 | doscall CHDIR ;AC000; ;noword ptr is result line a valid path? | ||
| 1083 | jnc fp2 ;yes, fcb and path are set | ||
| 1084 | fp5: | ||
| 1085 | cmp ax,1234h ;no, pass back error - path has first part of name, | ||
| 1086 | ret ;remainder is in fcb | ||
| 1087 | findpath endp ;AN000; | ||
| 1088 | |||
| 1089 | |||
| 1090 | ;------------------------------------------------------------------------------ | ||
| 1091 | ; BACKOFF - Removes the last name of a path and puts it into an FCB. Assumes at | ||
| 1092 | ; least one "\" in path. If no name is found then set the FCB to | ||
| 1093 | ; ????????.??? and | ||
| 1094 | ; | ||
| 1095 | ; INPUT - SI = ptr to path string. | ||
| 1096 | ; DI = ptr to FCB to format. | ||
| 1097 | ; OUTPUT - | ||
| 1098 | ;------------------------------------------------------------------------------ | ||
| 1099 | backoff proc near | ||
| 1100 | push si | ||
| 1101 | mov bx,[si+128] ;address of last \ in path | ||
| 1102 | cmp byte ptr [si+1],":" ;AN002; | ||
| 1103 | ; $if e ;AN002; | ||
| 1104 | JNE $$IF74 | ||
| 1105 | add si,2 ;char following d: in path name | ||
| 1106 | ; $endif ;AN002; | ||
| 1107 | $$IF74: | ||
| 1108 | cmp si,bx ;is it the only \ and is it at beg of line? | ||
| 1109 | mov si,bx | ||
| 1110 | ; $if e ;AC000; ;Yes | ||
| 1111 | JNE $$IF76 | ||
| 1112 | inc bx ;yes, going to root - leave \ alone | ||
| 1113 | ; $endif ;AC000; | ||
| 1114 | $$IF76: | ||
| 1115 | inc si ;char following \ | ||
| 1116 | cmp byte ptr [si],0 ;are there any? | ||
| 1117 | jne bo4 ;yes | ||
| 1118 | call setq ;no, use ????????.??? in root | ||
| 1119 | jmp short bo3 ;AC008; | ||
| 1120 | bo4: | ||
| 1121 | push di | ||
| 1122 | ;AC000; ;ds:si=POINTER TO COMMAND LINE TO PARSE | ||
| 1123 | ;AC000; ;es:di=POINTER TO UNOPENED fcb | ||
| 1124 | ;AC000; ;AL-BIT VALUE CONTROLS PARsiNG | ||
| 1125 | doscall PARSE_FILENAME,02h ;AC000; ;PARSE LAST NAME ON LINE INTO fcb, LEAVE DRIVE byte ALONE | ||
| 1126 | pop di | ||
| 1127 | cmp byte ptr [di+1]," " ;is there a file name? | ||
| 1128 | ; $if ne ;AC000; ;Yes, TRUNCATE PATH AND LEAVE | ||
| 1129 | JE $$IF78 | ||
| 1130 | bo3: | ||
| 1131 | mov byte ptr [bx],0 ;truncate the path name | ||
| 1132 | pop si | ||
| 1133 | ; $else ;AC000; ;siNCE NO FILE NAME, | ||
| 1134 | JMP SHORT $$EN78 | ||
| 1135 | $$IF78: | ||
| 1136 | pop si ;no, restore si | ||
| 1137 | pop ax ;strip return to findpath | ||
| 1138 | call setq ;fill fcb with ?'s | ||
| 1139 | cmp ax,1234h ;AN000; ;SET ERROR retURN | ||
| 1140 | ; $endif ;AC000; | ||
| 1141 | $$EN78: | ||
| 1142 | ret | ||
| 1143 | backoff endp ;AN000; | ||
| 1144 | |||
| 1145 | |||
| 1146 | ;------------------------------------------------------------------------------ | ||
| 1147 | ; SETQ - Set an FCB filename field to ????????.??? | ||
| 1148 | ; | ||
| 1149 | ; INPUT - DI = ptr to FCB | ||
| 1150 | ; OUTPUT - FCB is changed. | ||
| 1151 | ;------------------------------------------------------------------------------ | ||
| 1152 | setq proc near | ||
| 1153 | ;di = ^ fcb | ||
| 1154 | push di | ||
| 1155 | mov al,"?" | ||
| 1156 | mov cx,11 | ||
| 1157 | inc di ;point to filename | ||
| 1158 | ; $do ;AC000; | ||
| 1159 | $$DO81: | ||
| 1160 | stosb | ||
| 1161 | ; $enddo loop ;AC000; | ||
| 1162 | LOOP $$DO81 | ||
| 1163 | pop di | ||
| 1164 | ret | ||
| 1165 | setq endp ;AC000; | ||
| 1166 | |||
| 1167 | |||
| 1168 | ;------------------------------------------------------------------------------ | ||
| 1169 | ; GET - Fill large buffer | ||
| 1170 | ; | ||
| 1171 | ; INPUT - | ||
| 1172 | ; OUTPUT - | ||
| 1173 | ;------------------------------------------------------------------------------ | ||
| 1174 | get proc near | ||
| 1175 | push dx ;save fcb address | ||
| 1176 | mov ds,buf2 ;point to large buffer | ||
| 1177 | xor dx,dx | ||
| 1178 | doscall SETDTA ;AC000; ;SET DTA TO LARGE BUFFER | ||
| 1179 | push cs | ||
| 1180 | pop ds ;get ds back | ||
| 1181 | pop dx ;and get fcb addr back | ||
| 1182 | mov cx,word ptr mem ;# bytes of avail mem in large buffer | ||
| 1183 | doscall FCBRNDBLKREAD ;AC000; ;FILL LARGE BUFFER | ||
| 1184 | mov siz,cx ;# bytes we read | ||
| 1185 | mov word ptr curpos,0 ;current byte position offset in large buffer | ||
| 1186 | or al,al ;get eof? | ||
| 1187 | ; $if nz ;AC000; ;Yes, AT EOF | ||
| 1188 | JZ $$IF83 | ||
| 1189 | call fileend ;AC000; | ||
| 1190 | ; $endif ;AC000; | ||
| 1191 | $$IF83: | ||
| 1192 | ret ;No, keep on going | ||
| 1193 | get endp ;AC000; | ||
| 1194 | |||
| 1195 | |||
| 1196 | ;------------------------------------------------------------------------------ | ||
| 1197 | ; FILEEND - Check for EOF char on last read into large buffer (?) | ||
| 1198 | ; | ||
| 1199 | ; INPUT - | ||
| 1200 | ; OUTPUT - | ||
| 1201 | ;------------------------------------------------------------------------------ | ||
| 1202 | fileend proc near | ||
| 1203 | or byte ptr swt,1 ;yes, flag it | ||
| 1204 | mov bx,cx ;# bytes just read | ||
| 1205 | mov ds,buf2 | ||
| 1206 | cmp byte ptr [bx-1],26 ;is the last char of file an eof? | ||
| 1207 | push cs | ||
| 1208 | pop ds | ||
| 1209 | ; $if e ;AC000; ;Yes | ||
| 1210 | JNE $$IF85 | ||
| 1211 | or byte ptr swt,8 ;yes, say we found the eof | ||
| 1212 | ; $endif ;AC000; | ||
| 1213 | $$IF85: | ||
| 1214 | doscall FCBCLOSE ;AC000; ;Close the file filling large buffer | ||
| 1215 | ret | ||
| 1216 | fileend endp ;AN000; | ||
| 1217 | |||
| 1218 | |||
| 1219 | ;------------------------------------------------------------------------------ | ||
| 1220 | ; GETF2 - Read 8 sectors from file that FCB points to. | ||
| 1221 | ; | ||
| 1222 | ; INPUT - DX = ptr to FCB | ||
| 1223 | ; OUTPUT - fills small buffer | ||
| 1224 | ;------------------------------------------------------------------------------ | ||
| 1225 | getf2 proc near | ||
| 1226 | ;fill small buffer from fcb at [dx] | ||
| 1227 | push dx | ||
| 1228 | mov dx,offset buf ;small buffer addr | ||
| 1229 | doscall SETDTA ;AC000; ;SET THE DTA | ||
| 1230 | pop dx | ||
| 1231 | mov cx,4096 ;ask for 8 sectors | ||
| 1232 | doscall FCBRNDBLKREAD ;AC000; ;GET THE DATA | ||
| 1233 | ret | ||
| 1234 | getf2 endp ;AN000; | ||
| 1235 | |||
| 1236 | |||
| 1237 | ;------------------------------------------------------------------------------ | ||
| 1238 | ; FILL_N - This routine fills the buffer NAME1 or NAME2 with the full path name | ||
| 1239 | ; of the corresponding file. | ||
| 1240 | ; | ||
| 1241 | ; INPUT - DX = ptr to buffer to put full path name in | ||
| 1242 | ; DI = ptr to FCB to get drive letter,filename,extension from | ||
| 1243 | ; SI = ptr to PATH1 or PATH2 depending on whether first or second file | ||
| 1244 | ; OUTPUT - | ||
| 1245 | ;------------------------------------------------------------------------------ | ||
| 1246 | fill_n proc near | ||
| 1247 | push ax ;AN000; | ||
| 1248 | push cx ;AN000; | ||
| 1249 | mov string_off,dx ;AN006; pass whole string to Check_DBCS_slash | ||
| 1250 | mov string_seg,cs ;AN006; | ||
| 1251 | ;get drive letter & colon ;AN000; | ||
| 1252 | xchg dx,si ;AN000; ;make dx=fcb ptr, si=buffer ptr | ||
| 1253 | mov al,[di] ;AN000; ;drive byte from fcb | ||
| 1254 | inc di ;AN000; ;point to filename | ||
| 1255 | add al,64 ;AN000; ;drive to ascii | ||
| 1256 | mov [si],al ;AN000; ;save letter in string | ||
| 1257 | inc si ;AN000; ;increment ptr | ||
| 1258 | mov byte ptr [si],":" ;AN000; ;add colon to drive letter | ||
| 1259 | inc si ;AN000; | ||
| 1260 | xchg dx,si ;AN000; | ||
| 1261 | ;get full path ;AN000; | ||
| 1262 | xchg dx,di ;AN000; | ||
| 1263 | cmp byte ptr [si],0 ;AN000; ;is there a path? | ||
| 1264 | ; $if ne ;AN000; ;Yes | ||
| 1265 | JE $$IF87 | ||
| 1266 | cmp byte ptr [si+1],':' ;is thera a drive letter ? | ||
| 1267 | ; $if e | ||
| 1268 | JNE $$IF88 | ||
| 1269 | add si,2 ;AN000; ;yes, skip drive id in path | ||
| 1270 | ; $endif | ||
| 1271 | $$IF88: | ||
| 1272 | ; $do ;AC000; | ||
| 1273 | $$DO90: | ||
| 1274 | lodsb ;AN000; ;get a path char | ||
| 1275 | or al,al ;AN000; ;end of path? | ||
| 1276 | ; $leave Z ;AN000; ;Yes | ||
| 1277 | JZ $$EN90 | ||
| 1278 | stosb ;AN000; ;copy character | ||
| 1279 | ; $enddo ;AC000; | ||
| 1280 | JMP SHORT $$DO90 | ||
| 1281 | $$EN90: | ||
| 1282 | push si ;AN006; Check the character in AL == '\' | ||
| 1283 | mov si,di ;AN006; and the character in front of | ||
| 1284 | dec si ;AN006; the '\' is not DBCS. | ||
| 1285 | call Check_DBCS_slash ;AN006; | ||
| 1286 | pop si ;AN006; | ||
| 1287 | |||
| 1288 | ; $if NE ;AC000; ;NO | ||
| 1289 | JE $$IF93 | ||
| 1290 | mov al,"\" ;AC000; ;no, display separator ahead of filename | ||
| 1291 | stosb ;AN000; | ||
| 1292 | ; $endif ;AC000; | ||
| 1293 | $$IF93: | ||
| 1294 | ; $endif ;AC000; | ||
| 1295 | $$IF87: | ||
| 1296 | ;get filename ;AN000; | ||
| 1297 | xchg dx,si ;AC000; ;dx=path1 or path2, si=ptr buffer, di=ptr fcb | ||
| 1298 | mov cx,8 ;AN000; | ||
| 1299 | ; $do ;AC000; | ||
| 1300 | $$DO96: | ||
| 1301 | lodsb ;AC000; ;display filename | ||
| 1302 | cmp al," " ;AC000; ;Is it end of filename | ||
| 1303 | ; $leave e ;AC000; ;Yes, GET EXTENsiON | ||
| 1304 | JE $$EN96 | ||
| 1305 | stosb ;AN000; | ||
| 1306 | ; $enddo loop ;AC000; ;GET MORE CHARS, IF ANY | ||
| 1307 | LOOP $$DO96 | ||
| 1308 | $$EN96: | ||
| 1309 | and cx,cx ;AC008; | ||
| 1310 | ; $if ne | ||
| 1311 | JE $$IF99 | ||
| 1312 | dec cx ;AC000; ;# of spaces left to skip in filename | ||
| 1313 | ; $do ;AC000; ;step thru spaces to get to file extension | ||
| 1314 | $$DO100: | ||
| 1315 | inc si ;AN000; | ||
| 1316 | ; $enddo loop ;AC000; ;until cx=0 | ||
| 1317 | LOOP $$DO100 | ||
| 1318 | ; $endif | ||
| 1319 | $$IF99: | ||
| 1320 | ;get filename extension ;AN000; | ||
| 1321 | cmp byte ptr [si]," " ;AC000; ;is there an extension? | ||
| 1322 | ; $if ne ;AC000; ;Yes, DO PERIOD | ||
| 1323 | JE $$IF103 | ||
| 1324 | mov al,"." ;AN000; | ||
| 1325 | stosb ;AN000; | ||
| 1326 | mov cx,3 ;AN000; | ||
| 1327 | ; $do ;AC000; | ||
| 1328 | $$DO104: | ||
| 1329 | lodsb ;AC000; ;display extension | ||
| 1330 | cmp al," " ;AC000; ;is it end of extension? | ||
| 1331 | ; $leave e ;AC000; ;Yes | ||
| 1332 | JE $$EN104 | ||
| 1333 | stosb ;AN000; | ||
| 1334 | ; $enddo loop ;AC000; | ||
| 1335 | LOOP $$DO104 | ||
| 1336 | $$EN104: | ||
| 1337 | ; $endif ;AC000; ;EXTENsiON? | ||
| 1338 | $$IF103: | ||
| 1339 | mov al,0 ;AN000; | ||
| 1340 | stosb ;AC000; ;end of string marker | ||
| 1341 | xchg dx,si ;AN000; | ||
| 1342 | xchg dx,di ;AN000; | ||
| 1343 | pop cx ;AN000; | ||
| 1344 | pop ax ;AN000; | ||
| 1345 | ret | ||
| 1346 | fill_n endp ;AN000; | ||
| 1347 | |||
| 1348 | |||
| 1349 | ;------------------------------------------------------------------------------ | ||
| 1350 | ; MAKEPATHFROMFCB - Creates an ASCIIZ path at DI from the FCB pointed to by SI. | ||
| 1351 | ; | ||
| 1352 | ; INPUT - SI = ptr to FCB | ||
| 1353 | ; DI = buffer for path name to be stored. | ||
| 1354 | ; OUTPUT - | ||
| 1355 | ;------------------------------------------------------------------------------ | ||
| 1356 | MakePathFromFcb proc near | ||
| 1357 | push si ;Save fcb address | ||
| 1358 | mov al,byte ptr [si] ;Get drive letter from fcb (0=A,1=B,...) | ||
| 1359 | add al,64 ;Convert it to ASCII | ||
| 1360 | stosb ;Store it in the PATH | ||
| 1361 | mov al,":" ;Put a drive separator | ||
| 1362 | stosb ; in the PATH. | ||
| 1363 | inc si | ||
| 1364 | mov cx,8 ;Copy [1..8] bytes | ||
| 1365 | ; GET FILENAME | ||
| 1366 | ; $do ;AC000; | ||
| 1367 | $$DO108: | ||
| 1368 | movsb ;Move the char from the fcb | ||
| 1369 | cmp byte ptr [si]," " ;Is the next char a blank ? | ||
| 1370 | ; $leave e ;AC000; ;Yes, NO MORE CHARS IN FILENAME | ||
| 1371 | JE $$EN108 | ||
| 1372 | ; $enddo loop ;AC000; ;NO, GET NEXT CHAR, IF ANY | ||
| 1373 | LOOP $$DO108 | ||
| 1374 | $$EN108: | ||
| 1375 | ; InsertPeriod | ||
| 1376 | mov byte ptr [di],"." ;Stick a period in there... | ||
| 1377 | inc di ; and increment the pointer | ||
| 1378 | mov cx,3 ;Copy [0..3] bytes... | ||
| 1379 | pop si ; from the fcb's | ||
| 1380 | add si,9 ; extension area | ||
| 1381 | ; $do ;AC000; | ||
| 1382 | $$DO111: | ||
| 1383 | cmp byte ptr [si]," " ;Is the next char a blank? | ||
| 1384 | ; $leave e ;AC000; ;Yes, THEN WE ARE DONE | ||
| 1385 | JE $$EN111 | ||
| 1386 | movsb ; No, move it | ||
| 1387 | ; $enddo loop ;AC000; ;AND GET THE NEXT ONE, IF ANY | ||
| 1388 | LOOP $$DO111 | ||
| 1389 | $$EN111: | ||
| 1390 | mov al,00 | ||
| 1391 | stosb ;Copy in a byte of Hex 0 | ||
| 1392 | ret | ||
| 1393 | MakePathFromFcb endp | ||
| 1394 | |||
| 1395 | |||
| 1396 | ;------------------------------------------------------------------------------ | ||
| 1397 | ; RESTOREDIR - Do a CHDIR to the original directory this program started in. | ||
| 1398 | ; | ||
| 1399 | ; INPUT - OLDP2 = path string of original directory (for target filespec) | ||
| 1400 | ; PATH2 = path string of target filespec. | ||
| 1401 | ; OUTPUT - changes the current directory | ||
| 1402 | ;------------------------------------------------------------------------------ | ||
| 1403 | RestoreDir proc near | ||
| 1404 | cmp byte ptr path2,0 ;working with current dir on secondary file? | ||
| 1405 | ; $if ne ;AC000; ;NO, | ||
| 1406 | JE $$IF114 | ||
| 1407 | push ax ;restore old current directory | ||
| 1408 | mov dx,offset oldp2 | ||
| 1409 | doscall CHDIR ;AC000; | ||
| 1410 | pop ax | ||
| 1411 | ; $endif ;AC000; | ||
| 1412 | $$IF114: | ||
| 1413 | ret | ||
| 1414 | RestoreDir endp ;AN000; | ||
| 1415 | |||
| 1416 | |||
| 1417 | ;------------------------------------------------------------------------------ | ||
| 1418 | ; INIT_CP - To permit "COMP" to open the first and second files regardless of | ||
| 1419 | ; the system codepage, and to avoid any codepage mismatch critical | ||
| 1420 | ; error from occurring from the open, we temporarily suspend codepage | ||
| 1421 | ; support. It will be restored at the end of COMP. | ||
| 1422 | ; | ||
| 1423 | ; INPUT - | ||
| 1424 | ; OUTPUT - CPSW_ORIG byte will have the CPSW bit set on if cpsw = on | ||
| 1425 | ;------------------------------------------------------------------------------ | ||
| 1426 | init_cp proc near ;AN000; | ||
| 1427 | public init_cp ;AN000; | ||
| 1428 | |||
| 1429 | doscall CPSW_CHECK,GET_CPSW_STATE ;AN000; ;IS CODEPAGE SUPPORT LOADED | ||
| 1430 | and dl,dl ;AC008; ;AN000; | ||
| 1431 | ; $if ne ;AN000; ;IF CPSW IS LOADED | ||
| 1432 | JE $$IF116 | ||
| 1433 | or cpsw_orig,CPSW ;AN000; ;SET FLAG TO INdiCATE CPSW=ON | ||
| 1434 | mov dl,CPSW_OFF ;AN000; ; TO CPSW=OFF | ||
| 1435 | doscall CPSW_CHECK,SET_CPSW_STATE ;AN000; ;SET CPSW=OFF | ||
| 1436 | ; $endif ;AN000; ;CPSW LOADED? | ||
| 1437 | $$IF116: | ||
| 1438 | ret ;AN000; ;retURN TO callER | ||
| 1439 | init_cp endp ;AN000; | ||
| 1440 | |||
| 1441 | |||
| 1442 | ;------------------------------------------------------------------------------ | ||
| 1443 | ; RESTORE_CP - Restore chcp status (codepage support to original values) | ||
| 1444 | ; | ||
| 1445 | ; INPUT - | ||
| 1446 | ; OUTPUT - | ||
| 1447 | ;------------------------------------------------------------------------------ | ||
| 1448 | restore_cp proc near ;AN000; | ||
| 1449 | public restore_cp ;AN000; | ||
| 1450 | |||
| 1451 | test cpsw_orig,CPSW ;AN000; ;WAS CPSW ON WHEN WE STARTED? | ||
| 1452 | ; $if nz ;AN000; ;IF CPSW WAS ON | ||
| 1453 | JZ $$IF118 | ||
| 1454 | mov dl,CPSW_ON ;AN000; ; TO CPSW=ON | ||
| 1455 | doscall CPSW_CHECK,SET_CPSW_STATE ;AN000; ;SET CPSW=ON | ||
| 1456 | ; $endif ;AN000; ;CPSW WAS ON? | ||
| 1457 | $$IF118: | ||
| 1458 | ret ;AN000; ;retURN TO callER | ||
| 1459 | restore_cp endp ;AN000; | ||
| 1460 | |||
| 1461 | |||
| 1462 | ;------------------------------------------------------------------------------ | ||
| 1463 | ; COMP_CODEPAGE - If chcp=on, verify that the codepage of the two files agree. | ||
| 1464 | ; | ||
| 1465 | ; INPUT - PATH1 has the asciiz of the first path\filename | ||
| 1466 | ; PATH2 has the asciiz of the second path\filename | ||
| 1467 | ; OUTPUT - | ||
| 1468 | ;------------------------------------------------------------------------------ | ||
| 1469 | comp_codepage proc near ;AN000; | ||
| 1470 | public comp_codepage ;AN000; | ||
| 1471 | |||
| 1472 | test cpsw_orig,CPSW ;AN000; ;WAS CPSW=ON WHEN WE STARTED? | ||
| 1473 | ; $if nz ;AN000; ;IF CPSW IS LOADED | ||
| 1474 | JZ $$IF120 | ||
| 1475 | fill_name1 infcb ;AN000; ;get full path name | ||
| 1476 | mov cur_name,offset name1 ;AN000; ;PAss INPUTED FILENAME OF FIRST FILE | ||
| 1477 | call getcp ;AN000; ;GET CODEPAGE OF FIRST FILE | ||
| 1478 | mov ax,qlist_ea.ea_value ;AC001; ;SAVE ITS CODEPAGE | ||
| 1479 | push ax ;AN000; ;ON THE STACK | ||
| 1480 | fill_name2 ;AN000; ;get full path name | ||
| 1481 | mov cur_name,offset name2 ;AN000; ;PAss INPUTED FILENAME OF SECOND FILE | ||
| 1482 | call getcp ;AN000; ;GET CODEPAGE OF SECOND FILE | ||
| 1483 | pop ax ;AN000; ;GET FIRST FILE CODEPAGE | ||
| 1484 | mov bx,qlist_ea.ea_value ;AC001; ;GET SECOND FILE CODEPAGE | ||
| 1485 | and ax,ax ;AC008; ;AN000; ;COMPARE TO ZERO CP | ||
| 1486 | ; $if ne ;AN000; ;FIRST FILE HAS NON-ZERO CODE PAGE | ||
| 1487 | JE $$IF121 | ||
| 1488 | and bx,bx ;AC008; ;AN000; ;COMPARE TO ZERO CP | ||
| 1489 | ; $if ne ;AN000; ;SECOND FILE HAS NON-ZERO CODE PAGE | ||
| 1490 | JE $$IF122 | ||
| 1491 | cmp ax,bx ;AN000; ;COMPARE CP OF 1ST WITH CP OF 2ND | ||
| 1492 | ; $if e ;AN000; ;CP ARE ALIKE | ||
| 1493 | JNE $$IF123 | ||
| 1494 | clc ;AN000; ;INdiCATE MATCHING CP | ||
| 1495 | ; $else ;AN000; ;siNCE CP ARE NOT ALIKE | ||
| 1496 | JMP SHORT $$EN123 | ||
| 1497 | $$IF123: | ||
| 1498 | stc ;AN000; ;INdiCATE NON-MATCHING CP | ||
| 1499 | ; $endif ;AN000; ;CP ARE ALIKE | ||
| 1500 | $$EN123: | ||
| 1501 | ; $else ;AN000; ;siNCE 2ND HAS NO CODE PAGE | ||
| 1502 | JMP SHORT $$EN122 | ||
| 1503 | $$IF122: | ||
| 1504 | stc ;AN000; ;INdiCATE NON-MATCHING CP | ||
| 1505 | ; $endif ;AN000; ;2ND FILE HAS CODE PAGE? | ||
| 1506 | $$EN122: | ||
| 1507 | ; $else ;AN000; ;siNCE 1ST FILE HAS NO CODE PAGE | ||
| 1508 | JMP SHORT $$EN121 | ||
| 1509 | $$IF121: | ||
| 1510 | and bx,bx ;AC008; ;AN000; ;COMPARE TO ZERO CP | ||
| 1511 | ; $if ne ;AN000; ;2ND FILE HAS NO CODE PAGE | ||
| 1512 | JE $$IF129 | ||
| 1513 | stc ;AN000; ;INdiCATE NON-MATCHING CP | ||
| 1514 | ; $else ;AN000; ;siNCE 2ND FILE HAS NO CODE PAGE EITHER | ||
| 1515 | JMP SHORT $$EN129 | ||
| 1516 | $$IF129: | ||
| 1517 | clc ;AN000; ;INdiCATE OK, NO CP TO COMPARE | ||
| 1518 | ; $endif ;AN000; ;2ND FILE HAS CP? | ||
| 1519 | $$EN129: | ||
| 1520 | ; $endif ;AN000; ;1ST FILE HAS CODE PAGE? | ||
| 1521 | $$EN121: | ||
| 1522 | ; $if c ;AN000; ;IF CARRY | ||
| 1523 | JNC $$IF133 | ||
| 1524 | print_msg msgnum_cp_mismatch,STDERR ;AN000; ;"CODE PAGE MISMATCH" | ||
| 1525 | stc ;AN000; ;PAss INdiCATOR OF NON-MATCH CP | ||
| 1526 | ; $endif ;AN000; | ||
| 1527 | $$IF133: | ||
| 1528 | ; $else ;AN000; ;siNCE CODE PAGE NOT ACTIVE | ||
| 1529 | JMP SHORT $$EN120 | ||
| 1530 | $$IF120: | ||
| 1531 | clc ;AN000; ;PAss INdiCTOR OF OK CP | ||
| 1532 | ; $endif ;AN000; ;CODEPAGE LOADED? | ||
| 1533 | $$EN120: | ||
| 1534 | ret ;AN000; ;retURN TO callER | ||
| 1535 | comp_codepage endp ;AN000; | ||
| 1536 | |||
| 1537 | |||
| 1538 | ;------------------------------------------------------------------------------ | ||
| 1539 | ; GETCP - Does an extended open, gets codepage #, closes file. | ||
| 1540 | ; | ||
| 1541 | ; INPUT - AX = ptr to real filename to open | ||
| 1542 | ; CUR_NAME = ptr to inputed filename to open (display this if error) | ||
| 1543 | ; OUTPUT - | ||
| 1544 | ;------------------------------------------------------------------------------ | ||
| 1545 | getcp proc near ;AN000; | ||
| 1546 | public getcp ;AN000; | ||
| 1547 | |||
| 1548 | ; SET UP INPUTS TO EXTENDED OPEN: | ||
| 1549 | ; REQUesT FUNCTIONS: READ,COMPATABILITY,NO INHERIT,INT 24H ret ERR, | ||
| 1550 | ; NO COMMIT, NO ATTR, FAIL IF NOT EXIST, OPEN IF EXIST | ||
| 1551 | ; NO CODE PAGE CHECK | ||
| 1552 | |||
| 1553 | mov bx,OPEN_MODE ;AN000; ;SET READ MODE TO CORRECT VALUE FOR EXTENDED OPEN | ||
| 1554 | xor cx,cx ;AC008; ;AN000; ;NO ATTRIBUTE TO WORRY ABOUT (00H = NO_ATTR) | ||
| 1555 | mov dx,FUNC_CNTRL ;AN000; ;SET FUNCTION CONTROL FOR EXTENDED OPEN | ||
| 1556 | mov di,offset parm_list ;AN000; ;PAss offset TO PARM_LIST | ||
| 1557 | mov si,cur_name ;AN000; ;ptr to name of file to open | ||
| 1558 | doscall EXT_OPEN,EXT_OPEN_RD ;AN000; | ||
| 1559 | mov handle,ax ;AN000; ;SAVE HANDLE | ||
| 1560 | ; $if c ;AN000; ;IF ERROR | ||
| 1561 | JNC $$IF137 | ||
| 1562 | call exterr ;AN000; ;GET EXTENDED ERROR, SHOW MSG | ||
| 1563 | ; $else ;AN000; ;siNCE NO ERROR ON OPEN | ||
| 1564 | JMP SHORT $$EN137 | ||
| 1565 | $$IF137: | ||
| 1566 | ;AN000; ;GET_EXT_ATTR_LIST (5702), GET | ||
| 1567 | ;AN000; ;EXTENDED ATTR. TO LIST | ||
| 1568 | mov bx,handle ;AN000; ;bx=HANDLE | ||
| 1569 | mov di,offset qlist ;AC001; ;es:di=QLIST | ||
| 1570 | mov cx,13 ;AN001; ;size of QLIST returned | ||
| 1571 | mov si,offset querylist ;AN001; ;get code page attr. only | ||
| 1572 | doscall EXT_ATTR_LIST,GET_EXT_ATTR_LIST ;AN000; | ||
| 1573 | ;AN000; ;CY SET IF ERROR | ||
| 1574 | ; $if c ;AN000; ;IF ERROR | ||
| 1575 | JNC $$IF139 | ||
| 1576 | call exterr ;AN000; ;GET EXTENDED ERROR, SHOW MSG | ||
| 1577 | ; $endif ;AN000; | ||
| 1578 | $$IF139: | ||
| 1579 | mov bx,handle ;AN000; ;PAss HANDLE TO CLOSE FILE | ||
| 1580 | doscall HANDLECLOSE ;AN000; ;CLOSE THIS EXTENDED OPEN OF THE FILE | ||
| 1581 | ; $endif ;AN000; | ||
| 1582 | $$EN137: | ||
| 1583 | ret ;AN000; ;retURN TO callER | ||
| 1584 | getcp endp ;AN000; | ||
| 1585 | |||
| 1586 | |||
| 1587 | ;------------------------------------------------------------------------------ | ||
| 1588 | ; EXTERR - Displays the extended error message and filename. | ||
| 1589 | ; | ||
| 1590 | ; INPUT - | ||
| 1591 | ; OUTPUT - | ||
| 1592 | ;------------------------------------------------------------------------------ | ||
| 1593 | exterr proc near ;AN000; | ||
| 1594 | public exterr ;AN000; | ||
| 1595 | |||
| 1596 | xor bx,bx ;AC008; ;AN000; ;bx = MINOR VERsiON # OF DOS | ||
| 1597 | doscall EXTERROR ;AN000; ;GET EXTENDED ERROR | ||
| 1598 | mov msgnum_exterr.msg_num,ax ;AN000; ;PUT EXT. ERROR # IN MSG DesCRIPTOR STRUCT. | ||
| 1599 | mov msgnum_exterr.msg_sublist,offset sublist_EXTERR ;AN000; ;ptr TO sublist | ||
| 1600 | mov msgnum_exterr.msg_count,NO_SUBS ;AN000; ;ONE sublist WILL BE USED. | ||
| 1601 | mov ax,cur_name ;AN000; ;GET CURRENT FILENAME | ||
| 1602 | mov sublist_exterr.sub_value,ax ;AN000; ;FILL IN offset OF FILENAME TEXT | ||
| 1603 | print_msg msgnum_exterr,STDERR ;AN000; ;dispLAY EXTENDED ERROR MEssAGE | ||
| 1604 | |||
| 1605 | mov exitfl,EXVER ;AN000; ;INdiCATE AN ERROR | ||
| 1606 | ret ;AN000; | ||
| 1607 | exterr endp ;AN000; | ||
| 1608 | |||
| 1609 | |||
| 1610 | ;------------------------------------------------------------------------------ | ||
| 1611 | ; GET_DBCS_VECTOR - Get the DOS double byte character table segment and offset | ||
| 1612 | ; | ||
| 1613 | ; INPUT - | ||
| 1614 | ; OUTPUT - | ||
| 1615 | ;------------------------------------------------------------------------------ | ||
| 1616 | bufferDB db 6 dup(0) | ||
| 1617 | |||
| 1618 | get_dbcs_vector proc near ;AN006; | ||
| 1619 | push es ;AN006; | ||
| 1620 | push di ;AN006; | ||
| 1621 | push ax ;AN006; | ||
| 1622 | push bx ;AN006; | ||
| 1623 | push cx ;AN006; | ||
| 1624 | push dx ;AN006; | ||
| 1625 | ; | ||
| 1626 | mov ax,cs ;AN006; ;segment of return buffer | ||
| 1627 | mov es,ax ;AN006; | ||
| 1628 | mov di,offset bufferDB ;AN006; ;offset of return buffer | ||
| 1629 | mov ah,65h ;AN006; ;get extended country info | ||
| 1630 | mov al,07h ;AN006; ;get DBCS environment table | ||
| 1631 | mov bx,0ffffh ;AN006; ;use active code page | ||
| 1632 | mov cx,5 ;AN006; ;number of bytes returned | ||
| 1633 | mov dx,0ffffh ;AN006; ;default country ID | ||
| 1634 | int 21h ;AN006; ;DOS function call,vector returned | ||
| 1635 | ;AN006; ; in ES:DI | ||
| 1636 | inc di ;AN006; ;skip over id byte returned | ||
| 1637 | mov ax,word ptr es:[di] ;AN006; ;get offset of DBCS table | ||
| 1638 | mov cs:dbcs_off,ax ;AN006; ;save it | ||
| 1639 | ; | ||
| 1640 | add di,2 ;AN006; ;skip over offset to get segment | ||
| 1641 | mov bx,word ptr es:[di] ;AN006; ;get segment of DBCS table | ||
| 1642 | mov cs:dbcs_seg,bx ;AN006; ;save it | ||
| 1643 | ; | ||
| 1644 | mov di,ax ;AN006; ;Point to DBCS table to get length | ||
| 1645 | mov es,bx ;AN006; | ||
| 1646 | mov ax,word ptr es:[di] ;AN006; | ||
| 1647 | mov cs:dbcs_len,ax ;AN006; | ||
| 1648 | add cs:dbcs_off,2 ;AN006; ;change offset to point to table | ||
| 1649 | ; | ||
| 1650 | pop dx ;AN006; | ||
| 1651 | pop cx ;AN006; | ||
| 1652 | pop bx ;AN006; | ||
| 1653 | pop ax ;AN006; | ||
| 1654 | pop di ;AN006; | ||
| 1655 | pop es ;AN006; | ||
| 1656 | ; | ||
| 1657 | ret ;AN006; | ||
| 1658 | get_dbcs_vector endp ;AN006; | ||
| 1659 | |||
| 1660 | |||
| 1661 | ;------------------------------------------------------------------------------ | ||
| 1662 | ; Check_DBCS_slash - given SI pointing to string, check if the character SI | ||
| 1663 | ; points to is a slash and that the preceeding character | ||
| 1664 | ; is not DBCS. | ||
| 1665 | ; | ||
| 1666 | ; INPUT - SI = ptr to possible slash character | ||
| 1667 | ; STRING_SEG:STRING_OFF points to the beginning of string | ||
| 1668 | ; OUTPUT - set ZERO flag if [SI-1] != DBCS character AND [SI] == '\', | ||
| 1669 | ; else resets ZERO flag. | ||
| 1670 | ;------------------------------------------------------------------------------ | ||
| 1671 | Check_DBCS_slash proc near ;AN006; | ||
| 1672 | push es ;AN006; | ||
| 1673 | push di ;AN006; | ||
| 1674 | push si ;AN006; | ||
| 1675 | push ax ;AN006; | ||
| 1676 | push bx ;AN006; | ||
| 1677 | push cx ;AN006; | ||
| 1678 | ; | ||
| 1679 | cmp byte ptr [si],'\' ;AN006; ;Is character a slash ? | ||
| 1680 | jne reset_zero ;AN006; ;no, quit. | ||
| 1681 | ; | ||
| 1682 | cld ;AN006; | ||
| 1683 | mov cx,128 ;AN006; ;clear darray to zeroes | ||
| 1684 | mov di,offset dstring ;AN006; ;dstring will correspond to the string pointed to by | ||
| 1685 | mov al,00 ;AN006; ;string_seg:string_off and for each character in the string | ||
| 1686 | rep stosb ;AN006; ;that is DBCS a corresponding "D" will be stored in dstring. | ||
| 1687 | ;AN006; ;example: string : [c:\\\ ] | ||
| 1688 | ; dstring: [ D D ] (there are two DBCS characters) | ||
| 1689 | ; | ||
| 1690 | sub si,string_off ;AN006; ;si will equal length of string from beginning to character that may be a slash. | ||
| 1691 | and si,si ;AC008; ;AN006; ;is character in first position ? | ||
| 1692 | jbe set_zero ;AN006; ;yes, quit. | ||
| 1693 | mov cx,si ;AN006; ;cx will contain the count of characters to check DBCS status of. | ||
| 1694 | push cx ;AN006; ;save for later | ||
| 1695 | mov si,string_off ;AN006; ;si points to beginning of string. | ||
| 1696 | ; | ||
| 1697 | mov bx,cs:dbcs_seg ;AN006; ;ES:SI -> DOS dbcs table (segment) | ||
| 1698 | mov es,bx ;AN006; | ||
| 1699 | ; | ||
| 1700 | mov bx,offset dstring ;AN006; ;bx points to dstring | ||
| 1701 | DB_loop: ;AN006; | ||
| 1702 | mov di,cs:dbcs_off ;AN006; ;ES:SI -> DOS dbcs table (offset) | ||
| 1703 | lodsb ;AN006; ;get character into al | ||
| 1704 | ; | ||
| 1705 | ; Two consecutive 00 bytes signifies end of table | ||
| 1706 | ; | ||
| 1707 | |||
| 1708 | is_loop: ;AN006; | ||
| 1709 | cmp word ptr es:[di],00h ;AN006; ;Check for two consecutive 00 bytes | ||
| 1710 | jne is_next1 ;AN006; ;no, continue | ||
| 1711 | jmp short DB_inc ;AC008; ;AN006; ;yes, found them, quit | ||
| 1712 | ; | ||
| 1713 | ; Check if byte is within range values of DOS dbcs table | ||
| 1714 | ; | ||
| 1715 | is_next1: ;AN006; | ||
| 1716 | cmp al,byte ptr es:[di] ;AN006; ;is byte >= first byte in range? | ||
| 1717 | jae is_next2 ;AN006; ;yes, continue | ||
| 1718 | jmp short is_again ;AC008; ;AN006; ;no, loop again | ||
| 1719 | is_next2: ;AN006; | ||
| 1720 | cmp al,byte ptr es:[di+1] ;AN006; ;is byte <= last byte in range? | ||
| 1721 | jbe is_found ;AN006; ;yes, found a lead byte of db char | ||
| 1722 | is_again: ;AN006; | ||
| 1723 | add di,2 ;AN006; ;no, increment ptr to next range | ||
| 1724 | jmp is_loop ;AN006; | ||
| 1725 | is_found: ;AN006; | ||
| 1726 | mov byte ptr ds:[bx],'D' ;AN006; ;byte is lead byte of db char, set [BX] = 'D' | ||
| 1727 | inc bx ;AN006; ;skip over second part of double byte char. | ||
| 1728 | inc si ;AN006; ; " " " " " " " " | ||
| 1729 | DB_inc: ;AN006; | ||
| 1730 | inc bx ;AN006; | ||
| 1731 | dec cx ;AN006; | ||
| 1732 | and cx,cx ;AC008; ;AN006; ;are we done check characters for DBCS | ||
| 1733 | jne DB_loop ;AN006; ;no, check next character | ||
| 1734 | ; | ||
| 1735 | ; end of loop | ||
| 1736 | ; | ||
| 1737 | pop cx ;AN006; ;restore offset into string | ||
| 1738 | dec cx ;AN006; ;check character preceeding slah to see if it is DBCS | ||
| 1739 | mov si,offset dstring ;AN006; ;get beginning of string | ||
| 1740 | add si,cx ;AN006; ;si now point to char preceeding slash | ||
| 1741 | cmp byte ptr [si],'D' ;AN006; ;Is it DBCS ? | ||
| 1742 | je reset_zero ;AN006; ;yes | ||
| 1743 | set_zero: ;AN006; | ||
| 1744 | cmp al,al ;AN006; ;set ZERO flag | ||
| 1745 | jmp short is_bye ;AC008; ;AN006; | ||
| 1746 | reset_zero: ;AN006; | ||
| 1747 | mov bx,01h ;AN006; | ||
| 1748 | cmp bx,0ffh ;AN006; ;reset ZERO flag | ||
| 1749 | is_bye: ;AN006; | ||
| 1750 | pop cx ;AN006; | ||
| 1751 | pop bx ;AN006; | ||
| 1752 | pop ax ;AN006; | ||
| 1753 | pop si ;AN006; | ||
| 1754 | pop di ;AN006; | ||
| 1755 | pop es ;AN006; | ||
| 1756 | ; ;AN006; | ||
| 1757 | ret ;AN006; | ||
| 1758 | Check_DBCS_slash endp ;AN006; | ||
| 1759 | |||
| 1760 | |||
| 1761 | ;------------------------------------------------------------------------------ | ||
| 1762 | ; SENDMSG - Transfer msg descriptor info to registers and call the msg retriever | ||
| 1763 | ; | ||
| 1764 | ; INPUT - DX = ptr to msg descriptor for this message | ||
| 1765 | ; OUTPUT - DX, AX altered, others ok. | ||
| 1766 | ;------------------------------------------------------------------------------ | ||
| 1767 | sendmsg proc near ;AN000; | ||
| 1768 | public sendmsg ;AN000; | ||
| 1769 | |||
| 1770 | push bx ;AN000; ;SAVE callER'S REGS | ||
| 1771 | push cx ;AN000; | ||
| 1772 | push si ;AN000; | ||
| 1773 | push di ;AN000; | ||
| 1774 | mov di,dx ;AN000; ;PUT ptr TO MSG DesC. IN di | ||
| 1775 | mov dx,[di].msg_input ;AN000; ;GET ptr TO INPUT BUFFER AND PUT IN dx | ||
| 1776 | push dx ;AN000; ;SAVE IT ON THE STACK FOR LATER | ||
| 1777 | |||
| 1778 | ; PAss PARMS TO MEssAGE HANDLER IN | ||
| 1779 | ; THE APPROPRIATE REGISTERS IT NEEds. | ||
| 1780 | mov ax,[di].msg_num ;AN000; ;MEssAGE NUMBER | ||
| 1781 | mov bx,[di].msg_handle ;AN000; ;HANDLE TO dispLAY TO | ||
| 1782 | mov si,[di].msg_sublist ;AN000; ;offset IN es: OF sublist, OR 0 IF NONE | ||
| 1783 | mov cx,[di].msg_count ;AN000; ;NUMBER OF %PARMS, 0 IF NONE | ||
| 1784 | mov dx,[di].msg_class ;AN000; ;CLAss IN HIGH byte, INPUT FUNCTION IN LOW | ||
| 1785 | pop di ;AN000; ;GET OLD dx VALUE (ptr TO INPUT BUFFER) | ||
| 1786 | call sysdispmsg ;AN000; ;dispLAY THE MEssAGE | ||
| 1787 | ; $if c ;AN000; ;IF THERE IS A PROBLEM | ||
| 1788 | JNC $$IF142 | ||
| 1789 | ;AN000; ;ax=EXTENDED ERROR NUMBER | ||
| 1790 | mov bx,STDERR ;AN000; ;HANDLE TO dispLAY TO | ||
| 1791 | xor si,si ;AC008; ;AN000; ;offset IN es: OF sublist, OR 0 IF NONE | ||
| 1792 | xor cx,cx ;AC008; ;AN000; ;NUMBER OF %PARMS, 0 IF NONE | ||
| 1793 | mov dh,CLASS_1 ;AN000; ;CLAss IN HIGH byte, INPUT FUNCTION IN LOW | ||
| 1794 | call sysdispmsg ;AN000; ;TRY TO SAY WHAT HAPPENED | ||
| 1795 | stc ;AN000; ;REPORT PROBLEM | ||
| 1796 | ; $endif ;AN000; ;PROBLEM WITH dispLAY? | ||
| 1797 | $$IF142: | ||
| 1798 | |||
| 1799 | pop di ;AN000; ;ResTORE callER'S REGISTERS | ||
| 1800 | pop si ;AN000; | ||
| 1801 | pop cx ;AN000; | ||
| 1802 | pop bx ;AN000; | ||
| 1803 | |||
| 1804 | ret ;AN000; | ||
| 1805 | sendmsg endp ;AN000; | ||
| 1806 | |||
| 1807 | |||
| 1808 | |||
| 1809 | ;------FIND BOUNDARY-------------- | ||
| 1810 | if ($-cseg) mod 16 ;AN000; ;IF NOT ALREADY ON 16 byte BOUNDARY | ||
| 1811 | org ($-cseg)+16-(($-cseg) mod 16) ;AN000; ;ADJUST TO 16 byte BOUNDARY | ||
| 1812 | endif ;AN000; | ||
| 1813 | ;--------------------------------- | ||
| 1814 | |||
| 1815 | buf label byte | ||
| 1816 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 1817 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 1818 | ;;;;;;;ALL CODE BELOW THIS POINT WILL BE OVERLAID WITH DATA BEING COMPARED;;;;;; | ||
| 1819 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 1820 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 1821 | |||
| 1822 | |||
| 1823 | ;------------------------------------------------------------------------------ | ||
| 1824 | ; SETFILL - sets the fill_seg, fill_off with the current seg_id, offset in | ||
| 1825 | ; sublists of msg. | ||
| 1826 | ; | ||
| 1827 | ; INPUT - | ||
| 1828 | ; OUTPUT - | ||
| 1829 | ;------------------------------------------------------------------------------ | ||
| 1830 | setfill proc near ;AN000; | ||
| 1831 | public setfill ;AN000; | ||
| 1832 | push ax ;AN000; ;save registers | ||
| 1833 | mov ax,cs ;AN000; ;get the code segment | ||
| 1834 | mov sublist_6.sub_value_seg,ax ;AN000; ;save seg_id in sublist | ||
| 1835 | mov sublist_7.sub_value_seg,ax ;AN000; ;save seg_id in sublist | ||
| 1836 | mov sublist_8.sub_value_seg,ax ;AN000; ;save seg_id in sublist | ||
| 1837 | mov sublist_11.sub_value_seg,ax ;AN000; ;save seg_id in sublist | ||
| 1838 | mov sublist_12.sub_value_seg,ax ;AN000; ;save seg_id in sublist | ||
| 1839 | mov sublist_13.sub_value_seg,ax ;AN000; ;save seg_id in sublist | ||
| 1840 | mov sublist_19a.sub_value_seg,ax ;AN000; ;save seg_id in sublist | ||
| 1841 | mov sublist_19b.sub_value_seg,ax ;AN000; ;save seg_id in sublist | ||
| 1842 | mov sublist_24.sub_value_seg,ax ;AN000; ;FILL IN CODE SEGMENT | ||
| 1843 | mov sublist_exterr.sub_value_seg,ax ;AN000; ;FILL IN CODE SEGMENT | ||
| 1844 | pop ax ;AN000; ; GET OLD VALUE IN ax BACK | ||
| 1845 | ret ;AN000; | ||
| 1846 | setfill endp ;AN000; | ||
| 1847 | |||
| 1848 | |||
| 1849 | ;------------------------------------------------------------------------------ | ||
| 1850 | ; MORE_INIT - finishes the initialization. this code will be overlaid with data | ||
| 1851 | ; after it executes. | ||
| 1852 | ; | ||
| 1853 | ; INPUT - | ||
| 1854 | ; OUTPUT - | ||
| 1855 | ;------------------------------------------------------------------------------ | ||
| 1856 | more_init proc near ;AC000; | ||
| 1857 | public more_init ;AN000; | ||
| 1858 | |||
| 1859 | cld | ||
| 1860 | or ah,al | ||
| 1861 | cmp ah,-1 ;was either drive specified invalid? | ||
| 1862 | ; $if e ;AC000; ;one or both of drives are invalid | ||
| 1863 | JNE $$IF144 | ||
| 1864 | print_msg msgnum_baddrv,STDERR ;AN000; ;"INVALID DRIVE SPEC." | ||
| 1865 | int 20h ;and quit | ||
| 1866 | ; $endif ;AC000; | ||
| 1867 | $$IF144: | ||
| 1868 | mov ax, offset buf+4096 ;end of pgm | ||
| 1869 | add ax,16 | ||
| 1870 | mov cl,4 | ||
| 1871 | shr ax,cl ;in seg form | ||
| 1872 | push cs | ||
| 1873 | pop dx | ||
| 1874 | add ax,dx ;seg addr of buf2 | ||
| 1875 | mov buf2,ax | ||
| 1876 | mov dx,Memory_Size ;# paragraphs in machine | ||
| 1877 | cmp ax,dx ;does start of buf2 exceed mem? | ||
| 1878 | jnb badmem ;yes, can't do nothin' without mem | ||
| 1879 | sub dx,ax ;# avail paragraphs | ||
| 1880 | cmp dx,256 ;have at least 4k? | ||
| 1881 | jnb havmem ;yes | ||
| 1882 | badmem: | ||
| 1883 | print_msg msgnum_mem,STDERR ;AN000; ;"INSUFFICIENT MEMORY" | ||
| 1884 | int 20h ;and quit | ||
| 1885 | havmem: | ||
| 1886 | cmp dx,3840 ;over 61440 bytes avail? | ||
| 1887 | jbe cmem ;no | ||
| 1888 | mov dx,3840 ;yes, set to max of 61440 bytes | ||
| 1889 | cmem: | ||
| 1890 | mov cl,4 | ||
| 1891 | shl dx,cl ;# bytes avail | ||
| 1892 | and dx,0f000h ;round down to a 4096-byte boundary | ||
| 1893 | mov word ptr mem,dx ;and save buf2 size in bytes | ||
| 1894 | mov byte ptr swt,0 ;initialize master switch | ||
| 1895 | doscall DEFDRV ;AC000; ;get default drive | ||
| 1896 | inc al | ||
| 1897 | mov curdrv,al ;and save | ||
| 1898 | or al,64 ;drive to ascii | ||
| 1899 | mov cdrv,al ;save | ||
| 1900 | xor ch,ch | ||
| 1901 | mov cl,Parm_Area ;length of input parms | ||
| 1902 | mov si,129 ;where parms are | ||
| 1903 | |||
| 1904 | mov current_parm,si ;AN000; ;pass to parser ptr to input parm buffer | ||
| 1905 | mov ordinal,ZERO_PARM_CT ;AN000; ;pass ordinal #, this is begin of parse | ||
| 1906 | mov parm_count,FIRST_PARM_CT ;AN000; ;parse the first parm and second parm | ||
| 1907 | call parser ;AC000; ;returns first filename in path1, and the | ||
| 1908 | ;AN000; ;second filename in path2. | ||
| 1909 | ;fcb is already formatted with correct drive | ||
| 1910 | mov si,offset path2 | ||
| 1911 | mov di,offset fcb2 | ||
| 1912 | doscall PARSE_FILENAME,01H ;AC000; ;build 2nd fcb from 2nd parm, | ||
| 1913 | ;AC000; ;scan off leading separators | ||
| 1914 | cmp al,-1 ;invalid drive? | ||
| 1915 | ; $if e ;AC000; ;Yes, invalid drive | ||
| 1916 | JNE $$IF146 | ||
| 1917 | print_msg msgnum_baddrv,STDERR ;AN000; ;"Invalid drive spec." | ||
| 1918 | int 20h ;and quit | ||
| 1919 | ; $else ;AC000; | ||
| 1920 | JMP SHORT $$EN146 | ||
| 1921 | $$IF146: | ||
| 1922 | mov dx,offset CBExit | ||
| 1923 | doscall SETVECTOR,23H ;AC000; ;change control break vector, #23h | ||
| 1924 | ; $endif ;AC000; | ||
| 1925 | $$EN146: | ||
| 1926 | |||
| 1927 | ret ;AN000; ;return to main | ||
| 1928 | more_init endp ;AN000; | ||
| 1929 | |||
| 1930 | cseg ends | ||
| 1931 | end | ||
| 1932 | \ No newline at end of file | ||