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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
32 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
47 /* map of page names in ppd file to Windows paper constants */
53 {"10x11", DMPAPER_10X11
},
54 {"10x14", DMPAPER_10X14
},
55 {"11x17", DMPAPER_11X17
}, /* not in Adobe PPD file spec */
56 {"12x11", DMPAPER_12X11
},
57 {"15x11", DMPAPER_15X11
},
58 {"9x11", DMPAPER_9X11
},
61 {"A3.Transverse", DMPAPER_A3_TRANSVERSE
},
62 {"A3Extra", DMPAPER_A3_EXTRA
},
63 {"A3Extra.Transverse", DMPAPER_A3_EXTRA_TRANSVERSE
},
64 {"A3Rotated", DMPAPER_A3_ROTATED
},
66 {"A4.Transverse", DMPAPER_A4_TRANSVERSE
},
67 {"A4Extra", DMPAPER_A4_EXTRA
},
68 {"A4Plus", DMPAPER_A4_PLUS
},
69 {"A4Rotated", DMPAPER_A4_ROTATED
},
70 {"A4Small", DMPAPER_A4SMALL
},
72 {"A5.Transverse", DMPAPER_A5_TRANSVERSE
},
73 {"A5Extra", DMPAPER_A5_EXTRA
},
74 {"A5Rotated", DMPAPER_A5_ROTATED
},
76 {"A6Rotated", DMPAPER_A6_ROTATED
},
77 {"ARCHC", DMPAPER_CSHEET
},
78 {"ARCHD", DMPAPER_DSHEET
},
79 {"ARCHE", DMPAPER_ESHEET
},
81 {"B4Rotated", DMPAPER_B4_JIS_ROTATED
},
83 {"B5.Transverse", DMPAPER_B5_TRANSVERSE
},
84 {"B5Rotated", DMPAPER_B5_JIS_ROTATED
},
85 {"B6", DMPAPER_B6_JIS
},
86 {"B6Rotated", DMPAPER_B6_JIS_ROTATED
},
87 {"C4", DMPAPER_ENV_C4
}, /* use EnvC4 */
88 {"C5", DMPAPER_ENV_C5
}, /* use EnvC5 */
89 {"C6", DMPAPER_ENV_C6
}, /* use EnvC6 */
90 {"Comm10", DMPAPER_ENV_10
}, /* use Env10 */
91 {"DL", DMPAPER_ENV_DL
}, /* use EnvDL */
92 {"DoublePostcard", DMPAPER_DBL_JAPANESE_POSTCARD
},
93 {"DoublePostcardRotated", DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED
},
94 {"Env10", DMPAPER_ENV_10
},
95 {"Env11", DMPAPER_ENV_11
},
96 {"Env12", DMPAPER_ENV_12
},
97 {"Env14", DMPAPER_ENV_14
},
98 {"Env9", DMPAPER_ENV_9
},
99 {"EnvC3", DMPAPER_ENV_C3
},
100 {"EnvC4", DMPAPER_ENV_C4
},
101 {"EnvC5", DMPAPER_ENV_C5
},
102 {"EnvC6", DMPAPER_ENV_C6
},
103 {"EnvC65", DMPAPER_ENV_C65
},
104 {"EnvChou3", DMPAPER_JENV_CHOU3
},
105 {"EnvChou3Rotated", DMPAPER_JENV_CHOU3_ROTATED
},
106 {"EnvChou4", DMPAPER_JENV_CHOU4
},
107 {"EnvChou4Rotated", DMPAPER_JENV_CHOU4_ROTATED
},
108 {"EnvDL", DMPAPER_ENV_DL
},
109 {"EnvISOB4", DMPAPER_ENV_B4
},
110 {"EnvISOB5", DMPAPER_ENV_B5
},
111 {"EnvISOB6", DMPAPER_ENV_B6
},
112 {"EnvInvite", DMPAPER_ENV_INVITE
},
113 {"EnvItalian", DMPAPER_ENV_ITALY
},
114 {"EnvKaku2", DMPAPER_JENV_KAKU2
},
115 {"EnvKaku2Rotated", DMPAPER_JENV_KAKU2_ROTATED
},
116 {"EnvKaku3", DMPAPER_JENV_KAKU3
},
117 {"EnvKaku3Rotated", DMPAPER_JENV_KAKU3_ROTATED
},
118 {"EnvMonarch", DMPAPER_ENV_MONARCH
},
119 {"EnvPRC1", DMPAPER_PENV_1
},
120 {"EnvPRC10", DMPAPER_PENV_10
},
121 {"EnvPRC10Rotated", DMPAPER_PENV_10_ROTATED
},
122 {"EnvPRC1Rotated", DMPAPER_PENV_1_ROTATED
},
123 {"EnvPRC2", DMPAPER_PENV_2
},
124 {"EnvPRC2Rotated", DMPAPER_PENV_2_ROTATED
},
125 {"EnvPRC3", DMPAPER_PENV_3
},
126 {"EnvPRC3Rotated", DMPAPER_PENV_3_ROTATED
},
127 {"EnvPRC4", DMPAPER_PENV_4
},
128 {"EnvPRC4Rotated", DMPAPER_PENV_4_ROTATED
},
129 {"EnvPRC5", DMPAPER_PENV_5
},
130 {"EnvPRC5Rotated", DMPAPER_PENV_5_ROTATED
},
131 {"EnvPRC6", DMPAPER_PENV_6
},
132 {"EnvPRC6Rotated", DMPAPER_PENV_6_ROTATED
},
133 {"EnvPRC7", DMPAPER_PENV_7
},
134 {"EnvPRC7Rotated", DMPAPER_PENV_7_ROTATED
},
135 {"EnvPRC8", DMPAPER_PENV_8
},
136 {"EnvPRC8Rotated", DMPAPER_PENV_8_ROTATED
},
137 {"EnvPRC9", DMPAPER_PENV_9
},
138 {"EnvPRC9Rotated", DMPAPER_PENV_9_ROTATED
},
139 {"EnvPersonal", DMPAPER_ENV_PERSONAL
},
140 {"EnvYou4", DMPAPER_JENV_YOU4
},
141 {"EnvYou4Rotated", DMPAPER_JENV_YOU4_ROTATED
},
142 {"Executive", DMPAPER_EXECUTIVE
},
143 {"FanFoldGerman", DMPAPER_FANFOLD_STD_GERMAN
},
144 {"FanFoldGermanLegal", DMPAPER_FANFOLD_LGL_GERMAN
},
145 {"FanFoldUS", DMPAPER_FANFOLD_US
},
146 {"Folio", DMPAPER_FOLIO
},
147 {"ISOB4", DMPAPER_ISO_B4
},
148 {"ISOB5Extra", DMPAPER_B5_EXTRA
},
149 {"Ledger", DMPAPER_LEDGER
},
150 {"Legal", DMPAPER_LEGAL
},
151 {"LegalExtra", DMPAPER_LEGAL_EXTRA
},
152 {"Letter", DMPAPER_LETTER
},
153 {"Letter.Transverse", DMPAPER_LETTER_TRANSVERSE
},
154 {"LetterExtra", DMPAPER_LETTER_EXTRA
},
155 {"LetterExtra.Transverse", DMPAPER_LETTER_EXTRA_TRANSVERSE
},
156 {"LetterPlus", DMPAPER_LETTER_PLUS
},
157 {"LetterRotated", DMPAPER_LETTER_ROTATED
},
158 {"LetterSmall", DMPAPER_LETTERSMALL
},
159 {"Monarch", DMPAPER_ENV_MONARCH
}, /* use EnvMonarch */
160 {"Note", DMPAPER_NOTE
},
161 {"PRC16K", DMPAPER_P16K
},
162 {"PRC16KRotated", DMPAPER_P16K_ROTATED
},
163 {"PRC32K", DMPAPER_P32K
},
164 {"PRC32KBig", DMPAPER_P32KBIG
},
165 {"PRC32KBigRotated", DMPAPER_P32KBIG_ROTATED
},
166 {"PRC32KRotated", DMPAPER_P32K_ROTATED
},
167 {"Postcard", DMPAPER_JAPANESE_POSTCARD
},
168 {"PostcardRotated", DMPAPER_JAPANESE_POSTCARD_ROTATED
},
169 {"Quarto", DMPAPER_QUARTO
},
170 {"Statement", DMPAPER_STATEMENT
},
171 {"SuperA", DMPAPER_A_PLUS
},
172 {"SuperB", DMPAPER_B_PLUS
},
173 {"Tabloid", DMPAPER_TABLOID
},
174 {"TabloidExtra", DMPAPER_TABLOID_EXTRA
},
178 static WORD UserPageType
= DMPAPER_USER
;
179 static WORD UserBinType
= DMBIN_USER
;
181 /***********************************************************************
185 * Copies str into a newly allocated string from the process heap subsituting
186 * hex strings enclosed in '<' and '>' for their byte codes.
189 static char *PSDRV_PPDDecodeHex(char *str
)
191 char *buf
, *in
, *out
;
194 buf
= HeapAlloc(PSDRV_Heap
, 0, strlen(str
) + 1);
198 for(in
= str
, out
= buf
; *in
; in
++) {
209 else if(isspace(*in
))
213 if(!isxdigit(*in
) || !isxdigit(*(in
+ 1))) {
214 ERR("Invalid hex char in hex string\n");
215 HeapFree(PSDRV_Heap
, 0, buf
);
219 for(i
= 0; i
< 2; i
++) {
220 if(isdigit(*(in
+ i
)))
221 *out
|= (*(in
+ i
) - '0') << ((1-i
) * 4);
223 *out
|= (toupper(*(in
+ i
)) - 'A' + 10) << ((1-i
) * 4);
235 /***********************************************************************
237 * PSDRV_PPDGetTransValue
240 static BOOL
PSDRV_PPDGetTransValue(char *start
, PPDTuple
*tuple
)
244 end
= strpbrk(start
, "\r\n");
245 if(end
== start
) return FALSE
;
246 if(!end
) end
= start
+ strlen(start
);
247 buf
= HeapAlloc( PSDRV_Heap
, 0, end
- start
+ 1 );
248 memcpy(buf
, start
, end
- start
);
249 *(buf
+ (end
- start
)) = '\0';
250 tuple
->valtrans
= PSDRV_PPDDecodeHex(buf
);
251 HeapFree( PSDRV_Heap
, 0, buf
);
256 /***********************************************************************
258 * PSDRV_PPDGetInvocationValue
260 * Passed string that should be surrounded by `"'s, return string alloced
263 static BOOL
PSDRV_PPDGetInvocationValue(FILE *fp
, char *pos
, PPDTuple
*tuple
)
265 char *start
, *end
, *buf
;
270 buf
= HeapAlloc( PSDRV_Heap
, 0, strlen(start
) + 1 );
273 end
= strchr(start
, '"');
275 buf
= HeapReAlloc( PSDRV_Heap
, 0, buf
,
276 len
+ (end
- start
) + 1 );
277 memcpy(buf
+ len
, start
, end
- start
);
278 *(buf
+ len
+ (end
- start
)) = '\0';
280 start
= strchr(end
, '/');
282 return PSDRV_PPDGetTransValue(start
+ 1, tuple
);
285 int sl
= strlen(start
);
286 buf
= HeapReAlloc( PSDRV_Heap
, 0, buf
, len
+ sl
+ 1 );
287 strcpy(buf
+ len
, start
);
290 } while( fgets((start
= line
), sizeof(line
), fp
) );
293 HeapFree( PSDRV_Heap
, 0, buf
);
298 /***********************************************************************
300 * PSDRV_PPDGetQuotedValue
302 * Passed string that should be surrounded by `"'s. Expand <xx> as hex
303 * return string alloced from process heap.
305 static BOOL
PSDRV_PPDGetQuotedValue(FILE *fp
, char *pos
, PPDTuple
*tuple
)
309 if(!PSDRV_PPDGetInvocationValue(fp
, pos
, tuple
))
311 buf
= PSDRV_PPDDecodeHex(tuple
->value
);
312 HeapFree(PSDRV_Heap
, 0, tuple
->value
);
318 /***********************************************************************
320 * PSDRV_PPDGetStringValue
322 * Just strip leading white space.
324 static BOOL
PSDRV_PPDGetStringValue(char *str
, PPDTuple
*tuple
)
326 char *start
= str
, *end
;
328 while(*start
!= '\0' && isspace(*start
))
331 end
= strpbrk(start
, "/\r\n");
332 if(!end
) end
= start
+ strlen(start
);
333 tuple
->value
= HeapAlloc( PSDRV_Heap
, 0, (end
- start
) + 1 );
334 memcpy(tuple
->value
, start
, end
- start
);
335 *(tuple
->value
+ (end
- start
)) = '\0';
337 PSDRV_PPDGetTransValue(end
+ 1, tuple
);
342 /***********************************************************************
344 * PSDRV_PPDSymbolValue
346 * Not implemented yet.
348 static BOOL
PSDRV_PPDGetSymbolValue(char *pos
, PPDTuple
*tuple
)
355 /*********************************************************************
357 * PSDRV_PPDGetNextTuple
359 * Gets the next Keyword Option Value tuple from the file. Allocs space off
360 * the process heap which should be free()ed by the caller if not needed.
362 static BOOL
PSDRV_PPDGetNextTuple(FILE *fp
, PPDTuple
*tuple
)
364 char line
[257], *opt
, *cp
, *trans
, *endkey
;
371 memset(tuple
, 0, sizeof(*tuple
));
374 if(!fgets(line
, sizeof(line
), fp
))
376 if(line
[0] == '*' && line
[1] != '%' && strncmp(line
, "*End", 4))
380 if(line
[strlen(line
)-1] != '\n') {
381 ERR("Line too long.\n");
385 for(cp
= line
; !isspace(*cp
) && *cp
!= ':'; cp
++)
389 if(*cp
== ':') { /* <key>: */
394 if(*cp
== ':') { /* <key> : */
396 } else { /* <key> <option> */
401 tuple
->key
= HeapAlloc( PSDRV_Heap
, 0, endkey
- line
+ 1 );
402 if(!tuple
->key
) return FALSE
;
404 memcpy(tuple
->key
, line
, endkey
- line
);
405 tuple
->key
[endkey
- line
] = '\0';
407 if(gotoption
) { /* opt points to 1st non-space character of the option */
408 cp
= strpbrk(opt
, ":/");
410 ERR("Error in line '%s'?\n", line
);
411 HeapFree(GetProcessHeap(), 0, tuple
->key
);
414 tuple
->option
= HeapAlloc( PSDRV_Heap
, 0, cp
- opt
+ 1 );
415 if(!tuple
->option
) return FALSE
;
416 memcpy(tuple
->option
, opt
, cp
- opt
);
417 tuple
->option
[cp
- opt
] = '\0';
421 cp
= strchr(trans
, ':');
423 ERR("Error in line '%s'?\n", line
);
424 HeapFree(GetProcessHeap(), 0, tuple
->option
);
425 HeapFree(GetProcessHeap(), 0, tuple
->key
);
428 buf
= HeapAlloc( PSDRV_Heap
, 0, cp
- trans
+ 1 );
429 if(!buf
) return FALSE
;
430 memcpy(buf
, trans
, cp
- trans
);
431 buf
[cp
- trans
] = '\0';
432 tuple
->opttrans
= PSDRV_PPDDecodeHex(buf
);
433 HeapFree( PSDRV_Heap
, 0, buf
);
437 /* cp should point to a ':', so we increment past it */
445 if( (!gotoption
&& strncmp(tuple
->key
, "*?", 2) ) ||
446 !strncmp(tuple
->key
, "*JCL", 4))
447 PSDRV_PPDGetQuotedValue(fp
, cp
, tuple
);
449 PSDRV_PPDGetInvocationValue(fp
, cp
, tuple
);
453 PSDRV_PPDGetSymbolValue(cp
, tuple
);
457 PSDRV_PPDGetStringValue(cp
, tuple
);
462 /*********************************************************************
464 * PSDRV_PPDGetPageSizeInfo
466 * Searches ppd PageSize list to return entry matching name or creates new
467 * entry which is appended to the list if name is not found.
470 PAGESIZE
*PSDRV_PPDGetPageSizeInfo(PPD
*ppd
, char *name
)
472 PAGESIZE
*page
= ppd
->PageSizes
, *lastpage
;
475 page
= ppd
->PageSizes
= HeapAlloc( PSDRV_Heap
,
476 HEAP_ZERO_MEMORY
, sizeof(*page
) );
479 for( ; page
; page
= page
->next
) {
480 if(!strcmp(page
->Name
, name
))
485 lastpage
->next
= HeapAlloc( PSDRV_Heap
,
486 HEAP_ZERO_MEMORY
, sizeof(*page
) );
487 return lastpage
->next
;
491 /**********************************************************************
495 * Returns ptr alloced from heap to first word in str. Strips leading spaces.
496 * Puts ptr to next word in next
498 static char *PSDRV_PPDGetWord(char *str
, char **next
)
500 char *start
, *end
, *ret
;
503 while(start
&& *start
&& isspace(*start
))
505 if(!start
|| !*start
) return FALSE
;
508 while(*end
&& !isspace(*end
))
511 ret
= HeapAlloc( PSDRV_Heap
, 0, end
- start
+ 1 );
512 memcpy(ret
, start
, end
- start
);
513 *(ret
+ (end
- start
)) = '\0';
515 while(*end
&& isspace(*end
))
525 /*******************************************************************************
529 static INT
PSDRV_AddSlot(PPD
*ppd
, LPCSTR szName
, LPCSTR szFullName
,
530 LPSTR szInvocationString
, WORD wWinBin
)
532 INPUTSLOT
*slot
, **insert
= &ppd
->InputSlots
;
535 insert
= &((*insert
)->next
);
537 slot
= *insert
= HeapAlloc(PSDRV_Heap
, HEAP_ZERO_MEMORY
, 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 push_lc_numeric("C");
714 sscanf(tuple
.value
, "%f%f%f%f", &PIA
->llx
, &PIA
->lly
,
715 &PIA
->urx
, &PIA
->ury
);
722 else if(!strcmp("*PaperDimension", tuple
.key
)) {
724 page
= PSDRV_PPDGetPageSizeInfo(ppd
, tuple
.option
);
727 page
->Name
= tuple
.option
;
730 if(!page
->FullName
) {
731 page
->FullName
= tuple
.opttrans
;
732 tuple
.opttrans
= NULL
;
735 #define PD page->PaperDimension
737 PD
= HeapAlloc( PSDRV_Heap
, 0, sizeof(*PD
) );
738 push_lc_numeric("C");
739 sscanf(tuple
.value
, "%f%f", &PD
->x
, &PD
->y
);
745 else if(!strcmp("*LandscapeOrientation", tuple
.key
)) {
746 if(!strcmp(tuple
.value
, "Plus90"))
747 ppd
->LandscapeOrientation
= 90;
748 else if(!strcmp(tuple
.value
, "Minus90"))
749 ppd
->LandscapeOrientation
= -90;
751 /* anything else, namely 'any', leaves value at 0 */
753 TRACE("LandscapeOrientation = %d\n",
754 ppd
->LandscapeOrientation
);
757 else if(!strcmp("*UIConstraints", tuple
.key
)) {
759 CONSTRAINT
*con
, **insert
= &ppd
->Constraints
;
762 insert
= &((*insert
)->next
);
764 con
= *insert
= HeapAlloc( PSDRV_Heap
, HEAP_ZERO_MEMORY
,
769 con
->Feature1
= PSDRV_PPDGetWord(start
, &start
);
770 con
->Value1
= PSDRV_PPDGetWord(start
, &start
);
771 con
->Feature2
= PSDRV_PPDGetWord(start
, &start
);
772 con
->Value2
= PSDRV_PPDGetWord(start
, &start
);
775 else if (!strcmp("*InputSlot", tuple
.key
))
779 tuple
.opttrans
= tuple
.option
;
781 TRACE("Using Windows bin type %u for '%s'\n", UserBinType
,
784 /* FIXME - should check for failure */
785 PSDRV_AddSlot(ppd
, tuple
.option
, tuple
.opttrans
, tuple
.value
,
788 tuple
.option
= tuple
.opttrans
= tuple
.value
= NULL
;
792 * Windows treats "manual feed" as another paper source. Most PPD
793 * files, however, treat it as a separate option which is either on or
796 else if (!strcmp("*ManualFeed", tuple
.key
) && tuple
.option
&&
797 !strcmp ("True", tuple
.option
))
799 /* FIXME - should check for failure */
800 PSDRV_AddSlot(ppd
, "Manual Feed", "Manual Feed", tuple
.value
, DMBIN_MANUAL
);
804 else if(!strcmp("*TTRasterizer", tuple
.key
)) {
805 if(!strcasecmp("None", tuple
.value
))
806 ppd
->TTRasterizer
= RO_None
;
807 else if(!strcasecmp("Accept68K", tuple
.value
))
808 ppd
->TTRasterizer
= RO_Accept68K
;
809 else if(!strcasecmp("Type42", tuple
.value
))
810 ppd
->TTRasterizer
= RO_Type42
;
811 else if(!strcasecmp("TrueImage", tuple
.value
))
812 ppd
->TTRasterizer
= RO_TrueImage
;
814 FIXME("Unknown option %s for *TTRasterizer\n",
816 ppd
->TTRasterizer
= RO_None
;
818 TRACE("*TTRasterizer = %d\n", ppd
->TTRasterizer
);
821 else if(!strcmp("*Duplex", tuple
.key
)) {
823 for(duplex
= &ppd
->Duplexes
; *duplex
; duplex
= &(*duplex
)->next
)
825 *duplex
= HeapAlloc(GetProcessHeap(), 0, sizeof(**duplex
));
826 (*duplex
)->Name
= tuple
.option
;
827 (*duplex
)->FullName
= tuple
.opttrans
;
828 (*duplex
)->InvocationString
= tuple
.value
;
829 (*duplex
)->next
= NULL
;
830 if(!strcasecmp("None", tuple
.option
) || !strcasecmp("False", tuple
.option
)
831 || !strcasecmp("Simplex", tuple
.option
))
832 (*duplex
)->WinDuplex
= DMDUP_SIMPLEX
;
833 else if(!strcasecmp("DuplexNoTumble", tuple
.option
))
834 (*duplex
)->WinDuplex
= DMDUP_VERTICAL
;
835 else if(!strcasecmp("DuplexTumble", tuple
.option
))
836 (*duplex
)->WinDuplex
= DMDUP_HORIZONTAL
;
837 else if(!strcasecmp("Notcapable", tuple
.option
))
838 (*duplex
)->WinDuplex
= 0;
840 FIXME("Unknown option %s for *Duplex defaulting to simplex\n", tuple
.option
);
841 (*duplex
)->WinDuplex
= DMDUP_SIMPLEX
;
843 tuple
.option
= tuple
.opttrans
= tuple
.value
= NULL
;
846 else if(!strcmp("*DefaultDuplex", tuple
.key
)) {
848 WARN("Already set default duplex\n");
850 default_duplex
= tuple
.value
;
855 HeapFree(PSDRV_Heap
, 0, tuple
.key
);
856 HeapFree(PSDRV_Heap
, 0, tuple
.option
);
857 HeapFree(PSDRV_Heap
, 0, tuple
.value
);
858 HeapFree(PSDRV_Heap
, 0, tuple
.opttrans
);
859 HeapFree(PSDRV_Heap
, 0, tuple
.valtrans
);
864 ppd
->DefaultPageSize
= NULL
;
865 if(default_pagesize
) {
867 for(page
= ppd
->PageSizes
; page
; page
= page
->next
) {
868 if(!strcmp(page
->Name
, default_pagesize
)) {
869 ppd
->DefaultPageSize
= page
;
870 TRACE("DefaultPageSize: %s\n", page
->Name
);
874 HeapFree(PSDRV_Heap
, 0, default_pagesize
);
876 if(!ppd
->DefaultPageSize
) {
877 ppd
->DefaultPageSize
= ppd
->PageSizes
;
878 TRACE("Setting DefaultPageSize to first in list\n");
881 ppd
->DefaultDuplex
= NULL
;
884 for(duplex
= ppd
->Duplexes
; duplex
; duplex
= duplex
->next
) {
885 if(!strcmp(duplex
->Name
, default_duplex
)) {
886 ppd
->DefaultDuplex
= duplex
;
887 TRACE("DefaultDuplex: %s\n", duplex
->Name
);
891 HeapFree(PSDRV_Heap
, 0, default_duplex
);
893 if(!ppd
->DefaultDuplex
) {
894 ppd
->DefaultDuplex
= ppd
->Duplexes
;
895 TRACE("Setting DefaultDuplex to first in list\n");
905 OPTIONENTRY
*optionEntry
;
907 for(fn
= ppd
->InstalledFonts
; fn
; fn
= fn
->next
)
908 TRACE("'%s'\n", fn
->Name
);
910 for(page
= ppd
->PageSizes
; page
; page
= page
->next
) {
911 TRACE("'%s' aka '%s' (%d) invoked by '%s'\n", page
->Name
,
912 page
->FullName
, page
->WinPage
, page
->InvocationString
);
913 if(page
->ImageableArea
)
914 TRACE("Area = %.2f,%.2f - %.2f, %.2f\n",
915 page
->ImageableArea
->llx
, page
->ImageableArea
->lly
,
916 page
->ImageableArea
->urx
, page
->ImageableArea
->ury
);
917 if(page
->PaperDimension
)
918 TRACE("Dimension = %.2f x %.2f\n",
919 page
->PaperDimension
->x
, page
->PaperDimension
->y
);
922 for(con
= ppd
->Constraints
; con
; con
= con
->next
)
923 TRACE("CONSTRAINTS@ %s %s %s %s\n", con
->Feature1
,
924 con
->Value1
, con
->Feature2
, con
->Value2
);
926 for(option
= ppd
->InstalledOptions
; option
; option
= option
->next
) {
927 TRACE("OPTION: %s %s %s\n", option
->OptionName
,
928 option
->FullName
, option
->DefaultOption
);
929 for(optionEntry
= option
->Options
; optionEntry
;
930 optionEntry
= optionEntry
->next
)
931 TRACE("\tOPTIONENTRY: %s %s %s\n", optionEntry
->Name
,
932 optionEntry
->FullName
, optionEntry
->InvocationString
);
935 for(slot
= ppd
->InputSlots
; slot
; slot
= slot
->next
)
936 TRACE("INPUTSLOTS '%s' Name '%s' (%d) Invocation '%s'\n",
937 slot
->Name
, slot
->FullName
, slot
->WinBin
,
938 slot
->InvocationString
);