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
28 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
43 /* map of page names in ppd file to Windows paper constants */
49 {"10x11", DMPAPER_10X11
},
50 {"10x14", DMPAPER_10X14
},
51 {"11x17", DMPAPER_11X17
}, /* not in Adobe PPD file spec */
52 {"12x11", DMPAPER_12X11
},
53 {"15x11", DMPAPER_15X11
},
54 {"9x11", DMPAPER_9X11
},
57 {"A3.Transverse", DMPAPER_A3_TRANSVERSE
},
58 {"A3Extra", DMPAPER_A3_EXTRA
},
59 {"A3Extra.Transverse", DMPAPER_A3_EXTRA_TRANSVERSE
},
60 {"A3Rotated", DMPAPER_A3_ROTATED
},
62 {"A4.Transverse", DMPAPER_A4_TRANSVERSE
},
63 {"A4Extra", DMPAPER_A4_EXTRA
},
64 {"A4Plus", DMPAPER_A4_PLUS
},
65 {"A4Rotated", DMPAPER_A4_ROTATED
},
66 {"A4Small", DMPAPER_A4SMALL
},
68 {"A5.Transverse", DMPAPER_A5_TRANSVERSE
},
69 {"A5Extra", DMPAPER_A5_EXTRA
},
70 {"A5Rotated", DMPAPER_A5_ROTATED
},
72 {"A6Rotated", DMPAPER_A6_ROTATED
},
73 {"ARCHC", DMPAPER_CSHEET
},
74 {"ARCHD", DMPAPER_DSHEET
},
75 {"ARCHE", DMPAPER_ESHEET
},
77 {"B4Rotated", DMPAPER_B4_JIS_ROTATED
},
79 {"B5.Transverse", DMPAPER_B5_TRANSVERSE
},
80 {"B5Rotated", DMPAPER_B5_JIS_ROTATED
},
81 {"B6", DMPAPER_B6_JIS
},
82 {"B6Rotated", DMPAPER_B6_JIS_ROTATED
},
83 {"C4", DMPAPER_ENV_C4
}, /* use EnvC4 */
84 {"C5", DMPAPER_ENV_C5
}, /* use EnvC5 */
85 {"C6", DMPAPER_ENV_C6
}, /* use EnvC6 */
86 {"Comm10", DMPAPER_ENV_10
}, /* use Env10 */
87 {"DL", DMPAPER_ENV_DL
}, /* use EnvDL */
88 {"DoublePostcard", DMPAPER_DBL_JAPANESE_POSTCARD
},
89 {"DoublePostcardRotated", DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED
},
90 {"Env10", DMPAPER_ENV_10
},
91 {"Env11", DMPAPER_ENV_11
},
92 {"Env12", DMPAPER_ENV_12
},
93 {"Env14", DMPAPER_ENV_14
},
94 {"Env9", DMPAPER_ENV_9
},
95 {"EnvC3", DMPAPER_ENV_C3
},
96 {"EnvC4", DMPAPER_ENV_C4
},
97 {"EnvC5", DMPAPER_ENV_C5
},
98 {"EnvC6", DMPAPER_ENV_C6
},
99 {"EnvC65", DMPAPER_ENV_C65
},
100 {"EnvChou3", DMPAPER_JENV_CHOU3
},
101 {"EnvChou3Rotated", DMPAPER_JENV_CHOU3_ROTATED
},
102 {"EnvChou4", DMPAPER_JENV_CHOU4
},
103 {"EnvChou4Rotated", DMPAPER_JENV_CHOU4_ROTATED
},
104 {"EnvDL", DMPAPER_ENV_DL
},
105 {"EnvISOB4", DMPAPER_ENV_B4
},
106 {"EnvISOB5", DMPAPER_ENV_B5
},
107 {"EnvISOB6", DMPAPER_ENV_B6
},
108 {"EnvInvite", DMPAPER_ENV_INVITE
},
109 {"EnvItalian", DMPAPER_ENV_ITALY
},
110 {"EnvKaku2", DMPAPER_JENV_KAKU2
},
111 {"EnvKaku2Rotated", DMPAPER_JENV_KAKU2_ROTATED
},
112 {"EnvKaku3", DMPAPER_JENV_KAKU3
},
113 {"EnvKaku3Rotated", DMPAPER_JENV_KAKU3_ROTATED
},
114 {"EnvMonarch", DMPAPER_ENV_MONARCH
},
115 {"EnvPRC1", DMPAPER_PENV_1
},
116 {"EnvPRC10", DMPAPER_PENV_10
},
117 {"EnvPRC10Rotated", DMPAPER_PENV_10_ROTATED
},
118 {"EnvPRC1Rotated", DMPAPER_PENV_1_ROTATED
},
119 {"EnvPRC2", DMPAPER_PENV_2
},
120 {"EnvPRC2Rotated", DMPAPER_PENV_2_ROTATED
},
121 {"EnvPRC3", DMPAPER_PENV_3
},
122 {"EnvPRC3Rotated", DMPAPER_PENV_3_ROTATED
},
123 {"EnvPRC4", DMPAPER_PENV_4
},
124 {"EnvPRC4Rotated", DMPAPER_PENV_4_ROTATED
},
125 {"EnvPRC5", DMPAPER_PENV_5
},
126 {"EnvPRC5Rotated", DMPAPER_PENV_5_ROTATED
},
127 {"EnvPRC6", DMPAPER_PENV_6
},
128 {"EnvPRC6Rotated", DMPAPER_PENV_6_ROTATED
},
129 {"EnvPRC7", DMPAPER_PENV_7
},
130 {"EnvPRC7Rotated", DMPAPER_PENV_7_ROTATED
},
131 {"EnvPRC8", DMPAPER_PENV_8
},
132 {"EnvPRC8Rotated", DMPAPER_PENV_8_ROTATED
},
133 {"EnvPRC9", DMPAPER_PENV_9
},
134 {"EnvPRC9Rotated", DMPAPER_PENV_9_ROTATED
},
135 {"EnvPersonal", DMPAPER_ENV_PERSONAL
},
136 {"EnvYou4", DMPAPER_JENV_YOU4
},
137 {"EnvYou4Rotated", DMPAPER_JENV_YOU4_ROTATED
},
138 {"Executive", DMPAPER_EXECUTIVE
},
139 {"FanFoldGerman", DMPAPER_FANFOLD_STD_GERMAN
},
140 {"FanFoldGermanLegal", DMPAPER_FANFOLD_LGL_GERMAN
},
141 {"FanFoldUS", DMPAPER_FANFOLD_US
},
142 {"Folio", DMPAPER_FOLIO
},
143 {"ISOB4", DMPAPER_ISO_B4
},
144 {"ISOB5Extra", DMPAPER_B5_EXTRA
},
145 {"Ledger", DMPAPER_LEDGER
},
146 {"Legal", DMPAPER_LEGAL
},
147 {"LegalExtra", DMPAPER_LEGAL_EXTRA
},
148 {"Letter", DMPAPER_LETTER
},
149 {"Letter.Transverse", DMPAPER_LETTER_TRANSVERSE
},
150 {"LetterExtra", DMPAPER_LETTER_EXTRA
},
151 {"LetterExtra.Transverse", DMPAPER_LETTER_EXTRA_TRANSVERSE
},
152 {"LetterPlus", DMPAPER_LETTER_PLUS
},
153 {"LetterRotated", DMPAPER_LETTER_ROTATED
},
154 {"LetterSmall", DMPAPER_LETTERSMALL
},
155 {"Monarch", DMPAPER_ENV_MONARCH
}, /* use EnvMonarch */
156 {"Note", DMPAPER_NOTE
},
157 {"PRC16K", DMPAPER_P16K
},
158 {"PRC16KRotated", DMPAPER_P16K_ROTATED
},
159 {"PRC32K", DMPAPER_P32K
},
160 {"PRC32KBig", DMPAPER_P32KBIG
},
161 {"PRC32KBigRotated", DMPAPER_P32KBIG_ROTATED
},
162 {"PRC32KRotated", DMPAPER_P32K_ROTATED
},
163 {"Postcard", DMPAPER_JAPANESE_POSTCARD
},
164 {"PostcardRotated", DMPAPER_JAPANESE_POSTCARD_ROTATED
},
165 {"Quarto", DMPAPER_QUARTO
},
166 {"Statement", DMPAPER_STATEMENT
},
167 {"SuperA", DMPAPER_A_PLUS
},
168 {"SuperB", DMPAPER_B_PLUS
},
169 {"Tabloid", DMPAPER_TABLOID
},
170 {"TabloidExtra", DMPAPER_TABLOID_EXTRA
},
174 static WORD UserPageType
= DMPAPER_USER
;
175 static WORD UserBinType
= DMBIN_USER
;
177 /***********************************************************************
181 * Copies str into a newly allocated string from the process heap subsituting
182 * hex strings enclosed in '<' and '>' for their byte codes.
185 static char *PSDRV_PPDDecodeHex(char *str
)
187 char *buf
, *in
, *out
;
190 buf
= HeapAlloc(PSDRV_Heap
, 0, strlen(str
) + 1);
194 for(in
= str
, out
= buf
; *in
; in
++) {
205 else if(isspace(*in
))
209 if(!isxdigit(*in
) || !isxdigit(*(in
+ 1))) {
210 ERR("Invalid hex char in hex string\n");
211 HeapFree(PSDRV_Heap
, 0, buf
);
215 for(i
= 0; i
< 2; i
++) {
216 if(isdigit(*(in
+ i
)))
217 *out
|= (*(in
+ i
) - '0') << ((1-i
) * 4);
219 *out
|= (toupper(*(in
+ i
)) - 'A' + 10) << ((1-i
) * 4);
231 /***********************************************************************
233 * PSDRV_PPDGetTransValue
236 static BOOL
PSDRV_PPDGetTransValue(char *start
, PPDTuple
*tuple
)
240 end
= strpbrk(start
, "\r\n");
241 if(end
== start
) return FALSE
;
242 if(!end
) end
= start
+ strlen(start
);
243 buf
= HeapAlloc( PSDRV_Heap
, 0, end
- start
+ 1 );
244 memcpy(buf
, start
, end
- start
);
245 *(buf
+ (end
- start
)) = '\0';
246 tuple
->valtrans
= PSDRV_PPDDecodeHex(buf
);
247 HeapFree( PSDRV_Heap
, 0, buf
);
252 /***********************************************************************
254 * PSDRV_PPDGetInvocationValue
256 * Passed string that should be surrounded by `"'s, return string alloced
259 static BOOL
PSDRV_PPDGetInvocationValue(FILE *fp
, char *pos
, PPDTuple
*tuple
)
261 char *start
, *end
, *buf
;
266 buf
= HeapAlloc( PSDRV_Heap
, 0, strlen(start
) + 1 );
269 end
= strchr(start
, '"');
271 buf
= HeapReAlloc( PSDRV_Heap
, 0, buf
,
272 len
+ (end
- start
) + 1 );
273 memcpy(buf
+ len
, start
, end
- start
);
274 *(buf
+ len
+ (end
- start
)) = '\0';
276 start
= strchr(end
, '/');
278 return PSDRV_PPDGetTransValue(start
+ 1, tuple
);
281 int sl
= strlen(start
);
282 buf
= HeapReAlloc( PSDRV_Heap
, 0, buf
, len
+ sl
+ 1 );
283 strcpy(buf
+ len
, start
);
286 } while( fgets((start
= line
), sizeof(line
), fp
) );
289 HeapFree( PSDRV_Heap
, 0, buf
);
294 /***********************************************************************
296 * PSDRV_PPDGetQuotedValue
298 * Passed string that should be surrounded by `"'s. Expand <xx> as hex
299 * return string alloced from process heap.
301 static BOOL
PSDRV_PPDGetQuotedValue(FILE *fp
, char *pos
, PPDTuple
*tuple
)
305 if(!PSDRV_PPDGetInvocationValue(fp
, pos
, tuple
))
307 buf
= PSDRV_PPDDecodeHex(tuple
->value
);
308 HeapFree(PSDRV_Heap
, 0, tuple
->value
);
314 /***********************************************************************
316 * PSDRV_PPDGetStringValue
318 * Just strip leading white space.
320 static BOOL
PSDRV_PPDGetStringValue(char *str
, PPDTuple
*tuple
)
322 char *start
= str
, *end
;
324 while(*start
!= '\0' && isspace(*start
))
327 end
= strpbrk(start
, "/\r\n");
328 if(!end
) end
= start
+ strlen(start
);
329 tuple
->value
= HeapAlloc( PSDRV_Heap
, 0, (end
- start
) + 1 );
330 memcpy(tuple
->value
, start
, end
- start
);
331 *(tuple
->value
+ (end
- start
)) = '\0';
333 PSDRV_PPDGetTransValue(end
+ 1, tuple
);
338 /***********************************************************************
340 * PSDRV_PPDSymbolValue
342 * Not implemented yet.
344 static BOOL
PSDRV_PPDGetSymbolValue(char *pos
, PPDTuple
*tuple
)
351 /*********************************************************************
353 * PSDRV_PPDGetNextTuple
355 * Gets the next Keyword Option Value tuple from the file. Allocs space off
356 * the process heap which should be free()ed by the caller if not needed.
358 static BOOL
PSDRV_PPDGetNextTuple(FILE *fp
, PPDTuple
*tuple
)
360 char line
[257], *opt
, *cp
, *trans
, *endkey
;
367 memset(tuple
, 0, sizeof(*tuple
));
370 if(!fgets(line
, sizeof(line
), fp
))
372 if(line
[0] == '*' && line
[1] != '%' && strncmp(line
, "*End", 4))
376 if(line
[strlen(line
)-1] != '\n') {
377 ERR("Line too long.\n");
381 for(cp
= line
; !isspace(*cp
) && *cp
!= ':'; cp
++)
385 if(*cp
== ':') { /* <key>: */
390 if(*cp
== ':') { /* <key> : */
392 } else { /* <key> <option> */
397 tuple
->key
= HeapAlloc( PSDRV_Heap
, 0, endkey
- line
+ 1 );
398 if(!tuple
->key
) return FALSE
;
400 memcpy(tuple
->key
, line
, endkey
- line
);
401 tuple
->key
[endkey
- line
] = '\0';
403 if(gotoption
) { /* opt points to 1st non-space character of the option */
404 cp
= strpbrk(opt
, ":/");
406 ERR("Error in line '%s'?\n", line
);
407 HeapFree(GetProcessHeap(), 0, tuple
->key
);
410 tuple
->option
= HeapAlloc( PSDRV_Heap
, 0, cp
- opt
+ 1 );
411 if(!tuple
->option
) return FALSE
;
412 memcpy(tuple
->option
, opt
, cp
- opt
);
413 tuple
->option
[cp
- opt
] = '\0';
417 cp
= strchr(trans
, ':');
419 ERR("Error in line '%s'?\n", line
);
420 HeapFree(GetProcessHeap(), 0, tuple
->option
);
421 HeapFree(GetProcessHeap(), 0, tuple
->key
);
424 buf
= HeapAlloc( PSDRV_Heap
, 0, cp
- trans
+ 1 );
425 if(!buf
) return FALSE
;
426 memcpy(buf
, trans
, cp
- trans
);
427 buf
[cp
- trans
] = '\0';
428 tuple
->opttrans
= PSDRV_PPDDecodeHex(buf
);
429 HeapFree( PSDRV_Heap
, 0, buf
);
433 /* cp should point to a ':', so we increment past it */
441 if( (!gotoption
&& strncmp(tuple
->key
, "*?", 2) ) ||
442 !strncmp(tuple
->key
, "*JCL", 4))
443 PSDRV_PPDGetQuotedValue(fp
, cp
, tuple
);
445 PSDRV_PPDGetInvocationValue(fp
, cp
, tuple
);
449 PSDRV_PPDGetSymbolValue(cp
, tuple
);
453 PSDRV_PPDGetStringValue(cp
, tuple
);
458 /*********************************************************************
460 * PSDRV_PPDGetPageSizeInfo
462 * Searches ppd PageSize list to return entry matching name or creates new
463 * entry which is appended to the list if name is not found.
466 PAGESIZE
*PSDRV_PPDGetPageSizeInfo(PPD
*ppd
, char *name
)
468 PAGESIZE
*page
= ppd
->PageSizes
, *lastpage
;
471 page
= ppd
->PageSizes
= HeapAlloc( PSDRV_Heap
,
472 HEAP_ZERO_MEMORY
, sizeof(*page
) );
475 for( ; page
; page
= page
->next
) {
476 if(!strcmp(page
->Name
, name
))
481 lastpage
->next
= HeapAlloc( PSDRV_Heap
,
482 HEAP_ZERO_MEMORY
, sizeof(*page
) );
483 return lastpage
->next
;
487 /**********************************************************************
491 * Returns ptr alloced from heap to first word in str. Strips leading spaces.
492 * Puts ptr to next word in next
494 static char *PSDRV_PPDGetWord(char *str
, char **next
)
496 char *start
, *end
, *ret
;
499 while(start
&& *start
&& isspace(*start
))
501 if(!start
|| !*start
) return FALSE
;
504 while(*end
&& !isspace(*end
))
507 ret
= HeapAlloc( PSDRV_Heap
, 0, end
- start
+ 1 );
508 memcpy(ret
, start
, end
- start
);
509 *(ret
+ (end
- start
)) = '\0';
511 while(*end
&& isspace(*end
))
521 /*******************************************************************************
525 static INT
PSDRV_AddSlot(PPD
*ppd
, LPSTR szName
, LPSTR szFullName
,
526 LPSTR szInvocationString
, WORD wWinBin
)
528 INPUTSLOT
*slot
, **insert
= &ppd
->InputSlots
;
531 insert
= &((*insert
)->next
);
533 slot
= *insert
= HeapAlloc(PSDRV_Heap
, HEAP_ZERO_MEMORY
, sizeof(INPUTSLOT
));
536 ERR("Failed to allocate %i bytes of memory\n", sizeof(INPUTSLOT
));
541 slot
->FullName
= szFullName
;
542 slot
->InvocationString
= szInvocationString
;
543 slot
->WinBin
= wWinBin
;
548 /***********************************************************************
554 PPD
*PSDRV_ParsePPD(char *fname
)
559 char *default_pagesize
= NULL
, *default_duplex
= NULL
;
561 TRACE("file '%s'\n", fname
);
563 if((fp
= fopen(fname
, "r")) == NULL
) {
564 WARN("Couldn't open ppd file '%s'\n", fname
);
568 ppd
= HeapAlloc( PSDRV_Heap
, HEAP_ZERO_MEMORY
, sizeof(*ppd
));
570 ERR("Unable to allocate memory for ppd\n");
576 * The Windows PostScript drivers create the following "virtual bin" for
577 * every PostScript printer
579 if (PSDRV_AddSlot(ppd
, NULL
, "Automatically Select", NULL
,
582 HeapFree (PSDRV_Heap
, 0, ppd
);
587 while( PSDRV_PPDGetNextTuple(fp
, &tuple
)) {
589 if(!strcmp("*NickName", tuple
.key
)) {
590 ppd
->NickName
= tuple
.value
;
592 TRACE("NickName = '%s'\n", ppd
->NickName
);
595 else if(!strcmp("*LanguageLevel", tuple
.key
)) {
596 sscanf(tuple
.value
, "%d", &(ppd
->LanguageLevel
));
597 TRACE("LanguageLevel = %d\n", ppd
->LanguageLevel
);
600 else if(!strcmp("*ColorDevice", tuple
.key
)) {
601 if(!strcasecmp(tuple
.value
, "true"))
602 ppd
->ColorDevice
= TRUE
;
603 TRACE("ColorDevice = %d\n", (int)ppd
->ColorDevice
);
606 else if((!strcmp("*DefaultResolution", tuple
.key
)) ||
607 (!strcmp("*DefaultJCLResolution", tuple
.key
))) {
608 sscanf(tuple
.value
, "%d", &(ppd
->DefaultResolution
));
609 TRACE("DefaultResolution = %d\n", ppd
->DefaultResolution
);
612 else if(!strcmp("*Font", tuple
.key
)) {
615 for(fn
= ppd
->InstalledFonts
; fn
&& fn
->next
; fn
= fn
->next
)
618 ppd
->InstalledFonts
= HeapAlloc(PSDRV_Heap
,
619 HEAP_ZERO_MEMORY
, sizeof(*fn
));
620 fn
= ppd
->InstalledFonts
;
622 fn
->next
= HeapAlloc(PSDRV_Heap
,
623 HEAP_ZERO_MEMORY
, sizeof(*fn
));
626 fn
->Name
= tuple
.option
;
630 else if(!strcmp("*DefaultFont", tuple
.key
)) {
631 ppd
->DefaultFont
= tuple
.value
;
635 else if(!strcmp("*JCLBegin", tuple
.key
)) {
636 ppd
->JCLBegin
= tuple
.value
;
640 else if(!strcmp("*JCLToPSInterpreter", tuple
.key
)) {
641 ppd
->JCLToPSInterpreter
= tuple
.value
;
645 else if(!strcmp("*JCLEnd", tuple
.key
)) {
646 ppd
->JCLEnd
= tuple
.value
;
650 else if(!strcmp("*PageSize", tuple
.key
)) {
652 page
= PSDRV_PPDGetPageSizeInfo(ppd
, tuple
.option
);
657 page
->Name
= tuple
.option
;
660 for(i
= 0; PageTrans
[i
].PSName
; i
++) {
661 if(!strcmp(PageTrans
[i
].PSName
, page
->Name
)) { /* case ? */
662 page
->WinPage
= PageTrans
[i
].WinPage
;
667 TRACE("Can't find Windows page type for '%s' - using %u\n",
668 page
->Name
, UserPageType
);
669 page
->WinPage
= UserPageType
++;
672 if(!page
->FullName
) {
674 page
->FullName
= tuple
.opttrans
;
675 tuple
.opttrans
= NULL
;
678 page
->FullName
= HeapAlloc( PSDRV_Heap
, 0, strlen(page
->Name
)+1 );
679 strcpy( page
->FullName
, page
->Name
);
682 if(!page
->InvocationString
) {
683 page
->InvocationString
= tuple
.value
;
688 else if(!strcmp("*DefaultPageSize", tuple
.key
)) {
689 if(default_pagesize
) {
690 WARN("Already set default pagesize\n");
692 default_pagesize
= tuple
.value
;
697 else if(!strcmp("*ImageableArea", tuple
.key
)) {
699 page
= PSDRV_PPDGetPageSizeInfo(ppd
, tuple
.option
);
702 page
->Name
= tuple
.option
;
705 if(!page
->FullName
) {
706 page
->FullName
= tuple
.opttrans
;
707 tuple
.opttrans
= NULL
;
710 #define PIA page->ImageableArea
712 PIA
= HeapAlloc( PSDRV_Heap
, 0, sizeof(*PIA
) );
713 sscanf(tuple
.value
, "%f%f%f%f", &PIA
->llx
, &PIA
->lly
,
714 &PIA
->urx
, &PIA
->ury
);
720 else if(!strcmp("*PaperDimension", tuple
.key
)) {
722 page
= PSDRV_PPDGetPageSizeInfo(ppd
, tuple
.option
);
725 page
->Name
= tuple
.option
;
728 if(!page
->FullName
) {
729 page
->FullName
= tuple
.opttrans
;
730 tuple
.opttrans
= NULL
;
733 #define PD page->PaperDimension
735 PD
= HeapAlloc( PSDRV_Heap
, 0, sizeof(*PD
) );
736 sscanf(tuple
.value
, "%f%f", &PD
->x
, &PD
->y
);
741 else if(!strcmp("*LandscapeOrientation", tuple
.key
)) {
742 if(!strcmp(tuple
.value
, "Plus90"))
743 ppd
->LandscapeOrientation
= 90;
744 else if(!strcmp(tuple
.value
, "Minus90"))
745 ppd
->LandscapeOrientation
= -90;
747 /* anything else, namely 'any', leaves value at 0 */
749 TRACE("LandscapeOrientation = %d\n",
750 ppd
->LandscapeOrientation
);
753 else if(!strcmp("*UIConstraints", tuple
.key
)) {
755 CONSTRAINT
*con
, **insert
= &ppd
->Constraints
;
758 insert
= &((*insert
)->next
);
760 con
= *insert
= HeapAlloc( PSDRV_Heap
, HEAP_ZERO_MEMORY
,
765 con
->Feature1
= PSDRV_PPDGetWord(start
, &start
);
766 con
->Value1
= PSDRV_PPDGetWord(start
, &start
);
767 con
->Feature2
= PSDRV_PPDGetWord(start
, &start
);
768 con
->Value2
= PSDRV_PPDGetWord(start
, &start
);
771 else if (!strcmp("*InputSlot", tuple
.key
))
775 tuple
.opttrans
= tuple
.option
;
777 TRACE("Using Windows bin type %u for '%s'\n", UserBinType
,
780 /* FIXME - should check for failure */
781 PSDRV_AddSlot(ppd
, tuple
.option
, tuple
.opttrans
, tuple
.value
,
784 tuple
.option
= tuple
.opttrans
= tuple
.value
= NULL
;
788 * Windows treats "manual feed" as another paper source. Most PPD
789 * files, however, treat it as a separate option which is either on or
792 else if (!strcmp("*ManualFeed", tuple
.key
) && tuple
.option
&&
793 !strcmp ("True", tuple
.option
))
795 /* FIXME - should check for failure */
796 PSDRV_AddSlot(ppd
, "Manual Feed", "Manual Feed", tuple
.value
, DMBIN_MANUAL
);
800 else if(!strcmp("*TTRasterizer", tuple
.key
)) {
801 if(!strcasecmp("None", tuple
.value
))
802 ppd
->TTRasterizer
= RO_None
;
803 else if(!strcasecmp("Accept68K", tuple
.value
))
804 ppd
->TTRasterizer
= RO_Accept68K
;
805 else if(!strcasecmp("Type42", tuple
.value
))
806 ppd
->TTRasterizer
= RO_Type42
;
807 else if(!strcasecmp("TrueImage", tuple
.value
))
808 ppd
->TTRasterizer
= RO_TrueImage
;
810 FIXME("Unknown option %s for *TTRasterizer\n",
812 ppd
->TTRasterizer
= RO_None
;
814 TRACE("*TTRasterizer = %d\n", ppd
->TTRasterizer
);
817 else if(!strcmp("*Duplex", tuple
.key
)) {
819 for(duplex
= &ppd
->Duplexes
; *duplex
; duplex
= &(*duplex
)->next
)
821 *duplex
= HeapAlloc(GetProcessHeap(), 0, sizeof(**duplex
));
822 (*duplex
)->Name
= tuple
.option
;
823 (*duplex
)->FullName
= tuple
.opttrans
;
824 (*duplex
)->InvocationString
= tuple
.value
;
825 (*duplex
)->next
= NULL
;
826 if(!strcasecmp("None", tuple
.option
) || !strcasecmp("False", tuple
.option
)
827 || !strcasecmp("Simplex", tuple
.option
))
828 (*duplex
)->WinDuplex
= DMDUP_SIMPLEX
;
829 else if(!strcasecmp("DuplexNoTumble", tuple
.option
))
830 (*duplex
)->WinDuplex
= DMDUP_VERTICAL
;
831 else if(!strcasecmp("DuplexTumble", tuple
.option
))
832 (*duplex
)->WinDuplex
= DMDUP_HORIZONTAL
;
833 else if(!strcasecmp("Notcapable", tuple
.option
))
834 (*duplex
)->WinDuplex
= 0;
836 FIXME("Unknown option %s for *Duplex defaulting to simplex\n", tuple
.option
);
837 (*duplex
)->WinDuplex
= DMDUP_SIMPLEX
;
839 tuple
.option
= tuple
.opttrans
= tuple
.value
= NULL
;
842 else if(!strcmp("*DefaultDuplex", tuple
.key
)) {
844 WARN("Already set default duplex\n");
846 default_duplex
= tuple
.value
;
851 if(tuple
.key
) HeapFree(PSDRV_Heap
, 0, tuple
.key
);
852 if(tuple
.option
) HeapFree(PSDRV_Heap
, 0, tuple
.option
);
853 if(tuple
.value
) HeapFree(PSDRV_Heap
, 0, tuple
.value
);
854 if(tuple
.opttrans
) HeapFree(PSDRV_Heap
, 0, tuple
.opttrans
);
855 if(tuple
.valtrans
) HeapFree(PSDRV_Heap
, 0, tuple
.valtrans
);
860 ppd
->DefaultPageSize
= NULL
;
861 if(default_pagesize
) {
863 for(page
= ppd
->PageSizes
; page
; page
= page
->next
) {
864 if(!strcmp(page
->Name
, default_pagesize
)) {
865 ppd
->DefaultPageSize
= page
;
866 TRACE("DefaultPageSize: %s\n", page
->Name
);
870 HeapFree(PSDRV_Heap
, 0, default_pagesize
);
872 if(!ppd
->DefaultPageSize
) {
873 ppd
->DefaultPageSize
= ppd
->PageSizes
;
874 TRACE("Setting DefaultPageSize to first in list\n");
877 ppd
->DefaultDuplex
= NULL
;
880 for(duplex
= ppd
->Duplexes
; duplex
; duplex
= duplex
->next
) {
881 if(!strcmp(duplex
->Name
, default_duplex
)) {
882 ppd
->DefaultDuplex
= duplex
;
883 TRACE("DefaultDuplex: %s\n", duplex
->Name
);
887 HeapFree(PSDRV_Heap
, 0, default_duplex
);
889 if(!ppd
->DefaultDuplex
) {
890 ppd
->DefaultDuplex
= ppd
->Duplexes
;
891 TRACE("Setting DefaultDuplex to first in list\n");
901 OPTIONENTRY
*optionEntry
;
903 for(fn
= ppd
->InstalledFonts
; fn
; fn
= fn
->next
)
904 TRACE("'%s'\n", fn
->Name
);
906 for(page
= ppd
->PageSizes
; page
; page
= page
->next
) {
907 TRACE("'%s' aka '%s' (%d) invoked by '%s'\n", page
->Name
,
908 page
->FullName
, page
->WinPage
, page
->InvocationString
);
909 if(page
->ImageableArea
)
910 TRACE("Area = %.2f,%.2f - %.2f, %.2f\n",
911 page
->ImageableArea
->llx
, page
->ImageableArea
->lly
,
912 page
->ImageableArea
->urx
, page
->ImageableArea
->ury
);
913 if(page
->PaperDimension
)
914 TRACE("Dimension = %.2f x %.2f\n",
915 page
->PaperDimension
->x
, page
->PaperDimension
->y
);
918 for(con
= ppd
->Constraints
; con
; con
= con
->next
)
919 TRACE("CONSTRAINTS@ %s %s %s %s\n", con
->Feature1
,
920 con
->Value1
, con
->Feature2
, con
->Value2
);
922 for(option
= ppd
->InstalledOptions
; option
; option
= option
->next
) {
923 TRACE("OPTION: %s %s %s\n", option
->OptionName
,
924 option
->FullName
, option
->DefaultOption
);
925 for(optionEntry
= option
->Options
; optionEntry
;
926 optionEntry
= optionEntry
->next
)
927 TRACE("\tOPTIONENTRY: %s %s %s\n", optionEntry
->Name
,
928 optionEntry
->FullName
, optionEntry
->InvocationString
);
931 for(slot
= ppd
->InputSlots
; slot
; slot
= slot
->next
)
932 TRACE("INPUTSLOTS '%s' Name '%s' (%d) Invocation '%s'\n",
933 slot
->Name
, slot
->FullName
, slot
->WinBin
,
934 slot
->InvocationString
);