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.

765 lines
36 KiB

  1. ;/*
  2. ; * Microsoft Confidential
  3. ; * Copyright (C) Microsoft Corporation 1988 - 1991
  4. ; * All Rights Reserved.
  5. ; */
  6. PAGE ,132 ;AN000;
  7. TITLE DOS - GRAPHICS Command - Command line parsing module ;AN000;
  8. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000;
  9. ;; DOS - GRAPHICS Command
  10. ;;
  11. ;; ;AN000;
  12. ;; File Name: GRPARMS.ASM ;AN000;
  13. ;; ---------- ;AN000;
  14. ;; ;AN000;
  15. ;; Description: ;AN000;
  16. ;; ------------ ;AN000;
  17. ;; ;AN000;
  18. ;; This file contains modules for parsing the GRAPHICS.COM ;AN000;
  19. ;; command line; using the DOS PARSER. ;AN000;
  20. ;; ;AN000;
  21. ;; ;AN000;
  22. ;; Documentation Reference: ;AN000;
  23. ;; ------------------------ ;AN000;
  24. ;; OASIS High Level Design ;AN000;
  25. ;; OASIS GRAPHICS I1 Overview ;AN000;
  26. ;; DOS 3.3 Message Retriever Interface Supplement. ;AN000;
  27. ;; TUPPER I0 Document - PARSER HIGH LEVEL DESIGN REVIEW ;AN000;
  28. ;; ;AN000;
  29. ;; Procedures Contained in This File: ;AN000;
  30. ;; ---------------------------------- ;AN000;
  31. ;; PARSE_PARMS - Parse the command line ;AN000;
  32. ;; GET_R - Get /R ;AN000;
  33. ;; GET_B - Get /B ;AN000;
  34. ;; GET_LCD - Get /LCD ;AN000;
  35. ;; GET_PRINTBOX - Get /PRINTBOX ;AN000;
  36. ;; GET_PROFILE - Get the profile path and file name ;AN000;
  37. ;; GET_TYPE - Get the printer type ;AN000;
  38. ;; ;AN000;
  39. ;; Include Files Required: ;AN000;
  40. ;; ----------------------- ;AN000;
  41. ;; GRINST.EXT - Externals for installation modules ;AN000;
  42. ;; GRPARSE.EXT - Externals for the DOS parser code ;AN000;
  43. ;; GRSHAR.STR - Shared Data Area Structure ;AN000;
  44. ;; GRMSG.EQU - Equates for GRAPHICS.COM error messages ;AN000;
  45. ;; STRUC.INC - Macros for using structured assembly language ;AN000;
  46. ;; ;AN000;
  47. ;; External Procedure References: ;AN000;
  48. ;; ------------------------------ ;AN000;
  49. ;; FROM FILE GRINST.ASM: ;AN000;
  50. ;; GRAPHICS_INSTALL - Main module for the installation of GRAPHICS ;AN000;
  51. ;; SYSPARSE - DOS system parser ;AN000;
  52. ;; SYSDISPMSG - DOS message retriever ;AN000;
  53. ;; ;AN000;
  54. ;; Linkage Instructions: ;AN000;
  55. ;; -------------------- ;AN000;
  56. ;; Refer to GRAPHICS.ASM ;AN000;
  57. ;; ;AN000;
  58. ;; Change History: ;AN000;
  59. ;; --------------- ;AN000;
  60. ;; ;AN000;
  61. ;; ;AN000;
  62. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000;
  63. CODE SEGMENT PUBLIC 'CODE' ;AN000;
  64. ASSUME CS:CODE,DS:CODE ;AN000;
  65. PARSE_PARMS PROC NEAR ;AN000;
  66. jmp PARSE_PARMS_START ;AN000;
  67. PUBLIC PARSE_PARMS ;AN000;
  68. EXTRN ERROR_DEVICE: WORD ; grinst.asm
  69. .XLIST ;AN000;
  70. INCLUDE GRMSG.EQU ; Include GRAPHICS error messages equates ;AN000;
  71. INCLUDE GRSHAR.STR ; Include the Shared data area structure ;AN000;
  72. INCLUDE GRINST.EXT ; Include externals for the installation module ;AN000;
  73. INCLUDE GRPARSE.EXT ; Include externals for the DOS parse code ;AN000;
  74. INCLUDE STRUC.INC ; Include macros for using STRUCTURES ;AN000;
  75. .LIST ;AN000;
  76. ;AN000;
  77. PAGE ;AN000;
  78. ;===============================================================================;AN000;
  79. ; ;AN000;
  80. ; PARSE_PARMS : PARSE THE COMMAND LINE PARAMETERS. ;AN000;
  81. ; ;AN000;
  82. ;-------------------------------------------------------------------------------;AN000;
  83. ; ;AN000;
  84. ; INPUT: DS,ES = SEGMENT CONTAINING THE PROGRAM PREFIX SEGMENT ;AN000;(PSP)
  85. ; ;AN000;
  86. ; OUTPUT: SWITCHES = A bit mask in the shared data area indicating ;AN000;
  87. ; which command line switches are set. ;AN000;
  88. ; PROFILE_PATH = The profile file name and path (ASCIIZ string);AN000;
  89. ; PRINTBOX_ID_PTR = Offset of the printbox id (ASCIIZ string) ;AN000;
  90. ; PRINTER_TYPE_PARM = printer type (ASCIIZ string) ;AN000;
  91. ; CARRY FLAG IS SET if an error occurred ;AN000;
  92. ; ;AN000;
  93. ;-------------------------------------------------------------------------------;AN000;
  94. ; ;AN000;
  95. ; DESCRIPTION: Call the DOS parser to parse the command line parameters ;AN000;
  96. ; of the GRAPHICS command line which is obtained from the PSP (Program Segment ;AN000;
  97. ; Prefix). ;AN000;
  98. ; ;AN000;
  99. ; The format of the command line is: ;AN000;
  100. ; ;AN000;
  101. ; ;AN000;
  102. ; GRAPHICS {prt_type {profile}} {/R} {/B} {[/LCD | /PRINTBOX:id]} ;AN000;
  103. ; ;AN000;
  104. ; (All arguments are optional, /PRINTBOX can be spelled /PB.) ;AN000;
  105. ; ;AN000;
  106. ; If no printer type is specified then, a null pointer is returned. ;AN000;
  107. ; If no profile name is supplied then, a null string is returned. ;AN000;
  108. ; If "/LCD" is specified then, a pointer to the printbox id: "LCD" is returned. ;AN000;
  109. ; ;AN000;
  110. ; ;AN000;
  111. ; LOGIC: ;AN000;
  112. ; Set addressibility to the command line parameters in the PSP ;AN000;
  113. ; CALL SYSPARSE ; Call the system parser ;AN000;
  114. ; While not (End Of Line) AND no error ;AN000;
  115. ; IF argument is the profile name ;AN000;
  116. ; THEN Get the profile name ;AN000;
  117. ; IF argument is the printbox switch ;AN000;
  118. ; THEN Get the printbox id ;AN000;
  119. ; IF argument is a /r ;AN000;
  120. ; THEN Get /r ;AN000;
  121. ; IF argument is /b ;AN000;
  122. ; THEN Get /b ;AN000;
  123. ; IF argument /lcd ;AN000;
  124. ; THEN Get /lcd ;AN000;
  125. ; CALL SYSPARSE ;AN000;
  126. ; If error ;AN000;
  127. ; Then display the appropriate error message ;AN000;
  128. ; ;AN000;
  129. ;-------------------------------------------------------------------------------;AN000;
  130. ; BIT MASK INDICATING THE COMMAND LINE SWITCHES PARSED SO FAR: ;AN000;
  131. ;-------------------------------------------------------------------------------;AN000;
  132. SWITCH_PARSED DB 0 ;AN000;
  133. GOT_R EQU 1 ; Found /R ;AN000;
  134. GOT_B EQU 2 ; Found /B ;AN000;
  135. GOT_LCD EQU 4 ; Found /LCD ;AN000;
  136. GOT_PRINTBOX EQU 8 ; Found /PB:id or /PRINTBOX:id ;AN000;
  137. ;AN000;
  138. ;===============================================================================;AN000;
  139. ; ;AN000;
  140. ; CONTROL BLOCK DEFINITIONS FOR THE PARSER: ;AN000;
  141. ; ;AN000;
  142. ;===============================================================================;AN000;
  143. ;AN000;
  144. ;-------------------------------------------------------------------------------;AN000;
  145. ; PARMS INPUT BLOCK ;AN000;
  146. ;-------------------------------------------------------------------------------;AN000;
  147. PARMS LABEL WORD ;AN000;
  148. DW PARMSX ; Offset of parms extension block ;AN000;
  149. DB 0 ; No delimiters to define ;AN000;
  150. ; or end of line markers. ;AN000;
  151. ;AN000;
  152. ;AN000;
  153. ;-------------------------------------------------------------------------------;AN000;
  154. ; PARMS EXTENSION BLOCK : Describe what's on the command line ;AN000;
  155. ;-------------------------------------------------------------------------------;AN000;
  156. PARMSX LABEL BYTE ;AN000;
  157. DB 0,2 ; Max. 2 positional parameters ;AN000;
  158. DW TYPE_CTL ; Offset of type control block ;AN000;
  159. DW PROF_CTL ; Offset of profile control block ;AN000;
  160. ;AN000;
  161. DB 5 ; Max. 4 switch types ;AN000;
  162. DW PRINTBOX_CTL ; Offset of control for Printbox ;AN000;
  163. DW R_CTL ; Offset of control for /R ;AN000;
  164. DW B_CTL ; Offset of control for /B ;AN000;
  165. DW LCD_CTL ; Offset of control for /LCD ;AN000;
  166. DW ?_CTL ; offset of control for /?
  167. ;AN000;
  168. DB 0 ; No keywords ;AN000;
  169. ;AN000;
  170. ;-------------------------------------------------------------------------------;AN000;
  171. ; ;AN000;
  172. ; Describe the printer type parameter: ;AN000;
  173. ; ;AN000;
  174. ;-------------------------------------------------------------------------------;AN000;
  175. TYPE_CTL LABEL WORD ;AN000;
  176. DW 2001H ; Optional simple string ;AN000;
  177. DW 0002H ; Capitalize it ;AN000;
  178. DW TYPE_RESULT ; Offset of result buffer for printer type ;AN000;
  179. DW NO_VALUES ; No values (NOTE: The type returned is checked;AN000;
  180. DB 0 ; for validity by LOAD_PROFILE);AN000;
  181. ;AN000;
  182. NO_VALUES DB 0 ;AN000;
  183. ;AN000;
  184. TYPE_RESULT LABEL BYTE ;AN000;
  185. DB ? ; Type ;AN000;
  186. DB ? ; Item tag ;AN000;
  187. DW ? ; Offset of synomym ;AN000;
  188. DD ? ; Pointer to string found ;AN000;
  189. ;AN000;
  190. ;-------------------------------------------------------------------------------;AN000;
  191. ; ;AN000;
  192. ; Describe the format of the PROFILE parameter: ;AN000;
  193. ; ;AN000;
  194. ;-------------------------------------------------------------------------------;AN000;
  195. ;AN000;
  196. PROF_CTL LABEL WORD ;AN000;
  197. DW 0201H ; File spec. - Optional ;AN000;
  198. DW 0001h ; Capitalize ;AN000;
  199. DW PROFILE_RESULT ; Offset of result buffer for Profile ;AN000;
  200. DW NO_VALUES ; No values needed ;AN000;
  201. DB 0 ;AN000;
  202. ;AN000;
  203. ;AN000;
  204. PROFILE_RESULT LABEL BYTE ;AN000;
  205. DB ? ; Type ;AN000;
  206. DB ? ; Item tag ;AN000;
  207. DW ? ; Offset of synomym ;AN000;
  208. DD ? ; Offset of string ;AN000;
  209. ;AN000;
  210. ;-------------------------------------------------------------------------------;AN000;
  211. ; ;AN000;
  212. ; Describe the format of /R ;AN000;
  213. ; ;AN000;
  214. ;-------------------------------------------------------------------------------;AN000;
  215. R_CTL LABEL WORD ;AN000;
  216. DW 0 ; ;AN000;
  217. DW 0 ; ;AN000;
  218. DW R_RESULT ; Offset of result buffer for a simple switch ;AN000;
  219. DW NO_VALUES ; No values can be given with these switches. ;AN000;
  220. DB 1 ; 1 name for this switch ;AN000;
  221. DB "/R",0 ; Reverse ;AN000;
  222. ;AN000;
  223. R_RESULT LABEL BYTE ;AN000;
  224. DB ? ; Type ;AN000;
  225. DB ? ; Item tag ;AN000;
  226. DW ? ; Offset of synomym ;AN000;
  227. DD ? ; Offset of value ;AN000;
  228. ;----------------------------------------------------------------------------
  229. ;
  230. ; Describe the format of /?
  231. ;
  232. ;----------------------------------------------------------------------------
  233. ?_CTL LABEL WORD ;AN000;
  234. DW 0 ; ;AN000;
  235. DW 0 ; ;AN000;
  236. DW ?_RESULT ; Offset of result buffer for a simple switch
  237. DW NO_VALUES ; No values can be given with these switches.
  238. DB 1 ; 1 name for this switch
  239. DB "/?",0
  240. ;AN000;
  241. ?_RESULT LABEL BYTE ;AN000;
  242. DB ? ; Type ;AN000;
  243. DB ? ; Item tag ;AN000;
  244. DW ? ; Offset of synomym ;AN000;
  245. DD ? ; Offset of value ;AN000;
  246. ;-------------------------------------------------------------------------------;AN000;
  247. ; ;AN000;
  248. ; Describe the format of /B ;AN000;
  249. ; ;AN000;
  250. ;-------------------------------------------------------------------------------;AN000;
  251. B_CTL LABEL WORD ;AN000;
  252. DW 0 ; ;AN000;
  253. DW 0 ; ;AN000;
  254. DW B_RESULT ; Offset of result buffer for a simple switch ;AN000;
  255. DW NO_VALUES ; No values can be given with these switches. ;AN000;
  256. DB 1 ; 1 name allowed for this switch ;AN000;
  257. DB "/B",0 ; Background ;AN000;
  258. ;AN000;
  259. B_RESULT LABEL BYTE ;AN000;
  260. DB ? ; Type ;AN000;
  261. DB ? ; Item tag ;AN000;
  262. DW ? ; Offset of synomym ;AN000;
  263. DD ? ; Offset of value ;AN000;
  264. ;AN000;
  265. ;-------------------------------------------------------------------------------;AN000;
  266. ; ;AN000;
  267. ; Describe the format of /LCD ;AN000;
  268. ; ;AN000;
  269. ;-------------------------------------------------------------------------------;AN000;
  270. LCD_CTL LABEL WORD ;AN000;
  271. DW 0 ; ;AN000;
  272. DW 0 ; ;AN000;
  273. DW LCD_RESULT ; Offset of result buffer for a /LCD ;AN000;
  274. DW NO_VALUES ; No values can be given with these switches. ;AN000;
  275. DB 1 ; 1 name: ;AN000;
  276. DB "/LCD",0 ; /LCD ;AN000;
  277. ;AN000;
  278. LCD_RESULT LABEL BYTE ;AN000;
  279. DB ? ; Type ;AN000;
  280. DB ? ; Item tag ;AN000;
  281. DW ? ; Offset of synomym ;AN000;
  282. DD ? ; Offset of value ;AN000;
  283. ;AN000;
  284. ;-------------------------------------------------------------------------------;AN000;
  285. ; ;AN000;
  286. ; Describe the format of the PRINTBOX switch: ;AN000;
  287. ; ;AN000;
  288. ;-------------------------------------------------------------------------------;AN000;
  289. PRINTBOX_CTL LABEL WORD ;AN000;
  290. DW 2001H ; Optional simple string ;AN000;
  291. DW 0001H ; Capitalize ;AN000;
  292. DW PRINTBOX_RESULT ; Offset of result buffer for Printbox ;AN000;
  293. DW NO_VALUES ; Values will be validated when loading profile ;AN000;
  294. DB 2 ; 2 synomym for this switch: ;AN000;
  295. DB "/PRINTBOX",0 ; ;AN000;
  296. DB "/PB",0 ;AN000;
  297. ;AN000;
  298. PRINTBOX_RESULT LABEL BYTE ;AN000;
  299. DB ? ; Type ;AN000;
  300. DB ? ; Item tag ;AN000;
  301. DW ? ; Offset of synomym ;AN000;
  302. DD ? ; Offset of value ;AN000;
  303. ;AN000;
  304. ;===============================================================================;AN000;
  305. ; ;AN000;
  306. ; DOS "MESSAGE RETRIEVER" Substitution list control block: ;AN000;
  307. ; ;AN000;
  308. ;-------------------------------------------------------------------------------;AN000;
  309. SUBLIST LABEL DWORD ; List for substitution: ;AN000;
  310. DB 11 ; Size of this list ;AN000;
  311. DB 0 ; Reserved ;AN000;
  312. SAVE_SI DD ? ; Ptr to data item ;AN001;
  313. DB 1 ; Variable to be substitued: %1 ;AN000;
  314. DB 00010000B ; %1 is an ASCIIZ string left justifi;AN000;ed
  315. DB 0 ; Unlimited size for %1 ;AN000;
  316. DB 1 ; Minimum size is 1 character ;AN000;
  317. DB " " ; Delimiter is "space" ;AN000;
  318. ;AN000;
  319. ;===============================================================================;AN000;
  320. ; ;AN000;
  321. ; START OF EXECUTABLE CODE: ;AN000;
  322. ; ;AN000;
  323. ;-------------------------------------------------------------------------------;AN000;
  324. ;AN000;
  325. PARSE_PARMS_START: ;AN000;
  326. PUSH AX ;AN000;
  327. PUSH BX ;AN000;
  328. PUSH CX ;AN000;
  329. PUSH DX ;AN000;
  330. PUSH SI ;AN000;
  331. PUSH DI ;AN000;
  332. PUSH ES ;AN000;
  333. ;-------------------------------------------------------------------------------;AN000;
  334. ; Set up addressibility for the parser ;AN000;
  335. ;-------------------------------------------------------------------------------;AN000;
  336. MOV SI,81H ; DS:SI := Command line parameters ;AN000;
  337. ; to be parsed ;AN000;
  338. PUSH CS ;AN000;
  339. POP ES ;AN000;
  340. LEA DI,PARMS ; ES:DI := Parms control block ;AN000;
  341. ;(deleted ;AN001;) XOR DX,DX ; CX,DX must be zero for the ;AN000;
  342. XOR CX,CX ; Initially, CX should be zero ;AN001;
  343. MOV AX,0 ; No error yet ;AN000;
  344. ;-------------------------------------------------------------------------------;AN000;
  345. ; Parse FIRST argument ;AN000;
  346. ;-------------------------------------------------------------------------------;AN000;
  347. ;(deleted ;AN001;) CALL SYSPARSE ; Get one argument from the command line;AN000;
  348. CALL CALL_SYSPARSE ; Get one argument from the command line;AN001;
  349. ;(deleted ;AN001;) MOV BX,DX ; BX := Offset of result block ;AN000;
  350. .WHILE <AX EQ RC_NO_ERROR> ; While there is no error ;AN000;
  351. ;-------------------------------------------------------------------------------;AN000;
  352. ; Get the argument: ;AN000;
  353. ;-------------------------------------------------------------------------------;AN000;
  354. .SELECT ;AN000;
  355. .WHEN <BX EQ <OFFSET ?_RESULT>>
  356. MOV [ERROR_DEVICE], STDOUT ; output to stdout
  357. MOV AX, MSG_OPTIONS_FIRST ; number of first 'option' msg
  358. XOR CX, CX ; specify no subst
  359. PRMORE: CALL DISP_ERROR ; DISP_ERROR is a mistaken name
  360. ; in this case. I use it because it is the existing routine for printing out
  361. ; messages, and it is named so because the only messages graphics would
  362. ; display are error messages. Hence disp_error writes out to STDERR. I
  363. ; could write another message-display interface to sysdispmsg, but this one
  364. ; works fine, I just wanted to note that the name disp_error gives the wrong
  365. ; impression here.
  366. INC AX
  367. CMP AX, MSG_OPTIONS_LAST + 1 ; another msg to do
  368. JB PRMORE
  369. MOV [ERROR_DEVICE], STDERR ; set output back to stderr
  370. STC ; pretend to have an error so
  371. ; that graphics now cleans up and goes home without further action
  372. JMP PPST
  373. .WHEN <BX EQ <OFFSET TYPE_RESULT>> ;AN000;
  374. CALL GET_TYPE ;AN000;
  375. .WHEN <BX EQ <OFFSET PROFILE_RESULT>> ;AN000;
  376. CALL GET_PROFILE_NAME ;AN000;
  377. .WHEN <BX EQ <OFFSET LCD_RESULT >> ;AN000;
  378. CALL GET_LCD ;AN000;
  379. .WHEN <BX EQ <OFFSET R_RESULT>> ;AN000;
  380. CALL GET_REVERSE ;AN000;
  381. .WHEN <BX EQ <OFFSET B_RESULT>> ;AN000;
  382. CALL GET_BACKGROUND ;AN000;
  383. .WHEN <BX EQ <OFFSET PRINTBOX_RESULT>> ;AN000;
  384. CALL GET_PRINTBOX_ID ;AN000;
  385. .OTHERWISE ;AN000;
  386. ;-------No result block was returned by the parser ;AN000;
  387. STC ; Set error ;AN000;
  388. .ENDSELECT ;AN000;
  389. .LEAVE C ; IF error occurred while parsing the ;AN000;
  390. ; previous argument, exit the loop: ;AN000;
  391. ; stop parsing the command line. ;AN000;
  392. ;-------------------------------------------------------------------------------;AN000;
  393. ; Parse next argument: ;AN000;
  394. ;-------------------------------------------------------------------------------;AN000;
  395. ;(deleted ;AN001;) XOR DX,DX ; ;AN000;
  396. ;(deleted ;AN001;) CALL SYSPARSE ; Get one argument from the command line;AN000;
  397. CALL CALL_SYSPARSE ; Get one argument from the command line;AN001;
  398. ;(deleted ;AN001;) MOV BX,DX ; ES:BX := Offset of result block ;AN000;
  399. .ENDWHILE ;AN000;
  400. ;-------------------------------------------------------------------------------;AN000;
  401. ; Check for error, select and display an error message ;AN000;
  402. ;-------------------------------------------------------------------------------;AN000;
  403. .IF <AL NE RC_EOL> ; IF an error occurred ;AN000;
  404. .THEN ; then, display error message ;AN000;
  405. MOV CX,0 ; Assume no substitutions ;AN000;
  406. .SELECT ; (CX := Number of substitutions ;AN000;
  407. .WHEN <AL EQ RC_TOO_MANY> ; When RC = Too many parameters ;AN000;
  408. MOV AX,TOO_MANY_PARMS ; (AL = Message number to display) ;AN000;
  409. .WHEN <AL EQ RC_Not_In_Val> ; When RC = Not in value list provided ;AN000;
  410. MOV AX,VALUE_NOT_ALLOWED ; (AL = Message number to display) ;AN000;
  411. .WHEN <AL EQ RC_Not_In_Sw> ; When RC = Not in switch list provided ;AN000;
  412. MOV CX,1 ; 1 substitution in this message ;AN000;
  413. MOV BYTE PTR [SI],0 ; PUT NUL AT END OF THIS PARM ;AN001;
  414. LEA SI,SUBLIST ; DS:[SI]:="Invalid parm" Substitution;AN000; list
  415. ;(deleted ;AN001;) LES DX,ES:[BX+4] ; ES:DX := Offset of offending parm. ;AN000;
  416. ;(deleted ;AN001;) MOV [SI]+2,DX ; Store offset to this offender in the;AN000;
  417. MOV [SI]+4,ES ; substitution list control block ;AN000;
  418. MOV AX,INVALID_PARM ; AL := 'Invalid parameter' msg number;AN000;
  419. .WHEN <AL EQ RC_INVLD_COMBINATION> ; When RC = Invalid combination of parms;AN000;
  420. MOV AX,INVALID_COMBINATION ; (AL = Message number to display) ;AN000;
  421. .WHEN <AL EQ RC_DUPLICATE_PARMS> ; When RC = Invalid combination of parms;AN000;
  422. MOV AX,DUPLICATE_PARM ; (AL = Message number to display) ;AN000;
  423. .OTHERWISE ; ;AN000;
  424. MOV AX,FORMAT_NOT_CORRECT ; RC = Anything else, tell the user ;AN000;
  425. ; something is wrong with his ;AN000;
  426. .ENDSELECT ; command line. ;AN000;
  427. CALL DISP_ERROR ; Display the selected error message ;AN000;
  428. STC ; Indicate parse error occurred ;AN000;
  429. .ENDIF ;AN000;
  430. ;AN000;
  431. PPST: POP ES ;AN000;
  432. POP DI ;AN000;
  433. POP SI ;AN000;
  434. POP DX ;AN000;
  435. POP CX ;AN000;
  436. POP BX ;AN000;
  437. POP AX ;AN000;
  438. RET ; Return to GRAPHICS_INSTALL ;AN000;
  439. ;AN000;
  440. PARSE_PARMS ENDP ;AN000;
  441. CALL_SYSPARSE PROC NEAR ;COMMON INVOCATION OF SYSPARSE ;AN001;
  442. ;INPUT: - CX=ORDINAL VALUE ;AN001;
  443. ; DS:SI=WHERE COMMAND LINE IS, SAVED IN "SAVE_SI" ;AN001;
  444. ; ES:DI=WHERE PARMS DESCRIPTOR BLOCK IS ;AN001;
  445. ;OUTPUT: CX=NEW ORDINAL VALUE ;AN001;
  446. ; BX=OFFSET OF RESULT BLOCK, IF ONE IS RETURNED ;AN001;
  447. ; SI=OFFSET OF CHAR BEYOND PARSED PARM IN COMMAND LINE ;AN001;
  448. ;AN001;
  449. XOR DX,DX ;CLEAR DX FOR PARSER ;AN001;
  450. MOV WORD PTR SAVE_SI,SI ;REMEMBER WHERE TO START LOOKING ;AN001;
  451. CALL SYSPARSE ;GO PARSE THE NEXT PARM ;AN001;
  452. ;AN001;
  453. MOV BX,DX ; BX := Offset of result block ;AN001;
  454. RET ;RETURN TO CALLER ;AN001;
  455. CALL_SYSPARSE ENDP ;AN001;
  456. PAGE ;AN000;
  457. ;===============================================================================;AN000;
  458. ; ;AN000;
  459. ; PROCEDURE_NAME: GET_PROFILE ;AN000;
  460. ; ;AN000;
  461. ; INPUT: ES:[BX] := Result block ;AN000;
  462. ; ;AN000;
  463. ; OUTPUT: PROFILE_PATH = The profile file name and path (ASCIIZ string) ;AN000;
  464. ; ;AN000;
  465. ;-------------------------------------------------------------------------------;AN000;
  466. GET_PROFILE_NAME PROC ;AN000;
  467. PUSH AX ;AN000;
  468. PUSH BX ;AN000;
  469. PUSH DX ;AN000;
  470. PUSH SI ;AN000;
  471. PUSH DI ;AN000;
  472. ;AN000;
  473. ;-------------------------------------------------------------------------------;AN000;
  474. ; Get the name of the profile path found on the command line: ;AN000;
  475. ;-------------------------------------------------------------------------------;AN000;
  476. MOV DI,ES:[BX+4] ; DI := Offset of filename found ;AN000;
  477. XOR BX,BX ; BX := Byte index ;AN000;
  478. MOV SI,OFFSET PROFILE_PATH ; [BX][SI] := Where to store it ;AN000;
  479. ;AN000;
  480. .IF <<BYTE PTR [DI]> NE 0> ; Don't copy a NULL parm ;AN000;
  481. .REPEAT ; While not end of path name (NULL terminated) ;AN000;
  482. MOV AL,[BX][DI] ; Copy the byte (including the NULL) ;AN000;
  483. MOV [BX][SI],AL ;AN000;
  484. INC BX ; Get next one ;AN000;
  485. .UNTIL <<BYTE PTR [BX-1][DI]> EQ 0> ; ;AN000;
  486. .ENDIF ;AN000;
  487. ;AN000;
  488. POP DI ;AN000;
  489. POP SI ;AN000;
  490. POP DX ;AN000;
  491. POP BX ;AN000;
  492. POP AX ;AN000;
  493. CLC ;AN000;
  494. RET ;AN000;
  495. GET_PROFILE_NAME ENDP ;AN000;
  496. ;AN000;
  497. PAGE ;AN000;
  498. ;===============================================================================;AN000;
  499. ; ;AN000;
  500. ; PROCEDURE_NAME: GET_TYPE ;AN000;
  501. ; ;AN000;
  502. ; INPUT: ES:[BX] := Result block ;AN000;
  503. ; PRINTER_TYPE_LENGTH := Maximum length for the printer type string ;AN000;
  504. ; ;AN000;
  505. ; OUTPUT: PRINTER_TYPE_PARM = ASCIIZ string containing ;AN000;
  506. ; the Printer type. ;AN000;
  507. ; AX = Error code ;AN000;
  508. ; ;AN000;
  509. ;-------------------------------------------------------------------------------;AN000;
  510. GET_TYPE PROC ;AN000;
  511. PUSH BX ;AN000;
  512. PUSH CX ;AN000;
  513. PUSH SI ;AN000;
  514. PUSH DI ;AN000;
  515. ;AN000;
  516. ;---------------------------------------------------------------------- ;AN000;
  517. ; Overwrite the DEFAULT TYPE with the type found on the command line ;AN000;
  518. ;---------------------------------------------------------------------- ;AN000;
  519. MOV SI,ES:[BX+4] ; DS:SI := Offset of printer type found ;AN000;
  520. .IF <<BYTE PTR [SI]> NE 0> ; Do not copy an empty string ;AN000;
  521. .THEN ; ;AN000;
  522. MOV CL,PRINTER_TYPE_LENGTH ; CX := Maximum number of bytes ;AN000;
  523. XOR CH,CH ; to copy ;AN000;
  524. MOV DI,OFFSET PRINTER_TYPE_PARM; ES:DI := Where to store it ;AN000;
  525. REP MOVSB ; Copy the string ;AN000;
  526. ;---------------------------------------------------------------------- ;AN000;
  527. ; Verify that the string supplied is not too long: ;AN000;
  528. ;---------------------------------------------------------------------- ;AN000;
  529. .IF <<BYTE PTR [DI-1]> EQ 0> ; If the last byte is a null ;AN000;
  530. .THEN ; then, the string was not longer ;AN000;
  531. ; than the maximum ;AN000;
  532. CLC ; Clear the carry flag = No error ;AN000;
  533. .ELSE ; else, string provided is too long ;AN000;
  534. MOV AX,RC_Not_In_Sw ; Error := RC for Invalid parm ;AN000;
  535. STC ; Set error ;AN000;
  536. .ENDIF ; ENDIF string too long ;AN000;
  537. .ENDIF ; ENDIF string provided ;AN000;
  538. ;AN000;
  539. GET_TYPE_END: ;AN000;
  540. POP DI ;AN000;
  541. POP SI ;AN000;
  542. POP CX ;AN000;
  543. POP BX ;AN000;
  544. RET ;AN000;
  545. GET_TYPE ENDP ;AN000;
  546. ;AN000;
  547. PAGE ;AN000;
  548. ;===============================================================================;AN000;
  549. ; ;AN000;
  550. ; PROCEDURE_NAME: GET_REVERSE ;AN000;
  551. ; ;AN000;
  552. ; INPUT: ES:[BX] := Result block ;AN000;
  553. ; SWITCH_PARSED := The command line switches parsed so far (bit mask) ;AN000;
  554. ; ;AN000;
  555. ; OUTPUT: CS:[BP].SWITCHES (Bit mask in the Shared data area) is updated ;AN000;
  556. ; with the value of the switch found. ;AN000;
  557. ; GOT_R is set in SWITCH_PARSED ;AN000;
  558. ; AX := Error message number. ;AN000;
  559. ; CARRY FLAG IS SET IF ERROR FOUND ;AN000;
  560. ; ;AN000;
  561. ; ;AN000;
  562. ;-------------------------------------------------------------------------------;AN000;
  563. GET_REVERSE PROC ;AN000;
  564. ;AN000;
  565. TEST SWITCH_PARSED,GOT_R ; If already parsed this switch ;AN000;
  566. JNZ DUPLICATE_R ; then, error ;AN000;
  567. OR SWITCH_PARSED,GOT_R ; else, say we parsed it. ;AN000;
  568. ;AN000;
  569. ;-------------------------------------------------------------------------------;AN000;
  570. ; Set the Reverse switch in the Shared data area ;AN000;
  571. ;-------------------------------------------------------------------------------;AN000;
  572. OR CS:[BP].SWITCHES,REVERSE_SW ; Set the command line switch ;AN000;
  573. CLC ; Clear the error flag ;AN000;
  574. JMP SHORT GET_REVERSE_END ; Return ;AN000;
  575. ;AN000;
  576. DUPLICATE_R: ; Already got this switch ;AN000;
  577. MOV AX,RC_DUPLICATE_PARMS ; AX := error message number ;AN000;
  578. STC ; SET ERROR ;AN000;
  579. GET_REVERSE_END: ;AN000;
  580. ;AN000;
  581. RET ;AN000;
  582. GET_REVERSE ENDP ;AN000;
  583. ;AN000;
  584. PAGE ;AN000;
  585. ;===============================================================================;AN000;
  586. ; ;AN000;
  587. ; PROCEDURE_NAME: GET_BACKGROUND ;AN000;
  588. ; ;AN000;
  589. ; INPUT: ES:[BX] := Result block ;AN000;
  590. ; SWITCH_PARSED := The command line switches parsed so far (bit mask) ;AN000;
  591. ; ;AN000;
  592. ; OUTPUT: CS:[BP].SWITCHES (Bit mask in the Shared data area) is updated ;AN000;
  593. ; with the value of the switch found. ;AN000;
  594. ; ;AN000;
  595. ; GOT_B is set in SWITCH_PARSED ;AN000;
  596. ; AX := Error message number. ;AN000;
  597. ; CARRY FLAG IS SET IF ERROR FOUND ;AN000;
  598. ; ;AN000;
  599. ;-------------------------------------------------------------------------------;AN000;
  600. GET_BACKGROUND PROC ;AN000;
  601. ;AN000;
  602. TEST SWITCH_PARSED,GOT_B ; If already parsed this switch ;AN000;
  603. JNZ DUPLICATE_B ; then, error ;AN000;
  604. OR SWITCH_PARSED,GOT_B ; else, say we parsed it. ;AN000;
  605. ;-------------------------------------------------------------------------------;AN000;
  606. ; Set the switch in the Shared data area ;AN000;
  607. ;-------------------------------------------------------------------------------;AN000;
  608. OR CS:[BP].SWITCHES,BACKGROUND_SW ; Set the command line switch ;AN000;
  609. CLC ; Clear the error flag ;AN000;
  610. JMP SHORT GET_BACKGROUND_END ; Return ;AN000;
  611. ;AN000;
  612. DUPLICATE_B: ; Already got this switch ;AN000;
  613. MOV AX,RC_DUPLICATE_PARMS ; AX := error message number ;AN000;
  614. STC ; SET ERROR ;AN000;
  615. ;AN000;
  616. GET_BACKGROUND_END: ;AN000;
  617. RET ;AN000;
  618. GET_BACKGROUND ENDP ;AN000;
  619. ;AN000;
  620. PAGE ;AN000;
  621. ;===============================================================================;AN000;
  622. ; ;AN000;
  623. ; PROCEDURE_NAME: GET_LCD ;AN000;
  624. ; ;AN000;
  625. ; INPUT: SWITCH_PARSED := The command line switches parsed so far (bit mask) ;AN000;
  626. ; ;AN000;
  627. ; OUTPUT: PRINTBOX_ID_PTR := Point to /LCD ASCIIZ string. ;AN000;
  628. ; GOT_B is set in SWITCH_PARSED ;AN000;
  629. ; AX := Error message number. ;AN000;
  630. ; CARRY FLAG IS SET IF ERROR FOUND ;AN000;
  631. ; ;AN000;
  632. ;-------------------------------------------------------------------------------;AN000;
  633. ; Data Referenced: ;AN000;
  634. ; ;AN000;
  635. ; LCD_BOX = An ASCIIZ string representing the LCD printbox id. ;AN000;
  636. ; ;AN000;
  637. ;-------------------------------------------------------------------------------;AN000;
  638. GET_LCD PROC ;AN000;
  639. ;AN000;
  640. TEST SWITCH_PARSED,GOT_LCD ; If already parsed this switch ;AN000;
  641. JNZ DUPLICATE_LCD ; then, error: Duplicate switch ;AN000;
  642. TEST SWITCH_PARSED,GOT_PRINTBOX ; If printbox already mentioned ;AN000;
  643. JNZ BAD_COMBINATION ; then, error: Invalid combination ;AN000;
  644. ;AN000;
  645. ;-------------------------------------------------------------------------------;AN000;
  646. ; Set the pointer to the print box id to "LCD" ;AN000;
  647. ;-------------------------------------------------------------------------------;AN000;
  648. MOV AX,OFFSET LCD_BOX ; PRINTBOX id := LCD ;AN000;
  649. MOV PRINTBOX_ID_PTR,AX ; Save pointer to this printbox id. ;AN000;
  650. OR SWITCH_PARSED,GOT_LCD ; Say we found this switch ;AN000;
  651. CLC ; Clear the error flag ;AN000;
  652. JMP SHORT GET_LCD_END ; Return ;AN000;
  653. ;AN000;
  654. ;-------------------------------------------------------------------------------;AN000;
  655. ; /LCD was already parsed: ;AN000;
  656. ;-------------------------------------------------------------------------------;AN000;
  657. DUPLICATE_LCD: ; Already got this switch ;AN000;
  658. MOV AX,RC_DUPLICATE_PARMS ; AX := error message number ;AN000;
  659. STC ; SET ERROR ;AN000;
  660. JMP SHORT GET_LCD_END ; Return ;AN000;
  661. ;AN000;
  662. ;-------------------------------------------------------------------------------;AN000;
  663. ; /PRINTBOX was already parsed: ;AN000;
  664. ;-------------------------------------------------------------------------------;AN000;
  665. BAD_COMBINATION: ; /LCD and /PRINTBOX invalid at same ;AN000;
  666. MOV AX,RC_INVLD_COMBINATION ; time, Set the error flag ;AN000;
  667. STC ; AX := Error code ;AN000;
  668. ;AN000;
  669. GET_LCD_END: ;AN000;
  670. RET ;AN000;
  671. GET_LCD ENDP ;AN000;
  672. ;AN000;
  673. PAGE ;AN000;
  674. ;===============================================================================;AN000;
  675. ; ;AN000;
  676. ; PROCEDURE_NAME: GET_PRINTBOX ;AN000;
  677. ; ;AN000;
  678. ; INPUT: ES:[BX] := Result block ;AN000;
  679. ; SWITCH_PARSED := The command line switches parsed so far (bit mask) ;AN000;
  680. ; ;AN000;
  681. ; OUTPUT: DEFAULT_BOX := Is overwritten to contain the printbox id. found on ;AN000;
  682. ; the command line. ;AN000;
  683. ; GOT_PRINTBOX is set in SWITCH_PARSED ;AN000;
  684. ; AX := Error message number. ;AN000;
  685. ; CARRY FLAG IS SET IF ERROR FOUND ;AN000;
  686. ; ;AN000;
  687. ;-------------------------------------------------------------------------------;AN000;
  688. GET_PRINTBOX_ID PROC ;AN000;
  689. ;AN000;
  690. PUSH CX ;AN000;
  691. PUSH SI ;AN000;
  692. PUSH DI ;AN000;
  693. ;AN000;
  694. ;-------------------------------------------------------------------------------;AN000;
  695. ; Test for error in the printbox statement: ;AN000;
  696. ;-------------------------------------------------------------------------------;AN000;
  697. TEST SWITCH_PARSED,GOT_LCD ; If /LCD already mentioned ;AN000;
  698. JNZ BAD_COMBINATION2 ; then, error: Invalid combination ;AN000;
  699. TEST SWITCH_PARSED,GOT_PRINTBOX ; If already parsed this switch ;AN000;
  700. JNZ DUPLICATE_PRINTBOX ; then, error: Duplicate switch ;AN000;
  701. ;AN000;
  702. MOV DI,ES:[BX+4] ; DI := Offset of switch VALUE found;AN000;
  703. ;AN000;
  704. .IF <<BYTE PTR [DI]> EQ 0> ; IF no printbox id ;AN000;
  705. .THEN ; then, ;AN000;
  706. ;----------------------------------------------------------------------;AN000;
  707. ; No printbox id. was found: ;AN000;
  708. ;----------------------------------------------------------------------;AN000;
  709. MOV AX,FORMAT_NOT_CORRECT ; AX := Error code ;AN000;
  710. STC ; Set the error flag ;AN000;
  711. .ELSE ; else, ;AN000;
  712. OR SWITCH_PARSED,GOT_PRINTBOX; Say we found this switch ;AN000;
  713. ;----------------------------------------------------------------------;AN000;
  714. ; Overwrite DEFAULT_BOX with the Printbox id. found ;AN000;
  715. ;----------------------------------------------------------------------;AN000;
  716. MOV CL,PRINTBOX_ID_LENGTH ; CX := Maximum number of bytes ;AN000;
  717. XOR CH,CH ; to copy ;AN000;
  718. MOV SI,DI ; [DS][SI] := Value found ;AN000;
  719. MOV DI,OFFSET DEFAULT_BOX ; [ES][DI] := Default value ;AN000;
  720. REP MOVSB ; Copy the string ;AN000;
  721. ;----------------------------------------------------------------------;AN000;
  722. ; Verify that the Printbox id. string is not too long: ;AN000;
  723. ;----------------------------------------------------------------------;AN000;
  724. .IF <<BYTE PTR [DI-1]> EQ 0> ; If the last byte is a null ;AN000;
  725. .THEN ; then, the string was not longer ;AN000;
  726. ; than the maximum ;AN000;
  727. CLC ; Clear the carry flag = No error ;AN000;
  728. .ELSE ; else, string provided is too long ;AN000;
  729. MOV AX,RC_Not_In_Sw ; Error := RC for Invalid parm ;AN000;
  730. STC ; Set error ;AN000;
  731. .ENDIF ; ENDIF printbox id. too long ;AN000;
  732. .ENDIF ; ENDIF printbox id. provided ;AN000;
  733. ;AN000;
  734. JMP SHORT GET_PRINTBOX_END ; Return ;AN000;
  735. ;AN000;
  736. ;-------------------------------------------------------------------------------;AN000;
  737. ; /PRINTBOX was already parsed: ;AN000;
  738. ;-------------------------------------------------------------------------------;AN000;
  739. DUPLICATE_PRINTBOX: ; Already got this switch ;AN000;
  740. MOV AX,RC_DUPLICATE_PARMS ; AX := error message number ;AN000;
  741. STC ; SET ERROR ;AN000;
  742. JMP SHORT GET_PRINTBOX_END ; Return ;AN000;
  743. ;AN000;
  744. ;-------------------------------------------------------------------------------;AN000;
  745. ; /LCD was already parsed: ;AN000;
  746. ;-------------------------------------------------------------------------------;AN000;
  747. BAD_COMBINATION2: ; /LCD and /PRINTBOX invalid at same;AN000;
  748. MOV AX,RC_INVLD_COMBINATION ; time, Set the error flag ;AN000;
  749. STC ; AX := Error code ;AN000;
  750. ;AN000;
  751. GET_PRINTBOX_END: ;AN000;
  752. POP DI ;AN000;
  753. POP SI ;AN000;
  754. POP CX ;AN000;
  755. RET ;AN000;
  756. GET_PRINTBOX_ID ENDP ;AN000;
  757. ;AN000;
  758. CODE ENDS ;AN000;
  759. END ;AN000;
  760.