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.

302 lines
8.4 KiB

  1. page 60,132;
  2. title EDLPARSE for EDLIN
  3. ;/*
  4. ; * Microsoft Confidential
  5. ; * Copyright (C) Microsoft Corporation 1991
  6. ; * All Rights Reserved.
  7. ; */
  8. ;******************* START OF SPECIFICATIONS *****************************
  9. ;
  10. ; MODULE NAME: EDLPARSE.SAL
  11. ;
  12. ; DESCRIPTIVE NAME: PARSES THE EXTERNAL COMMAND LINE FOR EDLIN
  13. ;
  14. ; FUNCTION: THIS ROUTINE PROVIDES PARSING CAPABILITIES FOR THE
  15. ; EXTERNAL COMMAND LINE OF EDLIN. IT PARSES FOR THE PRESENCE
  16. ; OF A REQUIRED FILESPEC AND AN OPTIONAL SWITCH (/B).
  17. ;
  18. ; ENTRY POINT: PARSER_COMMAND
  19. ;
  20. ; INPUT: DOS COMMAND LINE
  21. ;
  22. ; EXIT NORMAL: AX = 0FFH - VALID SWITCH AND FILESPEC SPECIFIED
  23. ;
  24. ; EXIT ERROR: AX NOT= 0FFH - INVALID SWITCH OR NO FILESPEC SPECIFIED
  25. ;
  26. ; INTERNAL REFERENCES
  27. ;
  28. ; ROUTINE: PARSER_COMMAND - THIS ROUTINE PARSES FOR THE PRESENCE
  29. ; OF THE /B SWITCH AND A FILESPEC. THE
  30. ; FILEPSEC IS REQUIRED, WHILE THE SWITCH
  31. ; IS OPTIONAL.
  32. ;
  33. ; EXTERNAL REFERENCES:
  34. ;
  35. ; ROUTINE: PARSE.ASM - THIS IS THE PARSER CODE.
  36. ;
  37. ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS.
  38. ; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE
  39. ;
  40. ; REVISION HISTORY:
  41. ;
  42. ; AN000 VERSION 4.00 - IMPLEMENTS THE SYSTEM PARSER (SYSPARSE)
  43. ;
  44. ; COPYRIGHT: "THE IBM PERSONAL COMPUTER EDLIN UTILITY"
  45. ; "VERSION 4.00 (C) COPYRIGHT 1988"
  46. ; "LICENSED MATERIAL - PROPERTY OF Microsoft"
  47. ;
  48. ;
  49. ;******************** END OF SPECIFICATIONS ******************************
  50. ;======================= equates for edlparse ============================
  51. parse_ok equ 0 ;an000;good parse return
  52. parse_command equ 081h ;an000;offset of command line
  53. nul equ 0 ;an000;nul
  54. fs_flag equ 05h ;an000;filespec found
  55. sw_flag equ 03h ;an000;switch found
  56. true equ 0ffffh ;an000;true
  57. false equ 00h ;an000;false
  58. too_many equ 01h ;an000;too many parms
  59. ;======================= end equates =====================================
  60. CODE SEGMENT PUBLIC BYTE
  61. CODE ENDS
  62. CONST SEGMENT PUBLIC BYTE
  63. CONST ENDS
  64. cstack segment stack
  65. cstack ends
  66. DATA SEGMENT PUBLIC BYTE
  67. extrn path_name:byte
  68. extrn org_ds:word ;an000; dms;
  69. public parse_switch_b ;an000;parse switch result
  70. public parse_switch_? ; parse switch result
  71. public filespec ;an000;actual filespec
  72. ;======================= input parameters control blocks =================
  73. ; these control blocks are used by sysparse and must be pointed to by
  74. ; es:di on invocation.
  75. public parms ;an000;share parms
  76. parms label byte ;an000;parms control block
  77. dw dg:parmsx ;an000;point to parms structure
  78. db 00h ;an000;no additional delims.
  79. parmsx label byte ;an000;parameter types
  80. db 1,1 ;an000;must have filespec
  81. dw dg:fs_pos ;an000;filespec control block
  82. db 2 ;an000;max. number of switches
  83. dw dg:sw_b ;an000;/b switch control block
  84. dw dg:sw_? ;an000;/? switch control block
  85. db 00h ;an000;no keywords
  86. ;======================= filespec positional tables ======================
  87. fs_pos label byte ;an000;filespec positional
  88. dw 0200h ;an000;filespec/not optional
  89. dw 0001h ;an000;cap
  90. dw dg:filespec_res ;an000;filespec result table
  91. dw dg:noval ;an000;value list/none
  92. db 0 ;an000;no keyword/switch syns.
  93. filespec_res label byte ;an000;filespec result table
  94. parse_fs_res db ? ;an000;must be filespec (05)
  95. parse_fs_tag db ? ;an000;item tag
  96. parse_fs_syn dw ? ;an000;synonym pointer
  97. parse_fs_off dw ? ;an000;offset to filespec
  98. parse_fs_seg dw ? ;an000;segment of filespec
  99. ;======================= switch tables /b ================================
  100. sw_b label byte ;an000;/b switch
  101. dw 0000h ;an000;no match flags
  102. dw 0000h ;an000;no cap
  103. dw dg:switch_res ;an000;result buffer
  104. dw dg:noval ;an000;value list/none
  105. db 1 ;an000;1 switch
  106. sw_b_switch db "/B",0 ;an000;/B means ignore CTL-Z
  107. sw_? label byte ;an000;/b switch
  108. dw 0000h ;an000;no match flags
  109. dw 0000h ;an000;no cap
  110. dw dg:switch_res ;an000;result buffer
  111. dw dg:noval ;an000;value list/none
  112. db 1 ;an000;1 switch
  113. sw_?_switch db "/?",0 ;an000;/B means ignore CTL-Z
  114. PUBLIC sw_?_switch
  115. switch_res label byte ;an000;switch result table
  116. parse_sw_res db ? ;an000;must be string (03)
  117. parse_sw_tag db ? ;an000;item tag
  118. parse_sw_syn dw ? ;an000;synonym pointer
  119. parse_sw_ptr dd ? ;an000;pointer to result
  120. noval label byte ;an000;value table
  121. db 0 ;an000;no values
  122. ;======================= end input parameter control blocks ==============
  123. filespec db 128 dup (0) ;an000;holds filespec
  124. parse_switch_b db false ;an000;hold boolean result
  125. ; of /b parse
  126. parse_switch_? db false ; true if /? found
  127. parse_sw_b db "/B" ;an000;comparison switch
  128. DATA ENDS
  129. DG GROUP CODE,CONST,cstack,DATA
  130. code segment public byte ;an000;code segment
  131. assume cs:dg,ds:dg,es:dg,ss:CStack ;an000;
  132. public parser_command ;an000;share this routine
  133. ;======================= begin main routine ==============================
  134. .xlist
  135. include version.inc ; parse.asm include psdata.inc which needs defs from here
  136. include parse.asm ;an000;parser
  137. .list
  138. parser_command proc near ;an000;parse routine
  139. push es ;an000;save registers
  140. push ds ;an000;
  141. push di ;an000;
  142. push si ;an000;
  143. mov dg:parse_switch_b,false ;an000;init. to false
  144. xor cx,cx ;an000;set cx to 0
  145. xor dx,dx ;an000;set dx to 0
  146. mov di,offset dg:parms ;an000;point to parms
  147. mov si,parse_command ;an000;point to ds:81h
  148. mov ds,dg:org_ds ;an000;get ds at entry
  149. assume ds:nothing ;an000;
  150. parse_continue: ;an000;loop return point
  151. call sysparse ;an000;invoke parser
  152. cmp ax,parse_ok ;an000;is it a good parse
  153. jne parse_end ;an000;continue on good parse
  154. push si
  155. mov si,dx
  156. cmp byte ptr es:[si],fs_flag ;an000;do we have a filespec
  157. ; $if e ;an000;yes we do
  158. JNE $$IF1
  159. call build_fs ;an000;save filespec
  160. ; $else ;an000;
  161. JMP SHORT $$EN1
  162. $$IF1:
  163. ; A switch was found.
  164. ; See which one it was.
  165. call val_sw ;an000;see which switch
  166. ; $endif ;an000;
  167. $$EN1:
  168. pop si
  169. jmp parse_continue ;an000;continue parsing
  170. parse_end: ;an000;end parse routine
  171. pop si ;an000;restore registers
  172. pop di ;an000; for return to caller
  173. pop ds ;an000;
  174. assume ds:dg ;an000;
  175. pop es ;an000;
  176. ret ;an000;return to caller
  177. parser_command endp ;an000;end parser_command
  178. ;======================= subroutine area =================================
  179. ;=========================================================================
  180. ; build_fs: This routine saves the filespec for use by the calling program.
  181. ;=========================================================================
  182. build_fs proc near ;an000;save filespec
  183. push ax ;an000;save affected regs.
  184. push di ;an000;
  185. push si ;an000;
  186. push ds ;an000;
  187. push es ;an000;
  188. mov di,offset dg:filespec ;an000;point to filespec buffer
  189. lds si,dword ptr es:parse_fs_off ;an000;get offset
  190. build_cont: ;an000;continue routine
  191. lodsb ;an000;mov ds:si to al
  192. cmp al,nul ;an000;is it end of filespec
  193. ; $if nz ;an000;if not
  194. JZ $$IF7
  195. stosb ;an000;move byte to filespec
  196. jmp build_cont ;an000;continue buffer fill
  197. ; $endif ;an000;
  198. $$IF7:
  199. stosb ;an000;save nul
  200. pop es ;an000;restore regs
  201. pop ds ;an000;
  202. pop si ;an000;
  203. pop di ;an000;
  204. pop ax ;an000;
  205. ret ;an000;return to caller
  206. build_fs endp ;an000;end proc
  207. ;=========================================================================
  208. ; val_sw : determines which switch we have.
  209. ;=========================================================================
  210. val_sw proc near ;an000;switch determination
  211. ; Check for /B
  212. cmp es:[parse_sw_syn], offset es:sw_b_switch
  213. jne ValSwitchBDone
  214. cmp es:[parse_switch_b], true ; see if already given
  215. jne ValSwitchBOkay ; jump if not
  216. mov ax, too_many ; set error level
  217. jmp parse_end ; and exit parser
  218. ValSwitchBOkay:
  219. mov es:[parse_switch_b], true ; set the flag on
  220. jmp short ValSwitchExit ; and done
  221. ValSwitchBDone:
  222. ; Check for /?
  223. cmp es:[parse_sw_syn], offset es:sw_?_switch
  224. jne ValSwitch?Done
  225. mov es:[parse_switch_?], true ; set the flag on
  226. jmp short ValSwitchExit ; and done
  227. ValSwitch?Done:
  228. ValSwitchExit:
  229. ret ;an000;return to caller
  230. val_sw endp ;an000;end proc
  231. code ends ;an000;end segment
  232. end ;an000;
  233.