~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to Xprint/pcl/PclInit.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: PclInit.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
 
2
/*******************************************************************
 
3
**
 
4
**    *********************************************************
 
5
**    *
 
6
**    *  File:          PclInit.c
 
7
**    *
 
8
**    *  Contents:
 
9
**    *                 Initialization code of Pcl driver for the print server.
 
10
**    *
 
11
**    *  Created:       1/30/95
 
12
**    *
 
13
**    *********************************************************
 
14
** 
 
15
********************************************************************/
 
16
/*
 
17
(c) Copyright 1996 Hewlett-Packard Company
 
18
(c) Copyright 1996 International Business Machines Corp.
 
19
(c) Copyright 1996 Sun Microsystems, Inc.
 
20
(c) Copyright 1996 Novell, Inc.
 
21
(c) Copyright 1996 Digital Equipment Corp.
 
22
(c) Copyright 1996 Fujitsu Limited
 
23
(c) Copyright 1996 Hitachi, Ltd.
 
24
 
 
25
Permission is hereby granted, free of charge, to any person obtaining a copy
 
26
of this software and associated documentation files (the "Software"), to deal
 
27
in the Software without restriction, including without limitation the rights
 
28
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
29
copies of the Software, and to permit persons to whom the Software is
 
30
furnished to do so, subject to the following conditions:
 
31
 
 
32
The above copyright notice and this permission notice shall be included in
 
33
all copies or substantial portions of the Software.
 
34
 
 
35
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
36
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
37
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
38
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 
39
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
40
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
41
 
 
42
Except as contained in this notice, the names of the copyright holders shall
 
43
not be used in advertising or otherwise to promote the sale, use or other
 
44
dealings in this Software without prior written authorization from said
 
45
copyright holders.
 
46
*/
 
47
 
 
48
/*
 
49
(c) Copyright 1996 Hewlett-Packard Company
 
50
(c) Copyright 1996 International Business Machines Corp.
 
51
(c) Copyright 1996 Sun Microsystems, Inc.
 
52
(c) Copyright 1996 Novell, Inc.
 
53
(c) Copyright 1996 Digital Equipment Corp.
 
54
(c) Copyright 1996 Fujitsu Limited
 
55
(c) Copyright 1996 Hitachi, Ltd.
 
56
 
 
57
Permission is hereby granted, free of charge, to any person obtaining a copy
 
58
of this software and associated documentation files (the "Software"), to deal
 
59
in the Software without restriction, including without limitation the rights
 
60
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
61
copies of the Software, and to permit persons to whom the Software is
 
62
furnished to do so, subject to the following conditions:
 
63
 
 
64
The above copyright notice and this permission notice shall be included in
 
65
all copies or substantial portions of the Software.
 
66
 
 
67
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
68
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
69
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
70
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 
71
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
72
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
73
 
 
74
Except as contained in this notice, the names of the copyright holders shall
 
75
not be used in advertising or otherwise to promote the sale, use or other
 
76
dealings in this Software without prior written authorization from said
 
77
copyright holders.
 
78
*/
 
79
/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclInit.c,v 1.11 2001/12/21 21:02:05 dawes Exp $ */
 
80
 
 
81
#ifdef HAVE_DIX_CONFIG_H
 
82
#include <dix-config.h>
 
83
#endif
 
84
 
 
85
#include <stdio.h>
 
86
#include <string.h>
 
87
#include <sys/types.h>
 
88
#include <sys/wait.h>
 
89
 
 
90
#include "Pcl.h"
 
91
 
 
92
#include "cfb.h"
 
93
#include <X11/Xos.h>    /* for unlink() */
 
94
 
 
95
#include "attributes.h"
 
96
#include "DiPrint.h"
 
97
 
 
98
#define MODELDIRNAME "/models"
 
99
 
 
100
static void AllocatePclPrivates(ScreenPtr pScreen);
 
101
static int PclInitContext(XpContextPtr pCon);
 
102
static Bool PclDestroyContext(XpContextPtr pCon);
 
103
 
 
104
int PclScreenPrivateIndex;
 
105
int PclContextPrivateIndex;
 
106
int PclPixmapPrivateIndex;
 
107
int PclWindowPrivateIndex;
 
108
int PclGCPrivateIndex;
 
109
 
 
110
#ifdef XP_PCL_COLOR
 
111
/*
 
112
 * The supported visuals on this screen
 
113
 */
 
114
static VisualRec Visuals[] = 
 
115
{
 
116
    { 1, StaticGray, 1, 2, 1, 0, 0, 0, 0, 0, 0 },
 
117
    { 2, PseudoColor, 8, 256, 8, 0, 0, 0, 0, 0, 0 },
 
118
    { 3, TrueColor, 8, 256, 24, 0xFF0000, 0xFF00, 0xFF, 16, 8, 0 }
 
119
};
 
120
 
 
121
/*
 
122
 * The supported depths on this screen
 
123
 */
 
124
static DepthRec Depths[] = 
 
125
{
 
126
    { 1, 1, NULL },
 
127
    { 8, 1, NULL },
 
128
    { 24, 1, NULL }
 
129
};
 
130
#else
 
131
/*
 
132
 * The supported visuals on this screen
 
133
 */
 
134
static VisualRec Visuals[] = 
 
135
{
 
136
    { 1, StaticGray, 1, 2, 1, 0, 0, 0, 0, 0, 0}
 
137
};
 
138
 
 
139
/*
 
140
 * The supported depths on this screen
 
141
 */
 
142
static DepthRec Depths[] = 
 
143
{
 
144
    { 1, 1, NULL }
 
145
};
 
146
#endif /* XP_PCL_COLOR */
 
147
 
 
148
 
 
149
#define NUM_VISUALS(visuals) (sizeof(visuals) / sizeof(VisualRec))
 
150
#define NUM_DEPTHS(depths) (sizeof(depths) / sizeof(DepthRec))
 
151
 
 
152
Bool
 
153
PclCloseScreen(int index,
 
154
               ScreenPtr pScreen)
 
155
{
 
156
    PclScreenPrivPtr pPriv = pScreen->devPrivates[PclScreenPrivateIndex].ptr;
 
157
 
 
158
    pScreen->CloseScreen = pPriv->CloseScreen;
 
159
    xfree( pPriv );
 
160
    
 
161
    return (*pScreen->CloseScreen)(index, pScreen);
 
162
}
 
163
 
 
164
Bool
 
165
InitializePclDriver(
 
166
     int ndx,
 
167
     ScreenPtr pScreen,
 
168
     int argc,
 
169
     char **argv)
 
170
{
 
171
    int maxRes, xRes, yRes, maxDim;
 
172
    unsigned i;
 
173
    PclScreenPrivPtr pPriv;
 
174
    
 
175
    /*
 
176
     * Register this driver's InitContext function with the print
 
177
     * extension.  This is a bit sleazy, as the extension hasn't yet
 
178
     * been initialized, but the extensionneeds to know this, and this
 
179
     * seems the best time to provide the information.
 
180
     */
 
181
#ifdef XP_PCL_COLOR
 
182
    XpRegisterInitFunc( pScreen, "XP-PCL-COLOR", PclInitContext );
 
183
#elif XP_PCL_MONO
 
184
    XpRegisterInitFunc( pScreen, "XP-PCL-MONO", PclInitContext );
 
185
#else
 
186
    XpRegisterInitFunc( pScreen, "XP-PCL-LJ3", PclInitContext );
 
187
#endif /* XP_PCL_MONO */
 
188
    
 
189
    /*
 
190
     * Create and fill in the devPrivate for the PCL driver.
 
191
     */
 
192
    AllocatePclPrivates(pScreen);
 
193
   
 
194
    pPriv =
 
195
      (PclScreenPrivPtr)pScreen->devPrivates[PclScreenPrivateIndex].ptr;
 
196
 
 
197
    maxDim = MAX( pScreen->height, pScreen->width );
 
198
    xRes = pScreen->width / ( pScreen->mmWidth / 25.4 );
 
199
    yRes = pScreen->height / ( pScreen->mmHeight / 25.4 );
 
200
    maxRes = MAX( xRes, yRes );
 
201
 
 
202
#ifdef XP_PCL_COLOR
 
203
    cfbScreenInit( pScreen, NULL, maxDim, maxDim, maxRes, maxRes,
 
204
                  maxRes );
 
205
    /*
 
206
     * Clean up the fields that we stomp (code taken from cfbCloseScreen)
 
207
     */
 
208
    for( i = 0; (int) i < pScreen->numDepths; i++ )
 
209
      xfree( pScreen->allowedDepths[i].vids );
 
210
    xfree( pScreen->allowedDepths );
 
211
    xfree( pScreen->visuals );
 
212
#else
 
213
    mfbScreenInit( pScreen, NULL, maxDim, maxDim, maxRes, maxRes,
 
214
                  maxRes );
 
215
#endif /* XP_PCL_COLOR */
 
216
 
 
217
    miInitializeBackingStore ( pScreen );
 
218
 
 
219
    pScreen->defColormap = FakeClientID(0);
 
220
    pScreen->blackPixel = 1;
 
221
    pScreen->whitePixel = 0;
 
222
 
 
223
    pPriv->CloseScreen = pScreen->CloseScreen;
 
224
    pScreen->CloseScreen = PclCloseScreen;
 
225
    
 
226
    pScreen->QueryBestSize = (QueryBestSizeProcPtr)PclQueryBestSize;
 
227
    pScreen->SaveScreen = (SaveScreenProcPtr)_XpBoolNoop;
 
228
    pScreen->GetImage = (GetImageProcPtr)_XpVoidNoop;
 
229
    pScreen->GetSpans = (GetSpansProcPtr)_XpVoidNoop;
 
230
    pScreen->CreateWindow = PclCreateWindow;
 
231
    pScreen->DestroyWindow = PclDestroyWindow;
 
232
/*
 
233
    pScreen->PositionWindow = PclPositionWindow;
 
234
*/
 
235
    pScreen->ChangeWindowAttributes = PclChangeWindowAttributes;
 
236
/*
 
237
    pScreen->RealizeWindow = PclMapWindow;
 
238
    pScreen->UnrealizeWindow = PclUnmapWindow;
 
239
*/
 
240
    pScreen->PaintWindowBackground = PclPaintWindow;
 
241
    pScreen->PaintWindowBorder = PclPaintWindow;
 
242
    pScreen->CopyWindow = PclCopyWindow; /* XXX Hard routine to write! */
 
243
 
 
244
    pScreen->CreatePixmap = PclCreatePixmap;
 
245
    pScreen->DestroyPixmap = PclDestroyPixmap;
 
246
    pScreen->RealizeFont = PclRealizeFont;
 
247
    pScreen->UnrealizeFont = PclUnrealizeFont;
 
248
    pScreen->CreateGC = PclCreateGC;
 
249
 
 
250
    pScreen->CreateColormap = PclCreateColormap;
 
251
    pScreen->DestroyColormap = PclDestroyColormap;
 
252
    pScreen->InstallColormap = (InstallColormapProcPtr)NoopDDA;
 
253
    pScreen->UninstallColormap = (UninstallColormapProcPtr)NoopDDA;
 
254
    pScreen->ListInstalledColormaps = PclListInstalledColormaps;
 
255
    pScreen->StoreColors = PclStoreColors;
 
256
/*
 
257
    pScreen->ResolveColor = PclResolveColor;
 
258
*/
 
259
 
 
260
    pScreen->BitmapToRegion = mfbPixmapToRegion;
 
261
 
 
262
    pScreen->ConstrainCursor = PclConstrainCursor;
 
263
    pScreen->CursorLimits = PclCursorLimits;
 
264
    pScreen->DisplayCursor = PclDisplayCursor;
 
265
    pScreen->RealizeCursor = PclRealizeCursor;
 
266
    pScreen->UnrealizeCursor = PclUnrealizeCursor;
 
267
    pScreen->RecolorCursor = PclRecolorCursor;
 
268
    pScreen->SetCursorPosition = PclSetCursorPosition;
 
269
 
 
270
    pScreen->visuals = Visuals;
 
271
    pScreen->numVisuals = NUM_VISUALS( Visuals );
 
272
    pScreen->allowedDepths = Depths;
 
273
    pScreen->numDepths = NUM_DEPTHS( Depths );
 
274
 
 
275
    for( i = 0; i < NUM_DEPTHS( Depths ); i++ )
 
276
      {
 
277
          pScreen->allowedDepths[i].vids =
 
278
            (VisualID *)xalloc( sizeof(VisualID ) );
 
279
          pScreen->allowedDepths[i].vids[0] = i + 1;
 
280
      }
 
281
    
 
282
#ifdef XP_PCL_COLOR
 
283
    pScreen->rootVisual = 2;
 
284
    pScreen->rootDepth = 8;
 
285
#else
 
286
    pScreen->rootVisual = 1;
 
287
    pScreen->rootDepth = 1;
 
288
#endif /* XP_PCL_COLOR */
 
289
 
 
290
    pPriv->colormaps = NULL;
 
291
    PclCreateDefColormap( pScreen );
 
292
    
 
293
    return TRUE;
 
294
}
 
295
 
 
296
static void
 
297
AllocatePclPrivates(ScreenPtr pScreen)
 
298
{
 
299
    static unsigned long PclGeneration = 0;
 
300
 
 
301
    if((unsigned long) PclGeneration != serverGeneration)
 
302
    {
 
303
        PclScreenPrivateIndex = AllocateScreenPrivateIndex();
 
304
 
 
305
        PclWindowPrivateIndex = AllocateWindowPrivateIndex();
 
306
        AllocateWindowPrivate( pScreen, PclWindowPrivateIndex,
 
307
                               sizeof( PclWindowPrivRec ) );
 
308
 
 
309
        PclContextPrivateIndex = XpAllocateContextPrivateIndex();
 
310
        XpAllocateContextPrivate( PclContextPrivateIndex, 
 
311
                                  sizeof( PclContextPrivRec ) );
 
312
 
 
313
        PclGCPrivateIndex = AllocateGCPrivateIndex();
 
314
        AllocateGCPrivate( pScreen, PclGCPrivateIndex, 
 
315
                           sizeof( PclGCPrivRec ) );
 
316
 
 
317
        PclPixmapPrivateIndex = AllocatePixmapPrivateIndex();
 
318
        AllocatePixmapPrivate( pScreen, PclPixmapPrivateIndex, 
 
319
                               sizeof( PclPixmapPrivRec ) );
 
320
        
 
321
        PclGeneration = serverGeneration;
 
322
    }
 
323
 
 
324
    pScreen->devPrivates[PclScreenPrivateIndex].ptr = (pointer)xalloc(
 
325
                sizeof(PclScreenPrivRec));
 
326
}
 
327
 
 
328
/*
 
329
 * PclInitContext
 
330
 *
 
331
 * Establish the appropriate values for a PrintContext used with the PCL
 
332
 * driver.
 
333
 */
 
334
 
 
335
static char DOC_ATT_SUPP[]="document-attributes-supported";
 
336
static char DOC_ATT_VAL[]="document-format xp-listfonts-modes";
 
337
static char JOB_ATT_SUPP[]="job-attributes-supported";
 
338
static char JOB_ATT_VAL[]="";
 
339
static char PAGE_ATT_SUPP[]="xp-page-attributes-supported";
 
340
static char PAGE_ATT_VAL[]="content-orientation default-printer-resolution \
 
341
default-input-tray default-medium plex xp-listfonts-modes";
 
342
 
 
343
static int
 
344
PclInitContext(XpContextPtr pCon)
 
345
{
 
346
    XpDriverFuncsPtr pFuncs;
 
347
    PclContextPrivPtr pConPriv;
 
348
    char *server, *attrStr;
 
349
    char *modelID;
 
350
    char *configDir;
 
351
    char *pathName;
 
352
    int i, j;
 
353
    float width, height;
 
354
    XpOidMediumDiscreteSizeList* ds_list;
 
355
    XpOidArea* repro;
 
356
    XpOid page_size;
 
357
    XpOidMediumSS* m;
 
358
    
 
359
    /*
 
360
     * Initialize the attribute store for this printer.
 
361
     */
 
362
    XpInitAttributes( pCon );
 
363
 
 
364
    /*
 
365
     * Initialize the function pointers
 
366
     */
 
367
    pFuncs = &( pCon->funcs );
 
368
    pFuncs->StartJob = PclStartJob;
 
369
    pFuncs->EndJob = PclEndJob;
 
370
    pFuncs->StartDoc = PclStartDoc;
 
371
    pFuncs->EndDoc = PclEndDoc;
 
372
    pFuncs->StartPage = PclStartPage;
 
373
    pFuncs->EndPage = PclEndPage;
 
374
    pFuncs->PutDocumentData = PclDocumentData;
 
375
    pFuncs->GetDocumentData = PclGetDocumentData;
 
376
    pFuncs->GetAttributes = PclGetAttributes;
 
377
    pFuncs->SetAttributes = PclSetAttributes;
 
378
    pFuncs->AugmentAttributes = PclAugmentAttributes;
 
379
    pFuncs->GetOneAttribute = PclGetOneAttribute;
 
380
    pFuncs->DestroyContext = PclDestroyContext;
 
381
    pFuncs->GetMediumDimensions = PclGetMediumDimensions;
 
382
    pFuncs->GetReproducibleArea = PclGetReproducibleArea;
 
383
    
 
384
 
 
385
    /*
 
386
     * Set up the context privates
 
387
     */
 
388
    pConPriv =
 
389
      (PclContextPrivPtr)pCon->devPrivates[PclContextPrivateIndex].ptr;
 
390
    
 
391
    pConPriv->jobFileName = (char *)NULL;
 
392
    pConPriv->pageFileName = (char *)NULL;
 
393
    pConPriv->pJobFile = (FILE *)NULL;
 
394
    pConPriv->pPageFile = (FILE *)NULL;
 
395
    pConPriv->dash = NULL;
 
396
    pConPriv->validGC = 0;
 
397
 
 
398
    pConPriv->getDocClient = (ClientPtr)NULL;
 
399
    pConPriv->getDocBufSize = 0;
 
400
    modelID = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-model-identifier");
 
401
    if ( (configDir = XpGetConfigDir(False)) != (char *) NULL ) {
 
402
        pathName = (char *)xalloc(strlen(configDir) + strlen(MODELDIRNAME) +
 
403
                                strlen(modelID) + strlen("color.map") + 4);
 
404
        if (pathName) {
 
405
            sprintf(pathName, "%s/%s/%s/%s", configDir, MODELDIRNAME, modelID,
 
406
                                "color.map");
 
407
            pConPriv->ctbl = PclReadMap(pathName, &pConPriv->ctbldim);
 
408
            xfree(pathName);
 
409
 
 
410
        } else
 
411
            pConPriv->ctbl = NULL;
 
412
    } else
 
413
        pConPriv->ctbl = NULL;
 
414
 
 
415
#ifdef XP_PCL_LJ3
 
416
    /*
 
417
     * Initialize the spooling buffer for saving the figures temporary
 
418
     * (LaserJet IIIs printers don't support the macro function which
 
419
     *  includes some HP-GL/2 commands.)
 
420
     */
 
421
    pConPriv->fcount = 0;
 
422
    if ( !(pConPriv->figures = (char *)xalloc(1024)) )
 
423
        pConPriv->fcount_max = 0;
 
424
    else
 
425
        pConPriv->fcount_max = 1024;
 
426
#endif /* XP_PCL_LJ3 */
 
427
    
 
428
    /*
 
429
     * document-attributes-supported
 
430
     */
 
431
    server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP );
 
432
    if( ( attrStr = (char *)xalloc(strlen(server) + strlen(DOC_ATT_SUPP)
 
433
                                   + strlen(DOC_ATT_VAL) +
 
434
                                   strlen(PAGE_ATT_VAL) + 8 ) ) 
 
435
       == (char *)NULL )
 
436
      return BadAlloc;
 
437
    sprintf( attrStr, "*%s:\t%s %s %s", DOC_ATT_SUPP, server,
 
438
            DOC_ATT_VAL, PAGE_ATT_VAL );
 
439
    XpAugmentAttributes( pCon, XPPrinterAttr, attrStr );
 
440
    xfree( attrStr );
 
441
    
 
442
    /*
 
443
     * job-attributes-supported
 
444
     */
 
445
    server = XpGetOneAttribute( pCon, XPServerAttr, JOB_ATT_SUPP );
 
446
    if( ( attrStr = (char *)xalloc(strlen(server) + strlen(JOB_ATT_SUPP)
 
447
                                   + strlen(JOB_ATT_VAL) + 8 ) ) 
 
448
       == (char *)NULL )
 
449
      return BadAlloc;
 
450
    sprintf( attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL );
 
451
    XpAugmentAttributes( pCon, XPPrinterAttr, attrStr );
 
452
    xfree( attrStr );
 
453
    
 
454
    /*
 
455
     * xp-page-attributes-supported
 
456
     */
 
457
    server = XpGetOneAttribute( pCon, XPServerAttr, PAGE_ATT_SUPP );
 
458
    if( ( attrStr = (char *)xalloc(strlen(server) + strlen(PAGE_ATT_SUPP)
 
459
                                   + strlen(PAGE_ATT_VAL) + 8 ) ) 
 
460
       == (char *)NULL )
 
461
      return BadAlloc;
 
462
    sprintf( attrStr, "*%s:\t%s %s", PAGE_ATT_SUPP, server, PAGE_ATT_VAL );
 
463
    XpAugmentAttributes( pCon, XPPrinterAttr, attrStr );
 
464
    xfree( attrStr );
 
465
 
 
466
    /*
 
467
     * Validate the attribute pools
 
468
     */
 
469
    XpValidateAttributePool( pCon, XPPrinterAttr, &PclValidatePoolsRec );
 
470
 
 
471
    /*
 
472
     * Munge the reproducible areas to reflect the fact that PCL will not let
 
473
     * me move the right or left margins closer than .25" to the edge of the
 
474
     * paper.
 
475
     */
 
476
    m = XpGetMediumSSAttr( pCon, XPPrinterAttr,
 
477
                          xpoid_att_medium_source_sizes_supported, 
 
478
                          (const XpOidList*) NULL,
 
479
                          (const XpOidList*) NULL );
 
480
    for( i = 0; i < XpOidMediumSSCount( m ); i++ )
 
481
      {
 
482
          if( XpOidMediumSS_DISCRETE == (m->mss)[i].mstag )
 
483
            {
 
484
                ds_list = (m->mss)[i].ms.discrete;
 
485
                for( j = 0; j < ds_list->count; j++ )
 
486
                  {
 
487
                      repro = &(ds_list->list)[j].assured_reproduction_area;
 
488
                      page_size = (ds_list->list)[j].page_size;
 
489
                      XpGetMediumMillimeters( page_size, &width, &height );
 
490
                      
 
491
                      if( repro->minimum_x < 6.35 )
 
492
                        repro->minimum_x = 6.35;
 
493
                      if( width - repro->maximum_x < 6.35 )
 
494
                        repro->maximum_x = width - 6.35;
 
495
                  }
 
496
            }
 
497
      }
 
498
    XpPutMediumSSAttr( pCon, XPPrinterAttr,
 
499
                      xpoid_att_medium_source_sizes_supported, m );
 
500
    XpOidMediumSSDelete( m );
 
501
 
 
502
    /*
 
503
     * Finish validating the attribute pools
 
504
     */
 
505
 
 
506
    XpValidateAttributePool( pCon, XPDocAttr, &PclValidatePoolsRec );
 
507
    XpValidateAttributePool( pCon, XPJobAttr, &PclValidatePoolsRec );
 
508
    XpValidateAttributePool( pCon, XPPageAttr, &PclValidatePoolsRec );
 
509
 
 
510
    /*
 
511
     * Clear out the colormap storage
 
512
     */
 
513
    pConPriv->palettes = NULL;
 
514
    
 
515
    return Success;
 
516
}
 
517
 
 
518
static Bool
 
519
PclDestroyContext(XpContextPtr pCon)
 
520
{
 
521
    PclContextPrivPtr pConPriv = (PclContextPrivPtr)
 
522
      pCon->devPrivates[PclContextPrivateIndex].ptr;
 
523
    PclPaletteMapPtr p, t;
 
524
    PclCmapToContexts *pCmap;
 
525
    ScreenPtr screen;
 
526
    PclScreenPrivPtr sPriv;
 
527
    PclContextListPtr con, prevCon, temp;
 
528
    
 
529
    
 
530
    /*
 
531
     * Clean up the temporary files
 
532
     */
 
533
    if( pConPriv->pPageFile != (FILE *)NULL )
 
534
      {
 
535
          fclose( pConPriv->pPageFile );
 
536
          pConPriv->pPageFile = (FILE *)NULL;
 
537
      }
 
538
    if( pConPriv->pageFileName != (char *)NULL )
 
539
      {
 
540
          unlink( pConPriv->pageFileName );
 
541
          xfree( pConPriv->pageFileName );
 
542
          pConPriv->pageFileName = (char *)NULL;
 
543
      }
 
544
    
 
545
    if( pConPriv->pJobFile != (FILE *)NULL )
 
546
      {
 
547
          fclose( pConPriv->pJobFile );
 
548
          pConPriv->pJobFile = NULL;
 
549
      }
 
550
    if( pConPriv->jobFileName != (char *)NULL )
 
551
      {
 
552
          unlink( pConPriv->jobFileName );
 
553
          xfree( pConPriv->jobFileName );
 
554
          pConPriv->jobFileName = (char *)NULL;
 
555
      }
 
556
 
 
557
    xfree( pConPriv->dash );
 
558
    xfree(pConPriv->ctbl);
 
559
    pConPriv->ctbl = NULL;
 
560
#ifdef XP_PCL_LJ3
 
561
    xfree( pConPriv->figures );
 
562
#endif /* XP_PCL_LJ3 */
 
563
 
 
564
    /*
 
565
     * Destroy the colormap<->palette mappings
 
566
     */
 
567
    p = pConPriv->palettes;
 
568
    while( p )
 
569
      {
 
570
          t = p;
 
571
          p = p->next;
 
572
          xfree( t );
 
573
      }
 
574
    pConPriv->palettes = NULL;
 
575
 
 
576
    /*
 
577
     * Remove the context from the screen-level colormap<->contexts mappings
 
578
     */
 
579
    screen = screenInfo.screens[pCon->screenNum];
 
580
    sPriv = (PclScreenPrivPtr)screen->devPrivates[PclScreenPrivateIndex].ptr;
 
581
    pCmap = sPriv->colormaps;
 
582
    while( pCmap )
 
583
      {
 
584
          con = pCmap->contexts;
 
585
          prevCon = NULL;
 
586
          
 
587
          while( con )
 
588
            {
 
589
                if( con->context->contextID == pCon->contextID )
 
590
                  {
 
591
                      if( prevCon )
 
592
                        {
 
593
                            temp = con;
 
594
                            prevCon->next = con = con->next;
 
595
                        }
 
596
                      else
 
597
                        {
 
598
                            temp = pCmap->contexts;
 
599
                            pCmap->contexts = con = con->next;
 
600
                        }
 
601
                      xfree( temp );
 
602
                  }
 
603
                else
 
604
                  con = con->next;
 
605
            }
 
606
 
 
607
          pCmap = pCmap->next;
 
608
      }
 
609
    
 
610
    XpDestroyAttributes(pCon);
 
611
 
 
612
    return Success;
 
613
}
 
614
 
 
615
XpContextPtr
 
616
PclGetContextFromWindow(WindowPtr win)
 
617
{
 
618
    PclWindowPrivPtr pPriv;
 
619
    
 
620
    while( win )
 
621
      {
 
622
          pPriv =
 
623
            (PclWindowPrivPtr)win->devPrivates[PclWindowPrivateIndex].ptr;
 
624
          if( pPriv->validContext )
 
625
            return pPriv->context;
 
626
      
 
627
          win = win->parent;
 
628
      }
 
629
    
 
630
    return NULL;
 
631
}