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.

355 lines
8.1 KiB

  1. PAGE ,132
  2. TITLE PARSE CODE AND CONTROL BLOCKS FOR ANSI.SYS
  3. ;****************** START OF SPECIFICATIONS **************************
  4. ; MODULE NAME: PARSER.ASM
  5. ; DESCRIPTIVE NAME: PARSES THE DEVICE= STATEMENT IN CONFIG.SYS FOR
  6. ; ANSI.SYS
  7. ; FUNCTION: THE COMMAND LINE PASSED TO ANSI.SYS IN THE CONFIG.SYS
  8. ; STATEMENT IS PARSED TO CHECK FOR THE /X SWITCH. A FLAG
  9. ; IS CLEARED IF NOT FOUND.
  10. ; ENTRY POINT: PARSE_PARM
  11. ; INPUT: DS:SI POINTS TO EVERYTHING AFTER DEVICE=
  12. ; AT EXIT:
  13. ; NORMAL: SWITCH FLAGS WILL BE SET IF /X or /L IS FOUND
  14. ; ERROR: CARRY SET
  15. ; INTERNAL REFERENCES:
  16. ; ROUTINES: SYSLOADMSG - MESSAGE RETRIEVER LOADING CODE
  17. ; SYSDISPMSG - MESSAGE RETRIEVER DISPLAYING CODE
  18. ; PARM_ERROR - DISPLAYS ERROR MESSAGE
  19. ; SYSPARSE - PARSING CODE
  20. ; DATA AREAS: PARMS - PARSE CONTROL BLOCK FOR SYSPARSE
  21. ; EXTERNAL REFERENCES:
  22. ; ROUTINES: N/A
  23. ; DATA AREAS: SWITCH - BYTE FLAG FOR EXISTENCE OF SWITCH PARAMETER
  24. ; NOTES:
  25. ; REVISION HISTORY:
  26. ; A000 - DOS Version 4.00
  27. ; Label: "DOS ANSI.SYS Device Driver"
  28. ; "Version 4.00 (C) Copyright 1988 Microsoft"
  29. ; "Licensed Material - Program Property of Microsoft"
  30. ;****************** END OF SPECIFICATIONS ****************************
  31. ;Modification history**********************************************************
  32. ; P1529 ANSI /x /y gives wrong error message 10/8/87 J.K.
  33. ; D397 /L option for "Enforcing" the line number 12/17/87 J.K.
  34. ; D479 An option to disable the extended keyboard functions 02/12/88 J.K.
  35. ;******************************************************************************
  36. INCLUDE ANSI.INC ; ANSI equates and structures
  37. .XLIST
  38. INCLUDE SYSMSG.INC ; Message retriever code
  39. MSG_UTILNAME <ANSI> ; Let message retriever know its ANSI.SYS
  40. .LIST
  41. PUBLIC PARSE_PARM ; near procedure for parsing DEVICE= statement
  42. ; Set assemble switches for parse code that is not required!!
  43. DateSW EQU 0
  44. TimeSW EQU 0
  45. CmpxSW EQU 0
  46. DrvSW EQU 0
  47. QusSW EQU 0
  48. NumSW EQU 0
  49. KeySW EQU 0
  50. Val1SW EQU 0
  51. Val2SW EQU 0
  52. Val3SW EQU 0
  53. CODE SEGMENT PUBLIC BYTE
  54. ASSUME CS:CODE
  55. .XLIST
  56. MSG_SERVICES <MSGDATA>
  57. MSG_SERVICES <DISPLAYmsg,LOADmsg,CHARmsg>
  58. MSG_SERVICES <ANSI.CL1>
  59. MSG_SERVICES <ANSI.CL2>
  60. MSG_SERVICES <ANSI.CLA>
  61. INCLUDE VERSION.INC
  62. INCLUDE PARSE.ASM ; Parsing code
  63. .LIST
  64. EXTRN SWITCH_X:BYTE ; /X switch flag
  65. extrn Switch_L:Byte ; /L switch flag
  66. extrn Switch_K:Byte ; /K switch flag
  67. extrn Switch_S:Byte ; M008 ; /S or /SCREENSIZE switch flag
  68. ; PARM control blocks for ANSI
  69. ; Parsing DEVICE= statment from CONFIG.SYS
  70. ; DEVICE=[d:][path]ANSI.SYS [/X] [/K] [/L] [/S | /SCREENSIZE] ; M008
  71. PARMS LABEL WORD
  72. DW PARMSX
  73. DB 0 ; no extra delimeters or EOLs.
  74. PARMSX LABEL BYTE
  75. DB 1,1 ; 1 valid positional operand
  76. DW FILENAME ; filename
  77. DB 1 ; 1 switche definition in the following
  78. DW Switches
  79. DB 0 ; no keywords
  80. FILENAME LABEL WORD
  81. DW 0200H ; file spec
  82. DW 0001H ; cap by file table
  83. DW RESULT_BUF ; result
  84. DW NOVALS ; no value checking done
  85. DB 0 ; no switch/keyword synonyms
  86. Switches LABEL WORD
  87. DW 0 ; switch with no value
  88. DW 0 ; no functions
  89. DW RESULT_BUF ; result
  90. DW NOVALS ; no value checking done
  91. DB 5 ;AN003; M008; 5 switch synonym
  92. X_SWITCH DB "/X",0 ; /X name
  93. L_SWITCH DB "/L",0 ; /L
  94. K_SWITCH DB "/K",0 ; /K
  95. SSIZE_SWITCH DB "/SCREENSIZE",0 ; M008; /SCREENSIZE
  96. S_SWITCH DB "/S",0 ; M008; /S
  97. NOVALS LABEL BYTE
  98. DB 0 ; no value checking done
  99. RESULT_BUF LABEL BYTE
  100. DB ? ; type returned (number, string, etc.)
  101. DB ? ; matched item tag (if applicable)
  102. SYNONYM_PTR DW 0 ; synonym ptr (if applicable)
  103. DD ? ; value
  104. SUBLIST LABEL DWORD ; list for substitution
  105. DB SUB_SIZE
  106. DB 0
  107. DD ?
  108. DB 1
  109. DB LEFT_ASCIIZ
  110. DB UNLIMITED
  111. DB 1
  112. DB " "
  113. Old_SI dw ?
  114. Saved_Chr db 0
  115. Continue_Flag db ON
  116. Parse_Err_Flag db OFF
  117. ; PROCEDURE_NAME: PARSE_PARM
  118. ; FUNCTION:
  119. ; THIS PROCEDURE PARSES THE DEVICE= PARAMETERS FROM THE INIT REQUEST
  120. ; BLOCK. ERROR MESSAGES ARE DISPLAYED ACCORDINGLY.
  121. ; AT ENTRY: DS:SI POINTS TO EVERYTHING AFTER THE DEVICE= STATEMENT
  122. ; AT EXIT:
  123. ; NORMAL: CARRY CLEAR - SWITCH FLAG BYTE SET TO 1 IF /X FOUND
  124. ; ERROR: CARRY SET
  125. PARSE_PARM PROC NEAR
  126. CALL SYSLOADMSG ; load message
  127. jnc plab01
  128. CALL SYSDISPMSG ; display error message
  129. STC ; ensure carry still set
  130. jmp plab02
  131. plab01:
  132. PUSH CS ; establish ES ..
  133. POP ES ; addressability to data
  134. LEA DI,PARMS ; point to PARMS control block
  135. XOR CX,CX ; clear both CX and DX for
  136. XOR DX,DX ; SYSPARSE
  137. CALL SYSPARSE ; move pointer past file spec
  138. mov Switch_L, OFF
  139. mov Switch_X, OFF
  140. while01:
  141. cmp Continue_Flag,ON
  142. jz plab_bogus ; M008; bogus label to avoid jmp
  143. jmp while01_end ; M008; out of short range.
  144. plab_bogus: ; M008
  145. mov Old_SI, SI ;to be use by PARM_ERROR
  146. call SysParse
  147. cmp ax,RC_EOL
  148. jnz plab09
  149. mov Continue_Flag, OFF
  150. jmp short while01
  151. plab09:
  152. cmp ax,RC_NO_ERROR
  153. jz plab07
  154. mov Continue_Flag, OFF
  155. mov Switch_X, OFF
  156. mov Switch_L, OFF
  157. mov Switch_K, OFF
  158. call Parm_Error
  159. mov Parse_Err_Flag,ON
  160. jmp short while01
  161. plab07:
  162. cmp Synonym_ptr,offset X_SWITCH
  163. jnz plab05
  164. mov Switch_X,ON
  165. jmp short plab04
  166. plab05:
  167. cmp Synonym_ptr,offset L_SWITCH
  168. jnz plab03
  169. mov Switch_L,ON
  170. jmp short plab04
  171. plab03: ; M008
  172. cmp Synonym_ptr, offset S_SWITCH ; M008
  173. jnz plab11 ; M008
  174. plab12: ; M008
  175. mov Switch_S,ON ; M008
  176. jmp short plab04 ; M008
  177. plab11: ; M008
  178. cmp Synonym_ptr, offset SSIZE_SWITCH; M008
  179. jz plab12 ; M008
  180. mov Switch_K,ON ; must be /K
  181. plab04:
  182. clc
  183. jmp while01
  184. while01_end:
  185. cmp Parse_Err_Flag,ON
  186. jnz plab10
  187. stc
  188. jmp short plab02
  189. plab10:
  190. clc
  191. plab02:
  192. RET
  193. PARSE_PARM ENDP
  194. ; PROCEDURE_NAME: PARM_ERROR
  195. ; FUNCTION:
  196. ; LOADS AND DISPLAYS "Invalid parameter" MESSAGE
  197. ; AT ENTRY:
  198. ; DS:Old_SI -> parms that is invalid
  199. ; AT EXIT:
  200. ; NORMAL: ERROR MESSAGE DISPLAYED
  201. ; ERROR: N/A
  202. PARM_ERROR PROC NEAR
  203. PUSH CX
  204. PUSH SI
  205. PUSH ES
  206. PUSH DS
  207. ; PUSH CS
  208. ; POP DS ; establish addressability
  209. ; MOV BX,DX
  210. ; LES DX,[BX].RES_PTR ; find offending parameter
  211. push ds
  212. pop es
  213. mov si, cs:Old_SI ;Now es:dx -> offending parms
  214. push si ;Save it
  215. Get_CR:
  216. cmp byte ptr es:[si], 13 ;CR?
  217. je Got_CR
  218. inc si
  219. jmp Get_CR
  220. Got_CR:
  221. inc si ; The next char.
  222. mov al, byte ptr es:[si]
  223. mov cs:Saved_Chr, al ; Save the next char
  224. mov byte ptr es:[si], 0 ; and make it an ASCIIZ
  225. mov cs:Old_SI, si ; Set it again
  226. pop dx ; saved SI -> DX
  227. push cs
  228. pop ds ;for addressability
  229. LEA SI,SUBLIST ; ..and place the offset..
  230. MOV [SI].SUB_PTR_O,DX ; ..in the SUBLIST..
  231. MOV [SI].SUB_PTR_S,ES
  232. MOV AX,INVALID_PARM ; load 'Invalid parameter' message number
  233. MOV BX,STDERR ; to standard error
  234. MOV CX,ONE ; 1 substitution
  235. XOR DL,DL ; no input
  236. MOV DH,UTILITY_MSG_CLASS ; parse error
  237. CALL SYSDISPMSG ; display error message
  238. mov si, cs:Old_SI ;restore the original char.
  239. mov cl, cs:Saved_Chr
  240. mov byte ptr es:[si], cl
  241. POP DS
  242. POP ES
  243. POP SI
  244. POP CX
  245. RET
  246. PARM_ERROR ENDP
  247. include msgdcl.inc
  248. CODE ENDS
  249. END
  250.