First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xprint / ps / PsInit.c
blob639908f730dd6284ba1ac2db69c3f3a91ed04e85
1 /*
3 Copyright 1996, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
27 * (c) Copyright 1996 Hewlett-Packard Company
28 * (c) Copyright 1996 International Business Machines Corp.
29 * (c) Copyright 1996 Sun Microsystems, Inc.
30 * (c) Copyright 1996 Novell, Inc.
31 * (c) Copyright 1996 Digital Equipment Corp.
32 * (c) Copyright 1996 Fujitsu Limited
33 * (c) Copyright 1996 Hitachi, Ltd.
35 * Permission is hereby granted, free of charge, to any person obtaining
36 * a copy of this software and associated documentation files (the
37 * "Software"), to deal in the Software without restriction, including
38 * without limitation the rights to use, copy, modify, merge, publish,
39 * distribute, sublicense, and/or sell copies of the Software, and to
40 * permit persons to whom the Software is furnished to do so, subject
41 * to the following conditions:
43 * The above copyright notice and this permission notice shall be included
44 * in all copies or substantial portions of the Software.
46 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
49 * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
50 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
51 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52 * SOFTWARE.
54 * Except as contained in this notice, the names of the copyright holders
55 * shall not be used in advertising or otherwise to promote the sale, use
56 * or other dealings in this Software without prior written authorization
57 * from said copyright holders.
60 /*******************************************************************
62 ** *********************************************************
63 ** *
64 ** * File: PsInit.c
65 ** *
66 ** * Contents: Initialization code of Ps driver for the print server.
67 ** *
68 ** * Created By: Roger Helmendach (Liberty Systems)
69 ** *
70 ** * Copyright: Copyright 1996 The Open Group, Inc.
71 ** *
72 ** *********************************************************
73 **
74 ********************************************************************/
76 #ifdef HAVE_DIX_CONFIG_H
77 #include <dix-config.h>
78 #endif
80 #include <stdio.h>
81 #include <string.h>
82 #include <unistd.h>
83 #include <sys/types.h>
84 #include <sys/stat.h>
85 #include <sys/wait.h>
87 #include "Ps.h"
88 #include "mi.h"
89 #include "micmap.h"
90 #include "AttrValid.h"
91 #include "fb.h"
93 #include "windowstr.h"
94 #include "DiPrint.h"
96 static void AllocatePsPrivates(ScreenPtr pScreen);
97 static int PsInitContext(XpContextPtr pCon);
98 static int PsDestroyContext(XpContextPtr pCon);
100 int PsScreenPrivateIndex;
101 int PsContextPrivateIndex;
102 int PsPixmapPrivateIndex;
103 int PsWindowPrivateIndex;
105 #ifdef GLXEXT
106 extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
107 #endif /* GLXEXT */
109 Bool
110 InitializePsDriver(ndx, pScreen, argc, argv)
111 int ndx;
112 ScreenPtr pScreen;
113 int argc;
114 char **argv;
116 #if 0
117 int maxXres, maxYres, maxWidth, maxHeight;
118 int maxRes, maxDim, numBytes;
119 PsScreenPrivPtr pPriv;
120 #endif
121 int nv, /* total number of visuals */
122 nv_1bit, /* number of 8bit visuals */
123 nv_8bit, /* number of 8bit visuals */
124 nv_12bit, /* number of 12bit visuals */
125 nv_14bit, /* number of 14bit visuals */
126 nv_16bit, /* number of 16bit visuals */
127 nv_24bit, /* number of 24bit visuals*/
128 nv_30bit; /* number of 30bit visuals*/
129 int nd; /* number of depths */
130 int defaultVisualIndex = -1;
131 VisualID *vids_1bit,
132 *vids_8bit,
133 *vids_12bit,
134 *vids_14bit,
135 *vids_16bit,
136 *vids_24bit,
137 *vids_30bit;
138 VisualPtr visuals;
139 DepthPtr depths;
140 VisualID defaultVisual;
141 int rootDepth;
144 * Register this driver's InitContext function with the print
145 * extension.
147 XpRegisterInitFunc(pScreen, "XP-POSTSCRIPT", PsInitContext);
150 * Create and fill in the devPrivate for the PS driver.
152 AllocatePsPrivates(pScreen);
154 #if 0
155 pPriv = (PsScreenPrivPtr)pScreen->devPrivates[PsScreenPrivateIndex].ptr;
156 pPriv->resDB = rmdb;
157 #endif
159 pScreen->defColormap = (Colormap) FakeClientID(0);
160 pScreen->blackPixel = 1;
161 pScreen->whitePixel = 0;
162 pScreen->QueryBestSize = (QueryBestSizeProcPtr)PsQueryBestSize;
163 pScreen->SaveScreen = (SaveScreenProcPtr)_XpBoolNoop;
164 pScreen->GetImage = (GetImageProcPtr)_XpVoidNoop;
165 pScreen->GetSpans = (GetSpansProcPtr)_XpVoidNoop;
166 pScreen->CreateWindow = PsCreateWindow;
167 pScreen->DestroyWindow = PsDestroyWindow;
168 pScreen->PositionWindow = PsPositionWindow;
169 pScreen->ChangeWindowAttributes = PsChangeWindowAttributes;
170 pScreen->RealizeWindow = PsMapWindow;
171 pScreen->UnrealizeWindow = PsUnmapWindow;
172 pScreen->PaintWindowBackground = PsPaintWindow;
173 pScreen->PaintWindowBorder = PsPaintWindow;
174 pScreen->CloseScreen = PsCloseScreen;
175 pScreen->CopyWindow = PsCopyWindow;
176 /* XXX Hard routine to write! */
179 * These two are going to be VERY different...
181 pScreen->CreatePixmap = PsCreatePixmap;
182 pScreen->DestroyPixmap = PsDestroyPixmap;
183 pScreen->RealizeFont = PsRealizeFont;
184 pScreen->UnrealizeFont = PsUnrealizeFont;
185 pScreen->CreateGC = PsCreateGC;
186 pScreen->CreateColormap = PsCreateColormap;
187 pScreen->DestroyColormap = PsDestroyColormap;
188 pScreen->InstallColormap = PsInstallColormap;
189 pScreen->UninstallColormap = PsUninstallColormap;
190 pScreen->ListInstalledColormaps = PsListInstalledColormaps;
191 pScreen->StoreColors = PsStoreColors;
192 pScreen->ResolveColor = PsResolveColor;
193 /* Will BitmapToRegion make any difference at all? */
194 pScreen->BitmapToRegion = fbPixmapToRegion;
196 visuals = (VisualPtr) xalloc(16*sizeof(VisualRec));
197 depths = (DepthPtr) xalloc(16*sizeof(DepthRec));
198 vids_1bit = (VisualID *)xalloc(16*sizeof(VisualID));
199 vids_8bit = (VisualID *)xalloc(16*sizeof(VisualID));
200 vids_12bit = (VisualID *)xalloc(16*sizeof(VisualID));
201 vids_14bit = (VisualID *)xalloc(16*sizeof(VisualID));
202 vids_16bit = (VisualID *)xalloc(16*sizeof(VisualID));
203 vids_24bit = (VisualID *)xalloc(16*sizeof(VisualID));
204 vids_30bit = (VisualID *)xalloc(16*sizeof(VisualID));
206 nv = nv_1bit = nv_8bit = nv_12bit = nv_14bit = nv_16bit = nv_24bit = nv_30bit = nd = 0;
208 #ifdef PSOUT_USE_DEEPCOLOR
209 /* gisburn: 30bit TrueColor has been disabled for now since it causes problems
210 * with GLX - see https://bugs.freedesktop.org/show_bug.cgi?id=2868 ("Mesa
211 * seems to be unable to handle 30bit TrueColor visuals") for details...
213 #ifdef DISABLED_FOR_NOW
214 /* TrueColor, 30bit, 10bit per R-,G-,B-gun */
215 visuals[nv].vid = FakeClientID(0);
216 visuals[nv].class = TrueColor;
217 visuals[nv].bitsPerRGBValue = 10;
218 visuals[nv].ColormapEntries = 1024;
219 visuals[nv].nplanes = 30;
220 visuals[nv].redMask = 0X3FF00000;
221 visuals[nv].greenMask = 0X000FFC00;
222 visuals[nv].blueMask = 0X000003FF;
223 visuals[nv].offsetRed = 20;
224 visuals[nv].offsetGreen = 10;
225 visuals[nv].offsetBlue = 0;
226 vids_30bit[nv_30bit] = visuals[nv].vid;
227 nv++; nv_30bit++;
228 #endif /* DISABLED_FOR_NOW */
229 #endif /* PSOUT_USE_DEEPCOLOR */
231 /* TrueColor, 24bit */
232 visuals[nv].vid = FakeClientID(0);
233 visuals[nv].class = TrueColor;
234 visuals[nv].bitsPerRGBValue = 8;
235 visuals[nv].ColormapEntries = 256;
236 visuals[nv].nplanes = 24;
237 visuals[nv].redMask = 0X00FF0000;
238 visuals[nv].greenMask = 0X0000FF00;
239 visuals[nv].blueMask = 0X000000FF;
240 visuals[nv].offsetRed = 16;
241 visuals[nv].offsetGreen = 8;
242 visuals[nv].offsetBlue = 0;
243 vids_24bit[nv_24bit] = visuals[nv].vid;
244 nv++; nv_24bit++;
246 /* TrueColor, 16bit */
247 visuals[nv].vid = FakeClientID(0);
248 visuals[nv].class = TrueColor;
249 visuals[nv].bitsPerRGBValue = 6;
250 visuals[nv].ColormapEntries = 64;
251 visuals[nv].nplanes = 16;
252 visuals[nv].redMask = 0x0000f800;
253 visuals[nv].greenMask = 0x000007e0;
254 visuals[nv].blueMask = 0x0000001f;
255 visuals[nv].offsetRed = 11;
256 visuals[nv].offsetGreen = 5;
257 visuals[nv].offsetBlue = 0;
258 vids_16bit[nv_16bit] = visuals[nv].vid;
259 nv++; nv_16bit++;
261 #ifdef PSOUT_USE_DEEPCOLOR
262 /* PostScript Level 2 and above, colors can have 12 bits per component
263 * (36 bit for RGB) */
265 /* PseudoColor, 14bit (15bit won't work as |ColormapEntries==32768|
266 * is too large for a |signed short|... xx@@!!!... ;-( ) */
267 visuals[nv].vid = FakeClientID(0);
268 visuals[nv].class = PseudoColor;
269 visuals[nv].bitsPerRGBValue = 12;
270 visuals[nv].ColormapEntries = 16384;
271 visuals[nv].nplanes = 14;
272 visuals[nv].redMask = 0x0;
273 visuals[nv].greenMask = 0x0;
274 visuals[nv].blueMask = 0x0;
275 visuals[nv].offsetRed = 0x0;
276 visuals[nv].offsetGreen = 0x0;
277 visuals[nv].offsetBlue = 0x0;
278 vids_14bit[nv_14bit] = visuals[nv].vid;
279 nv++; nv_14bit++;
281 /* PseudoColor, 12bit */
282 visuals[nv].vid = FakeClientID(0);
283 visuals[nv].class = PseudoColor;
284 visuals[nv].bitsPerRGBValue = 12;
285 visuals[nv].ColormapEntries = 4096;
286 visuals[nv].nplanes = 12;
287 visuals[nv].redMask = 0x0;
288 visuals[nv].greenMask = 0x0;
289 visuals[nv].blueMask = 0x0;
290 visuals[nv].offsetRed = 0x0;
291 visuals[nv].offsetGreen = 0x0;
292 visuals[nv].offsetBlue = 0x0;
293 vids_12bit[nv_12bit] = visuals[nv].vid;
294 defaultVisualIndex = nv;
295 nv++; nv_12bit++;
297 /* GrayScale, 12bit, 12bit per R-,G-,B-gun */
298 visuals[nv].vid = FakeClientID(0);
299 visuals[nv].class = GrayScale;
300 visuals[nv].bitsPerRGBValue = 12;
301 visuals[nv].ColormapEntries = 4096;
302 visuals[nv].nplanes = 12;
303 visuals[nv].redMask = 0x0;
304 visuals[nv].greenMask = 0x0;
305 visuals[nv].blueMask = 0x0;
306 visuals[nv].offsetRed = 0x0;
307 visuals[nv].offsetGreen = 0x0;
308 visuals[nv].offsetBlue = 0x0;
309 vids_12bit[nv_12bit] = visuals[nv].vid;
310 nv++; nv_12bit++;
312 /* StaticGray, 12bit, 12bit per R-,G-,B-gun */
313 visuals[nv].vid = FakeClientID(0);
314 visuals[nv].class = StaticGray;
315 visuals[nv].bitsPerRGBValue = 12;
316 visuals[nv].ColormapEntries = 4096;
317 visuals[nv].nplanes = 12;
318 visuals[nv].redMask = 0x0;
319 visuals[nv].greenMask = 0x0;
320 visuals[nv].blueMask = 0x0;
321 visuals[nv].offsetRed = 0x0;
322 visuals[nv].offsetGreen = 0x0;
323 visuals[nv].offsetBlue = 0x0;
324 vids_12bit[nv_12bit] = visuals[nv].vid;
325 nv++; nv_12bit++;
326 #endif /* PSOUT_USE_DEEPCOLOR */
328 /* PseudoColor, 8bit */
329 visuals[nv].vid = FakeClientID(0);
330 visuals[nv].class = PseudoColor;
331 visuals[nv].bitsPerRGBValue = 8;
332 visuals[nv].ColormapEntries = 256;
333 visuals[nv].nplanes = 8;
334 visuals[nv].redMask = 0x0;
335 visuals[nv].greenMask = 0x0;
336 visuals[nv].blueMask = 0x0;
337 visuals[nv].offsetRed = 0x0;
338 visuals[nv].offsetGreen = 0x0;
339 visuals[nv].offsetBlue = 0x0;
340 vids_8bit[nv_8bit] = visuals[nv].vid;
341 #ifndef PSOUT_USE_DEEPCOLOR
342 defaultVisualIndex = nv;
343 #endif /* !PSOUT_USE_DEEPCOLOR */
344 nv++; nv_8bit++;
346 /* GrayScale, 8bit */
347 visuals[nv].vid = FakeClientID(0);
348 visuals[nv].class = GrayScale;
349 visuals[nv].bitsPerRGBValue = 8;
350 visuals[nv].ColormapEntries = 256;
351 visuals[nv].nplanes = 8;
352 visuals[nv].redMask = 0x0;
353 visuals[nv].greenMask = 0x0;
354 visuals[nv].blueMask = 0x0;
355 visuals[nv].offsetRed = 0x0;
356 visuals[nv].offsetGreen = 0x0;
357 visuals[nv].offsetBlue = 0x0;
358 vids_8bit[nv_8bit] = visuals[nv].vid;
359 nv++; nv_8bit++;
361 /* StaticGray, 8bit */
362 visuals[nv].vid = FakeClientID(0);
363 visuals[nv].class = StaticGray;
364 visuals[nv].bitsPerRGBValue = 8;
365 visuals[nv].ColormapEntries = 256;
366 visuals[nv].nplanes = 8;
367 visuals[nv].redMask = 0x0;
368 visuals[nv].greenMask = 0x0;
369 visuals[nv].blueMask = 0x0;
370 visuals[nv].offsetRed = 0x0;
371 visuals[nv].offsetGreen = 0x0;
372 visuals[nv].offsetBlue = 0x0;
373 vids_8bit[nv_8bit] = visuals[nv].vid;
374 nv++; nv_8bit++;
376 /* StaticGray, 1bit */
377 visuals[nv].vid = FakeClientID(0);
378 visuals[nv].class = StaticGray;
379 visuals[nv].bitsPerRGBValue = 1;
380 visuals[nv].ColormapEntries = 2;
381 visuals[nv].nplanes = 1;
382 visuals[nv].redMask = 0x0;
383 visuals[nv].greenMask = 0x0;
384 visuals[nv].blueMask = 0x0;
385 visuals[nv].offsetRed = 0x0;
386 visuals[nv].offsetGreen = 0x0;
387 visuals[nv].offsetBlue = 0x0;
388 vids_1bit[nv_1bit] = visuals[nv].vid;
389 nv++; nv_1bit++;
391 if( nv_30bit > 0 )
393 depths[nd].depth = 30;
394 depths[nd].numVids = nv_30bit;
395 depths[nd].vids = vids_30bit;
396 nd++;
399 if( nv_24bit > 0 )
401 depths[nd].depth = 24;
402 depths[nd].numVids = nv_24bit;
403 depths[nd].vids = vids_24bit;
404 nd++;
407 if( nv_16bit > 0 )
409 depths[nd].depth = 16;
410 depths[nd].numVids = nv_16bit;
411 depths[nd].vids = vids_16bit;
412 nd++;
415 if( nv_14bit > 0 )
417 depths[nd].depth = 14;
418 depths[nd].numVids = nv_14bit;
419 depths[nd].vids = vids_14bit;
420 nd++;
423 if( nv_12bit > 0 )
425 depths[nd].depth = 12;
426 depths[nd].numVids = nv_12bit;
427 depths[nd].vids = vids_12bit;
428 nd++;
431 if( nv_8bit > 0 )
433 depths[nd].depth = 8;
434 depths[nd].numVids = nv_8bit;
435 depths[nd].vids = vids_8bit;
436 nd++;
439 if( nv_1bit > 0 )
441 depths[nd].depth = 1;
442 depths[nd].numVids = nv_1bit;
443 depths[nd].vids = vids_1bit;
444 nd++;
447 /* Defaul visual is 12bit PseudoColor */
448 defaultVisual = visuals[defaultVisualIndex].vid;
449 rootDepth = visuals[defaultVisualIndex].nplanes;
451 #ifdef GLXEXT
453 miInitVisualsProcPtr proc = NULL;
455 GlxWrapInitVisuals(&proc);
456 /* GlxInitVisuals ignores the last three arguments. */
457 proc(&visuals, &depths, &nv, &nd,
458 &rootDepth, &defaultVisual, 0, 0, 0);
460 #endif /* GLXEXT */
462 miScreenInit(pScreen, (pointer)0,
463 pScreen->width, pScreen->height,
464 (int) (pScreen->width / (pScreen->mmWidth / 25.40)),
465 (int) (pScreen->height / (pScreen->mmHeight / 25.40)),
466 0, rootDepth, nd,
467 depths, defaultVisual, nv, visuals);
469 if( miCreateDefColormap(pScreen)==FALSE ) return FALSE;
471 /*scalingScreenInit(pScreen);*/
473 return TRUE;
476 static void
477 AllocatePsPrivates(ScreenPtr pScreen)
479 static unsigned long PsGeneration = 0;
481 if((unsigned long)PsGeneration != serverGeneration)
483 PsScreenPrivateIndex = AllocateScreenPrivateIndex();
485 PsWindowPrivateIndex = AllocateWindowPrivateIndex();
486 AllocateWindowPrivate(pScreen, PsWindowPrivateIndex,
487 sizeof(PsWindowPrivRec));
489 PsContextPrivateIndex = XpAllocateContextPrivateIndex();
490 XpAllocateContextPrivate(PsContextPrivateIndex,
491 sizeof(PsContextPrivRec));
493 PsPixmapPrivateIndex = AllocatePixmapPrivateIndex();
494 AllocatePixmapPrivate(pScreen, PsPixmapPrivateIndex,
495 sizeof(PsPixmapPrivRec));
497 PsGeneration = serverGeneration;
499 pScreen->devPrivates[PsScreenPrivateIndex].ptr =
500 (pointer)xalloc(sizeof(PsScreenPrivRec));
504 * PsInitContext
506 * Establish the appropriate values for a PrintContext used with the PS
507 * driver.
510 static char DOC_ATT_SUPP[]="document-attributes-supported";
511 static char DOC_ATT_VAL[]="document-format xp-listfonts-modes";
512 static char JOB_ATT_SUPP[]="job-attributes-supported";
513 static char JOB_ATT_VAL[]="";
514 static char PAGE_ATT_SUPP[]="xp-page-attributes-supported";
515 static char PAGE_ATT_VAL[]="content-orientation default-printer-resolution \
516 default-input-tray default-medium plex xp-listfonts-modes";
518 static int
519 PsInitContext(pCon)
520 XpContextPtr pCon;
522 XpDriverFuncsPtr pFuncs;
523 PsContextPrivPtr pConPriv;
524 char *server, *attrStr;
527 * Initialize the attribute store for this printer.
529 XpInitAttributes(pCon);
532 * Initialize the function pointers
534 pFuncs = &(pCon->funcs);
535 pFuncs->StartJob = PsStartJob;
536 pFuncs->EndJob = PsEndJob;
537 pFuncs->StartDoc = PsStartDoc;
538 pFuncs->EndDoc = PsEndDoc;
539 pFuncs->StartPage = PsStartPage;
540 pFuncs->EndPage = PsEndPage;
541 pFuncs->PutDocumentData = PsDocumentData;
542 pFuncs->GetDocumentData = PsGetDocumentData;
543 pFuncs->GetAttributes = PsGetAttributes;
544 pFuncs->SetAttributes = PsSetAttributes;
545 pFuncs->AugmentAttributes = PsAugmentAttributes;
546 pFuncs->GetOneAttribute = PsGetOneAttribute;
547 pFuncs->DestroyContext = PsDestroyContext;
548 pFuncs->GetMediumDimensions = PsGetMediumDimensions;
549 pFuncs->GetReproducibleArea = PsGetReproducibleArea;
550 pFuncs->SetImageResolution = PsSetImageResolution;
553 * Set up the context privates
555 pConPriv =
556 (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
558 memset(pConPriv, 0, sizeof(PsContextPrivRec));
559 pConPriv->jobFileName = (char *)NULL;
560 pConPriv->pJobFile = (FILE *)NULL;
561 pConPriv->dash = (unsigned char *)NULL;
562 pConPriv->validGC = 0;
563 pConPriv->getDocClient = (ClientPtr)NULL;
564 pConPriv->getDocBufSize = 0;
565 pConPriv->pPsOut = NULL;
566 pConPriv->fontInfoRecords = NULL;
567 pConPriv->fontTypeInfoRecords = NULL;
570 * document-attributes-supported
572 server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP );
573 if ((attrStr = (char *) xalloc(strlen(server) +
574 strlen(DOC_ATT_SUPP) + strlen(DOC_ATT_VAL)
575 + strlen(PAGE_ATT_VAL) + 8)) == NULL)
577 return BadAlloc;
579 sprintf(attrStr, "*%s:\t%s %s %s",
580 DOC_ATT_SUPP, server, DOC_ATT_VAL, PAGE_ATT_VAL);
581 XpAugmentAttributes( pCon, XPPrinterAttr, attrStr);
582 xfree(attrStr);
585 * job-attributes-supported
587 server = XpGetOneAttribute( pCon, XPServerAttr, JOB_ATT_SUPP );
588 if ((attrStr = (char *) xalloc(strlen(server) + strlen(JOB_ATT_SUPP) +
589 strlen(JOB_ATT_VAL) + 8)) == NULL)
591 return BadAlloc;
593 sprintf(attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL);
594 XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
595 xfree(attrStr);
598 * xp-page-attributes-supported
600 server = XpGetOneAttribute( pCon, XPServerAttr, PAGE_ATT_SUPP );
601 if ((attrStr = (char *) xalloc(strlen(server) + strlen(PAGE_ATT_SUPP) +
602 strlen(PAGE_ATT_VAL) + 8)) == NULL)
604 return BadAlloc;
606 sprintf(attrStr, "*%s:\t%s %s", PAGE_ATT_SUPP, server, PAGE_ATT_VAL);
607 XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
608 xfree(attrStr);
611 * Validate the attribute pools
613 XpValidateAttributePool(pCon, XPPrinterAttr, &PsValidatePoolsRec);
614 XpValidateAttributePool(pCon, XPDocAttr, &PsValidatePoolsRec);
615 XpValidateAttributePool(pCon, XPJobAttr, &PsValidatePoolsRec);
616 XpValidateAttributePool(pCon, XPPageAttr, &PsValidatePoolsRec);
618 return Success;
621 static Bool
622 PsDestroyContext(pCon)
623 XpContextPtr pCon;
625 PsContextPrivPtr pConPriv =
626 (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
628 if( pConPriv->pJobFile!=(FILE *)NULL )
630 fclose(pConPriv->pJobFile);
631 pConPriv->pJobFile = NULL;
633 if( pConPriv->jobFileName!=(char *)NULL )
635 unlink(pConPriv->jobFileName);
636 xfree(pConPriv->jobFileName);
637 pConPriv->jobFileName = (char *)NULL;
640 PsFreeFontInfoRecords(pConPriv);
642 /* Reset context to make sure we do not use any stale/invalid/obsolete data */
643 memset(pConPriv, 0, sizeof(PsContextPrivRec));
645 /*### free up visuals/depths ###*/
647 return Success;
650 XpContextPtr
651 PsGetContextFromWindow(win)
652 WindowPtr win;
654 PsWindowPrivPtr pPriv;
656 while( win )
658 pPriv = (PsWindowPrivPtr)win->devPrivates[PsWindowPrivateIndex].ptr;
659 if( pPriv->validContext ) return pPriv->context;
660 win = win->parent;
663 return NULL;