1 /* PostScript Printer Description (PPD) file parser
3 * See http://www.adobe.com/supportservice/devrelations/PDFS/TN/5003.PPD_Spec_v4.3.pdf
5 * Copyright 1998 Huw D M Davies
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
44 /* map of page names in ppd file to Windows paper constants */
50 {"10x11", DMPAPER_10X11
},
51 {"10x14", DMPAPER_10X14
},
52 {"11x17", DMPAPER_11X17
}, /* not in Adobe PPD file spec */
53 {"12x11", DMPAPER_12X11
},
54 {"15x11", DMPAPER_15X11
},
55 {"9x11", DMPAPER_9X11
},
58 {"A3.Transverse", DMPAPER_A3_TRANSVERSE
},
59 {"A3Extra", DMPAPER_A3_EXTRA
},
60 {"A3Extra.Transverse", DMPAPER_A3_EXTRA_TRANSVERSE
},
61 {"A3Rotated", DMPAPER_A3_ROTATED
},
63 {"A4.Transverse", DMPAPER_A4_TRANSVERSE
},
64 {"A4Extra", DMPAPER_A4_EXTRA
},
65 {"A4Plus", DMPAPER_A4_PLUS
},
66 {"A4Rotated", DMPAPER_A4_ROTATED
},
67 {"A4Small", DMPAPER_A4SMALL
},
69 {"A5.Transverse", DMPAPER_A5_TRANSVERSE
},
70 {"A5Extra", DMPAPER_A5_EXTRA
},
71 {"A5Rotated", DMPAPER_A5_ROTATED
},
73 {"A6Rotated", DMPAPER_A6_ROTATED
},
74 {"ARCHC", DMPAPER_CSHEET
},
75 {"ARCHD", DMPAPER_DSHEET
},
76 {"ARCHE", DMPAPER_ESHEET
},
78 {"B4Rotated", DMPAPER_B4_JIS_ROTATED
},
80 {"B5.Transverse", DMPAPER_B5_TRANSVERSE
},
81 {"B5Rotated", DMPAPER_B5_JIS_ROTATED
},
82 {"B6", DMPAPER_B6_JIS
},
83 {"B6Rotated", DMPAPER_B6_JIS_ROTATED
},
84 {"C4", DMPAPER_ENV_C4
}, /* use EnvC4 */
85 {"C5", DMPAPER_ENV_C5
}, /* use EnvC5 */
86 {"C6", DMPAPER_ENV_C6
}, /* use EnvC6 */
87 {"Comm10", DMPAPER_ENV_10
}, /* use Env10 */
88 {"DL", DMPAPER_ENV_DL
}, /* use EnvDL */
89 {"DoublePostcard", DMPAPER_DBL_JAPANESE_POSTCARD
},
90 {"DoublePostcardRotated", DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED
},
91 {"Env10", DMPAPER_ENV_10
},
92 {"Env11", DMPAPER_ENV_11
},
93 {"Env12", DMPAPER_ENV_12
},
94 {"Env14", DMPAPER_ENV_14
},
95 {"Env9", DMPAPER_ENV_9
},
96 {"EnvC3", DMPAPER_ENV_C3
},
97 {"EnvC4", DMPAPER_ENV_C4
},
98 {"EnvC5", DMPAPER_ENV_C5
},
99 {"EnvC6", DMPAPER_ENV_C6
},
100 {"EnvC65", DMPAPER_ENV_C65
},
101 {"EnvChou3", DMPAPER_JENV_CHOU3
},
102 {"EnvChou3Rotated", DMPAPER_JENV_CHOU3_ROTATED
},
103 {"EnvChou4", DMPAPER_JENV_CHOU4
},
104 {"EnvChou4Rotated", DMPAPER_JENV_CHOU4_ROTATED
},
105 {"EnvDL", DMPAPER_ENV_DL
},
106 {"EnvISOB4", DMPAPER_ENV_B4
},
107 {"EnvISOB5", DMPAPER_ENV_B5
},
108 {"EnvISOB6", DMPAPER_ENV_B6
},
109 {"EnvInvite", DMPAPER_ENV_INVITE
},
110 {"EnvItalian", DMPAPER_ENV_ITALY
},
111 {"EnvKaku2", DMPAPER_JENV_KAKU2
},
112 {"EnvKaku2Rotated", DMPAPER_JENV_KAKU2_ROTATED
},
113 {"EnvKaku3", DMPAPER_JENV_KAKU3
},
114 {"EnvKaku3Rotated", DMPAPER_JENV_KAKU3_ROTATED
},
115 {"EnvMonarch", DMPAPER_ENV_MONARCH
},
116 {"EnvPRC1", DMPAPER_PENV_1
},
117 {"EnvPRC10", DMPAPER_PENV_10
},
118 {"EnvPRC10Rotated", DMPAPER_PENV_10_ROTATED
},
119 {"EnvPRC1Rotated", DMPAPER_PENV_1_ROTATED
},
120 {"EnvPRC2", DMPAPER_PENV_2
},
121 {"EnvPRC2Rotated", DMPAPER_PENV_2_ROTATED
},
122 {"EnvPRC3", DMPAPER_PENV_3
},
123 {"EnvPRC3Rotated", DMPAPER_PENV_3_ROTATED
},
124 {"EnvPRC4", DMPAPER_PENV_4
},
125 {"EnvPRC4Rotated", DMPAPER_PENV_4_ROTATED
},
126 {"EnvPRC5", DMPAPER_PENV_5
},
127 {"EnvPRC5Rotated", DMPAPER_PENV_5_ROTATED
},
128 {"EnvPRC6", DMPAPER_PENV_6
},
129 {"EnvPRC6Rotated", DMPAPER_PENV_6_ROTATED
},
130 {"EnvPRC7", DMPAPER_PENV_7
},
131 {"EnvPRC7Rotated", DMPAPER_PENV_7_ROTATED
},
132 {"EnvPRC8", DMPAPER_PENV_8
},
133 {"EnvPRC8Rotated", DMPAPER_PENV_8_ROTATED
},
134 {"EnvPRC9", DMPAPER_PENV_9
},
135 {"EnvPRC9Rotated", DMPAPER_PENV_9_ROTATED
},
136 {"EnvPersonal", DMPAPER_ENV_PERSONAL
},
137 {"EnvYou4", DMPAPER_JENV_YOU4
},
138 {"EnvYou4Rotated", DMPAPER_JENV_YOU4_ROTATED
},
139 {"Executive", DMPAPER_EXECUTIVE
},
140 {"FanFoldGerman", DMPAPER_FANFOLD_STD_GERMAN
},
141 {"FanFoldGermanLegal", DMPAPER_FANFOLD_LGL_GERMAN
},
142 {"FanFoldUS", DMPAPER_FANFOLD_US
},
143 {"Folio", DMPAPER_FOLIO
},
144 {"ISOB4", DMPAPER_ISO_B4
},
145 {"ISOB5Extra", DMPAPER_B5_EXTRA
},
146 {"Ledger", DMPAPER_LEDGER
},
147 {"Legal", DMPAPER_LEGAL
},
148 {"LegalExtra", DMPAPER_LEGAL_EXTRA
},
149 {"Letter", DMPAPER_LETTER
},
150 {"Letter.Transverse", DMPAPER_LETTER_TRANSVERSE
},
151 {"LetterExtra", DMPAPER_LETTER_EXTRA
},
152 {"LetterExtra.Transverse", DMPAPER_LETTER_EXTRA_TRANSVERSE
},
153 {"LetterPlus", DMPAPER_LETTER_PLUS
},
154 {"LetterRotated", DMPAPER_LETTER_ROTATED
},
155 {"LetterSmall", DMPAPER_LETTERSMALL
},
156 {"Monarch", DMPAPER_ENV_MONARCH
}, /* use EnvMonarch */
157 {"Note", DMPAPER_NOTE
},
158 {"PRC16K", DMPAPER_P16K
},
159 {"PRC16KRotated", DMPAPER_P16K_ROTATED
},
160 {"PRC32K", DMPAPER_P32K
},
161 {"PRC32KBig", DMPAPER_P32KBIG
},
162 {"PRC32KBigRotated", DMPAPER_P32KBIG_ROTATED
},
163 {"PRC32KRotated", DMPAPER_P32K_ROTATED
},
164 {"Postcard", DMPAPER_JAPANESE_POSTCARD
},
165 {"PostcardRotated", DMPAPER_JAPANESE_POSTCARD_ROTATED
},
166 {"Quarto", DMPAPER_QUARTO
},
167 {"Statement", DMPAPER_STATEMENT
},
168 {"SuperA", DMPAPER_A_PLUS
},
169 {"SuperB", DMPAPER_B_PLUS
},
170 {"Tabloid", DMPAPER_TABLOID
},
171 {"TabloidExtra", DMPAPER_TABLOID_EXTRA
},
175 static WORD UserPageType
= DMPAPER_USER
;
176 static WORD UserBinType
= DMBIN_USER
;
178 /***********************************************************************
182 * Copies str into a newly allocated string from the process heap subsituting
183 * hex strings enclosed in '<' and '>' for their byte codes.
186 static char *PSDRV_PPDDecodeHex(char *str
)
188 char *buf
, *in
, *out
;
191 buf
= HeapAlloc(PSDRV_Heap
, 0, strlen(str
) + 1);
195 for(in
= str
, out
= buf
; *in
; in
++) {
206 else if(isspace(*in
))
210 if(!isxdigit(*in
) || !isxdigit(*(in
+ 1))) {
211 ERR("Invalid hex char in hex string\n");
212 HeapFree(PSDRV_Heap
, 0, buf
);
216 for(i
= 0; i
< 2; i
++) {
217 if(isdigit(*(in
+ i
)))
218 *out
|= (*(in
+ i
) - '0') << ((1-i
) * 4);
220 *out
|= (toupper(*(in
+ i
)) - 'A' + 10) << ((1-i
) * 4);
232 /***********************************************************************
234 * PSDRV_PPDGetTransValue
237 static BOOL
PSDRV_PPDGetTransValue(char *start
, PPDTuple
*tuple
)
241 end
= strpbrk(start
, "\r\n");
242 if(end
== start
) return FALSE
;
243 if(!end
) end
= start
+ strlen(start
);
244 buf
= HeapAlloc( PSDRV_Heap
, 0, end
- start
+ 1 );
245 memcpy(buf
, start
, end
- start
);
246 *(buf
+ (end
- start
)) = '\0';
247 tuple
->valtrans
= PSDRV_PPDDecodeHex(buf
);
248 HeapFree( PSDRV_Heap
, 0, buf
);
253 /***********************************************************************
255 * PSDRV_PPDGetInvocationValue
257 * Passed string that should be surrounded by `"'s, return string alloced
260 static BOOL
PSDRV_PPDGetInvocationValue(FILE *fp
, char *pos
, PPDTuple
*tuple
)
262 char *start
, *end
, *buf
;
267 buf
= HeapAlloc( PSDRV_Heap
, 0, strlen(start
) + 1 );
270 end
= strchr(start
, '"');
272 buf
= HeapReAlloc( PSDRV_Heap
, 0, buf
,
273 len
+ (end
- start
) + 1 );
274 memcpy(buf
+ len
, start
, end
- start
);
275 *(buf
+ len
+ (end
- start
)) = '\0';
277 start
= strchr(end
, '/');
279 return PSDRV_PPDGetTransValue(start
+ 1, tuple
);
282 int sl
= strlen(start
);
283 buf
= HeapReAlloc( PSDRV_Heap
, 0, buf
, len
+ sl
+ 1 );
284 strcpy(buf
+ len
, start
);
287 } while( fgets((start
= line
), sizeof(line
), fp
) );
290 HeapFree( PSDRV_Heap
, 0, buf
);
295 /***********************************************************************
297 * PSDRV_PPDGetQuotedValue
299 * Passed string that should be surrounded by `"'s. Expand <xx> as hex
300 * return string alloced from process heap.
302 static BOOL
PSDRV_PPDGetQuotedValue(FILE *fp
, char *pos
, PPDTuple
*tuple
)
306 if(!PSDRV_PPDGetInvocationValue(fp
, pos
, tuple
))
308 buf
= PSDRV_PPDDecodeHex(tuple
->value
);
309 HeapFree(PSDRV_Heap
, 0, tuple
->value
);
315 /***********************************************************************
317 * PSDRV_PPDGetStringValue
319 * Just strip leading white space.
321 static BOOL
PSDRV_PPDGetStringValue(char *str
, PPDTuple
*tuple
)
323 char *start
= str
, *end
;
325 while(*start
!= '\0' && isspace(*start
))
328 end
= strpbrk(start
, "/\r\n");
329 if(!end
) end
= start
+ strlen(start
);
330 tuple
->value
= HeapAlloc( PSDRV_Heap
, 0, (end
- start
) + 1 );
331 memcpy(tuple
->value
, start
, end
- start
);
332 *(tuple
->value
+ (end
- start
)) = '\0';
334 PSDRV_PPDGetTransValue(end
+ 1, tuple
);
339 /***********************************************************************
341 * PSDRV_PPDSymbolValue
343 * Not implemented yet.
345 static BOOL
PSDRV_PPDGetSymbolValue(char *pos
, PPDTuple
*tuple
)
352 /*********************************************************************
354 * PSDRV_PPDGetNextTuple
356 * Gets the next Keyword Option Value tuple from the file. Allocs space off
357 * the process heap which should be free()ed by the caller if not needed.
359 static BOOL
PSDRV_PPDGetNextTuple(FILE *fp
, PPDTuple
*tuple
)
361 char line
[257], *opt
, *cp
, *trans
, *endkey
;
368 memset(tuple
, 0, sizeof(*tuple
));
371 if(!fgets(line
, sizeof(line
), fp
))
373 if(line
[0] == '*' && line
[1] != '%' && strncmp(line
, "*End", 4))
377 if(line
[strlen(line
)-1] != '\n') {
378 ERR("Line too long.\n");
382 for(cp
= line
; !isspace(*cp
) && *cp
!= ':'; cp
++)
386 if(*cp
== ':') { /* <key>: */
391 if(*cp
== ':') { /* <key> : */
393 } else { /* <key> <option> */
398 tuple
->key
= HeapAlloc( PSDRV_Heap
, 0, endkey
- line
+ 1 );
399 if(!tuple
->key
) return FALSE
;
401 memcpy(tuple
->key
, line
, endkey
- line
);
402 tuple
->key
[endkey
- line
] = '\0';
404 if(gotoption
) { /* opt points to 1st non-space character of the option */
405 cp
= strpbrk(opt
, ":/");
407 ERR("Error in line '%s'?\n", line
);
408 HeapFree(GetProcessHeap(), 0, tuple
->key
);
411 tuple
->option
= HeapAlloc( PSDRV_Heap
, 0, cp
- opt
+ 1 );
412 if(!tuple
->option
) return FALSE
;
413 memcpy(tuple
->option
, opt
, cp
- opt
);
414 tuple
->option
[cp
- opt
] = '\0';
418 cp
= strchr(trans
, ':');
420 ERR("Error in line '%s'?\n", line
);
421 HeapFree(GetProcessHeap(), 0, tuple
->option
);
422 HeapFree(GetProcessHeap(), 0, tuple
->key
);
425 buf
= HeapAlloc( PSDRV_Heap
, 0, cp
- trans
+ 1 );
426 if(!buf
) return FALSE
;
427 memcpy(buf
, trans
, cp
- trans
);
428 buf
[cp
- trans
] = '\0';
429 tuple
->opttrans
= PSDRV_PPDDecodeHex(buf
);
430 HeapFree( PSDRV_Heap
, 0, buf
);
434 /* cp should point to a ':', so we increment past it */
442 if( (!gotoption
&& strncmp(tuple
->key
, "*?", 2) ) ||
443 !strncmp(tuple
->key
, "*JCL", 4))
444 PSDRV_PPDGetQuotedValue(fp
, cp
, tuple
);
446 PSDRV_PPDGetInvocationValue(fp
, cp
, tuple
);
450 PSDRV_PPDGetSymbolValue(cp
, tuple
);
454 PSDRV_PPDGetStringValue(cp
, tuple
);
459 /*********************************************************************
461 * PSDRV_PPDGetPageSizeInfo
463 * Searches ppd PageSize list to return entry matching name or creates new
464 * entry which is appended to the list if name is not found.
467 PAGESIZE
*PSDRV_PPDGetPageSizeInfo(PPD
*ppd
, char *name
)
469 PAGESIZE
*page
= ppd
->PageSizes
, *lastpage
;
472 page
= ppd
->PageSizes
= HeapAlloc( PSDRV_Heap
,
473 HEAP_ZERO_MEMORY
, sizeof(*page
) );
476 for( ; page
; page
= page
->next
) {
477 if(!strcmp(page
->Name
, name
))
482 lastpage
->next
= HeapAlloc( PSDRV_Heap
,
483 HEAP_ZERO_MEMORY
, sizeof(*page
) );
484 return lastpage
->next
;
488 /**********************************************************************
492 * Returns ptr alloced from heap to first word in str. Strips leading spaces.
493 * Puts ptr to next word in next
495 static char *PSDRV_PPDGetWord(char *str
, char **next
)
497 char *start
, *end
, *ret
;
500 while(start
&& *start
&& isspace(*start
))
502 if(!start
|| !*start
) return FALSE
;
505 while(*end
&& !isspace(*end
))
508 ret
= HeapAlloc( PSDRV_Heap
, 0, end
- start
+ 1 );
509 memcpy(ret
, start
, end
- start
);
510 *(ret
+ (end
- start
)) = '\0';
512 while(*end
&& isspace(*end
))
522 /*******************************************************************************
526 static INT
PSDRV_AddSlot(PPD
*ppd
, LPSTR szName
, LPSTR szFullName
,
527 LPSTR szInvocationString
, WORD wWinBin
)
529 INPUTSLOT
*slot
, **insert
= &ppd
->InputSlots
;
532 insert
= &((*insert
)->next
);
534 slot
= *insert
= HeapAlloc(PSDRV_Heap
, HEAP_ZERO_MEMORY
, sizeof(INPUTSLOT
));
537 ERR("Failed to allocate %i bytes of memory\n", sizeof(INPUTSLOT
));
542 slot
->FullName
= szFullName
;
543 slot
->InvocationString
= szInvocationString
;
544 slot
->WinBin
= wWinBin
;
549 /***********************************************************************
555 PPD
*PSDRV_ParsePPD(char *fname
)
560 char *default_pagesize
= NULL
, *default_duplex
= NULL
;
562 TRACE("file '%s'\n", fname
);
564 if((fp
= fopen(fname
, "r")) == NULL
) {
565 WARN("Couldn't open ppd file '%s'\n", fname
);
569 ppd
= HeapAlloc( PSDRV_Heap
, HEAP_ZERO_MEMORY
, sizeof(*ppd
));
571 ERR("Unable to allocate memory for ppd\n");
577 * The Windows PostScript drivers create the following "virtual bin" for
578 * every PostScript printer
580 if (PSDRV_AddSlot(ppd
, NULL
, "Automatically Select", NULL
,
583 HeapFree (PSDRV_Heap
, 0, ppd
);
588 while( PSDRV_PPDGetNextTuple(fp
, &tuple
)) {
590 if(!strcmp("*NickName", tuple
.key
)) {
591 ppd
->NickName
= tuple
.value
;
593 TRACE("NickName = '%s'\n", ppd
->NickName
);
596 else if(!strcmp("*LanguageLevel", tuple
.key
)) {
597 sscanf(tuple
.value
, "%d", &(ppd
->LanguageLevel
));
598 TRACE("LanguageLevel = %d\n", ppd
->LanguageLevel
);
601 else if(!strcmp("*ColorDevice", tuple
.key
)) {
602 if(!strcasecmp(tuple
.value
, "true"))
603 ppd
->ColorDevice
= TRUE
;
604 TRACE("ColorDevice = %d\n", (int)ppd
->ColorDevice
);
607 else if((!strcmp("*DefaultResolution", tuple
.key
)) ||
608 (!strcmp("*DefaultJCLResolution", tuple
.key
))) {
609 sscanf(tuple
.value
, "%d", &(ppd
->DefaultResolution
));
610 TRACE("DefaultResolution = %d\n", ppd
->DefaultResolution
);
613 else if(!strcmp("*Font", tuple
.key
)) {
616 for(fn
= ppd
->InstalledFonts
; fn
&& fn
->next
; fn
= fn
->next
)
619 ppd
->InstalledFonts
= HeapAlloc(PSDRV_Heap
,
620 HEAP_ZERO_MEMORY
, sizeof(*fn
));
621 fn
= ppd
->InstalledFonts
;
623 fn
->next
= HeapAlloc(PSDRV_Heap
,
624 HEAP_ZERO_MEMORY
, sizeof(*fn
));
627 fn
->Name
= tuple
.option
;
631 else if(!strcmp("*DefaultFont", tuple
.key
)) {
632 ppd
->DefaultFont
= tuple
.value
;
636 else if(!strcmp("*JCLBegin", tuple
.key
)) {
637 ppd
->JCLBegin
= tuple
.value
;
641 else if(!strcmp("*JCLToPSInterpreter", tuple
.key
)) {
642 ppd
->JCLToPSInterpreter
= tuple
.value
;
646 else if(!strcmp("*JCLEnd", tuple
.key
)) {
647 ppd
->JCLEnd
= tuple
.value
;
651 else if(!strcmp("*PageSize", tuple
.key
)) {
653 page
= PSDRV_PPDGetPageSizeInfo(ppd
, tuple
.option
);
658 page
->Name
= tuple
.option
;
661 for(i
= 0; PageTrans
[i
].PSName
; i
++) {
662 if(!strcmp(PageTrans
[i
].PSName
, page
->Name
)) { /* case ? */
663 page
->WinPage
= PageTrans
[i
].WinPage
;
668 TRACE("Can't find Windows page type for '%s' - using %u\n",
669 page
->Name
, UserPageType
);
670 page
->WinPage
= UserPageType
++;
673 if(!page
->FullName
) {
675 page
->FullName
= tuple
.opttrans
;
676 tuple
.opttrans
= NULL
;
679 page
->FullName
= HeapAlloc( PSDRV_Heap
, 0, strlen(page
->Name
)+1 );
680 strcpy( page
->FullName
, page
->Name
);
683 if(!page
->InvocationString
) {
684 page
->InvocationString
= tuple
.value
;
689 else if(!strcmp("*DefaultPageSize", tuple
.key
)) {
690 if(default_pagesize
) {
691 WARN("Already set default pagesize\n");
693 default_pagesize
= tuple
.value
;
698 else if(!strcmp("*ImageableArea", tuple
.key
)) {
700 page
= PSDRV_PPDGetPageSizeInfo(ppd
, tuple
.option
);
703 page
->Name
= tuple
.option
;
706 if(!page
->FullName
) {
707 page
->FullName
= tuple
.opttrans
;
708 tuple
.opttrans
= NULL
;
711 #define PIA page->ImageableArea
713 PIA
= HeapAlloc( PSDRV_Heap
, 0, sizeof(*PIA
) );
714 push_lc_numeric("C");
715 sscanf(tuple
.value
, "%f%f%f%f", &PIA
->llx
, &PIA
->lly
,
716 &PIA
->urx
, &PIA
->ury
);
723 else if(!strcmp("*PaperDimension", tuple
.key
)) {
725 page
= PSDRV_PPDGetPageSizeInfo(ppd
, tuple
.option
);
728 page
->Name
= tuple
.option
;
731 if(!page
->FullName
) {
732 page
->FullName
= tuple
.opttrans
;
733 tuple
.opttrans
= NULL
;
736 #define PD page->PaperDimension
738 PD
= HeapAlloc( PSDRV_Heap
, 0, sizeof(*PD
) );
739 push_lc_numeric("C");
740 sscanf(tuple
.value
, "%f%f", &PD
->x
, &PD
->y
);
746 else if(!strcmp("*LandscapeOrientation", tuple
.key
)) {
747 if(!strcmp(tuple
.value
, "Plus90"))
748 ppd
->LandscapeOrientation
= 90;
749 else if(!strcmp(tuple
.value
, "Minus90"))
750 ppd
->LandscapeOrientation
= -90;
752 /* anything else, namely 'any', leaves value at 0 */
754 TRACE("LandscapeOrientation = %d\n",
755 ppd
->LandscapeOrientation
);
758 else if(!strcmp("*UIConstraints", tuple
.key
)) {
760 CONSTRAINT
*con
, **insert
= &ppd
->Constraints
;
763 insert
= &((*insert
)->next
);
765 con
= *insert
= HeapAlloc( PSDRV_Heap
, HEAP_ZERO_MEMORY
,
770 con
->Feature1
= PSDRV_PPDGetWord(start
, &start
);
771 con
->Value1
= PSDRV_PPDGetWord(start
, &start
);
772 con
->Feature2
= PSDRV_PPDGetWord(start
, &start
);
773 con
->Value2
= PSDRV_PPDGetWord(start
, &start
);
776 else if (!strcmp("*InputSlot", tuple
.key
))
780 tuple
.opttrans
= tuple
.option
;
782 TRACE("Using Windows bin type %u for '%s'\n", UserBinType
,
785 /* FIXME - should check for failure */
786 PSDRV_AddSlot(ppd
, tuple
.option
, tuple
.opttrans
, tuple
.value
,
789 tuple
.option
= tuple
.opttrans
= tuple
.value
= NULL
;
793 * Windows treats "manual feed" as another paper source. Most PPD
794 * files, however, treat it as a separate option which is either on or
797 else if (!strcmp("*ManualFeed", tuple
.key
) && tuple
.option
&&
798 !strcmp ("True", tuple
.option
))
800 /* FIXME - should check for failure */
801 PSDRV_AddSlot(ppd
, "Manual Feed", "Manual Feed", tuple
.value
, DMBIN_MANUAL
);
805 else if(!strcmp("*TTRasterizer", tuple
.key
)) {
806 if(!strcasecmp("None", tuple
.value
))
807 ppd
->TTRasterizer
= RO_None
;
808 else if(!strcasecmp("Accept68K", tuple
.value
))
809 ppd
->TTRasterizer
= RO_Accept68K
;
810 else if(!strcasecmp("Type42", tuple
.value
))
811 ppd
->TTRasterizer
= RO_Type42
;
812 else if(!strcasecmp("TrueImage", tuple
.value
))
813 ppd
->TTRasterizer
= RO_TrueImage
;
815 FIXME("Unknown option %s for *TTRasterizer\n",
817 ppd
->TTRasterizer
= RO_None
;
819 TRACE("*TTRasterizer = %d\n", ppd
->TTRasterizer
);
822 else if(!strcmp("*Duplex", tuple
.key
)) {
824 for(duplex
= &ppd
->Duplexes
; *duplex
; duplex
= &(*duplex
)->next
)
826 *duplex
= HeapAlloc(GetProcessHeap(), 0, sizeof(**duplex
));
827 (*duplex
)->Name
= tuple
.option
;
828 (*duplex
)->FullName
= tuple
.opttrans
;
829 (*duplex
)->InvocationString
= tuple
.value
;
830 (*duplex
)->next
= NULL
;
831 if(!strcasecmp("None", tuple
.option
) || !strcasecmp("False", tuple
.option
)
832 || !strcasecmp("Simplex", tuple
.option
))
833 (*duplex
)->WinDuplex
= DMDUP_SIMPLEX
;
834 else if(!strcasecmp("DuplexNoTumble", tuple
.option
))
835 (*duplex
)->WinDuplex
= DMDUP_VERTICAL
;
836 else if(!strcasecmp("DuplexTumble", tuple
.option
))
837 (*duplex
)->WinDuplex
= DMDUP_HORIZONTAL
;
838 else if(!strcasecmp("Notcapable", tuple
.option
))
839 (*duplex
)->WinDuplex
= 0;
841 FIXME("Unknown option %s for *Duplex defaulting to simplex\n", tuple
.option
);
842 (*duplex
)->WinDuplex
= DMDUP_SIMPLEX
;
844 tuple
.option
= tuple
.opttrans
= tuple
.value
= NULL
;
847 else if(!strcmp("*DefaultDuplex", tuple
.key
)) {
849 WARN("Already set default duplex\n");
851 default_duplex
= tuple
.value
;
856 HeapFree(PSDRV_Heap
, 0, tuple
.key
);
857 HeapFree(PSDRV_Heap
, 0, tuple
.option
);
858 HeapFree(PSDRV_Heap
, 0, tuple
.value
);
859 HeapFree(PSDRV_Heap
, 0, tuple
.opttrans
);
860 HeapFree(PSDRV_Heap
, 0, tuple
.valtrans
);
865 ppd
->DefaultPageSize
= NULL
;
866 if(default_pagesize
) {
868 for(page
= ppd
->PageSizes
; page
; page
= page
->next
) {
869 if(!strcmp(page
->Name
, default_pagesize
)) {
870 ppd
->DefaultPageSize
= page
;
871 TRACE("DefaultPageSize: %s\n", page
->Name
);
875 HeapFree(PSDRV_Heap
, 0, default_pagesize
);
877 if(!ppd
->DefaultPageSize
) {
878 ppd
->DefaultPageSize
= ppd
->PageSizes
;
879 TRACE("Setting DefaultPageSize to first in list\n");
882 ppd
->DefaultDuplex
= NULL
;
885 for(duplex
= ppd
->Duplexes
; duplex
; duplex
= duplex
->next
) {
886 if(!strcmp(duplex
->Name
, default_duplex
)) {
887 ppd
->DefaultDuplex
= duplex
;
888 TRACE("DefaultDuplex: %s\n", duplex
->Name
);
892 HeapFree(PSDRV_Heap
, 0, default_duplex
);
894 if(!ppd
->DefaultDuplex
) {
895 ppd
->DefaultDuplex
= ppd
->Duplexes
;
896 TRACE("Setting DefaultDuplex to first in list\n");
906 OPTIONENTRY
*optionEntry
;
908 for(fn
= ppd
->InstalledFonts
; fn
; fn
= fn
->next
)
909 TRACE("'%s'\n", fn
->Name
);
911 for(page
= ppd
->PageSizes
; page
; page
= page
->next
) {
912 TRACE("'%s' aka '%s' (%d) invoked by '%s'\n", page
->Name
,
913 page
->FullName
, page
->WinPage
, page
->InvocationString
);
914 if(page
->ImageableArea
)
915 TRACE("Area = %.2f,%.2f - %.2f, %.2f\n",
916 page
->ImageableArea
->llx
, page
->ImageableArea
->lly
,
917 page
->ImageableArea
->urx
, page
->ImageableArea
->ury
);
918 if(page
->PaperDimension
)
919 TRACE("Dimension = %.2f x %.2f\n",
920 page
->PaperDimension
->x
, page
->PaperDimension
->y
);
923 for(con
= ppd
->Constraints
; con
; con
= con
->next
)
924 TRACE("CONSTRAINTS@ %s %s %s %s\n", con
->Feature1
,
925 con
->Value1
, con
->Feature2
, con
->Value2
);
927 for(option
= ppd
->InstalledOptions
; option
; option
= option
->next
) {
928 TRACE("OPTION: %s %s %s\n", option
->OptionName
,
929 option
->FullName
, option
->DefaultOption
);
930 for(optionEntry
= option
->Options
; optionEntry
;
931 optionEntry
= optionEntry
->next
)
932 TRACE("\tOPTIONENTRY: %s %s %s\n", optionEntry
->Name
,
933 optionEntry
->FullName
, optionEntry
->InvocationString
);
936 for(slot
= ppd
->InputSlots
; slot
; slot
= slot
->next
)
937 TRACE("INPUTSLOTS '%s' Name '%s' (%d) Invocation '%s'\n",
938 slot
->Name
, slot
->FullName
, slot
->WinBin
,
939 slot
->InvocationString
);