2 TITLE DOS
- GRAPHICS Command
- Command line parsing module
;AN000;
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000;
4 ;; DOS - GRAPHICS Command
5 ;; (C) Copyright 1988 Microsoft
7 ;; File Name: GRPARMS.ASM ;AN000;
10 ;; Description: ;AN000;
11 ;; ------------ ;AN000;
13 ;; This file contains modules for parsing the GRAPHICS.COM ;AN000;
14 ;; command line; using the DOS PARSER. ;AN000;
17 ;; Documentation Reference: ;AN000;
18 ;; ------------------------ ;AN000;
19 ;; OASIS High Level Design ;AN000;
20 ;; OASIS GRAPHICS I1 Overview ;AN000;
21 ;; DOS 3.3 Message Retriever Interface Supplement. ;AN000;
22 ;; TUPPER I0 Document - PARSER HIGH LEVEL DESIGN REVIEW ;AN000;
24 ;; Procedures Contained in This File: ;AN000;
25 ;; ---------------------------------- ;AN000;
26 ;; PARSE_PARMS - Parse the command line ;AN000;
27 ;; GET_R - Get /R ;AN000;
28 ;; GET_B - Get /B ;AN000;
29 ;; GET_LCD - Get /LCD ;AN000;
30 ;; GET_PRINTBOX - Get /PRINTBOX ;AN000;
31 ;; GET_PROFILE - Get the profile path and file name ;AN000;
32 ;; GET_TYPE - Get the printer type ;AN000;
34 ;; Include Files Required: ;AN000;
35 ;; ----------------------- ;AN000;
36 ;; GRINST.EXT - Externals for installation modules ;AN000;
37 ;; GRPARSE.EXT - Externals for the DOS parser code ;AN000;
38 ;; GRSHAR.STR - Shared Data Area Structure ;AN000;
39 ;; GRMSG.EQU - Equates for GRAPHICS.COM error messages ;AN000;
40 ;; STRUC.INC - Macros for using structured assembly language ;AN000;
42 ;; External Procedure References: ;AN000;
43 ;; ------------------------------ ;AN000;
44 ;; FROM FILE GRINST.ASM: ;AN000;
45 ;; GRAPHICS_INSTALL - Main module for the installation of GRAPHICS ;AN000;
46 ;; SYSPARSE - DOS system parser ;AN000;
47 ;; SYSDISPMSG - DOS message retriever ;AN000;
49 ;; Linkage Instructions: ;AN000;
50 ;; -------------------- ;AN000;
51 ;; Refer to GRAPHICS.ASM ;AN000;
53 ;; Change History: ;AN000;
54 ;; --------------- ;AN000;
57 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000;
58 CODE SEGMENT PUBLIC 'CODE' ;AN000;
59 ASSUME
CS:CODE,DS:CODE ;AN000;
60 PARSE_PARMS PROC
NEAR ;AN000;
61 jmp PARSE_PARMS_START
;AN000;
62 PUBLIC PARSE_PARMS
;AN000;
64 INCLUDE GRMSG
.EQU
; Include GRAPHICS error messages equates ;AN000;
65 INCLUDE GRSHAR
.STR ; Include the Shared data area structure ;AN000;
66 INCLUDE GRINST
.EXT
; Include externals for the installation module ;AN000;
67 INCLUDE GRPARSE
.EXT
; Include externals for the DOS parse code ;AN000;
68 INCLUDE STRUC.INC ; Include macros for using STRUCTURES ;AN000;
72 ;===============================================================================;AN000;
74 ; PARSE_PARMS : PARSE THE COMMAND LINE PARAMETERS. ;AN000;
76 ;-------------------------------------------------------------------------------;AN000;
78 ; INPUT: DS,ES = SEGMENT CONTAINING THE PROGRAM PREFIX SEGMENT ;AN000;(PSP)
80 ; OUTPUT: SWITCHES = A bit mask in the shared data area indicating ;AN000;
81 ; which command line switches are set. ;AN000;
82 ; PROFILE_PATH = The profile file name and path (ASCIIZ string);AN000;
83 ; PRINTBOX_ID_PTR = Offset of the printbox id (ASCIIZ string) ;AN000;
84 ; PRINTER_TYPE_PARM = printer type (ASCIIZ string) ;AN000;
85 ; CARRY FLAG IS SET if an error occurred ;AN000;
87 ;-------------------------------------------------------------------------------;AN000;
89 ; DESCRIPTION: Call the DOS parser to parse the command line parameters ;AN000;
90 ; of the GRAPHICS command line which is obtained from the PSP (Program Segment ;AN000;
93 ; The format of the command line is: ;AN000;
96 ; GRAPHICS {prt_type {profile}} {/R} {/B} {[/LCD | /PRINTBOX:id]} ;AN000;
98 ; (All arguments are optional, /PRINTBOX can be spelled /PB.) ;AN000;
100 ; If no printer type is specified then, a null pointer is returned. ;AN000;
101 ; If no profile name is supplied then, a null string is returned. ;AN000;
102 ; If "/LCD" is specified then, a pointer to the printbox id: "LCD" is returned. ;AN000;
106 ; Set addressibility to the command line parameters in the PSP ;AN000;
107 ; CALL SYSPARSE ; Call the system parser ;AN000;
108 ; While not (End Of Line) AND no error ;AN000;
109 ; IF argument is the profile name ;AN000;
110 ; THEN Get the profile name ;AN000;
111 ; IF argument is the printbox switch ;AN000;
112 ; THEN Get the printbox id ;AN000;
113 ; IF argument is a /r ;AN000;
114 ; THEN Get /r ;AN000;
115 ; IF argument is /b ;AN000;
116 ; THEN Get /b ;AN000;
117 ; IF argument /lcd ;AN000;
118 ; THEN Get /lcd ;AN000;
119 ; CALL SYSPARSE ;AN000;
121 ; Then display the appropriate error message ;AN000;
123 ;-------------------------------------------------------------------------------;AN000;
124 ; BIT MASK INDICATING THE COMMAND LINE SWITCHES PARSED SO FAR: ;AN000;
125 ;-------------------------------------------------------------------------------;AN000;
126 SWITCH_PARSED
DB 0 ;AN000;
127 GOT_R EQU
1 ; Found /R ;AN000;
128 GOT_B EQU
2 ; Found /B ;AN000;
129 GOT_LCD EQU
4 ; Found /LCD ;AN000;
130 GOT_PRINTBOX EQU
8 ; Found /PB:id or /PRINTBOX:id ;AN000;
132 ;===============================================================================;AN000;
134 ; CONTROL BLOCK DEFINITIONS FOR THE PARSER: ;AN000;
136 ;===============================================================================;AN000;
138 ;-------------------------------------------------------------------------------;AN000;
139 ; PARMS INPUT BLOCK ;AN000;
140 ;-------------------------------------------------------------------------------;AN000;
141 PARMS
LABEL WORD ;AN000;
142 DW PARMSX
; Offset of parms extension block ;AN000;
143 DB 0 ; No delimiters to define ;AN000;
144 ; or end of line markers. ;AN000;
147 ;-------------------------------------------------------------------------------;AN000;
148 ; PARMS EXTENSION BLOCK : Describe what's on the command line ;AN000;
149 ;-------------------------------------------------------------------------------;AN000;
150 PARMSX
LABEL BYTE ;AN000;
151 DB 0,2 ; Max. 2 positional parameters ;AN000;
152 DW TYPE_CTL
; Offset of type control block ;AN000;
153 DW PROF_CTL
; Offset of profile control block ;AN000;
155 DB 4 ; Max. 4 switch types ;AN000;
156 DW PRINTBOX_CTL
; Offset of control for Printbox ;AN000;
157 DW R_CTL
; Offset of control for /R ;AN000;
158 DW B_CTL
; Offset of control for /B ;AN000;
159 DW LCD_CTL
; Offset of control for /LCD ;AN000;
161 DB 0 ; No keywords ;AN000;
163 ;-------------------------------------------------------------------------------;AN000;
165 ; Describe the printer type parameter: ;AN000;
167 ;-------------------------------------------------------------------------------;AN000;
168 TYPE_CTL
LABEL WORD ;AN000;
169 DW 2001H
; Optional simple string ;AN000;
170 DW 0002H ; Capitalize it ;AN000;
171 DW TYPE_RESULT
; Offset of result buffer for printer type ;AN000;
172 DW NO_VALUES
; No values (NOTE: The type returned is checked;AN000;
173 DB 0 ; for validity by LOAD_PROFILE);AN000;
175 NO_VALUES
DB 0 ;AN000;
177 TYPE_RESULT
LABEL BYTE ;AN000;
179 DB ?
; Item tag ;AN000;
180 DW ?
; Offset of synomym ;AN000;
181 DD ?
; Pointer to string found ;AN000;
183 ;-------------------------------------------------------------------------------;AN000;
185 ; Describe the format of the PROFILE parameter: ;AN000;
187 ;-------------------------------------------------------------------------------;AN000;
189 PROF_CTL
LABEL WORD ;AN000;
190 DW 0201H ; File spec. - Optional ;AN000;
191 DW 0001h ; Capitalize ;AN000;
192 DW PROFILE_RESULT
; Offset of result buffer for Profile ;AN000;
193 DW NO_VALUES
; No values needed ;AN000;
197 PROFILE_RESULT
LABEL BYTE ;AN000;
199 DB ?
; Item tag ;AN000;
200 DW ?
; Offset of synomym ;AN000;
201 DD ?
; Offset of string ;AN000;
203 ;-------------------------------------------------------------------------------;AN000;
205 ; Describe the format of /R ;AN000;
207 ;-------------------------------------------------------------------------------;AN000;
208 R_CTL
LABEL WORD ;AN000;
211 DW R_RESULT
; Offset of result buffer for a simple switch ;AN000;
212 DW NO_VALUES
; No values can be given with these switches. ;AN000;
213 DB 1 ; 1 name for this switch ;AN000;
214 DB "/R",0 ; Reverse ;AN000;
216 R_RESULT
LABEL BYTE ;AN000;
218 DB ?
; Item tag ;AN000;
219 DW ?
; Offset of synomym ;AN000;
220 DD ?
; Offset of value ;AN000;
222 ;-------------------------------------------------------------------------------;AN000;
224 ; Describe the format of /B ;AN000;
226 ;-------------------------------------------------------------------------------;AN000;
227 B_CTL
LABEL WORD ;AN000;
230 DW B_RESULT
; Offset of result buffer for a simple switch ;AN000;
231 DW NO_VALUES
; No values can be given with these switches. ;AN000;
232 DB 1 ; 1 name allowed for this switch ;AN000;
233 DB "/B",0 ; Background ;AN000;
235 B_RESULT
LABEL BYTE ;AN000;
237 DB ?
; Item tag ;AN000;
238 DW ?
; Offset of synomym ;AN000;
239 DD ?
; Offset of value ;AN000;
241 ;-------------------------------------------------------------------------------;AN000;
243 ; Describe the format of /LCD ;AN000;
245 ;-------------------------------------------------------------------------------;AN000;
246 LCD_CTL
LABEL WORD ;AN000;
249 DW LCD_RESULT
; Offset of result buffer for a /LCD ;AN000;
250 DW NO_VALUES
; No values can be given with these switches. ;AN000;
251 DB 1 ; 1 name: ;AN000;
252 DB "/LCD",0 ; /LCD ;AN000;
254 LCD_RESULT
LABEL BYTE ;AN000;
256 DB ?
; Item tag ;AN000;
257 DW ?
; Offset of synomym ;AN000;
258 DD ?
; Offset of value ;AN000;
260 ;-------------------------------------------------------------------------------;AN000;
262 ; Describe the format of the PRINTBOX switch: ;AN000;
264 ;-------------------------------------------------------------------------------;AN000;
265 PRINTBOX_CTL
LABEL WORD ;AN000;
266 DW 2001H
; Optional simple string ;AN000;
267 DW 0001H ; Capitalize ;AN000;
268 DW PRINTBOX_RESULT
; Offset of result buffer for Printbox ;AN000;
269 DW NO_VALUES
; Values will be validated when loading profile ;AN000;
270 DB 2 ; 2 synomym for this switch: ;AN000;
271 DB "/PRINTBOX",0 ; ;AN000;
274 PRINTBOX_RESULT
LABEL BYTE ;AN000;
276 DB ?
; Item tag ;AN000;
277 DW ?
; Offset of synomym ;AN000;
278 DD ?
; Offset of value ;AN000;
280 ;===============================================================================;AN000;
282 ; DOS "MESSAGE RETRIEVER" Substitution list control block: ;AN000;
284 ;-------------------------------------------------------------------------------;AN000;
285 SUBLIST
LABEL DWORD ; List for substitution: ;AN000;
286 DB 11 ; Size of this list ;AN000;
287 DB 0 ; Reserved ;AN000;
288 SAVE_SI
DD ?
; Ptr to data item ;AN001;
289 DB 1 ; Variable to be substitued: %1 ;AN000;
290 DB 00010000B ; %1 is an ASCIIZ string left justifi;AN000;ed
291 DB 0 ; Unlimited size for %1 ;AN000;
292 DB 1 ; Minimum size is 1 character ;AN000;
293 DB " " ; Delimiter is "space" ;AN000;
295 ;===============================================================================;AN000;
297 ; START OF EXECUTABLE CODE: ;AN000;
299 ;-------------------------------------------------------------------------------;AN000;
301 PARSE_PARMS_START: ;AN000;
309 ;-------------------------------------------------------------------------------;AN000;
310 ; Set up addressibility for the parser ;AN000;
311 ;-------------------------------------------------------------------------------;AN000;
312 MOV SI,81H
; DS:SI := Command line parameters ;AN000;
313 ; to be parsed ;AN000;
316 LEA DI,PARMS
; ES:DI := Parms control block ;AN000;
317 ;(deleted ;AN001;) XOR DX,DX ; CX,DX must be zero for the ;AN000;
318 XOR CX,CX ; Initially, CX should be zero ;AN001;
319 MOV AX,0 ; No error yet ;AN000;
320 ;-------------------------------------------------------------------------------;AN000;
321 ; Parse FIRST argument ;AN000;
322 ;-------------------------------------------------------------------------------;AN000;
323 ;(deleted ;AN001;) CALL SYSPARSE ; Get one argument from the command line;AN000;
324 CALL CALL_SYSPARSE
; Get one argument from the command line;AN001;
325 ;(deleted ;AN001;) MOV BX,DX ; BX := Offset of result block ;AN000;
326 .WHILE <AX EQ RC_NO_ERROR
> ; While there is no error ;AN000;
327 ;-------------------------------------------------------------------------------;AN000;
328 ; Get the argument: ;AN000;
329 ;-------------------------------------------------------------------------------;AN000;
331 .WHEN
<BX EQ <OFFSET TYPE_RESULT
>> ;AN000;
332 CALL GET_TYPE
;AN000;
333 .WHEN
<BX EQ <OFFSET PROFILE_RESULT
>> ;AN000;
334 CALL GET_PROFILE_NAME
;AN000;
335 .WHEN
<BX EQ <OFFSET LCD_RESULT
>> ;AN000;
337 .WHEN
<BX EQ <OFFSET R_RESULT
>> ;AN000;
338 CALL GET_REVERSE
;AN000;
339 .WHEN
<BX EQ <OFFSET B_RESULT
>> ;AN000;
340 CALL GET_BACKGROUND
;AN000;
341 .WHEN
<BX EQ <OFFSET PRINTBOX_RESULT
>> ;AN000;
342 CALL GET_PRINTBOX_ID
;AN000;
344 ;-------No result block was returned by the parser ;AN000;
345 STC ; Set error ;AN000;
347 .LEAVE C
; IF error occurred while parsing the ;AN000;
348 ; previous argument, exit the loop: ;AN000;
349 ; stop parsing the command line. ;AN000;
350 ;-------------------------------------------------------------------------------;AN000;
351 ; Parse next argument: ;AN000;
352 ;-------------------------------------------------------------------------------;AN000;
353 ;(deleted ;AN001;) XOR DX,DX ; ;AN000;
354 ;(deleted ;AN001;) CALL SYSPARSE ; Get one argument from the command line;AN000;
355 CALL CALL_SYSPARSE
; Get one argument from the command line;AN001;
356 ;(deleted ;AN001;) MOV BX,DX ; ES:BX := Offset of result block ;AN000;
358 ;-------------------------------------------------------------------------------;AN000;
359 ; Check for error, select and display an error message ;AN000;
360 ;-------------------------------------------------------------------------------;AN000;
361 .IF <AL NE RC_EOL
> ; IF an error occurred ;AN000;
362 .THEN
; then, display error message ;AN000;
363 MOV CX,0 ; Assume no substitutions ;AN000;
364 .SELECT
; (CX := Number of substitutions ;AN000;
365 .WHEN
<AL EQ RC_TOO_MANY
> ; When RC = Too many parameters ;AN000;
366 MOV AX,TOO_MANY_PARMS
; (AL = Message number to display) ;AN000;
367 .WHEN
<AL EQ RC_Not_In_Val
> ; When RC = Not in value list provided ;AN000;
368 MOV AX,VALUE_NOT_ALLOWED
; (AL = Message number to display) ;AN000;
369 .WHEN
<AL EQ RC_Not_In_Sw
> ; When RC = Not in switch list provided ;AN000;
370 MOV CX,1 ; 1 substitution in this message ;AN000;
371 MOV BYTE PTR [SI],0 ; PUT NUL AT END OF THIS PARM ;AN001;
372 LEA SI,SUBLIST
; DS:[SI]:="Invalid parm" Substitution;AN000; list
373 ;(deleted ;AN001;) LES DX,ES:[BX+4] ; ES:DX := Offset of offending parm. ;AN000;
374 ;(deleted ;AN001;) MOV [SI]+2,DX ; Store offset to this offender in the;AN000;
375 MOV [SI]+4,ES ; substitution list control block ;AN000;
376 MOV AX,INVALID_PARM
; AL := 'Invalid parameter' msg number;AN000;
377 .WHEN
<AL EQ RC_INVLD_COMBINATION
> ; When RC = Invalid combination of parms;AN000;
378 MOV AX,INVALID_COMBINATION
; (AL = Message number to display) ;AN000;
379 .WHEN
<AL EQ RC_DUPLICATE_PARMS
> ; When RC = Invalid combination of parms;AN000;
380 MOV AX,DUPLICATE_PARM
; (AL = Message number to display) ;AN000;
382 MOV AX,FORMAT_NOT_CORRECT
; RC = Anything else, tell the user ;AN000;
383 ; something is wrong with his ;AN000;
384 .ENDSELECT
; command line. ;AN000;
385 CALL DISP_ERROR
; Display the selected error message ;AN000;
386 STC ; Indicate parse error occurred ;AN000;
396 RET ; Return to GRAPHICS_INSTALL ;AN000;
398 PARSE_PARMS ENDP
;AN000;
399 CALL_SYSPARSE PROC
NEAR ;COMMON INVOCATION OF SYSPARSE ;AN001;
400 ;INPUT: - CX=ORDINAL VALUE ;AN001;
401 ; DS:SI=WHERE COMMAND LINE IS, SAVED IN "SAVE_SI" ;AN001;
402 ; ES:DI=WHERE PARMS DESCRIPTOR BLOCK IS ;AN001;
403 ;OUTPUT: CX=NEW ORDINAL VALUE ;AN001;
404 ; BX=OFFSET OF RESULT BLOCK, IF ONE IS RETURNED ;AN001;
405 ; SI=OFFSET OF CHAR BEYOND PARSED PARM IN COMMAND LINE ;AN001;
407 XOR DX,DX ;CLEAR DX FOR PARSER ;AN001;
408 MOV WORD PTR SAVE_SI
,SI ;REMEMBER WHERE TO START LOOKING ;AN001;
409 CALL SYSPARSE
;GO PARSE THE NEXT PARM ;AN001;
411 MOV BX,DX ; BX := Offset of result block ;AN001;
412 RET ;RETURN TO CALLER ;AN001;
413 CALL_SYSPARSE ENDP
;AN001;
415 ;===============================================================================;AN000;
417 ; PROCEDURE_NAME: GET_PROFILE ;AN000;
419 ; INPUT: ES:[BX] := Result block ;AN000;
421 ; OUTPUT: PROFILE_PATH = The profile file name and path (ASCIIZ string) ;AN000;
423 ;-------------------------------------------------------------------------------;AN000;
424 GET_PROFILE_NAME PROC
;AN000;
431 ;-------------------------------------------------------------------------------;AN000;
432 ; Get the name of the profile path found on the command line: ;AN000;
433 ;-------------------------------------------------------------------------------;AN000;
434 MOV DI,ES:[BX+4] ; DI := Offset of filename found ;AN000;
435 XOR BX,BX ; BX := Byte index ;AN000;
436 MOV SI,OFFSET PROFILE_PATH
; [BX][SI] := Where to store it ;AN000;
438 .IF <<BYTE PTR [DI]> NE
0> ; Don't copy a NULL parm ;AN000;
439 .REPEAT ; While not end of path name (NULL terminated) ;AN000;
440 MOV AL,[BX][DI] ; Copy the byte (including the NULL) ;AN000;
441 MOV [BX][SI],AL ;AN000;
442 INC BX ; Get next one ;AN000;
443 .UNTIL
<<BYTE PTR [BX-1][DI]> EQ 0> ; ;AN000;
453 GET_PROFILE_NAME ENDP
;AN000;
456 ;===============================================================================;AN000;
458 ; PROCEDURE_NAME: GET_TYPE ;AN000;
460 ; INPUT: ES:[BX] := Result block ;AN000;
461 ; PRINTER_TYPE_LENGTH := Maximum length for the printer type string ;AN000;
463 ; OUTPUT: PRINTER_TYPE_PARM = ASCIIZ string containing ;AN000;
464 ; the Printer type. ;AN000;
465 ; AX = Error code ;AN000;
467 ;-------------------------------------------------------------------------------;AN000;
468 GET_TYPE PROC
;AN000;
474 ;---------------------------------------------------------------------- ;AN000;
475 ; Overwrite the DEFAULT TYPE with the type found on the command line ;AN000;
476 ;---------------------------------------------------------------------- ;AN000;
477 MOV SI,ES:[BX+4] ; DS:SI := Offset of printer type found ;AN000;
478 .IF <<BYTE PTR [SI]> NE
0> ; Do not copy an empty string ;AN000;
480 MOV CL,PRINTER_TYPE_LENGTH
; CX := Maximum number of bytes ;AN000;
481 XOR CH,CH ; to copy ;AN000;
482 MOV DI,OFFSET PRINTER_TYPE_PARM
; ES:DI := Where to store it ;AN000;
483 REP MOVSB ; Copy the string ;AN000;
484 ;---------------------------------------------------------------------- ;AN000;
485 ; Verify that the string supplied is not too long: ;AN000;
486 ;---------------------------------------------------------------------- ;AN000;
487 .IF <<BYTE PTR [DI-1]> EQ 0> ; If the last byte is a null ;AN000;
488 .THEN
; then, the string was not longer ;AN000;
489 ; than the maximum ;AN000;
490 CLC ; Clear the carry flag = No error ;AN000;
491 .ELSE ; else, string provided is too long ;AN000;
492 MOV AX,RC_Not_In_Sw
; Error := RC for Invalid parm ;AN000;
493 STC ; Set error ;AN000;
494 .ENDIF
; ENDIF string too long ;AN000;
495 .ENDIF
; ENDIF string provided ;AN000;
497 GET_TYPE_END: ;AN000;
503 GET_TYPE ENDP
;AN000;
506 ;===============================================================================;AN000;
508 ; PROCEDURE_NAME: GET_REVERSE ;AN000;
510 ; INPUT: ES:[BX] := Result block ;AN000;
511 ; SWITCH_PARSED := The command line switches parsed so far (bit mask) ;AN000;
513 ; OUTPUT: CS:[BP].SWITCHES (Bit mask in the Shared data area) is updated ;AN000;
514 ; with the value of the switch found. ;AN000;
515 ; GOT_R is set in SWITCH_PARSED ;AN000;
516 ; AX := Error message number. ;AN000;
517 ; CARRY FLAG IS SET IF ERROR FOUND ;AN000;
520 ;-------------------------------------------------------------------------------;AN000;
521 GET_REVERSE PROC
;AN000;
523 TEST SWITCH_PARSED
,GOT_R
; If already parsed this switch ;AN000;
524 JNZ DUPLICATE_R
; then, error ;AN000;
525 OR SWITCH_PARSED
,GOT_R
; else, say we parsed it. ;AN000;
527 ;-------------------------------------------------------------------------------;AN000;
528 ; Set the Reverse switch in the Shared data area ;AN000;
529 ;-------------------------------------------------------------------------------;AN000;
530 OR CS:[BP].SWITCHES
,REVERSE_SW
; Set the command line switch ;AN000;
531 CLC ; Clear the error flag ;AN000;
532 JMP SHORT GET_REVERSE_END
; Return ;AN000;
534 DUPLICATE_R: ; Already got this switch ;AN000;
535 MOV AX,RC_DUPLICATE_PARMS
; AX := error message number ;AN000;
536 STC ; SET ERROR ;AN000;
537 GET_REVERSE_END: ;AN000;
540 GET_REVERSE ENDP
;AN000;
543 ;===============================================================================;AN000;
545 ; PROCEDURE_NAME: GET_BACKGROUND ;AN000;
547 ; INPUT: ES:[BX] := Result block ;AN000;
548 ; SWITCH_PARSED := The command line switches parsed so far (bit mask) ;AN000;
550 ; OUTPUT: CS:[BP].SWITCHES (Bit mask in the Shared data area) is updated ;AN000;
551 ; with the value of the switch found. ;AN000;
553 ; GOT_B is set in SWITCH_PARSED ;AN000;
554 ; AX := Error message number. ;AN000;
555 ; CARRY FLAG IS SET IF ERROR FOUND ;AN000;
557 ;-------------------------------------------------------------------------------;AN000;
558 GET_BACKGROUND PROC
;AN000;
560 TEST SWITCH_PARSED
,GOT_B
; If already parsed this switch ;AN000;
561 JNZ DUPLICATE_B
; then, error ;AN000;
562 OR SWITCH_PARSED
,GOT_B
; else, say we parsed it. ;AN000;
563 ;-------------------------------------------------------------------------------;AN000;
564 ; Set the switch in the Shared data area ;AN000;
565 ;-------------------------------------------------------------------------------;AN000;
566 OR CS:[BP].SWITCHES
,BACKGROUND_SW
; Set the command line switch ;AN000;
567 CLC ; Clear the error flag ;AN000;
568 JMP SHORT GET_BACKGROUND_END
; Return ;AN000;
570 DUPLICATE_B: ; Already got this switch ;AN000;
571 MOV AX,RC_DUPLICATE_PARMS
; AX := error message number ;AN000;
572 STC ; SET ERROR ;AN000;
574 GET_BACKGROUND_END: ;AN000;
576 GET_BACKGROUND ENDP
;AN000;
579 ;===============================================================================;AN000;
581 ; PROCEDURE_NAME: GET_LCD ;AN000;
583 ; INPUT: SWITCH_PARSED := The command line switches parsed so far (bit mask) ;AN000;
585 ; OUTPUT: PRINTBOX_ID_PTR := Point to /LCD ASCIIZ string. ;AN000;
586 ; GOT_B is set in SWITCH_PARSED ;AN000;
587 ; AX := Error message number. ;AN000;
588 ; CARRY FLAG IS SET IF ERROR FOUND ;AN000;
590 ;-------------------------------------------------------------------------------;AN000;
591 ; Data Referenced: ;AN000;
593 ; LCD_BOX = An ASCIIZ string representing the LCD printbox id. ;AN000;
595 ;-------------------------------------------------------------------------------;AN000;
598 TEST SWITCH_PARSED
,GOT_LCD
; If already parsed this switch ;AN000;
599 JNZ DUPLICATE_LCD
; then, error: Duplicate switch ;AN000;
600 TEST SWITCH_PARSED
,GOT_PRINTBOX
; If printbox already mentioned ;AN000;
601 JNZ BAD_COMBINATION
; then, error: Invalid combination ;AN000;
603 ;-------------------------------------------------------------------------------;AN000;
604 ; Set the pointer to the print box id to "LCD" ;AN000;
605 ;-------------------------------------------------------------------------------;AN000;
606 MOV AX,OFFSET LCD_BOX
; PRINTBOX id := LCD ;AN000;
607 MOV PRINTBOX_ID_PTR
,AX ; Save pointer to this printbox id. ;AN000;
608 OR SWITCH_PARSED
,GOT_LCD
; Say we found this switch ;AN000;
609 CLC ; Clear the error flag ;AN000;
610 JMP SHORT GET_LCD_END
; Return ;AN000;
612 ;-------------------------------------------------------------------------------;AN000;
613 ; /LCD was already parsed: ;AN000;
614 ;-------------------------------------------------------------------------------;AN000;
615 DUPLICATE_LCD: ; Already got this switch ;AN000;
616 MOV AX,RC_DUPLICATE_PARMS
; AX := error message number ;AN000;
617 STC ; SET ERROR ;AN000;
618 JMP SHORT GET_LCD_END
; Return ;AN000;
620 ;-------------------------------------------------------------------------------;AN000;
621 ; /PRINTBOX was already parsed: ;AN000;
622 ;-------------------------------------------------------------------------------;AN000;
623 BAD_COMBINATION: ; /LCD and /PRINTBOX invalid at same ;AN000;
624 MOV AX,RC_INVLD_COMBINATION
; time, Set the error flag ;AN000;
625 STC ; AX := Error code ;AN000;
632 ;===============================================================================;AN000;
634 ; PROCEDURE_NAME: GET_PRINTBOX ;AN000;
636 ; INPUT: ES:[BX] := Result block ;AN000;
637 ; SWITCH_PARSED := The command line switches parsed so far (bit mask) ;AN000;
639 ; OUTPUT: DEFAULT_BOX := Is overwritten to contain the printbox id. found on ;AN000;
640 ; the command line. ;AN000;
641 ; GOT_PRINTBOX is set in SWITCH_PARSED ;AN000;
642 ; AX := Error message number. ;AN000;
643 ; CARRY FLAG IS SET IF ERROR FOUND ;AN000;
645 ;-------------------------------------------------------------------------------;AN000;
646 GET_PRINTBOX_ID PROC
;AN000;
652 ;-------------------------------------------------------------------------------;AN000;
653 ; Test for error in the printbox statement: ;AN000;
654 ;-------------------------------------------------------------------------------;AN000;
655 TEST SWITCH_PARSED
,GOT_LCD
; If /LCD already mentioned ;AN000;
656 JNZ BAD_COMBINATION2
; then, error: Invalid combination ;AN000;
657 TEST SWITCH_PARSED
,GOT_PRINTBOX
; If already parsed this switch ;AN000;
658 JNZ DUPLICATE_PRINTBOX
; then, error: Duplicate switch ;AN000;
660 MOV DI,ES:[BX+4] ; DI := Offset of switch VALUE found;AN000;
662 .IF <<BYTE PTR [DI]> EQ 0> ; IF no printbox id ;AN000;
663 .THEN
; then, ;AN000;
664 ;----------------------------------------------------------------------;AN000;
665 ; No printbox id. was found: ;AN000;
666 ;----------------------------------------------------------------------;AN000;
667 MOV AX,FORMAT_NOT_CORRECT
; AX := Error code ;AN000;
668 STC ; Set the error flag ;AN000;
669 .ELSE ; else, ;AN000;
670 OR SWITCH_PARSED
,GOT_PRINTBOX
; Say we found this switch ;AN000;
671 ;----------------------------------------------------------------------;AN000;
672 ; Overwrite DEFAULT_BOX with the Printbox id. found ;AN000;
673 ;----------------------------------------------------------------------;AN000;
674 MOV CL,PRINTBOX_ID_LENGTH
; CX := Maximum number of bytes ;AN000;
675 XOR CH,CH ; to copy ;AN000;
676 MOV SI,DI ; [DS][SI] := Value found ;AN000;
677 MOV DI,OFFSET DEFAULT_BOX
; [ES][DI] := Default value ;AN000;
678 REP MOVSB ; Copy the string ;AN000;
679 ;----------------------------------------------------------------------;AN000;
680 ; Verify that the Printbox id. string is not too long: ;AN000;
681 ;----------------------------------------------------------------------;AN000;
682 .IF <<BYTE PTR [DI-1]> EQ 0> ; If the last byte is a null ;AN000;
683 .THEN
; then, the string was not longer ;AN000;
684 ; than the maximum ;AN000;
685 CLC ; Clear the carry flag = No error ;AN000;
686 .ELSE ; else, string provided is too long ;AN000;
687 MOV AX,RC_Not_In_Sw
; Error := RC for Invalid parm ;AN000;
688 STC ; Set error ;AN000;
689 .ENDIF
; ENDIF printbox id. too long ;AN000;
690 .ENDIF
; ENDIF printbox id. provided ;AN000;
692 JMP SHORT GET_PRINTBOX_END
; Return ;AN000;
694 ;-------------------------------------------------------------------------------;AN000;
695 ; /PRINTBOX was already parsed: ;AN000;
696 ;-------------------------------------------------------------------------------;AN000;
697 DUPLICATE_PRINTBOX: ; Already got this switch ;AN000;
698 MOV AX,RC_DUPLICATE_PARMS
; AX := error message number ;AN000;
699 STC ; SET ERROR ;AN000;
700 JMP SHORT GET_PRINTBOX_END
; Return ;AN000;
702 ;-------------------------------------------------------------------------------;AN000;
703 ; /LCD was already parsed: ;AN000;
704 ;-------------------------------------------------------------------------------;AN000;
705 BAD_COMBINATION2: ; /LCD and /PRINTBOX invalid at same;AN000;
706 MOV AX,RC_INVLD_COMBINATION
; time, Set the error flag ;AN000;
707 STC ; AX := Error code ;AN000;
709 GET_PRINTBOX_END: ;AN000;
714 GET_PRINTBOX_ID ENDP
;AN000;