Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

595 lines
17 KiB

  1. ;/*
  2. ; * Microsoft Confidential
  3. ; * Copyright (C) Microsoft Corporation 1991
  4. ; * All Rights Reserved.
  5. ; */
  6. ************************************************************
  7. ************************************************************
  8. ** **
  9. ** THIS FILE IS OBSOLETE, NO LONGER USED, DEFUNCT, **
  10. ** AND, IN FACT, DOESN'T EVEN EXIST. YOU ARE NOT **
  11. ** HERE. YOU MAY NOT BE ANYWHERE AT ALL. THIS **
  12. ** WHOLE THING COULDN'T POSSIBLY BE HAPPENING. **
  13. ** **
  14. ** See DIR.ASM for a reality check. **
  15. ** **
  16. ************************************************************
  17. ************************************************************
  18. page 80,132
  19. ; SCCSID = @(#)tcmd1a.asm 1.1 85/05/14
  20. ; SCCSID = @(#)tcmd1a.asm 1.1 85/05/14
  21. TITLE PART4 COMMAND Transient routines.
  22. ; Internal commands DIR,PAUSE,ERASE,TYPE,VOL,VER
  23. INCLUDE comsw.asm
  24. .xlist
  25. .xcref
  26. INCLUDE DOSSYM.INC
  27. INCLUDE comseg.asm
  28. INCLUDE comequ.asm ;AC000;
  29. include ioctl.inc ;AN000;
  30. .list
  31. .cref
  32. TRANDATA SEGMENT PUBLIC BYTE ;AC000;
  33. EXTRN BadCD_ptr:word
  34. EXTRN bits:word
  35. EXTRN Bytmes_ptr:word
  36. EXTRN comsw:word
  37. EXTRN dir_w_syn:word ;AC000;
  38. EXTRN dirdat_mo_day:word ;AC000;
  39. EXTRN dirdat_yr:word ;AC000;
  40. EXTRN dirdattim_ptr:word
  41. EXTRN dirhead_ptr:word
  42. EXTRN dirtim_hr_min:word ;AC000;
  43. EXTRN Dirmes_ptr:word
  44. EXTRN disp_file_size_ptr:word
  45. EXTRN Dmes_ptr:word
  46. EXTRN Extend_buf_ptr:word ;AN000;
  47. EXTRN msg_disp_class:byte ;AN000;
  48. EXTRN parse_dir:byte ;AC000;
  49. EXTRN slash_p_syn:word ;AC000;
  50. EXTRN string_buf_ptr:word
  51. EXTRN tab_ptr:word ;AC000;
  52. TRANDATA ENDS
  53. TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
  54. EXTRN bytes_free:word
  55. EXTRN charbuf:byte
  56. EXTRN COM:byte
  57. EXTRN Destisdir:byte
  58. EXTRN Desttail:word
  59. EXTRN dir_num:word
  60. EXTRN Dirbuf:byte
  61. EXTRN dirflag:byte ;AN015;
  62. EXTRN display_ioctl:word ;AC000;
  63. EXTRN display_mode:byte ;AC000;
  64. EXTRN filecnt:word
  65. EXTRN file_size_high:word
  66. EXTRN file_size_low:word
  67. EXTRN fullscr:word
  68. EXTRN ID:byte
  69. EXTRN lincnt:byte ;AC000;
  70. EXTRN linlen:byte
  71. EXTRN linperpag:word ;AC000;
  72. EXTRN msg_numb:word ;AN022;
  73. EXTRN parse1_addr:dword ;AC000;
  74. EXTRN parse1_syn:word ;AC000;
  75. EXTRN parse1_type:byte ;AC000;
  76. EXTRN pathcnt:word ;AN000;
  77. EXTRN pathpos:word ;AN000;
  78. EXTRN srcbuf:byte ;AC000;
  79. EXTRN string_ptr_2:word
  80. TRANSPACE ENDS
  81. TRANCODE SEGMENT PUBLIC BYTE
  82. ASSUME CS:TRANGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING
  83. ;---------------
  84. TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
  85. EXTRN arg:byte ; the arg structure!
  86. TRANSPACE ENDS
  87. ;---------------
  88. EXTRN cerror:near
  89. EXTRN std_printf:near
  90. PUBLIC catalog
  91. break Catalog - Directory command
  92. assume ds:trangroup,es:trangroup
  93. ;
  94. ; The DIR command displays the contents of a directory.
  95. ;
  96. ; ****************************************************************
  97. ; *
  98. ; * ROUTINE: CATALOG - display file(s) in directory
  99. ; *
  100. ; * FUNCTION: PARSE command line for drive, file, or path name.
  101. ; * DIR allows two switches, /P (pause) and /W (wide).
  102. ; * If an error occurs issue and error message and
  103. ; * transfer control to CERROR.
  104. ; *
  105. ; * INPUT: command line at offset 81H
  106. ; *
  107. ; * OUTPUT: none
  108. ; *
  109. ; ****************************************************************
  110. CATALOG:
  111. ;
  112. ; Set up DTA for dir search firsts
  113. ;
  114. mov dx,offset trangroup:Dirbuf ;AC000; Set Disk transfer address
  115. mov ah,Set_DMA ;AC000;
  116. int int_command ;AC000;
  117. ;
  118. ; Set up defaults for switches and parse the command line.
  119. ;
  120. mov msg_numb,0 ;AN022; initialize message flag
  121. mov di,offset trangroup:srcbuf ;AN000; get address of srcbuf
  122. mov [pathpos],di ;AN000; this is start of path
  123. mov [pathcnt],1 ;AN000; initialize length to 1 char
  124. mov al,star ;AN000; initialize srcbuf to *,0d
  125. stosb ;AN000;
  126. mov al,end_of_line_in ;AN000;
  127. stosb ;AN000;
  128. mov si,81H ;AN000; Get command line
  129. mov di,offset trangroup:parse_dir ;AN000; Get adderss of PARSE_DIR
  130. xor cx,cx ;AC000; clear counter for positionals
  131. mov ComSw,cx ;AC000; initialize flags
  132. mov bits,cx ;AC000; initialize switches
  133. mov linperpag,linesperpage ;AC000; Set default for lines per page
  134. mov linlen,normperlin ;AC000; Set number of entries per line
  135. mov lincnt,normperlin ;AC000;
  136. dirscan:
  137. xor dx,dx ;AN000;
  138. invoke parse_with_msg ;AC018; call parser
  139. cmp ax,end_of_line ;AN000; are we at end of line?
  140. jne dirscan_cont ;AN000; No - continue parsing
  141. jmp scandone ;AN000; yes - go process
  142. dirscan_cont:
  143. cmp ax,result_no_error ;AN000; did we have an error?
  144. jz dirscan_cont2 ;AN000; No - continue parsing
  145. jmp badparm ;AN000; yes - exit
  146. dirscan_cont2:
  147. cmp parse1_syn,offset trangroup:dir_w_syn ;AN000; was /W entered?
  148. je set_dir_width ;AN000; yes - go set wide lines
  149. cmp parse1_syn,offset trangroup:slash_p_syn ;AN000; was /P entered?
  150. je set_dir_pause ;AN000; yes - go set pause at end of screen
  151. ;
  152. ; Must be filespec since no other matches occurred. move filename to srcbuf
  153. ;
  154. push si ;AC000; save position in line
  155. lds si,parse1_addr ;AC000; get address of filespec
  156. push si ;AN000; save address
  157. invoke move_to_srcbuf ;AC000; move to srcbuf
  158. pop dx ;AC000; get address in DX
  159. ;
  160. ; The user may have specified a device. Search for the path and see if the
  161. ; attributes indicate a device.
  162. ;
  163. mov ah,Find_First ;AC000; find the file
  164. int int_command ;AC000;
  165. jnc Dir_check_device ;AN022; if no error - check device
  166. invoke get_ext_error_number ;AN022; get the extended error
  167. cmp ax,error_no_more_files ;AN022; was error no file found
  168. jz Dir_fspec_end ;AC022; yes -> obviously not a device
  169. cmp ax,error_path_not_found ;AN022; was error no file found
  170. jz Dir_fspec_end ;AC022; yes -> obviously not a device
  171. jmp dir_err_setup ;AN022; otherwise - go issue error message
  172. dir_check_device: ;AN022;
  173. test byte ptr (DirBuf+find_buf_attr),attr_device ;AC000;
  174. jz Dir_fspec_end ;AC000; no, go do normal operation
  175. mov ComSw,-2 ;AC000; signal device
  176. dir_fspec_end:
  177. pop si ;AC000; restore position in line
  178. jmp short dirscan ;AC000; keep parsing
  179. set_dir_width:
  180. test byte ptr[bits],SwitchW ;AN018; /W already set?
  181. jz ok_set_width ;AN018; no - okay to set width
  182. mov ax,moreargs_ptr ;AN018; set up too many arguments
  183. invoke setup_parse_error_msg ;AN018; set up an error message
  184. jmp badparm ;AN018; exit
  185. ok_set_width:
  186. or bits,switchw ;AC000; indicate /w was selected
  187. mov linlen,wideperlin ;AC000; Set number of entries per line
  188. mov lincnt,wideperlin ;AC000;
  189. jmp short dirscan ;AC000; keep parsing
  190. set_dir_pause:
  191. test byte ptr[bits],SwitchP ;AN018; /p already set?
  192. jz ok_set_pause ;AN018; no - okay to set width
  193. mov ax,moreargs_ptr ;AN018; set up too many arguments
  194. invoke setup_parse_error_msg ;AN018; set up an error message
  195. jmp badparm ;AN018; exit
  196. ok_set_pause:
  197. or bits,switchp ;AC000; indicate /p was selected
  198. push cx ;AN000; save necessary registers
  199. push si ;AN000;
  200. mov ax,(IOCTL SHL 8) + generic_ioctl_handle ;AN000; get lines per page on display
  201. mov bx,stdout ;AN000; lines for stdout
  202. mov ch,ioc_sc ;AN000; type is display
  203. mov cl,get_generic ;AN000; get information
  204. mov dx,offset trangroup:display_ioctl ;AN000;
  205. int int_command ;AN000;
  206. lines_set:
  207. dec linperpag ;AN000; lines per actual page should
  208. dec linperpag ;AN000; two less than the max
  209. mov ax,linperpag ;AN000; get number of lines into
  210. mov [fullscr],ax ;AC000; screen line counter
  211. pop si ;AN000; restore registers
  212. pop cx ;AN000;
  213. jmp dirscan ;AC000; keep parsing
  214. ;
  215. ; The syntax is incorrect. Report only message we can.
  216. ;
  217. BadParm:
  218. jmp cerror ;AC000; invalid switches get displayed
  219. ScanDone:
  220. ;
  221. ; Find and display the volume ID on the drive.
  222. ;
  223. invoke okvolarg ;AC000;
  224. ;
  225. ; OkVolArg also disables APPEND, which will be re-enabled
  226. ; in the HeadFix routine, after we're done.
  227. ;
  228. mov [filecnt],0 ;AC000; Keep track of how many files found
  229. cmp comsw,0 ;AC000; did an error occur?
  230. jnz doheader ;AC000; yes - don't bother to fix path
  231. mov dirflag,-1 ;AN015; set pathcrunch called from DIR
  232. invoke pathcrunch ;AC000; set up FCB for dir
  233. mov dirflag,0 ;AN015; reset dirflag
  234. jc DirCheckPath ;AC015; no CHDIRs worked.
  235. jz doheader ;AC015; chdirs worked - path\*.*
  236. mov si,[desttail] ;AN015; get filename back
  237. jmp short DoRealParse ;AN015; go parse it
  238. DirCheckPath:
  239. mov ax,[msg_numb] ;AN022; get message number
  240. cmp ax,0 ;AN022; Is there a message?
  241. jnz dir_err_setup ;AN022; yes - there's an error
  242. cmp [destisdir],0 ;AC000; Were pathchars found?
  243. jz doparse ;AC000; no - no problem
  244. inc comsw ;AC000; indicate error
  245. jmp short doheader ;AC000; go print header
  246. DirNF:
  247. mov ax,error_file_not_found ;AN022; get message number in control block
  248. dir_err_setup:
  249. mov msg_disp_class,ext_msg_class ;AN000; set up extended error msg class
  250. mov dx,offset TranGroup:Extend_Buf_ptr ;AC000; get extended message pointer
  251. mov extend_buf_ptr,ax ;AN022;
  252. DirError:
  253. jmp Cerror
  254. ;
  255. ; We have changed to something. We also have a file. Parse it into a
  256. ; reasonable form, leaving drive alone, leaving extention alone and leaving
  257. ; filename alone. We need to special case ... If we are at the root, the
  258. ; parse will fail and it will give us a file not found instead of file not
  259. ; found.
  260. ;
  261. DoParse:
  262. mov si,offset trangroup:srcbuf ;AN000; Get address of source
  263. cmp byte ptr [si+1],colon_char ;AN000; Is there a drive?
  264. jnz dir_no_drive ;AN000; no - keep going
  265. lodsw ;AN000; bypass drive
  266. dir_no_drive:
  267. cmp [si],".."
  268. jnz DoRealParse
  269. cmp byte ptr [si+2],0
  270. jnz DoRealParse
  271. inc ComSw
  272. jmp short DoHeader
  273. DoRealParse:
  274. mov di,FCB ; where to put the file name
  275. mov ax,(Parse_File_Descriptor SHL 8) OR 0EH
  276. int int_command
  277. ;
  278. ; Check to see if APPEND installed. If it is installed, set all flags
  279. ; off. This will be reset in the HEADFIX routine
  280. ;
  281. DoHeader:
  282. ; ORIGINAL APPEND CHECK CODE LOCATION ******************************
  283. ;
  284. ; Display the header
  285. ;
  286. DoHeaderCont:
  287. mov al,blank ;AN051; Print out a blank
  288. invoke print_char ;AN051; before DIR header
  289. invoke build_dir_string ; get current dir string
  290. mov dx,offset trangroup:Dirhead_ptr
  291. invoke printf_crlf ; bang!
  292. ;
  293. ; If there were chars left after parse or device, then invalid file name
  294. ;
  295. cmp ComSw,0
  296. jz DoSearch ; nothing left; good parse
  297. jl DirNFFix ; not .. => error file not found
  298. invoke RestUDir
  299. mov dx,offset TranGroup:BadCD_ptr
  300. jmp Cerror ; was .. => error directory not found
  301. DirNFFix:
  302. invoke RestUDir
  303. jmp DirNF
  304. ;
  305. ; We are assured that everything is correct. Let's go and search. Use
  306. ; attributes that will include finding directories. perform the first search
  307. ; and reset our directory afterward.
  308. ;
  309. DoSearch:
  310. mov byte ptr DS:[FCB-7],0FFH
  311. mov byte ptr DS:[FCB-1],010H
  312. ;
  313. ; Caution! Since we are using an extended FCB, we will *also* be returning
  314. ; the directory information as an extended FCB. We must bias all fetches into
  315. ; DIRBUF by 8 (Extended FCB part + drive)
  316. ;
  317. mov ah,Dir_Search_First
  318. mov dx,FCB-7
  319. int int_command
  320. push ax ;AN022; save return state
  321. inc al ;AN022; did an error occur?
  322. pop ax ;AN022; get return state back
  323. jnz found_first_file ;AN022; no error - start dir
  324. invoke set_ext_error_msg ;AN022; yes - set up error message
  325. push dx ;AN022; save message
  326. invoke restudir ;AN022; restore user's dir
  327. pop dx ;AN022; restore message
  328. cmp word ptr Extend_Buf_Ptr,Error_No_More_Files ;AN022; convert no more files to
  329. jnz DirCerrorJ ;AN022; file not found
  330. mov Extend_Buf_Ptr,Error_File_Not_Found ;AN022;
  331. DirCerrorJ: ;AN022;
  332. jmp Cerror ;AN022; exit
  333. ;
  334. ; Restore the user's directory. We preserve, though, the return from the
  335. ; previous system call for later checking.
  336. ;
  337. found_first_file:
  338. push ax
  339. invoke restudir
  340. pop ax
  341. ;
  342. ; Main scanning loop. Entry has AL = Search first/next error code. Test for
  343. ; no more.
  344. ;
  345. DIRSTART:
  346. inc al ; FF = file not found
  347. jnz Display
  348. jmp DirDone ; Either an error or we are finished
  349. ;
  350. ; Note that we've seen a file and display the found file.
  351. ;
  352. Display:
  353. inc [filecnt] ; Keep track of how many we find
  354. mov si,offset trangroup:dirbuf+8 ; SI -> information returned by sys call
  355. call shoname
  356. ;
  357. ; If we are displaying in wide mode, do not output the file info
  358. ;
  359. test byte ptr[bits],SwitchW ; W switch set?
  360. jz DirTest
  361. jmp nexent ; If so, no size, date, or time
  362. ;
  363. ; Test for directory.
  364. ;
  365. DirTest:
  366. test [dirbuf+8].dir_attr,attr_directory
  367. jz fileent
  368. ;
  369. ; We have a directory. Display the <DIR> field in place of the file size
  370. ;
  371. mov dx,offset trangroup:Dmes_ptr
  372. call std_printf
  373. jmp short nofsiz
  374. ;
  375. ; We have a file. Display the file size
  376. ;
  377. fileent:
  378. mov dx,[DirBuf+8].dir_size_l
  379. mov file_size_low,dx
  380. mov dx,[DirBuf+8].dir_size_h
  381. mov file_size_high,dx
  382. mov dx,offset trangroup:disp_file_size_ptr
  383. call std_printf
  384. ;
  385. ; Display time and date of last modification
  386. ;
  387. nofsiz:
  388. mov ax,[DirBuf+8].dir_date ; Get date
  389. ;
  390. ; If the date is 0, then we have found a 1.x level diskette. We skip the
  391. ; date/time fields as 1.x did not have them.
  392. ;
  393. or ax,ax
  394. jz nexent ; Skip if no date
  395. mov bx,ax
  396. and ax,1FH ; get day
  397. mov dl,al
  398. mov ax,bx
  399. mov cl,5
  400. shr ax,cl ; Align month
  401. and al,0FH ; Get month
  402. mov dh,al
  403. mov cl,bh
  404. shr cl,1 ; Align year
  405. xor ch,ch
  406. add cx,80 ; Relative 1980
  407. cmp cl,100
  408. jb millenium
  409. sub cl,100
  410. millenium:
  411. xchg dh,dl ;AN000; switch month & day
  412. mov DirDat_yr,cx ;AC000; put year into message control block
  413. mov DirDat_mo_day,dx ;AC000; put month and day into message control block
  414. mov cx,[DirBuf+8].dir_time ; Get time
  415. jcxz prbuf ; Time field present?
  416. shr cx,1
  417. shr cx,1
  418. shr cx,1
  419. shr cl,1
  420. shr cl,1 ; Hours in CH, minutes in CL
  421. xchg ch,cl ;AN000; switch hours & minutes
  422. mov DirTim_hr_min,cx ;AC000; put hours and minutes into message subst block
  423. prbuf:
  424. mov dx,offset trangroup:DirDatTim_ptr
  425. call std_printf
  426. invoke crlf2 ;AC066;end the line
  427. dec byte ptr [fullscr] ;AC066;count the line
  428. jnz endif04 ;AN066;IF the last on the screen THEN
  429. call check_for_P ;AN066; pause if /P requested
  430. endif04: ;AN066;
  431. jmp scroll ; If not, just continue
  432. ;AD061; mov DirDat_yr,0 ;AC000; reset year, month and day
  433. ;AD061; mov DirDat_mo_day,0 ;AC000; in control block
  434. ;AD061; mov DirTim_hr_min,0 ;AC000; reset hour & minute in control block
  435. ;
  436. ; We are done displaying an entry. The code between "noexent:" and "scroll:"
  437. ; is only for /W case.
  438. ;
  439. nexent:
  440. mov bl,[lincnt] ;AN066;save for check for first entry on line
  441. dec [lincnt] ;count this entry on the line
  442. jnz else01 ;AX066;IF last entry on line THEN
  443. mov al,[linlen]
  444. mov [lincnt],al
  445. invoke crlf2
  446. cmp [fullscr],0 ;AC066;IF have filled the screen THEN
  447. jnz endif02 ;AN066;
  448. call check_for_P ;AN066; reinitialize fullscr,
  449. endif02: ;AN066; IF P requested THEN pause
  450. jmp short endif01 ;AN066;
  451. else01: ;AN066;ELSE since screen not full
  452. cmp bl,[linlen] ;AN066; IF starting new line THEN
  453. jne endif03 ; count the line
  454. dec byte ptr [fullscr] ;AN066; ENDIF
  455. endif03: ;AC066;We are outputting on the same line, between fields, we tab.
  456. mov dx,offset trangroup:tab_ptr ;Output a tab
  457. call std_printf
  458. endif01: ;AX066;
  459. ;
  460. ; All we need to do now is to get the next directory entry.
  461. ;
  462. scroll:
  463. mov ah,Dir_Search_Next
  464. mov dx,FCB-7 ; DX -> Unopened FCB
  465. int int_command ; Search for a file to match FCB
  466. jmp DirStart
  467. ;
  468. ; If no files have been found, display a not-found message
  469. ;
  470. DirDone:
  471. invoke get_ext_error_number ;AN022; get the extended error number
  472. cmp ax,error_no_more_files ;AN022; was error file not found?
  473. jnz dir_err_setup_jmp ;AN022; no - setup error message
  474. test [filecnt],-1
  475. jnz Trailer
  476. mov ax,error_file_not_found ;AN022;
  477. dir_err_setup_jmp: ;AN022;
  478. jmp dir_err_setup ;AN022; go setup error msg & print it
  479. ;
  480. ; If we have printed the maximum number of files per line, terminate it with
  481. ; CRLF.
  482. ;
  483. Trailer:
  484. mov al,[linlen]
  485. cmp al,[lincnt] ; Will be equal if just had CR/LF
  486. jz mmessage
  487. invoke crlf2
  488. cmp [fullscr],0 ;AN066;IF on last line of screen THEN
  489. jnz endif06 ;AN066; pause before going on
  490. call check_for_P ;AN066; to number and freespace
  491. endif06: ;AN066; displays
  492. mmessage:
  493. mov dx,offset trangroup:Dirmes_ptr
  494. mov si,[filecnt]
  495. mov dir_num,si
  496. call std_printf
  497. mov ah,Get_Drive_Freespace
  498. mov dl,byte ptr DS:[FCB]
  499. int int_command
  500. cmp ax,-1
  501. retz
  502. mul cx ; AX is bytes per cluster
  503. mul bx
  504. mov bytes_free,ax ;AC000;
  505. mov bytes_free+2,dx ;AC000;
  506. MOV DX,OFFSET TRANGROUP:BYTMES_ptr
  507. jmp std_printf
  508. shoname:
  509. mov di,offset trangroup:charbuf
  510. mov cx,8
  511. rep movsb
  512. mov al,' '
  513. stosb
  514. mov cx,3
  515. rep movsb
  516. xor ax,ax
  517. stosb
  518. push dx
  519. mov dx,offset trangroup:charbuf
  520. mov string_ptr_2,dx
  521. mov dx,offset trangroup:string_buf_ptr
  522. call std_printf
  523. pop DX
  524. return
  525. check_for_P PROC NEAR ;AN066;
  526. test byte ptr[bits],SwitchP ;P switch present?
  527. jz endif05 ;AN066;
  528. mov ax,linperpag ;AN000; transfer lines per page
  529. mov [fullscr],ax ;AC000; to fullscr
  530. invoke Pause
  531. endif05:
  532. ret ;AN066;
  533. check_for_P ENDP ;AN066;
  534. trancode ends
  535. end
  536.