]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/DOS/ISEARCH.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / DOS / ISEARCH.ASM
1 ; SCCSID = @(#)isearch.asm 1.1 85/04/10
2 TITLE DOS_SEARCH - Internal SEARCH calls for MS-DOS
3 NAME DOS_SEARCH
4 ; Low level routines for doing local and NET directory searches
5 ;
6 ; DOS_SEARCH_FIRST
7 ; DOS_SEARCH_NEXT
8 ; RENAME_NEXT
9 ;
10 ; Revision history:
11 ;
12 ; Created: ARR 30 March 1983
13 ; A000 version 4.00 Jan. 1988
14 ; A001 PTM 3564 -- serach for fastopen
15
16 ;
17 ; get the appropriate segment definitions
18 ;
19 .xlist
20 include dosseg.asm
21
22 CODE SEGMENT BYTE PUBLIC 'CODE'
23 ASSUME SS:DOSGROUP,CS:DOSGROUP
24
25 .xcref
26 INCLUDE DOSSYM.INC
27 INCLUDE DEVSYM.INC
28 INCLUDE fastopen.inc
29 INCLUDE fastxxxx.inc
30 .cref
31 .list
32
33 Installed = TRUE
34
35 i_need NoSetDir,BYTE
36 i_need Creating,BYTE
37 i_need THISCDS,DWORD
38 i_need CURBUF,DWORD
39 i_need DMAADD,DWORD
40 i_need DummyCDS,128
41 i_need THISDPB,DWORD
42 i_need THISDRV,BYTE
43 i_need NAME1,BYTE
44 i_need ATTRIB,BYTE
45 i_need DIRSTART,WORD
46 i_need LASTENT,WORD
47 i_need FOUND_DEV,BYTE
48 I_need WFP_Start,WORD
49 i_need EXTERR_LOCUS,BYTE
50 i_need FastopenFlg,BYTE
51 I_need DOS34_FLAG,WORD
52
53 ; Inputs:
54 ; [WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
55 ; terminated)
56 ; [CURR_DIR_END] Points to end of Current dir part of string
57 ; ( = -1 if current dir not involved, else
58 ; Points to first char after last "/" of current dir part)
59 ; [THISCDS] Points to CDS being used
60 ; (Low word = -1 if NUL CDS (Net direct request))
61 ; [SATTRIB] Is attribute of search, determines what files can be found
62 ; [DMAADD] Points to 53 byte buffer
63 ; Function:
64 ; Initiate a search for the given file spec
65 ; Outputs:
66 ; CARRY CLEAR
67 ; The 53 bytes ot DMAADD are filled in as follows:
68 ;
69 ; LOCAL
70 ; Drive Byte (A=1, B=2, ...) High bit clear
71 ; NEVER STORE DRIVE BYTE AFTER found_it
72 ; 11 byte search name with Meta chars in it
73 ; Search Attribute Byte, attribute of search
74 ; WORD LastEnt value
75 ; WORD DirStart
76 ; 4 byte pad
77 ; 32 bytes of the directory entry found
78 ; NET
79 ; 21 bytes First byte has high bit set
80 ; 32 bytes of the directory entry found
81 ;
82 ; CARRY SET
83 ; AX = error code
84 ; error_no_more_files
85 ; No match for this file
86 ; error_path_not_found
87 ; Bad path (not in curr dir part if present)
88 ; error_bad_curr_dir
89 ; Bad path in current directory part of path
90 ; DS preserved, others destroyed
91
92 procedure DOS_SEARCH_FIRST,NEAR
93 DOSAssume CS,<DS>,"DOS_Search_First"
94 ASSUME ES:NOTHING
95
96 LES DI,[THISCDS]
97 CMP DI,-1
98 JNZ TEST_RE_NET
99 IF NOT Installed
100 transfer NET_SEQ_SEARCH_FIRST
101 ELSE
102 MOV AX,(multNET SHL 8) OR 25
103 INT 2FH
104 return
105 ENDIF
106
107 TEST_RE_NET:
108 TEST ES:[DI.curdir_flags],curdir_isnet
109 JZ LOCAL_SEARCH_FIRST
110 IF NOT Installed
111 transfer NET_SEARCH_FIRST
112 ELSE
113 MOV AX,(multNET SHL 8) OR 27
114 INT 2FH
115 return
116 ENDIF
117
118 LOCAL_SEARCH_FIRST:
119 EnterCrit critDisk
120 TEST [DOS34_FLAG],SEARCH_FASTOPEN ;AN000;
121 JZ NOFN ;AN000;
122 OR [FastOpenflg],Fastopen_Set ;AN000;
123 NOFN: ;AN000;
124 MOV [NoSetDir],1 ; if we find a dir, don't change to it
125 CALL CHECK_QUESTION ;AN000;;FO. is '?' in path
126 JNC norm_getpath ;AN000;;FO. no
127 AND [FastOpenflg],Fast_yes ;AN000;;FO. reset fastopen
128 norm_getpath:
129 invoke GetPath
130 getdone:
131 JNC find_check_dev
132 JNZ bad_path
133 OR CL,CL
134 JZ bad_path
135 find_no_more:
136 MOV AX,error_no_more_files
137 BadBye:
138 AND CS:[FastOpenflg],Fast_yes ;AN000;;FO. reset fastopen
139
140 STC
141 LeaveCrit critDisk
142 return
143
144 bad_path:
145 MOV AX,error_path_not_found
146 JMP BadBye
147
148 find_check_dev:
149 OR AH,AH
150 JNS found_entry
151 MOV [LastEnt],-1 ; Cause DOS_SEARCH_NEXT to fail
152 INC [Found_Dev] ; Tell DOS_RENAME we found a device
153 found_entry:
154 ;
155 ; We set the physical drive byte here Instead of after found_it; Doing
156 ; a search-next may not have wfp_start set correctly
157 ;
158 LES DI,[DMAADD]
159 MOV SI,WFP_Start ; get pointer to beginning
160 LODSB
161 SUB AL,'A'-1 ; logical drive
162 STOSB ; High bit not set (local)
163 found_it:
164 LES DI,[DMAADD]
165 INC DI
166 PUSH DS ;FO.;AN001; save ds
167 TEST [Fastopenflg],Set_For_Search ;FO.;AN001; from fastopen
168 JZ notfast ;FO.;AN001;
169 MOV SI,BX ;FO.;AN001;
170 MOV DS,WORD PTR [CURBUF+2] ;FO.;AN001;
171 JMP SHORT movmov ;FO.;AN001;
172
173
174 notfast:
175 MOV SI,OFFSET DOSGROUP:NAME1; find_buf 2 = formatted name
176 movmov:
177 ; Special E5 code
178 MOVSB
179 CMP BYTE PTR ES:[DI-1],5
180 JNZ NOTKANJB
181 MOV BYTE PTR ES:[DI-1],0E5H
182 NOTKANJB:
183
184 MOV CX,10
185 REP MOVSB
186 POP DS ;FO.;AN001; restore ds
187
188
189 MOV AL,[Attrib]
190 STOSB
191 PUSH AX ; Save AH device info
192 MOV AX,[LastEnt]
193 STOSW
194 MOV AX,[DirStart]
195 STOSW
196 ; 4 bytes of 21 byte cont structure left for NET stuff
197 ADD DI,4
198 POP AX ; Recover AH device info
199 OR AH,AH
200 JS DOSREL ; Device entry is DOSGROUP relative
201 CMP WORD PTR [CURBUF],-1
202 JNZ OKSTORE
203 TEST [FastOPenFlg],Set_For_Search ;AN000;;FO. from fastopen and is good
204 JNZ OKSTORE ;AN000;;FO.
205
206
207
208 ; The user has specified the root directory itself, rather than some
209 ; contents of it. We can't "find" that.
210 MOV WORD PTR ES:[DI-8],-1 ; Cause DOS_SEARCH_NEXT to fail by
211 ; stuffing a -1 at Lastent
212 JMP find_no_more
213
214 OKSTORE:
215 MOV DS,WORD PTR [CURBUF+2]
216 ASSUME DS:NOTHING
217 DOSREL:
218 MOV SI,BX ; SI-> start of entry
219
220 ; NOTE: DOS_RENAME depends on BX not being altered after this point
221
222 MOV CX,SIZE dir_entry
223 ;;;;; 7/29/86
224 MOV AX,DI ; save the 1st byte addr
225 REP MOVSB
226 MOV DI,AX ; restore 1st byte addr
227 CMP BYTE PTR ES:[DI],05H ; special char check
228 JNZ NO05
229 MOV BYTE PTR ES:[DI],0E5H ; convert it back to E5
230 NO05:
231
232 ;;;;; 7/29/86
233 AND CS:[FastOpenflg],Fast_yes ;AN000;;FO. reset fastopen
234 context DS
235 CLC
236 LeaveCrit critDisk
237 return
238
239 EndProc DOS_SEARCH_FIRST
240
241 BREAK <DOS_SEARCH_NEXT - scan for subsequent matches>
242
243 ; Inputs:
244 ; [DMAADD] Points to 53 byte buffer returned by DOS_SEARCH_FIRST
245 ; (only first 21 bytes must have valid information)
246 ; Function:
247 ; Look for subsequent matches
248 ; Outputs:
249 ; CARRY CLEAR
250 ; The 53 bytes at DMAADD are updated for next call
251 ; (see DOS_SEARCH_FIRST)
252 ; CARRY SET
253 ; AX = error code
254 ; error_no_more_files
255 ; No more files to find
256 ; DS preserved, others destroyed
257
258 procedure DOS_SEARCH_NEXT,NEAR
259 DOSAssume CS,<DS>,"DOS_Search_Next"
260 ASSUME ES:NOTHING
261
262 LES DI,[DMAADD]
263 MOV AL,ES:[DI]
264 TEST AL,80H ; Test for NET
265 JZ LOCAL_SEARCH_NEXT
266 IF NOT Installed
267 transfer NET_SEARCH_NEXT
268 ELSE
269 MOV AX,(multNET SHL 8) OR 28
270 INT 2FH
271 return
272 ENDIF
273
274 LOCAL_SEARCH_NEXT:
275 ;AL is drive A=1
276 MOV [EXTERR_LOCUS],errLOC_Disk
277 EnterCrit critDisk
278 MOV WORD PTR ThisCDS,OFFSET DOSGROUP:DummyCDS
279 MOV WORD PTR ThisCDS+2,CS
280 ADD AL,'A'-1
281 invoke InitCDS
282
283 ; invoke GetThisDrv ; Set CDS pointer
284
285 JC No_files ; Bogus drive letter
286 LES DI,[THISCDS] ; Get CDS pointer
287 LES BP,ES:[DI.curdir_devptr]; Get DPB pointer
288 invoke GOTDPB ; [THISDPB] = ES:BP
289
290 mov AL,ES:[BP.dpb_drive]
291 mov ThisDrv,AL
292
293 MOV WORD PTR [CREATING],0E500H
294 MOV [NoSetDir],1 ; if we find a dir, don't change to it
295 LDS SI,[DMAADD]
296 ASSUME DS:NOTHING
297 LODSB ; Drive Byte
298
299 ; DEC AL
300 ; MOV [THISDRV],AL
301
302 entry RENAME_NEXT ; Entry used by DOS_RENAME
303
304 context ES ; THIS BLOWS ES:BP POINTER TO DPB
305 MOV DI,OFFSET DOSGROUP:NAME1
306 MOV CX,11
307 REP MOVSB ; Search name
308 LODSB ; Attribute
309 MOV [ATTRIB],AL
310 LODSW ; LastEnt
311 OR AX,AX
312 JNS cont_load
313 No_files:
314 JMP find_no_more
315
316 cont_load:
317 PUSH AX ; Save LastEnt
318 LODSW ; DirStart
319 MOV BX,AX
320 context DS
321 LES BP,[THISDPB] ; Recover ES:BP
322 invoke SetDirSrch
323 JNC SEARCH_GOON
324 POP AX ; Clean stack
325 JMP No_files
326
327 SEARCH_GOON:
328 invoke StartSrch
329 POP AX
330 invoke GetEnt
331 JC No_files
332 invoke NextEnt
333 JC No_files
334 XOR AH,AH ; If Search_Next, can't be a DEV
335 JMP found_it
336
337 EndProc DOS_SEARCH_NEXT
338
339
340 ;Input: [WFP_START]= pointer to final path
341 ;Function: check '?' char
342 ;Output: carry clear, if no '?'
343 ; carry set, if '?' exists
344
345 procedure CHECK_QUESTION,NEAR ;AN000;
346 ASSUME ES:NOTHING,DS:NOTHING ;AN000;
347
348 PUSH CS ;AN000;;FO.
349 POP DS ;AN000;;FO. ds:si -> final path
350 MOV SI,[WFP_START] ;AN000;;FO.
351 getnext: ;AN000;
352 LODSB ;AN000;;FO. get char
353 OR AL,AL ;AN000;;FO. is it null
354 JZ NO_Question ;AN000;;FO. yes
355 CMP AL,'?' ;AN000;;FO. is '?'
356 JNZ getnext ;AN000;;FO. no
357 STC ;AN000;;FO.
358 NO_Question: ;AN000;
359 return ;AN000;;FO.
360
361 EndProc CHECK_QUESTION ;AN000;
362
363 CODE ENDS
364 END