summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/COMP
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/COMP')
-rw-r--r--v4.0/src/CMD/COMP/COMP.LNK6
-rw-r--r--v4.0/src/CMD/COMP/COMP.SKL30
-rw-r--r--v4.0/src/CMD/COMP/COMP1.ASM190
-rw-r--r--v4.0/src/CMD/COMP/COMP2.ASM1932
-rw-r--r--v4.0/src/CMD/COMP/COMPEQ.INC184
-rw-r--r--v4.0/src/CMD/COMP/COMPMS.INC156
-rw-r--r--v4.0/src/CMD/COMP/COMPP.ASM130
-rw-r--r--v4.0/src/CMD/COMP/COMPPAR.ASM410
-rw-r--r--v4.0/src/CMD/COMP/COMPSM.ASM159
-rw-r--r--v4.0/src/CMD/COMP/MAKEFILE52
10 files changed, 3249 insertions, 0 deletions
diff --git a/v4.0/src/CMD/COMP/COMP.LNK b/v4.0/src/CMD/COMP/COMP.LNK
new file mode 100644
index 0000000..f8b53de
--- /dev/null
+++ b/v4.0/src/CMD/COMP/COMP.LNK
@@ -0,0 +1,6 @@
1COMP1+
2COMPPAR+
3COMPP+
4COMPSM+
5COMP2,COMP,COMP.MAP/M;
6 \ No newline at end of file
diff --git a/v4.0/src/CMD/COMP/COMP.SKL b/v4.0/src/CMD/COMP/COMP.SKL
new file mode 100644
index 0000000..96a1115
--- /dev/null
+++ b/v4.0/src/CMD/COMP/COMP.SKL
@@ -0,0 +1,30 @@
1:util COMP ;utility name ;AN000;
2
3:class A ;system messages ;AN000;
4
5:use 1 COMMON1 ;"Incorrect DOS version" ;AN000;
6:use 2 EXTEND8 ;"Insufficient memory" ;AN000;
7:use 3 PARSE10 ;"Invalid parameter" ;AN000;
8
9:def 4 "10 Mismatches - ending compare",CR,LF ;AN000;
10:use 5 EXTEND15 ;"Invalid drive specification" ;AN000;
11:def 6 "Compare error at OFFSET %1",CR,LF ;AN000;
12:def 7 "File 1 = %1",CR,LF ;AN000;
13:def 8 "File 2 = %1",CR,LF ;AN000;
14:def 9 "Eof mark not found",CR,LF ;AN000;
15:def 10 "Files compare ok",CR,LF ;AN000;
16:use 11 EXTEND2 ;"File not found" ;AN000;
17:use 12 COMMON25 ;"Invalid path" ;AN000;
18:use 13 EXTEND32 ;"Sharing violation" ;AN000;
19:use 14 EXTEND4 ;"Too many open files" ;AN000;
20:def 15 CR,LF,CR,LF,"Enter primary filename",CR,LF ;AN000;
21:def 16 CR,LF,CR,LF,"Enter 2nd filename or drive id",CR,LF ;AN000;
22:def 17 "Files are different sizes",CR,LF ;AN000;
23:def 18 "Compare more files (Y/N) ?" ;AN000;
24:def 19 "%1 and %2",CR,LF ;AN000;
25:def 20 CR,LF ;AN000;
26:use 21 EXTEND5 ;"Access Denied" ;AN000;
27:use 22 EXTEND37 ;"Code page mismatch" ;AN000;
28:DEF 23 "Files compare ok",CR,LF ;AN000;
29:end ;AN000;
30 \ No newline at end of file
diff --git a/v4.0/src/CMD/COMP/COMP1.ASM b/v4.0/src/CMD/COMP/COMP1.ASM
new file mode 100644
index 0000000..b732543
--- /dev/null
+++ b/v4.0/src/CMD/COMP/COMP1.ASM
@@ -0,0 +1,190 @@
1 page ,132 ;
2 title COMP.SAL - COMPARE A PAIR OF FILES
3;****************** START OF SPECIFICATIONS *****************************
4; MODULE NAME: COMP1.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, or
13; (3) either path is invalid.
14;
15; During the comparison, an error message will appear for any
16; location that contains mismatching information in the 2
17; files. The message indicates the offset into the files of
18; the mismatching bytes, and the contents of the 2 bytes
19; themselves (all in hex). This will occur for up to 10
20; mismatching bytes - if more than 10 compare errors are
21; found, the program assumes that further comparison would be
22; useless, and ends its compare of the 2 files at that point.
23;
24; If all bytes in the 2 files match, a "Files compare OK"
25; message will appear.
26;
27; In all cases, after the comparing of 2 files ends, comparing
28; will proceed with the next pair of files that match the 2
29; filenames, until no more files can be found that match the
30; first filename. You are then asked if you want to compare
31; any more files. Replying "N" returns you to the DOS prompt
32; (such as A>); a reply of "Y" results in prompts for new
33; primary and secondary filenames.
34;
35; In all compares, COMP looks at the last byte of one of the
36; files being compared to assure that it contains a valid
37; end-of-file mark (CTRL-Z, which is the hex character 1A).
38; If found, no action is taken by COMP. If the end-of-file
39; mark is NOT found, COMP produces the message "EOF mark not
40; found". This is done because some products produce files
41; whose sizes are always recorded in the directory as a
42; multiple of 128 bytes, even though the actual usable data in
43; the file will usually be a few bytes less than the directory
44; size. In this case, COMP may produce "Compare error"
45; messages when comparing the few bytes beyond the last real
46; data byte in the last block of 128 bytes (COMP always
47; compares the number of bytes reflected in the directory).
48; Thus, the "EOF mark not found" message indicates that the
49; compare errors may not have occurred in the usable data
50; portion of the file.
51;
52; Multiple compare operations may be performed with one load
53; of COMP. A prompt, "Compare more files (Y/N)?" permits additional
54; executions.
55;
56; ENTRY POINT: "START" at ORG 100h, jumps to "INIT".
57;
58; INPUT: (DOS command line parameters)
59; [d:][path] COMP [d:][path][filenam1[.ext]] [d:][path][filenam2[.ext]]
60;
61; Where
62; [d:][path] before COMP to specify the drive and path that
63; contains the COMP command file.
64;
65; [d:][path][filenam1[.ext]] - to specify the FIRST (or primary)
66; file or group of files to be compared
67;
68; [d:][path][filenam2[.ext]] - to specify the SECOND file or group
69; of files to be compared with the corresponding file
70; from the FIRST group
71;
72; Global filename characters are allowed in both filenames,
73; and will cause all of the files matching the first filename
74; to be compared with the corresponding files from the second
75; filename. Thus, entering COMP A:*.ASM B:*.BAK will cause
76; each file from drive A: that has an extension of .ASM to be
77; compared with a file of the same name (but with an extension
78; of .BAK) from drive B:.
79;
80; If you enter only a drive specification, COMP will assume
81; all files in the current directory of the specified drive.
82; If you enter a path without a filename, COMP assumes all
83; files in the specified directory. Thus, COMP A:\LEVEL1
84; B:\LEVEL2 will compare all files in directory A:\LEVEL1 with
85; the files of the same names in directory B:\LEVEL2.
86;
87; If no parameters are entered with the COMP command, you will
88; be prompted for both. If the second parm is omitted, COMP
89; will prompt for it. If you simply press ENTER when prompted
90; for the second filename, COMP assumes *.* (all files
91; matching the primary filename), and will use the current
92; directory of the default drive.
93;
94; If no file matches the primary filename, COMP will prompt
95; again for both parameters.
96;
97; EXIT-NORMAL: Errorlevel = 0, Function completed successfully.
98;
99; EXIT-ERROR: Errorlevel = 1, Abnormal termination due to error, wrong DOS,
100; invalid parameters, unrecoverable I/O errors on the diskette.
101;
102; EFFECTS: Files are not altered. A Message will show result of compare.
103;
104; INTERNAL REFERENCES:
105; ROUTINES: none
106;
107; DATA AREAS:
108; PSP - Contains the DOS command line parameters.
109; WORKAREA - Temporary storage
110;
111; EXTERNAL REFERENCES:
112; ROUTINES:
113; SYSDISPMSG - Uses the MSG parm lists to construct the messages
114; on STDOUT.
115; SYSLOADMSG - Loads messages, makes them accessable.
116; SYSPARSE - Processes the DOS Command line, finds parms.
117;
118; DATA AREAS:
119; COMPSM.SAL - Defines the control blocks that describe the messages
120; COMPPAR.SAL - Defines the control blocks that describe the
121; DOS Command line parameters.
122;
123; NOTES:
124; This module should be processed with the SALUT preprocessor
125; with the re-alignment not requested, as:
126;
127; SALUT COMP1,NUL
128;
129; To assemble these modules, the alphabetical or sequential
130; ordering of segments may be used.
131;
132; Sample LINK command:
133;
134; LINK @COMP.ARF
135;
136; Where the COMP.ARF is defined as:
137;
138; COMP1+
139; COMPPAR+
140; COMPP+
141; COMPSM+
142; COMP2
143;
144; These modules must be linked in this order. The load module is
145; a COM file, to be converted to COM with EXE2BIN.
146;
147; REVISION HISTORY:
148; AN000 Version 4.00: add PARSER, System Message Handler,
149; Add compare of code page extended attribute, if present.
150;
151; COPYRIGHT: The following notice is found in the OBJ code generated from
152; the "COMPSM.SAL" module:
153;
154; "The DOS COMP Utility"
155; "Version 4.00 (C) Copyright 1988 Microsoft"
156; "Licensed Material - Property of Microsoft"
157;
158;PROGRAM AUTHOR: Original written by: Dave L.
159; 3.30 modifications by Russ W.
160; 4.0 modifications by: Edwin M. K.
161; 4.0 modifications by: Bill L.
162;****************** END OF SPECIFICATIONS *****************************
163 PAGE
164; $SALUT (4,13,18,36)
165 IF1
166 %OUT COMPONENT=COMP, MODULE=COMP1.ASM
167 ENDIF
168
169CSEG segment PARA public 'CODE' ;AN000;
170 assume cs:CSEG,ds:CSEG,es:CSEG,ss:CSEG ;AS SET BY DOS LOADER
171PSP_HEADER EQU $ ;START OF PROGRAM SEGMENT PREFIX AREA
172 org 02h
173MEMORY_SIZE LABEL WORD
174 PUBLIC MEMORY_SIZE
175
176 org 5Ch
177FCB LABEL BYTE
178 PUBLIC FCB
179
180 org 80h
181PARM_AREA LABEL BYTE
182 PUBLIC PARM_AREA
183
184 org 100h
185 EXTRN INIT:NEAR ;"INIT" IS IN COMP2.SAL
186START: jmp INIT ;DEFINE THE DOS ENTRY POINT
187
188CSEG ENDS
189 END START
190 \ No newline at end of file
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
184fill_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
197fill_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
210print_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
223doscall 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
244ea struc ;AN001; ;extended attr. structure
245ea_type db EAISBINARY ;AN001;
246ea_flags dw EASYSTEM ;AN001;
247ea_rc db ? ;AN001;
248ea_namelen db 2 ;AN001;
249ea_vallen dw 2 ;AN001;
250ea_name db "CP" ;AN001;
251ea_value dw ? ;AN001;
252ea ends ;AN001;
253
254qea struc ;AN001; ;query extended attr. name
255qea_type db EAISBINARY ;AN001;
256qea_flags dw EASYSTEM ;AN001;
257qea_namelen db 2 ;AN001;
258qea_name db "CP" ;AN001;
259qea ends ;AN001;
260
261;***********************************
262; Code Segment
263;***********************************
264
265cseg 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
327stack_area db 512 dup ("S") ;Added in DOS 3.20 to support hardware requiring
328End_Stack_Area db 00h ;large stacks. DO NOT PUT DATA ABOVE THIS !
329
330clear db 00h ;AN000; ;clear path2
331cur_name dw 00h ;AN000; ;ptr to current filename
332input_buf db 130 dup (0) ;AN000; ;input buffer for keyb input
333name1 db 130 dup (0) ;AN000; ;source file name
334name2 db 130 dup (0) ;AN000; ;target file name
335byte1 db 00h ;AN000; ;on compare: bad byte for source
336byte2 db 00h ;AN000; ;on compare: bad byte for target
337fcb2 db 16 dup (0) ;entered target filespec
338;--------KEEP NEXT VARIABLes IN ORIGINAL ORDER-------------
339oldp1 db 67 dup (0) ;original path for the first drive 1 KEEP IN ORDER
340path1 db 130 dup (0) ;path we'll use for the first drive 2
341infcb db 37 dup (0) ;source fcb 3
342oldp2 db 67 dup (0) ;original path for second drive 4
343path2 db 130 dup (0) ;path we'll use for second drive 5
344outfcb db 37 dup (0) ;target fcb 6
345;--------KEEP ABOVE VARIABLes IN ORIGINAL ORDER------------
346sav db 2 dup (0)
347mem db 2 dup (0) ;size of large buffer in bytes
348curfcb db 4 dup (0) ;first 2 bytes = addr of fcb for large buffer,
349 ;last 2 bytes = addr of fcb for small buffer
350curpos dw 00h ;current byte offset in large buffer
351buf2 dw 00h ;seg address of large buffer
352siz dw 512 ;# bytes of data left to compare in large buffer
353swt 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
361swt2 db 00h ;Bit switch:
362 ; 1 = oldp1 setup
363 ; 2 = oldp2 setup
364offs db 00h,00h,00h,00h ;count of bytes compared
365cnt db 00h ;# of bad compares
366offp db 8 dup(0) ;AC000; ;offset of mis-compare between bytes
367off_byte db 8 dup (0) ;AN000; ;same as offp, but the words are reversed
368curdrv db 00h ;actual number of default drive
369cdrv db " :" ;ascii letter of default drive
370pathchar db "\",00h
371tbl db "0123456789ABCDEF"
372openpath db 15 dup (0) ;An fcb will be parsed into this path.
373cpsw_orig db 00h ;AN000; ;save original cpsw value
374exitfl db EXOK ;AN000; ;errorlevel return code
375handle dw 00h ;AN000;
376
377dbcs_off dw 0 ;AN006;
378dbcs_seg dw 0 ;AN006;
379dbcs_len dw 0 ;AN006;
380string_off dw 0 ;AN006;
381string_seg dw 0 ;AN006;
382dstring db 128 dup(0) ;AN006;
383
384parm_list label word ;AN001;
385 dd -1 ;AN001;
386 dw 1 ;AN001;
387 db 6 ;AN001;
388 dw 2 ;AN001;
389
390querylist label byte ;AN001; ;query general list
391 dw 1 ;AN001; ;# of entries
392querylist_qea qea <EAISBINARY,EASYSTEM,2,"CP"> ;AN001;
393
394qlist label byte ;AN001; ;general get/set list
395 dw 1 ;AN001; ;count of attr entries
396qlist_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;-----------------------------------------------------------------------------
409init 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
436init endp ;AN000;
437
438
439;------------------------------------------------------------------------------
440; MAIN - Does the compare for two sets of files
441;------------------------------------------------------------------------------
442;
443main 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
453rpt:
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:
546f1ok: ;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
680accessdenied2: ;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
690ShrViolation:
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
699filopn:
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
711invsiz:
712 print_msg msgnum_badsiz,STDOUT ;AN000; ;"Files are different sizes"
713 jmp quit3 ;tell user sizes are different and process next source file
714sizok:
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
726process: ;**** 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
747large: ;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
752getsec:
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
758comp:
759 jcxz compok ;all done and equal
760 repe cmpsb
761 jne cmp1 ;bytes don't match
762compok:
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
771cmp1: ;***** 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
803mdone:
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
816gotten:
817 push ds
818 pop es ;get es back
819 print_msg msgnum_tenmsg,STDOUT ;AN000; ;"10 Mismatches - ending compare"
820
821quit3: ;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
837AccessDenied1: ;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
844ShrErr:
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
849badfil: ;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;
864quit4: ;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
869quit5:
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;--------------------------------------------
922CBExit:
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
944main 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;------------------------------------------------------------------------------
959findfs 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;
989findfs 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;------------------------------------------------------------------------------
1001getnam 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
1016getnam 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;------------------------------------------------------------------------------
1031findpath 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
1062fp0:
1063 cmp byte ptr [di+1]," " ;no, is there a name in the fcb?
1064 jne fp2 ;yes, use current dir
1065fp1:
1066 call setq ;no, set it to ????????.???
1067fp2:
1068 cmp al,al ;force eq on return
1069 ret
1070fp3: ;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
1079fp4:
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
1084fp5:
1085 cmp ax,1234h ;no, pass back error - path has first part of name,
1086 ret ;remainder is in fcb
1087findpath 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;------------------------------------------------------------------------------
1099backoff 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;
1120bo4:
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
1130bo3:
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
1143backoff 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;------------------------------------------------------------------------------
1152setq 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
1165setq endp ;AC000;
1166
1167
1168;------------------------------------------------------------------------------
1169; GET - Fill large buffer
1170;
1171; INPUT -
1172; OUTPUT -
1173;------------------------------------------------------------------------------
1174get 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
1193get endp ;AC000;
1194
1195
1196;------------------------------------------------------------------------------
1197; FILEEND - Check for EOF char on last read into large buffer (?)
1198;
1199; INPUT -
1200; OUTPUT -
1201;------------------------------------------------------------------------------
1202fileend 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
1216fileend 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;------------------------------------------------------------------------------
1225getf2 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
1234getf2 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;------------------------------------------------------------------------------
1246fill_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
1346fill_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;------------------------------------------------------------------------------
1356MakePathFromFcb 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
1393MakePathFromFcb 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;------------------------------------------------------------------------------
1403RestoreDir 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
1414RestoreDir 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;------------------------------------------------------------------------------
1426init_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
1439init_cp endp ;AN000;
1440
1441
1442;------------------------------------------------------------------------------
1443; RESTORE_CP - Restore chcp status (codepage support to original values)
1444;
1445; INPUT -
1446; OUTPUT -
1447;------------------------------------------------------------------------------
1448restore_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
1459restore_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;------------------------------------------------------------------------------
1469comp_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
1535comp_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;------------------------------------------------------------------------------
1545getcp 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
1584getcp endp ;AN000;
1585
1586
1587;------------------------------------------------------------------------------
1588; EXTERR - Displays the extended error message and filename.
1589;
1590; INPUT -
1591; OUTPUT -
1592;------------------------------------------------------------------------------
1593exterr 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;
1607exterr 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;------------------------------------------------------------------------------
1616bufferDB db 6 dup(0)
1617
1618get_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;
1658get_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;------------------------------------------------------------------------------
1671Check_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
1701DB_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
1708is_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;
1715is_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
1719is_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
1722is_again: ;AN006;
1723 add di,2 ;AN006; ;no, increment ptr to next range
1724 jmp is_loop ;AN006;
1725is_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; ; " " " " " " " "
1729DB_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
1743set_zero: ;AN006;
1744 cmp al,al ;AN006; ;set ZERO flag
1745 jmp short is_bye ;AC008; ;AN006;
1746reset_zero: ;AN006;
1747 mov bx,01h ;AN006;
1748 cmp bx,0ffh ;AN006; ;reset ZERO flag
1749is_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;
1758Check_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;------------------------------------------------------------------------------
1767sendmsg 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;
1805sendmsg 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
1815buf 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;------------------------------------------------------------------------------
1830setfill 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;
1846setfill 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;------------------------------------------------------------------------------
1856more_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
1882badmem:
1883 print_msg msgnum_mem,STDERR ;AN000; ;"INSUFFICIENT MEMORY"
1884 int 20h ;and quit
1885havmem:
1886 cmp dx,3840 ;over 61440 bytes avail?
1887 jbe cmem ;no
1888 mov dx,3840 ;yes, set to max of 61440 bytes
1889cmem:
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
1928more_init endp ;AN000;
1929
1930cseg ends
1931 end
1932 \ No newline at end of file
diff --git a/v4.0/src/CMD/COMP/COMPEQ.INC b/v4.0/src/CMD/COMP/COMPEQ.INC
new file mode 100644
index 0000000..5272927
--- /dev/null
+++ b/v4.0/src/CMD/COMP/COMPEQ.INC
@@ -0,0 +1,184 @@
1;*****************************************************************************
2;
3; MODULE: compeq.inc
4;
5; Modification History:
6;
7; version author date comment
8; ------- ------ ---- -------
9; V4.0 Bill L. 9/17/87 moved equates from comp2.sal to here!
10;
11;*****************************************************************************
12 if1 ;AN000;
13 %OUT INCLUDING COMPEQ.INC... ;AN000;
14 endif ;AN000;
15
16EAISBINARY equ 02h ;extended attribute is a binary integer ;AN001;
17EASYSTEM equ 8000h ;extended attr. is system defined ;AN001;
18
19VERSION EQU 00H ;DOS VERSION, =00H (NOT USED) ;AN000;
20NUL EQU 00H ;END OF STRING (ASCIIZ) MARKER ;AN000;
21ONE_PARM EQU 01H ;ONLY PARSE ONE PARAMETER ;AN000;
22ZERO_PARM_CT EQU 00H ;ORDINAL # BEFORE PARSING FIRST PARM. ;AN000;
23FIRST_PARM_CT EQU 01H ;ORDINAL # AFTER PARSING FIRST PARM. ;AN000;
24TRICK_PARM_CT EQU 02H ;TRICK PARSER SO THAT FILENAME GOES TO PATH2 ;AN000;
25 ;INSTEAD OF PATH1 ;AN000;
26YES EQU 01H ;A VALID YES RESPONSE EQUALS 1 ;AN000;
27KEYB_INP_CLR EQU 0C1H ; does an INT 21H fuction 0CH, 01H ;AN000;
28KEYB_INPUT EQU 0FFH ;DO A READ ON CLEAR KEYBOARD ;AN000;
29INPUT_LEN EQU 127 ;LENGTH OF INPUT BUFFER ON BUFFERED INPUT ;AN000;
30KEYIN EQU 01H ;WAIT FOR KEYBOARD INPUT TO AL ;AN000;
31DISP_OUT EQU 02H ;DL = CHAR TO BE DISPLAYED TO STD OUT ;AN000;
32DIRECT_IO EQU 06H ;DUMBY CALL, USED IN CLEARING KEYBOARD ;AN000;
33BUFFD_KEYBD EQU 0AH ;BUFFERED KEYBOARD INPUT TO DX ;AN000;
34IN_STAT EQU 0BH ;check keyboard status ;AC210;
35CLEAR_KEYBD EQU 0CH ;CLEAR KEYB, DO KEYB FUNC IN AL ;AN000;
36FCBOpen equ 0FH ;fcb open ;AN000;
37FCBCLOSE EQU 10H ;FCB CLOSE FILE ;AN000;
38SearchF equ 11H ;FCB Search function call ;AN000;
39SEARCHN EQU 12H ;FCB SEARCH NEXT ;AN000;
40SetDTA equ 1AH ;Set DTA ;AN000;
41DEFDRV equ 19H ;get default drive ;AN000;
42YESNO_CHECK EQU 23H ;CHECK (Y/N) RESPONSE ON INPUT (EXTENDED COUNTRY INFO) ;AN000;
43SETVECTOR equ 25H ;set interrupt vector in AL to DS:DX ;AN000;
44FCBRndBlkRead equ 27H ;Read function call ;AN000;
45PARSE_FILENAME EQU 29H ;PARSE FILENAME ;AN000;
46GETVER equ 30H ;get dos version ;AN000;
47CHDIR equ 3BH ;CHDIR function call ;AN000;
48HandleOpen equ 3DH ;Handle open function call ;AN000;
49HANDLECLOSE EQU 3EH ;HANDLE CLOSE FUNCTION CALL ;AN000;
50Write equ 40H ;Write function call ;AN000;
51CURDIR equ 47H ;get current directory for drive in [dl] ;AN000;
52RET_FN EQU 4CH ;"RETURN TO DOS" NOT REMAIN RESIDENT ;AN000;
53GET_EXT_CNTRY_INFO EQU 65H ;EXTENED COUNTRY INFO DOS CALL ;AN000;
54
55STDOUT equ 0001H ;Standard output device ;AN000;
56STDERR equ 0002H ;Standard error device ;AN000;
57
58ReadOnlyAccess equ 00H ;Access code for Handle Open function call ;AN000;
59
60CPSW_CHECK EQU 33H ;CODE PAGE SWITCHING CONTROL ;AN000;
61GET_CPSW_STATE EQU 03H ;AL=3, GET STATE TO DL ;AN000;
62SET_CPSW_STATE EQU 04H ;AL=4, SET STATE FROM DL ;AN000;
63CPSW_OFF EQU 00H ; DL=0, OFF ;AN000;
64CPSW_ON EQU 01H ; DL=1, ON ;AN000;
65CPSW EQU 40H ;IN CPSW_ORIG: ON, CPSW=ON ;AN000;
66ZERO_CP EQU 00H ; A ZERO CODE PAGE ;AN000;
67
68; EXTENDED OPEN EQUATES ; LOOK ;AN000;
69NO_ATTR_LIST EQU 00H ;NO ATTRIBUTE LIST NEEDED || ;AN000;
70OPEN_MODE EQU 82H ;OPEN MODE FOR EXTENDED OPEN || ;AN000;
71FUNC_CNTRL EQU 0101H ;FUNCTION CONTROL FOR EXTENDED OPEN || ;AN000;
72EXT_OPEN_RD EQU 00H ;READ MODE ON EXTENDED OPEN \/ ;AN000;
73EXT_OPEN EQU 6CH ;EXTENDED OPEN ;AN000;
74 ;AL=FUNCTION CONTROL, IN FORMAT=CE ;AN000;
75 ; C=DOES NOT EXIST ACTION: ;AN000;
76 ; 0=FAIL, 1=CREATE ;AN000;
77 ; E=EXISTS ACTION ;AN000;
78 ; 0=FAIL, 1=OPEN, 2=REPLACE/OPEN ;AN000;
79 ;BX=OPEN MODE, FORMAT=0WF00000ISSS0AAA ;AN000;
80 ; AAA=ACCESS CODE: 0=READ, 1=WRITE ;AN000;
81 ; 2=READ/WRITE, 4=EXECUTE (UNDOC) ;AN000;
82 ; 7=FCB (UNDOC) ;AN000;
83 ; SSS=SHARING MODE: 0=COMPATIBILITY ;AN000;
84 ; 1=DENY READ/WRITE, 2=DENY WRITE ;AN000;
85 ; 2=DENY READ, 3=DENY NONE ;AN000;
86 ; I=0, PASS HANDLE TO CHILD, 1=NO INHERIT ;AN000;
87 ; F=0, INT 24H, 1=RETURN ERROR ;AN000;
88 ;ON THIS OPEN AND ANY IO TO THIS HANDLE ;AN000;
89 ; W=0, NO COMMIT, 1=AUTO-COMMIT ON WRITE ;AN000;
90 ;CX=SCARCH/CREATE ATTRIBUTE ;AN000;
91 ;DX=FUNCTION CONTROL, 0000000C NNNNEEEE ;AN000;
92 ; NNNN=DOES NOT EXIST ACTION: ;AN000;
93 ; 0=FAIL,1=CREATE ;AN000;
94 ; EEEE=DOES EXIST ACTION: ;AN000;
95 ; 0=FAIL,1=OPEN,2=REPLACE/OPEN ;AN000;
96 ; C=CODEPAGE ACTION: ;AN000;
97 ; 0=VALIDATE, 1=NO CHECK CODE PAGE ;AN000;
98 ;DS:SI=PARM LIST: ;AN000;
99 ; DD POINT TO NAME TO OPEN ;AN000;
100 ; DB NUMBER OF ADDITIONAL PARMS ;AN000;
101 ; DB 1 IO MODE ;AN000;
102 ; DB IOMODE ;AN000;
103 ; ???0H=UNSPECIFIED (DEFAULT) ;AN000;
104 ; ???1H=MAINLY SEQUENTIAL ;AN000;
105 ; ???2H=MAINLY RANDOM ;AN000;
106 ; ???3H=RANDOM WITH LOCALITY ;AN000;
107 ; ???=RESERVED (SET TO ZERO) ;AN000;
108 ;ES:DI=EXTENTED ATTR LIST ;AN000;
109
110 ;OUTPUT: CY SET ON ERROR ;AN000;
111 ; AX=HANDLE ;AN000;
112 ; CX=ACTION TAKEN: 1=FILE OPENED, ;AN000;
113 ; 2=FILE CREATED/OPENED, ;AN000;
114 ; 3=FILE REPLACED/OPENED ;AN000;
115
116EXT_ATTR_LIST EQU 57H ;FUNCTION # : EXTENDED ATTR LIST ;AN000;
117GET_EXT_ATTR_LIST EQU 02H ;SUB-FUNC. # : GET EXTENDED ATTR TO LIST ;AN000;
118 ;BX=HANDLE ;AN000;
119 ;ES:DI=LIST ;AN000;
120 ;CY SET IF ERROR ;AN000;
121
122
123EXTERROR EQU 59H ;EXTENDED ERROR ;AN000;
124 ;BX = 40 VERSION NUMBER (FOR 3.40) ;AN000;
125 ;OUTPUT: ;AN000;
126 ;AX=EXTENDED ERROR ;AN000;
127 ;BH=ERROR CLASS ;AN000;
128 ;BL=SUGGESTED ACTION ;AN000;
129 ;CH=LOCUS ;AN000;
130
131; ERRORLEVEL RETURN CODES, PASSED IN "EXITFL" ;AN000;
132EXOK EQU 0 ;NORMAL RETURN CODE, NO PROBLEM ;AN000;
133EXCB EQU 1 ;CONTROL BREAK EXIT ;AN000;
134EXVER EQU 1 ;BAD DOS VERSION OR OTHER ;AN000;
135 ; SYSLOADMSG DIFFICULTY ;AN000;
136
137; VALUES FOR THE MSG_DESC CONTROL BLOCK ;AN000;
138NO_SUBS EQU 0 ;NO VARIABLE FIELDS IN MESSAGE ;AN000;
139ONE_SUBS EQU 1 ;ONE VARIABLE FIELD IN MESSAGE ;AN000;
140TWO_SUBS EQU 2 ;TWO VARIABLE FIELDS IN MESSAGE ;AN000;
141THREE_SUBS EQU 3 ;THREE VARIABLE FIELDS IN MESSAGE ;AN000;
142CLASS_1 EQU 1 ;CLASS 1 (DOS EXTENDED ERRORS) ;AN000;
143CLASS_2 EQU 2 ;CLASS 2 (PARSE ERRORS) ;AN000;
144CLASS_A EQU -1 ;CLASS A TYPE MESSAGE ;AN000;
145
146;***************************** ;AN000;
147; Message Retriever structures ;AN000;
148;***************************** ;AN000;
149
150msg_desc struc ;AN000;
151msg_num dw 0 ;MESSAGE NUMBER (TO AX) ;AN000;
152msg_handle dw STDOUT ;HANDLE OF OUTPUT DEVICE (TO BX) ;AN000;
153msg_sublist dw 0 ;POINTER TO SUBLIST (TO SI) ;AN000;
154msg_count dw 0 ;SUBSTITUTION COUNT (TO CX) ;AN000;
155msg_class dw CLASS_A shl 8 ;MESSAGE CLASS (IN HIGH BYTE, TO DH) ;AN000;
156 ;LOW BYTE HAS 0 (FUNCTION "NO INPUT", TO DL) ;AN000;
157msg_input dw ? ;######EXTRA WORD - ONLY FOR MESSAGES WITH BUFFERED INPUT ;AN000;
158 ;######OTHERWISE THIS WORD IS NOT VALID AS PART OF THE STRUCT ;AN000;
159 ;POINTER TO INPUT BUFFER ;AN000;
160msg_desc ends ;AN000;
161
162MAX_0 equ 0 ;MAXIMUM WIDTH OF STRING FIELD (0=NO LIMIT) ;AN000;
163PAD_BLK equ " " ;CHAR FOR PAD FIELD ;AN000;
164
165
166sublist struc ;AN000;
167sub_size db 11 ;SUBLIST SIZE (POINTER TO NEXT SUBLIST) ;AN000;
168sub_res db 0 ;RESERVED ;AN000;
169 ;NEXT FIELD IS TO BE USED AS A DOUBLE WORD ;AN000;
170sub_value dw 0 ;TIME, DATE, OR PTR TO DATA ITEM ;AN000;
171sub_value_seg dw 0 ;SEG ID OF PTR ;AN000;
172 ;(ABOVE FIELD MUST BE FILLED AT EXECUTION TIME ;AN000;
173 ; IF THIS IS A .COM FILE) ;AN000;
174sub_id db 0 ;N OF %N ;AN000;
175sub_flags db 0 ;DATA TYPE FLAGS ;AN000;
176sub_max_width db MAX_0 ;MAXIMUM FIELD WIDTH (0=UNLIMITED) ;AN000;
177sub_min_width db 0 ;MINIMUM FIELD WIDTH ;AN000;
178sub_pad_char db PAD_BLK ;CHARACTER FOR PAD FIELD ;AN000;
179 ; CAN BE " ", "0" OR ",". ;AN000;
180 ; "," CAUSES INSERTION OF THE ACTIVE ;AN000;
181 ; THOUSANDS SEPARATOR BETWEEN EVERY 3 DIGITS. ;AN000;
182sublist ends ;AN000;
183
184;end of COMPEQ.INC ;AN000;
diff --git a/v4.0/src/CMD/COMP/COMPMS.INC b/v4.0/src/CMD/COMP/COMPMS.INC
new file mode 100644
index 0000000..3ac0844
--- /dev/null
+++ b/v4.0/src/CMD/COMP/COMPMS.INC
@@ -0,0 +1,156 @@
1;:util COMP ;utility name ;AN000;
2;:class 1 ;DOS extended errors: ;AN000;
3;:class 2 ;parse errors: ;AN000;
4;; ;AN000;
5;:class A ;system messages ;AN000;
6; ;AN000;
7;:use 1 COMMON1 ;"Incorrect DOS version" ;AN000;
8;:use 2 EXTEND8 ;"Insufficient memory" ;AN000;
9;:use 3 PARSE10 ;"Invalid parameter" ;AN000;
10;:def 4 "10 Mismatches - ending compare",CR,LF ;AN000;
11;:use 5 EXTEND15 ;"Invalid drive specification" ;AN000;
12;:def 6 "Compare error at OFFSET %1",CR,LF ;AN000;
13;:def 7 "File 1 = %1",CR,LF ;AN000;
14;:def 8 "File 2 = %1",CR,LF ;AN000;
15;:def 9 "Eof mark not found",CR,LF ;AN000;
16;:def 10 "Files compare ok",CR,LF ;AN000;
17;:use 11 EXTEND2 ;"File not found" ;AN000;
18;:use 12 COMMON25 ;"Invalid path" ;AN000;
19;:use 13 EXTEND32 ;"Sharing violation" ;AN000;
20;:use 14 EXTEND4 ;"Too many open files" ;AN000;
21;:def 15 CR,LF,CR,LF,"Enter primary file name",CR,LF ;AN000;
22;:def 16 CR,LF,CR,LF,"Enter 2nd file name or drive id",CR,LF ;AN000;
23;:def 17 "Files are different sizes",CR,LF ;AN000;
24;:def 18 "Compare more files? (Y/N)",CR,LF ;AN000;
25;:def 19 "%1 and %2",CR,LF ;AN000;
26;:def 20 CR,LF ;AN000;
27;:use 21 EXTEND5 ;"Access Denied" ;AN000;
28;:use 22 EXTEND37 ;"Code page mismatch" ;AN000;
29;:DEF 23 "Files compare ok",CR,LF ;AN000;
30;:end ;AN000;
31; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ;AN000;
32 IF1 ;AN000;
33 %OUT COMPONENT=COMP, MODULE=COMPMS.INC... ;AN000;
34 ENDIF ;AN000;
35; $SALUT (0,13,18,22) ;AN000;
36; ;AN000;
37; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ;AN000;
38 HEADER <MESSAGE DESCRIPTORS FOR SPECIFIC MESSAGES> ;AN000;
39; ;AN000;
40; THE NEXT GROUP ARE ADDITIONAL CLASS "A" MESSAGES ;AN000;
41; SPECIFICALLY DEFINED FOR THE COMP UTILITY ;AN000;
42; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ;AN000;
43; ;AN000;
44; THIS IS SUBLIST FOR MSGNUM_EXTERR (A CLASS 1 MESSAGE) ;AN000;
45SUBLIST_EXTERR SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_0,SF_BITS<SF_LEFT,,SF_ASCIIZ,SF_CHAR>,MAX_0,MIN_1> ;AN000;
46 PUBLIC SUBLIST_EXTERR ;AN000;
47; ;AN000;
48; "Insufficient memory" ;AN000;
49MSGNUM_MEM MSG_DESC <2> ;AN000;
50 PUBLIC MSGNUM_MEM ;AN000;
51; ;AN000;
52; "invalid parameter" ;AN000;
53MSGNUM_PARA MSG_DESC <3> ;AN000;
54 PUBLIC MSGNUM_PARA ;AN000;
55; ;AN000;
56; "10 Mismatches - ending compare",CR,LF ;AN000;
57MSGNUM_TENMSG MSG_DESC <4> ;AN000;
58 PUBLIC MSGNUM_TENMSG ;AN000;
59; ;AN000;
60; "Invalid drive specification",CR,LF ;AN000;
61MSGNUM_BADDRV MSG_DESC <5,STDOUT> ;AN000;
62 PUBLIC MSGNUM_BADDRV ;AN000;
63; ;AN000;
64; "Compare error at OFFSET %1",CR,LF ;AN000;
65MSGNUM_BAD MSG_DESC <6,,SUBLIST_6,ONE_SUBS> ;AN000;
66SUBLIST_6 SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_1,SF_BITS<SF_LEFT,,SF_DWORD,SF_UN_BH>,MAX_0,MIN_1> ;AN000;
67; NOTE: ERROR NUMBER IS DWORD ;AN000;
68 PUBLIC MSGNUM_BAD,SUBLIST_6 ;AN000;
69; ;AN000;
70; "File 1 = %1",CR,LF ;AN000;
71MSGNUM_ADR MSG_DESC <7,,SUBLIST_7,ONE_SUBS> ;AN000;
72SUBLIST_7 SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_1,SF_BITS<SF_LEFT,,SF_BYTE,SF_UN_BH>,MAX_0,MIN_1> ;AN000;
73 PUBLIC MSGNUM_ADR,SUBLIST_7 ;AN000;
74; ;AN000;
75; "File 2 = %1",CR,LF ;AN000;
76MSGNUM_BDR MSG_DESC <8,,SUBLIST_8,ONE_SUBS> ;AN000;
77SUBLIST_8 SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_1,SF_BITS<SF_LEFT,,SF_BYTE,SF_UN_BH>,MAX_0,MIN_1> ;AN000;
78 PUBLIC MSGNUM_BDR,SUBLIST_8 ;AN000;
79; ;AN000;
80; "Eof mark not found",CR,LF ;AN000;
81MSGNUM_EOR MSG_DESC <9> ;AN000;
82 PUBLIC MSGNUM_EOR ;AN000;
83; ;AN000;
84; "Files compare ok",CR,LF ;AN000;
85MSGNUM_DONE MSG_DESC <10> ;AN000;
86 PUBLIC MSGNUM_DONE ;AN000;
87; ;AN000;
88; "%1 - File not found",CR,LF ;AN000;
89MSGNUM_FNF MSG_DESC <11,,SUBLIST_11,ONE_SUBS> ;AN000;
90SUBLIST_11 SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_0,SF_BITS<SF_LEFT,,SF_ASCIIZ,SF_CHAR>,MAX_0,MIN_1> ;AN000;
91 PUBLIC MSGNUM_FNF,SUBLIST_11 ;AN000;
92; ;AN000;
93; "%1 - Invalid path",CR,LF ;AN000;
94MSGNUM_BAD_PATH MSG_DESC <12,,SUBLIST_12,ONE_SUBS> ;AN000;
95SUBLIST_12 SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_0,SF_BITS<SF_LEFT,,SF_ASCIIZ,SF_CHAR>,MAX_0,MIN_1> ;AN000;
96 PUBLIC MSGNUM_BAD_PATH,SUBLIST_12 ;AN000;
97; ;AN000;
98; "%1 - File sharing conflict",CR,LF ;AN000;
99MSGNUM_SHARE MSG_DESC <13,,SUBLIST_13,ONE_SUBS> ;AN000;
100SUBLIST_13 SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_0,SF_BITS<SF_LEFT,,SF_ASCIIZ,SF_CHAR>,MAX_0,MIN_1> ;AN000;
101 PUBLIC MSGNUM_SHARE,SUBLIST_13 ;AN000;
102; ;AN000;
103; "Too many files open",CR,LF ;AN000;
104MSGNUM_TOO_MANY MSG_DESC <14> ;AN000;
105 PUBLIC MSGNUM_TOO_MANY ;AN000;
106; ;AN000;
107; CR,LF,CR,LF,"Enter primary file name",CR,LF ;AN000;
108MSGNUM_PRINAM MSG_DESC <15,,,,(CLASS_A SHL 8) OR DOS_BUF_KEYB_INP> ;AN000;
109 DW ? ;DEFINE EXTRA WORD FOR PTR TO INPUT BUFFER ;AN000;
110 ;IT WILL BE ACCESSED AS A FIELD OF THE ABOVE STRUCT ;AN000;
111 PUBLIC MSGNUM_PRINAM ;AN000;
112; ;AN000;
113; CR,LF,CR,LF,"Enter 2nd file name or drive id",CR,LF ;AN000;
114MSGNUM_SECNAM MSG_DESC <16,,,,(CLASS_A SHL 8) OR DOS_BUF_KEYB_INP> ;AN000;
115 DW ? ;DEFINE EXTRA WORD FOR PTR TO INPUT BUFFER ;AN000;
116 ;IT WILL BE ACCESSED AS A FIELD OF THE ABOVE STRUCT ;AN000;
117 PUBLIC MSGNUM_SECNAM ;AN000;
118; ;AN000;
119; "Files are different sizes",CR,LF ;AN000;
120MSGNUM_BADSIZ MSG_DESC <17> ;AN000;
121 PUBLIC MSGNUM_BADSIZ ;AN000;
122; ;AN000;
123; "Compare more files (Y/N) ?",CR,LF ;AN000;
124MSGNUM_NOTHER MSG_DESC <18,STDOUT,,,(CLASS_A SHL 8) OR 0C1H> ;AC210;;AD176;
125 PUBLIC MSGNUM_NOTHER ;AN000;
126; ;AN000;
127; "%1 and %2",CR,LF ;AN000;
128MSGNUM_AND_MSG MSG_DESC <19,,SUBLIST_19A,TWO_SUBS> ;AN000;
129SUBLIST_19A SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_1,SF_BITS<SF_LEFT,,SF_ASCIIZ,SF_CHAR>,MAX_0,MIN_1> ;AN000;
130SUBLIST_19B SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_2,SF_BITS<SF_LEFT,,SF_ASCIIZ,SF_CHAR>,MAX_0,MIN_1> ;AN000;
131 PUBLIC MSGNUM_AND_MSG,SUBLIST_19A,SUBLIST_19B ;AN000;
132; ;AN000;
133; CR,LF ;AN000;
134MSGNUM_CRLF MSG_DESC <20> ;AN000;
135 PUBLIC MSGNUM_CRLF ;AN000;
136; ;AN000;
137; "%1 - Access Denied",CR,LF ;AN000;
138MSGNUM_ACCESSDENIED MSG_DESC <21,,SUBLIST_21,ONE_SUBS> ;AN000;
139SUBLIST_21 SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_0,SF_BITS<SF_LEFT,,SF_ASCIIZ,SF_CHAR>,MAX_0,MIN_1> ;AN000;
140 PUBLIC MSGNUM_ACCESSDENIED,SUBLIST_21 ;AN000;
141; ;AN000;
142; "Code page mismatch" ;AN000;
143MSGNUM_CP_MISMATCH MSG_DESC <22> ;AN000;
144 PUBLIC MSGNUM_CP_MISMATCH ;AN000;
145; ;AN000;
146; "Files compare ok" ;AN000;
147MSGNUM_OK MSG_DESC <23> ;AN000;
148 PUBLIC MSGNUM_OK ;AN000;
149;
150;
151MSGNUM_PPARSE MSG_DESC <,STDERR,SUBLIST_24,ONE_SUBS,(CLASS_2 SHL 8)> ;AN000;
152SUBLIST_24 SUBLIST <,,FILL_OFF,FILL_SEG,PC_ID_0,SF_BITS<SF_LEFT,,SF_ASCIIZ,SF_CHAR>,MAX_0,MIN_1> ;AN000;
153 PUBLIC MSGNUM_PPARSE,SUBLIST_24 ;AN000;
154
155; ;AN000;
156;end of COMPMS.INC ;AN000;
diff --git a/v4.0/src/CMD/COMP/COMPP.ASM b/v4.0/src/CMD/COMP/COMPP.ASM
new file mode 100644
index 0000000..9f2bbba
--- /dev/null
+++ b/v4.0/src/CMD/COMP/COMPP.ASM
@@ -0,0 +1,130 @@
1 PAGE ,132 ;
2 TITLE COMPP.SAL - COMP SYSTEM COMMAND LINE PARSER
3;****************** START OF SPECIFICATIONS *****************************
4; MODULE NAME: COMPP.SAL
5;
6; DESCRIPTIVE NAME: Include the DOS system PARSER in the SEGMENT
7; configuration expected by the modules of COMP.
8;
9;FUNCTION: The common code of the DOS command line PARSER is optimized by
10; the setting of certain switches that cause the conditional
11; assembly of only the required portions of the common PARSER.
12; The segment registers are ASSUMED according to the type .COM.
13; The Common PARSER is then INCLUDEd.
14;
15; ENTRY POINT: SYSPARSE, near
16;
17; INPUT:
18; ES - has seg id of the SEGMENT
19; that contains the input control blocks,
20; defined below.
21;
22; DI - offset into ES of the PARMS INPUT BLOCK
23;
24; DS - has seg id of the SEGMENT
25; that contains the DOS input COMMAND
26; string, which is originally presented at 81h
27; in the PSP.
28;
29; SI - offset into DS of the text of the DOS input COMMAND string
30; as originally presented at 81H in the PSP.
31;
32; DX - zero
33;
34; CX - ordinal value, intially zero, updated on each subsequent call
35; to the value returned in CX on the previous call.
36;
37; CS - points to the segment containing the
38; INCLUDE PARSE.ASM statement
39;
40; DS - also points to the segment containing the INCLUDE
41; PARSE.ASM statement.
42;
43; EXIT-NORMAL: Output registers:
44; AX - return code:
45; RC_No_Error equ 0 ; No error
46; RC_EOL equ -1 ; End of command line
47;
48; DX - Offset into ES of the selected RESULT BLOCK.
49; BL - terminated delimiter code
50; CX - new operand ordinal
51; SI - set past scanned operand
52;
53; EXIT-ERROR: Output registers:
54; AX - return code:
55; RC_Too_Many equ 1 ; Too many operands
56; RC_Op_Missing equ 2 ; Required operand missing
57; RC_Not_In_SW equ 3 ; Not in switch list provided
58; RC_Not_In_Key equ 4 ; Not in keyword list provided
59; RC_Out_Of_Range equ 6 ; Out of range specified
60; RC_Not_In_Val equ 7 ; Not in value list provided
61; RC_Not_In_Str equ 8 ; Not in string list provided
62; RC_Syntax equ 9 ; Syntax error
63;
64; INTERNAL REFERENCES:
65; ROUTINES: SYSPARSE:near (INCLUDEd in PARSE.ASM)
66;
67; DATA AREAS: none
68;
69; EXTERNAL REFERENCES:
70; ROUTINES: none
71;
72; DATA AREAS: control blocks pointed to by input registers.
73;
74; NOTES:
75; This module should be processed with the SALUT preprocessor
76; with the re-alignment not requested, as:
77;
78; SALUT COMPP,NUL,;
79;
80; To assemble these modules, the alphabetical or sequential
81; ordering of segments may be used.
82;
83; For LINK instructions, refer to the PROLOG of the main module,
84; COMP1.ASM.
85;
86; REVISION HISTORY: A000 Version 4.00: add PARSER, System Message Handler,
87; Add compare of code page extended attribute, if present.
88;
89; COPYRIGHT: "The DOS COMP Utility"
90; "Version 4.0 (C)Copyright 1988 Microsoft"
91; "Licensed Material - Property of Microsoft"
92;
93;PROGRAM AUTHOR: DOS 4.0 Edwin M. K., Bill L.
94;
95;****************** END OF SPECIFICATIONS *****************************
96 IF1 ;AN000;
97 %OUT COMPONENT=COMP, MODULE=COMPP.SAL... ;AN000;
98 ENDIF ;AN000;
99
100CSEG SEGMENT PARA PUBLIC 'CODE' ;AN000;
101 ASSUME CS:CSEG,DS:CSEG,ES:CSEG,SS:CSEG ;AN000;
102
103 PUBLIC SYSPARSE ;SUBROUTINE ENTRY POINT ;AN000;
104
105FARSW EQU 0 ;CALL THE PARSER BY NEAR CALL ;AN000;
106DATESW EQU 0 ;SUPPRESS DATE CHECKING ;AN000;
107TIMESW EQU 0 ;SUPPRESS TIME CHECKING ;AN000;
108FILESW EQU 1 ;DO CHECK FILE SPECIFICATION ;AN000;
109CAPSW EQU 1 ;DO USE FILE TABLE CAPS ;AN000;
110CMPXSW EQU 0 ;SUPPRESS CHECKING COMPLEX LIST ;AN000;
111DRVSW EQU 1 ;DO SUPPORT DRIVE ONLY FORMAT ;AN000;
112QUSSW EQU 0 ;SUPPRESS SUPPORT OF QUOTED STRING FORMT ;AN000;
113NUMSW EQU 0 ;SUPPRESS CHECKING NUMERIC VALUE ;AN000;
114KEYSW EQU 0 ;SUPPRESS KEYWORD SUPPORT ;AN000;
115SWSW EQU 1 ;DO SUPPORT SWITCHES ;AN000;
116VAL1SW EQU 0 ;SUPPRESS SUPPORT OF VALUE DEFINITION 1 ;AN000;
117VAL2SW EQU 0 ;SUPPRESS SUPPORT OF VALUE DEFINITION 2 ;AN000;
118VAL3SW EQU 0 ;SUPPRESS SUPPORT OF VALUE DEFINITION 3 ;AN000;
119INCSW EQU 0 ;DON'T INCLUDE PSDATA.INC
120BASESW EQU 1 ;use DS to index off of for PSDATA
121
122 IF1 ;AN000;
123 %OUT COMPONENT=COMP, SUBCOMPONENT=PARSE, INCLUDED PARSE.ASM... ;AN000;
124 ENDIF ;AN000;
125
126 INCLUDE PSDATA.INC ;AN000;
127 INCLUDE PARSE.ASM ;AN000;
128CSEG ENDS ;AN000;
129 END ;AN000;
130 \ No newline at end of file
diff --git a/v4.0/src/CMD/COMP/COMPPAR.ASM b/v4.0/src/CMD/COMP/COMPPAR.ASM
new file mode 100644
index 0000000..e47ce55
--- /dev/null
+++ b/v4.0/src/CMD/COMP/COMPPAR.ASM
@@ -0,0 +1,410 @@
1 PAGE ,132 ;
2 TITLE COMPPAR.SAL - LOOK AT COMMAND LINE PARMS
3;****************** START OF SPECIFICATIONS *****************************
4; MODULE NAME: COMPPAR.SAL
5;
6; DESCRIPTIVE NAME: Handle the definition of the DOS command line parameters
7; and the interface to the DOS system PARSER.
8;
9;FUNCTION: The static data areas are prescribed by the DOS system PARSER
10; to define the several parameters presented to COMP. These
11; data areas are passed to the PARSER, and its responses checked
12; to determine the nature of the user's specifications. Any errors
13; found in the user's parameters are defined in messages back
14; to the user.
15;
16; ENTRY POINT: PARSER, near
17;
18; INPUT: (DOS COMMAND LINE PARAMETERS)
19;
20; [d:][path] COMP [d:][path][filenam1[.ext]] [d:][path][filenam2[.ext]]
21;
22; Where
23; [d:][path] before COMP to specify the drive and path that
24; contains the COMP command file.
25;
26; [d:][path][filenam1[.ext]] - to specify the FIRST (or primary)
27; file or group of files to be compared
28;
29; [d:][path][filenam2[.ext]] - to specify the SECOND file or group
30; of files to be compared with the corresponding file
31; from the FIRST group
32;
33; Global filename characters are allowed in both filenames,
34; and will cause all of the files matching the first filename
35; to be compared with the corresponding files from the second
36; filename. Thus, entering COMP A:*.ASM B:*.BAK will cause
37; each file from drive A: that has an extension of .ASM to be
38; compared with a file of the same name (but with an extension
39; of .BAK) from drive B:.
40;
41; If you enter only a drive specification, COMP will assume
42; all files in the current directory of the specified drive.
43; If you enter a path without a filename, COMP assumes all
44; files in the specified directory. Thus, COMP A:\LEVEL1
45; B:\LEVEL2 will compare all files in directory A:\LEVEL1 with
46; the files of the same names in directory B:\LEVEL2.
47;
48; If no parameters are entered with the COMP command, you will
49; be prompted for both. If the second parm is omitted, COMP
50; will prompt for it. If you simply press ENTER when prompted
51; for the second filename, COMP assumes *.* (all files
52; matching the primary filename), and will use the current
53; directory of the default drive.
54;
55; If no file matches the primary filename, COMP will prompt
56; again for both parameters.
57;
58;
59; Upon entry to PARSER in this module,
60; "CURRENT_PARM" = offset to start of parm text in command string
61; "ORDINAL" = initialized to zero
62; PSP+81H = text of DOS command line parms string
63;
64; EXIT-NORMAL: If a Code Page number was specified
65; BX = Offset to language table to be loaded
66; DX = Integer value of Code Page specified
67; If /STATUS (or /STA) was specified
68; BX = 0
69; If Question mark was specified
70; BX=-1
71;
72; EXIT-ERROR: If there was any problem with the parms,
73; the question mark is assumed, and the appropriate
74; PARSE error message is displayed.
75; The Errorlevel code of "EXPAR" (3), meaning: "PARM ERROR",
76; set in "EXITFL", is requested to be returned to the user.
77;
78; INTERNAL REFERENCES:
79; ROUTINES:
80; PARSE_ERROR:NEAR Display the appropriate Parse error message.
81;
82; DATA AREAS:
83; The several parameter control blocks, defined by the System
84; PARSER interface, defining the COMP parameters.
85;
86; EXTERNAL REFERENCES:
87; ROUTINES:
88; SENDMSG:NEAR Uses Msg Descriptor to drive message handler.
89; SYSPARSE:NEAR System Command Line Common Parser.
90;
91; DATA AREAS:
92; EXITFL:BYTE Errorlevel return code.
93; MSGNUM_PARSE:WORD Message descriptor for all parse errors.
94;
95; NOTES:
96; This module should be processed with the SALUT preprocessor
97; with the re-alignment not requested, as:
98;
99; SALUT COMPPAR,NUL
100;
101; To assemble these modules, the alphabetical or sequential
102; ordering of segments may be used.
103;
104; For LINK instructions, refer to the PROLOG of the main module,
105; COMP1.SAL.
106;
107; REVISION HISTORY:
108; A000 Version 4.0 : add PARSER, System Message Handler,
109; Add compare of extended attributes, if present.
110;
111; COPYRIGHT: The following notice is found in the OBJ code generated from
112; the "COMPSM.SAL" module:
113;
114; "The DOS COMP Utility"
115; "Version 4.0 (C) Copyright 1988 Microsoft"
116; "Licensed Material - Property of Microsoft"
117;
118;PROGRAM AUTHOR: Edwin M. K.
119; modified: Bill L.
120;****************** END OF SPECIFICATIONS *****************************
121 IF1 ;AN000;
122 %OUT COMPONENT=COMP, MODULE=COMPPAR.SAL... ;AN000;
123 ENDIF ;AN000;
124; = = = = = = = = = = = = ;AN000;
125HEADER MACRO TEXT ;;AN000;
126.XLIST ;;AN000;
127 SUBTTL TEXT ;;AN000;
128.LIST ;;AN000;
129 PAGE ;;AN000;
130 ENDM ;;AN000;
131; = = = = = = = = = = = = ;AN000;
132; $SALUT (4,23,28,36) ;AN000;
133
134 INCLUDE COMPEQ.INC ;AN000;
135; LOCAL EQUATES ;AN000;
136MAX_PATH_LEN EQU 64 ;MAX CHAR IN A PATH ;AN000;
137EXPAR EQU 1 ;RETURN TO DOS, INVALID DOS COMMAND LINE PARMS ;AN000;
138ZERO_PARM_CT EQU 0 ;ORDINAL VALUE BEFORE FIRST PARM FOUND ;AN000;
139FIRST_PARM_CT EQU 1 ;ORDINAL VALUE AFTER FIRST PARM FOUND ;AN000;
140NUL EQU 0 ;ASCIIZ STRING DELIMITER ;AN000;
141; = = = = = = = = = = = = ;AN000;
142; EXIT CODES FROM SYSPARSE (WHEN CY=0) ;AN000;
143
144SYSPRM_EX_OK EQU 0 ; no error ;AN000;
145SYSPRM_EX_MANY EQU 1 ; too many operands ;AN000;
146SYSPRM_EX_MISSING EQU 2 ; required operand missing ;AN000;
147SYSPRM_EX_NOT_SWLIST EQU 3 ; not in switch list provided ;AN000;
148SYSPRM_EX_NOT_KEYLIST EQU 4 ; not in keyword list provided ;AN000;
149SYSPRM_EX_RANGE EQU 6 ; out of range specified ;AN000;
150SYSPRM_EX_VALUE EQU 7 ; not in value list provided ;AN000;
151SYSPRM_EX_STRING EQU 8 ; not in string list provided ;AN000;
152SYSPRM_EX_SYNTAX EQU 9 ; syntax error ;AN000;
153SYSPRM_EX_EOL EQU -1 ; end of command line ;AN000;
154; = = = = = = = = = = = = ;AN000;
155 HEADER <STRUC - DEFINITIONS OF EXTERNAL CONTROL BLOCKS> ;AN000;
156PSP STRUC ;AN000;
157 DB 80H DUP (?) ;SKIP OVER FIRST HALF OF PSP ;AN000;
158PSP_PARMLEN DB ? ;NUMBER OF BYTES IN DOS COMMAND LINE ;AN000;
159PSP_COMMAND DB 127 DUP(?) ;TEXT OF DOS COMMAND LINE ;AN000;
160PSP ENDS ;AN000;
161; = = = = = = = = = = = = ;AN000;
162FILESPEC STRUC ;AN000;
163FS_DRIVE_ID DB ? ;DRIVE LETTER ;AN000;
164FS_COLON DB ":" ;COLON SEPARATOR ;AN000;
165FS_SLASH1 DB "\" ;LEADING BACKSLASH,START AT ROOT ;AN000;
166FS_PATH DB MAX_PATH_LEN DUP (0) ;TEXT OF PATH ;AN000;
167
168;LOCATION OF REMAINING FIELDS DEPENDS ON LENGTH OF ACTUAL PATH ;AN000;
169;POSITIONS SHOWN ARE FOR MAX PATH LENGTH ONLY ;AN000;
170
171FS_SLASH2 DB 0 ;TRAILING BACKSLASH ;AN000;
172FS_FNAME DB 8 DUP (0) ;FILENAME ;AN000;
173FS_PER DB 0 ;PERIOD END OF FILENAME ;AN000;
174FS_EXT DB 3 DUP (0) ;FILENAME EXTENSION ;AN000;
175FILESPEC ENDS ;AN000;
176; = = = = = = = = = = = = ;AN000;
177 HEADER <PARSING WORKAREAS> ;AN000;
178; $SALUT (4,14,19,36) ;AN000;
179CSEG SEGMENT PARA PUBLIC 'CODE' ;AN000;
180 ASSUME CS:CSEG,DS:CSEG,ES:CSEG,SS:CSEG ;AN000;
181
182 EXTRN SENDMSG:NEAR ;USES MSG DESCRIPTOR TO DRIVE MESSAGE HANDLR ;AN000;
183 EXTRN SYSPARSE:NEAR ;SYSTEM COMMAND LINE PARSER ;AN000;
184
185 EXTRN EXITFL:BYTE ;ERRORLEVEL RETURN CODE ;AN000;
186 EXTRN PATH1:BYTE ;FIRST POSITIONAL PARM ;AN000;
187 EXTRN PATH2:BYTE ;SECOND POSITIONAL PARM ;AN000;
188 EXTRN MSGNUM_PPARSE:WORD ;MESSAGE DESCRIPTOR FOR ALL PARSE ERRORS ;AN000;
189 EXTRN SUBLIST_24:WORD ;sublist for parse error messages ;AN000;
190; = = = = = = = = = = = = ;AN000;
191
192CURRENT_PARM DW 81H ;POINTER INTO COMMAND OF NEXT OPERAND ;AN000;
193 PUBLIC CURRENT_PARM ;AN000;
194
195ORDINAL DW 0 ;ORDINAL NUMBER OF WHICH PARM TO PARSE ;AN000;
196 PUBLIC ORDINAL ;AN000;
197
198PARM_COUNT DW 00H ;CURRENT PARM COUNT (USED TO TRICK "PARSER" ;AN000;
199 PUBLIC PARM_COUNT ;INTO PARSING FILE NAMES ENTERED FROM THE ;AN000;
200 ;KEYBOARD INSTEAD OF COMMAND LINE ;AN000;
201; = = = = = = = = = = = = ;AN000;
202 HEADER <DOS COMMAND LINE PARSER CONTROL BLOCKS> ;AN000;
203
204;INPUT PARAMETERS CONTROL BLOCK, POINTED TO BY ES:DI WHEN CALLING PARSER ;AN000;
205
206 PUBLIC PARMS ;LET LINK MAKE PARMS BLOCK ADDRESSABLE ;AN000;
207PARMS LABEL BYTE ;PARMS CONTROL BLOCK ;AN000;
208 DW PARMSX ;POINTER TO PARMS EXTENSION ;AN000;
209 DB 0 ; NUMBER OF STRINGS (0, 1, 2) ;AN000;
210 ; NEXT LIST WOULD BE EXTRA DELIM LIST ;AN000;
211 ; (,& WHITESPACE ALWAYS) ;AN000;
212 ; NEXT LIST WOULD BE EXTRA END OF LINE LIST ;AN000;
213 ; (CR,LF,0 ALWAYS) ;AN000;
214
215;SYSTEM PARSER PARAMETER EXTENSION CONTROL BLOCK ;AN000;
216PARMSX LABEL BYTE ;PARMS EXTENSION CONTROL BLOCK ;AN000;
217 DB 0,2 ; MIN, MAX POSITIONAL OPERANDS ALLOWED ;AN000;
218 DW CONTROL_POS ; DESCRIPTION OF POSITIONAL 1 ;AN000;
219 DW CONTROL_POS ; DESCRIPTION OF POSITIONAL 2 ;AN000;
220
221 DB 0 ; MAX SWITCH OPERANDS ALLOWED ;AN000;
222
223 DB 0 ; MAX KEYWORD OPERANDS ALLOWED ;AN000;
224 ; THERE IS NO CONTROL BLOCK ;AN000;
225 ; DEFINING KEYWORDS ;AN000;
226
227; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ;AN000;
228 HEADER <POSITIONAL PARM DESCRIPTOR BLOCK> ;AN000;
229;PARSER CONTROL BLOCK DEFINING THE ONLY POSITIONAL PARAMETER, OPTIONAL ;AN000;
230;BOTH POSITIONAL PARAMETER ARE: ;AN000;
231; [d:][path][filename[.ext]] ;AN000;
232
233 PUBLIC CONTROL_POS ;LET LINK MAKE THIS ADDRESSABLE ;AN000;
234CONTROL_POS LABEL BYTE ;FIRST POSITIONAL DESCRIPTOR FOR FILESPEC, ;AN000;
235 ; OPTIONAL ;AN000;
236 DW 0201H ; CONTROLS TYPE MATCHED ;AN000;
237 ; SELECTED BITS: "FILESPEC" AND "OPTIONAL" ;AN000;
238
239 ; 8000H=NUMERIC VALUE, (VALUE LIST WILL BE CHECKED) ;AN000;
240 ; 4000H=SIGNED NUMERIC VALUE (VALUE LIST WILL BE ;AN000;
241 ; CHECKED) ;AN000;
242 ; 2000H=SIMPLE STRING(VALUE LIST WILL BE CHECKED) ;AN000;
243 ; 1000H=DATE STRING (VALUE LIST WON'T BE CHECKED) ;AN000;
244 ; 0800H=TIME STRING (VALUE LIST WON'T BE CHECKED) ;AN000;
245 ; 0400H=COMPLEX LIST (VALUE LIST WON'T BE CHECKED) ;AN000;
246 ; 0200H=FILE SPEC (VALUE LIST WON'T BE CHECKED) ;AN000;
247 ; 0100H=DRIVE ONLY (VALUE LIST WON'T BE CHECKED) ;AN000;
248 ; 0080H=QUOTED STRING (VALUE LIST WON'T BE CHECKED) ;AN000;
249 ; 0010H=IGNORE ":" AT END IN MATCH ;AN000;
250 ; 0002H=REPEATS ALLOWED ;AN000;
251 ; 0001H=OPTIONAL ;AN000;
252
253 DW 0001H ;FUNCTION_FLAGS ;AN000;
254 ; 0001H=CAP RESULT BY FILE TABLE ;AN000;
255 ; 0002H=CAP RESULT BY CHAR TABLE ;AN000;
256 ; 0010H=REMOVE ":" AT END ;AN000;
257 DW RESULT1 ; RESULT BUFFER ;AN000;
258 DW NOVALS ; VALUE LISTS ;AN000;
259 DB 0 ; NUMBER OF KEYWORD/SWITCH SYNONYMS ;AN000;
260 ; IN FOLLOWING LIST ;AN000;
261
262; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ;AN000;
263;RESULTS CONTROL BLOCK FOR THE POSITIONAL PARAMETER ;AN000;
264RESULT1 LABEL BYTE ; BELOW FILLED IN FOR DEFAULTS ;AN000;
265 DB 5 ; TYPE RETURNED: 0=RESERVED, ;AN000;
266 ; 1=NUMBER, 2=LIST INDEX, ;AN000;
267 ; 3=STRING, 4=COMPLEX, ;AN000;
268 ; 5=FILESPEC, 6=DRIVE ;AN000;
269 ; 7=DATE, 8=TIME ;AN000;
270 ; 9=QUOTED STRING ;AN000;
271RESULT_TAG DB 0FFH ; MATCHED ITEM TAG ;AN000;
272 DW 0 ;POINTER TO SYNONYM ;AN000;
273
274RESULT_PTR1 DD ? ; OFFSET OF STRING VALUE ;AN000;
275
276; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ;AN000;
277;VALUE CONTROL BLOCK ;AN000;
278NOVALS LABEL BYTE ;AN000;
279 DB 0 ; NUMBER OF VALUE DEFINITIONS (0 - 3) ;AN000;
280
281; = = = = = = = = = = = = ;AN000;
282 HEADER <PARSER - ASK SYSPARM TO DECODE PARAMETERS> ;AN000;
283; $SALUT (4,4,9,36) ;AN000;
284PARSER PROC NEAR ;AN000;
285 PUBLIC PARSER ;AN000;
286
287;INPUT: "CURRENT_PARM" = OFFSET TO NEXT PARM IN COMMAND STRING ;AN000;
288; "ORDINAL" = COUNT OF NEXT PARM TO PARSE ;AN000;
289; PSP+81H = TEXT OF DOS COMMAND LINE PARMS STRING ;AN000;
290
291;OUTPUT: IF SPECIFIED, FIRST PARM GOES TO "PATH1". ;AN000;
292; IF SPECIFIED, SECOND PARM GOES TO "PATH2". ;AN000;
293; IF EITHER PARM MISSING, THEN "PATHn" STARTS WITH NUL CHAR. ;AN000;
294; CARRY SET IF ERROR. ;AN000;
295; = = = = = = = = = = = = ;AN000;
296
297; $SEARCH COMPLEX ;LOOP THRU COMMAND LINE ;AN000;
298 JMP SHORT $$SS1
299$$DO1:
300 ;LOOKING AT RETURN CODE FROM SYSPARSE... ;AN000;
301 AND AX,AX ;AN008; ;WERE THERE ANY ERRORS? ;AN000;
302; $EXITIF NE ;HAD A PROBLEM ;AN000;
303 JE $$IF1
304 CALL PARSE_ERROR ;DISPLAY REASON FOR ERROR ;AN000;
305 MOV AL,01h ;AN000; ;pass back errorlevel ret code
306 mov ah,4ch
307 int 21h
308; $ORELSE ;SINCE NO PROBLEM, SO FAR ;AN000;
309 JMP SHORT $$SR1
310$$IF1:
311 MOV ORDINAL,CX ;SAVE UPDATED COUNT ;AN000;
312 MOV CURRENT_PARM,SI ;REMEMBER HOW FAR I GOT ;AN000;
313 MOV BX,DX ;SET DATA BASE REG TO POINT TO ;AN000;
314 ;RESULT BUFFER OF THIS OPERAND ;AN000;
315
316 MOV SI,WORD PTR RESULT_PTR1 ;GET WHERE STRING IS PUT ;AN000;
317 ;GUESS, THIS IS THE FIRST PARM ;AN000;
318 MOV DI,OFFSET PATH1 ;GET WHERE STRING IS TO GO ;AN000;
319
320 ;IF PARSING FILENAME INPUTED FROM KEYBOARD ;AN000;
321 ;THEN PARM_COUNT MUST = ZERO_PARM_CT = 0 ;AN000;
322 CMP CX,PARM_COUNT ;IS THIS THE FIRST PARM OR JUST A FILENAME IN BUFFER ;AN000;
323
324; $IF NE ;NO, MUST BE THE SECOND PARM ;AN000;
325 JE $$IF4
326 ;MADE A BAD GUESS, FIX IT ;AN000;
327 MOV DI,OFFSET PATH2 ;CHANGE DEST TO WHERE SECOND STRING GOES ;AN000;
328; $ENDIF ;AN000;
329$$IF4:
330
331 ;MOVE ASCIIZ STRING FROM DS:SI ;AN000;
332 ;WHERE COMMAND PARSE PUT IT ;AN000;
333 ;TO ES:DI WHERE COMP2 USES IT ;AN000;
334
335; $DO COMPLEX ;AN000;
336 JMP SHORT $$SD6
337$$DO6:
338 STOSB ;PUT CHAR IN AL TO ES:DI ;AN000;
339; $STRTDO ;AN000;
340$$SD6:
341 LODSB ;GET CHAR FROM DS:SI TO AL ;AN000;
342 CMP AL,NUL ;IS THAT THE END OF STRING? ;AN000;
343; $ENDDO E ;IF SO, QUIT ;AN000;
344 JNE $$DO6
345
346; $STRTSRCH ;AN000;
347$$SS1:
348 LEA DI,PARMS ;ES:DI = PARSE CONTROL DEFINITON ;AN000;
349 MOV SI,CURRENT_PARM ;DS:SI = COMMAND STRING, NEXT PARM ;AN000;
350 XOR DX,DX ;RESERVED, INIT TO ZERO ;AN000;
351 MOV CX,ORDINAL ;OPERAND ORDINAL, INITIALLY ZERO ;AN000;
352 CALL SYSPARSE ;LOOK AT DOS PARMS ;AN000;
353 ;AX=EXIT CODE ;AN000;
354 ;BL=TERMINATED DELIMETER CODE ;AN000;
355 ;CX=NEW OPERAND ORDINAL ;AN000;
356 ;SI=SET TO PAST SCANNED OPERAND ;AN000;
357 ;DX=SELECTED RESULT BUFFER ;AN000;
358 CMP AX,SYSPRM_EX_EOL ;IS THAT THE END OF THE PARMS? ;AN000;
359 ;IF NOT, LOOP BACK AND FIND OUT ;AN000;
360 ;WHAT THAT PARM IS ;AN000;
361; $ENDLOOP E ;END OF LIST ;AN000;
362 JNE $$DO1
363 CLC ;RETURN FLAG FOR "NO ERROR" ;AN000;
364; $ENDSRCH ;FINISHED WITH DOS COMMAND LINE ;AN000;
365$$SR1:
366 RET ;RETURN TO CALLER ;AN000;
367PARSER ENDP ;AN000;
368; = = = = = = = = = = = = ;AN000;
369 HEADER <PARSE_ERROR - DISPLAY REASON FOR PARSE ERROR> ;AN000;
370PARSE_ERROR PROC NEAR ;AN000;
371
372;INPUT: "FIRST_TIME" - IF NON-ZERO, FORCE ERROR CODE TO "TOO MANY PARMS" ;AN000;
373; AX - ERROR NUMBER RETURNED FROM PARSE. ;AN000;
374;OUTPUT: APPROPRIATE ERROR MESSAGE IS DISPLAYED. ;AN000;
375; = = = = = = = = = = = = ;AN000;
376
377 MOV MSGNUM_PPARSE,AX ;PASS MESSAGE NUMBER TO DESCRIPTOR ;AN000;
378 MOV DX,OFFSET MSGNUM_PPARSE ;PASS MESSAGE DESCRIPTOR ;AN000;
379 MOV BX,CURRENT_PARM ;AN000;
380PE_BX: ;AN000;
381 CMP BX,SI ;are we past the point the parser stopped ? ;AN000;
382 JAE PE_BX_OK ;yes, we are done. ;AN000;
383 CMP BYTE PTR [BX],20H ;by-pass leading blanks ;AN000;
384 JNE PE_BX_OK ;AN000;
385 INC BX ;AN000;
386 JMP PE_BX ;AN000;
387PE_BX_OK: ;AN000;
388 MOV SUBLIST_24.SUB_VALUE,BX ;AN000;
389;
390;make a ASCIIZ string out of parameter
391;
392PE_LOOP: ;AN000;
393 CMP BX,SI ;are we past the point the parser stopped ? ;AN000;
394 JAE PE_OK ;yes, we are done. ;AN000;
395 CMP BYTE PTR [BX],20H ;check for spaec or end of line ;AN000;
396 JE PE_OK ;AN000;
397 INC BX ;AN000;
398 JMP PE_LOOP ;AN000;
399PE_OK: ;AN000;
400 MOV byte ptr [BX],00H ;end string with zero ;AN000;
401
402 CALL SENDMSG ;DISPLAY ERROR MESSAGE ;AN000;
403
404 MOV EXITFL,EXPAR ;ERRORLEVEL CODE TO "PARM ERROR" ;AN000;
405 RET ;RETURN TO CALLER ;AN000;
406PARSE_ERROR ENDP ;AN000; ;AN000;
407; = = = = = = = = = = = = ;AN000;
408CSEG ENDS ;AN000;
409 END ;AN000;
410 \ No newline at end of file
diff --git a/v4.0/src/CMD/COMP/COMPSM.ASM b/v4.0/src/CMD/COMP/COMPSM.ASM
new file mode 100644
index 0000000..9bf26ab
--- /dev/null
+++ b/v4.0/src/CMD/COMP/COMPSM.ASM
@@ -0,0 +1,159 @@
1 PAGE ,132 ;
2 TITLE COMPSM.SAL - COMP SYSTEM MESSAGES
3;****************** START OF SPECIFICATIONS *****************************
4; MODULE NAME: COMPSM.SAL
5;
6; DESCRIPTIVE NAME: Include the DOS system MESSAGE HANDLER in the SEGMENT
7; configuration expected by the modules of COMP.
8;
9;FUNCTION: The common code of the DOS SYSTEM MESSAGE HANDLER is made a
10; part of the COMP module by using INCLUDE to bring in the
11; common portion, in SYSMSG.INC. This included code contains
12; the routines to initialize for message services, to find
13; where a particular message is, and to display a message.
14;
15; ENTRY POINT: SYSDISPMSG:near
16; SYSGETMSG:near
17; SYSLOADMSG:near
18;
19; INPUT:
20; AX = MESSAGE NUMBER
21; BX = HANDLE TO DISPLAY TO (-1 means use DOS functions 1-12)
22; SI = OFFSET IN ES: OF SUBLIST, OR 0 IF NONE
23; CX = NUMBER OF %PARMS, 0 IF NONE
24; DX = CLASS IN HIGH BYTE, INPUT FUNCTION IN LOW
25; CALL SYSDISPMSG ;DISPLAY THE MESSAGE
26;
27; If carry set, extended error already called:
28; AX = EXTENDED MESSAGE NUMBER
29; BH = ERROR CLASS
30; BL = SUGGESTED ACTION
31; CH = LOCUS
32; _ _ _ _ _ _ _ _ _ _ _ _
33;
34; AX = MESSAGE NUMBER
35; DH = MESSAGE CLASS (1=DOS EXTENDED ERROR, 2=PARSE ERROR, -1=UTILITY MSG)
36; CALL SYSGETMSG ;FIND WHERE A MSG IS
37;
38; If carry set, error
39; CX = 0, MESSAGE NOT FOUND
40; If carry NOT set, ok, and resulting regs are:
41; CX = MESSAGE SIZE
42; DS:SI = MESSAGE TEXT
43; _ _ _ _ _ _ _ _ _ _ _ _
44;
45; CALL SYSLOADMSG ;SET ADDRESSABILITY TO MSGS, CHECK DOS VERSION
46; If carry not set:
47; CX = SIZE OF MSGS LOADED
48;
49; If carry is set, regs preset up for SYSDISPMSG, as:
50; AX = ERROR CODE IF CARRY SET
51; AX = 1, INCORRECT DOS VERSION
52; DH =-1, (Utility msg)
53; OR,
54; AX = 1, Error loading messages
55; DH = 0, (Message manager error)
56; BX = STDERR
57; CX = NO_REPLACE
58; DL = NO_INPUT
59;
60; EXIT-NORMAL: CARRY is not set
61;
62; EXIT-ERROR: CARRY is set
63; Call Get Extended Error for reason code, for SYSDISPMSG and
64; SYSGETMSG.
65;
66; INTERNAL REFERENCES:
67; ROUTINES: (Generated by the MSG_SERVICES macro)
68; SYSLOADMSG
69; SYSDISPMSG
70; SYSGETMSG
71;
72; DATA AREAS:
73; INCLUDED "COMPMS.INC" - message defining control blocks
74; INCLUDED "MSGHAN.INC" - Define STRUCs for msg control blocks
75; INCLUDE SYSMSG.INC ;Permit System Message handler definition
76;
77; EXTERNAL REFERENCES:
78; ROUTINES: none
79;
80; DATA AREAS: control blocks pointed to by input registers.
81;
82; NOTES:
83; This module should be processed with the SALUT preprocessor
84; with the re-alignment not requested, as:
85;
86; SALUT COMPSM,nul,;
87;
88; To assemble these modules, the alphabetical or sequential
89; ordering of segments may be used.
90;
91; For LINK instructions, refer to the PROLOG of the main module,
92; COMP1.ASM.
93;
94; REVISION HISTORY: A000 Version 4.0 : add PARSER, System Message Handler,
95; Add compare of code page extended attribute, if present.
96;
97; COPYRIGHT: "The DOS COMP Utility"
98; "Version 4.0 (C)Copyright 1988 Micorsoft "
99; "Licensed Material - Property of Microsoft "
100;
101;PROGRAM AUTHOR: DOS 3.20 Dave L.
102; DOS 3.30 modifications by Russ W.
103; DOS 4.0 modifications by Edwin M. K., Bill L.
104;****************** END OF SPECIFICATIONS *****************************
105; ;AN000;
106 IF1 ;AN000;
107 %OUT COMPONENT=COMP, MODULE=COMPSM.SAL... ;AN000;
108 ENDIF ;AN000;
109; = = = = = = = = = = = = ;AN000;
110; ;AN000;
111HEADER MACRO TEXT ;AN000;
112.XLIST ;AN000;
113 SUBTTL TEXT ;AN000;
114.LIST ;AN000;
115 PAGE ;AN000;
116 ENDM ;AN000;
117; = = = = = = = = = = = = ;AN000;
118 INCLUDE SYSMSG.INC ;PERMIT SYSTEM MESSAGE HANDLER DEFINITION ;AN000;
119 MSG_UTILNAME <COMP> ;IDENTIFY THE UTILITY ;AN000;
120; = = = = = = = = = = = = ;AN000;
121 HEADER <DEFINITION OF MESSAGES> ;AN000;
122; $SALUT (4,12,18,36) ;AN000;
123CSEG SEGMENT PARA PUBLIC 'CODE' ;AN000;
124 ASSUME CS:CSEG,DS:CSEG,ES:CSEG,SS:CSEG ;AN000;
125; ;AN000;
126 PUBLIC COPYRIGHT ;AN000;
127COPYRIGHT DB "The DOS COMP Utility" ;AN000;
128 INCLUDE MSGHAN.INC ;DEFINE THE MESSAGE HANDLER CONTROL BLOCKS ;AN000;
129 INCLUDE COMPMS.INC ;DEFINE THE MESSAGES, AND CONTROL BLOCKS ;AN000;
130 MSG_SERVICES <MSGDATA> ;AN000;
131; = = = = = = = = = = = = ;AN000;
132 HEADER <SYSTEM MESSAGE HANDLER> ;AN000;
133 PUBLIC SYSLOADMSG ;AN000;
134 PUBLIC SYSDISPMSG ;AN000;
135 PUBLIC SYSGETMSG ;AN000;
136; ;AN000;
137; MSG_SERVICES <LOADmsg,GETmsg,DISPLAYmsg,CHARmsg,INPUTmsg,NUMmsg> ;AN000;
138 ;DEFAULT=CHECK DOS VERSION ;AN000;
139 ;DEFAULT=NEARmsg ;AN000;
140 ;DEFAULT=INPUTmsg ;AN000;
141 ;DEFAULT=NUMmsg ;AN000;
142 ;DEFAULT=NO TIMEmsg ;AN000;
143 ;DEFAULT=NO DATEmsg ;AN000;
144.XLIST ;AN000;
145.XCREF ;AN000;
146 MSG_SERVICES <LOADmsg> ;AN000;
147 MSG_SERVICES <GETmsg> ;AN000;
148 MSG_SERVICES <DISPLAYmsg,CHARmsg,INPUTmsg,NUMmsg> ;AN000;
149.LIST ;AN000;
150.CREF ;AN000;
151; ;AN000;
152 MSG_SERVICES <COMP.CLA,COMP.CL1,COMP.CL2> ;TEXTS OF MESSAGES ;AN000;
153; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ;AN000;
154CSEG ENDS ;AN000;
155
156 include msgdcl.inc
157
158 END ;AN000;
159 \ No newline at end of file
diff --git a/v4.0/src/CMD/COMP/MAKEFILE b/v4.0/src/CMD/COMP/MAKEFILE
new file mode 100644
index 0000000..b1bfdde
--- /dev/null
+++ b/v4.0/src/CMD/COMP/MAKEFILE
@@ -0,0 +1,52 @@
1#************************* makefile for cmd\comp *************************
2
3msg =..\..\messages
4dos =..\..\dos
5inc =..\..\inc
6hinc =..\..\h
7
8#
9####################### dependencies begin here. #########################
10#
11
12all: comp.com
13
14comp.ctl: comp.skl \
15 $(msg)\$(COUNTRY).msg \
16
17comp1.obj: comp1.asm \
18 makefile
19
20comppar.obj: comppar.asm \
21 compeq.inc \
22 makefile
23
24compp.obj: compp.asm \
25 $(inc)\parse.asm \
26 makefile
27
28compsm.obj: compsm.asm \
29 $(inc)\copyrigh.inc \
30 $(inc)\versiona.inc \
31 $(inc)\sysmsg.inc \
32 $(inc)\msghan.inc \
33 comp.ctl \
34 comp.cl1 \
35 comp.cl2 \
36 comp.cla \
37 compms.inc \
38 makefile
39
40comp2.obj: comp2.asm \
41 compeq.inc \
42 makefile
43
44comp.com: comp1.obj \
45 comp.lnk \
46 comppar.obj \
47 compp.obj \
48 compsm.obj \
49 comp2.obj
50 link @comp.lnk
51 exe2bin comp.exe comp.com
52 del comp.exe