First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xprint / raster / Raster.c
blob0286a18fa32dd96a6ede2ab015fa4421a19fb2dc
1 /*
2 (c) Copyright 1996 Hewlett-Packard Company
3 (c) Copyright 1996 International Business Machines Corp.
4 (c) Copyright 1996 Sun Microsystems, Inc.
5 (c) Copyright 1996 Novell, Inc.
6 (c) Copyright 1996 Digital Equipment Corp.
7 (c) Copyright 1996 Fujitsu Limited
8 (c) Copyright 1996 Hitachi, Ltd.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 Except as contained in this notice, the names of the copyright holders shall
28 not be used in advertising or otherwise to promote the sale, use or other
29 dealings in this Software without prior written authorization from said
30 copyright holders.
34 /*******************************************************************
36 ** *********************************************************
37 ** *
38 ** * File: printer/Raster.c
39 ** *
40 ** * Contents:
41 ** * Raster driver for the print server.
42 ** *
43 ** * Copyright: Copyright 1993, 1995 Hewlett-Packard Company
44 ** *
45 ** *********************************************************
46 **
47 ********************************************************************/
49 #ifdef HAVE_DIX_CONFIG_H
50 #include <dix-config.h>
51 #endif
53 #include <errno.h>
54 #include <stdio.h>
55 #include <string.h>
56 #include <sys/stat.h>
57 #include <sys/wait.h>
58 #include <unistd.h>
59 #include <sys/types.h>
60 #include <sys/stat.h>
61 #include <X11/X.h>
62 #include <X11/Xos.h> /* for SIGCLD on pre-POSIX systems */
63 #define NEED_EVENTS
64 #include <X11/Xproto.h>
65 #undef NEED_EVENTS
66 #include <X11/Xatom.h>
67 #include "misc.h"
68 #include "dixstruct.h"
69 #include "scrnintstr.h"
70 #include "screenint.h"
71 #include "colormapst.h"
72 #include "windowstr.h"
73 #include "propertyst.h"
74 #include "servermd.h" /* needed for IMAGE_BUFSIZE */
75 #include "fb.h"
76 #include "mi.h"
78 #include <X11/extensions/Print.h>
79 #include "Raster.h"
81 #include "attributes.h"
82 #include "AttrValid.h"
83 #include "DiPrint.h"
85 static void AllocateRasterPrivates(
86 ScreenPtr pScreen);
87 static Bool RasterChangeWindowAttributes(
88 WindowPtr pWin,
89 unsigned long mask);
90 static int StartJob(
91 XpContextPtr pCon,
92 Bool sendClientData,
93 ClientPtr client);
94 static int StartPage(
95 XpContextPtr pCon,
96 WindowPtr pWin);
97 static int StartDoc(
98 XpContextPtr pCon,
99 XPDocumentType type);
100 static int EndDoc(
101 XpContextPtr pCon,
102 Bool cancel);
103 static int EndJob(
104 XpContextPtr pCon,
105 Bool cancel);
106 static int EndPage(
107 XpContextPtr pCon,
108 WindowPtr pWin);
109 static int DocumentData(
110 XpContextPtr pCon,
111 DrawablePtr pDraw,
112 char *pData,
113 int len_data,
114 char *pDoc_fmt,
115 int len_fmt,
116 char *pOptions,
117 int len_options,
118 ClientPtr client);
119 static int GetDocumentData(
120 XpContextPtr pContext,
121 ClientPtr client,
122 int maxBufferSize);
123 static void FreePageFiles(
124 RasterContextPrivPtr pWinPriv);
125 static int SystemCmd(
126 char *pCommand);
127 static Bool RasterCloseScreen(
128 int index,
129 ScreenPtr pScreen);
130 static int RasterInitContext(XpContextPtr pCon);
131 static Bool RasterDestroyContext(XpContextPtr pCon);
132 static char *RasterGetAttributes(
133 XpContextPtr pContext,
134 XPAttributes class);
135 static char *RasterGetOneAttribute(XpContextPtr pCon,
136 XPAttributes class,
137 char *attribute);
138 static int RasterSetAttributes(XpContextPtr pCon,
139 XPAttributes class,
140 char *attributes);
141 static int RasterAugmentAttributes(XpContextPtr pCon,
142 XPAttributes class,
143 char *attributes);
144 static int RasterMediumDimensions(XpContextPtr pCon,
145 CARD16 *width,
146 CARD16 *height);
147 static int RasterReproducibleArea(XpContextPtr pCon,
148 xRectangle *pRect);
150 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
151 #define DOC_PCL 1
152 #define DOC_RASTER 2
154 static int RasterScreenPrivateIndex, RasterContextPrivateIndex;
155 static int RasterGeneration = 0;
156 static char RASTER_DRIV_NAME[] = "XP-RASTER";
157 static int doc_type = DOC_RASTER;
159 #define ABSOLUTE_PCLCOMP_PATH1 "/usr/openwin/bin/pclcomp"
160 #define ABSOLUTE_PCLCOMP_PATH2 "/usr/X11/bin/pclcomp"
162 static char *pcl3_output_cmds[] = {
163 "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -0 > %(OutFile)%",
164 "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -01 > %(OutFile)%",
165 "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -02 > %(OutFile)%",
166 "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -03 > %(OutFile)%",
167 "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -012 > %(OutFile)%",
168 "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -013 > %(OutFile)%",
169 "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -023 > %(OutFile)%",
170 "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -0123 > %(OutFile)%",
171 "xpr -device ljet -rv -landscape < %(InFile)% > %(OutFile)%",
172 "xpr -device ljet -rv < %(InFile)% | pclcomp -0 > %(OutFile)%",
173 "xpr -device ljet -rv < %(InFile)% | pclcomp -01 > %(OutFile)%",
174 "xpr -device ljet -rv < %(InFile)% | pclcomp -02 > %(OutFile)%",
175 "xpr -device ljet -rv < %(InFile)% | pclcomp -03 > %(OutFile)%",
176 "xpr -device ljet -rv < %(InFile)% | pclcomp -012 > %(OutFile)%",
177 "xpr -device ljet -rv < %(InFile)% | pclcomp -013 > %(OutFile)%",
178 "xpr -device ljet -rv < %(InFile)% | pclcomp -023 > %(OutFile)%",
179 "xpr -device ljet -rv < %(InFile)% | pclcomp -0123 > %(OutFile)%",
180 "xpr -device ljet -rv < %(InFile)% > %(OutFile)%"};
182 Bool
183 InitializeRasterDriver(
184 int ndx,
185 ScreenPtr pScreen,
186 int argc,
187 char **argv)
189 int xRes, yRes;
190 int maxRes, maxDim, numBytes;
191 RasterScreenPrivPtr pPriv;
194 * Register this driver's InitContext function with the print extension.
195 * This is a bit
196 * sleazy, as the extension hasn't yet been initialized, but the
197 * extension needs to know this, and this seems the best time to
198 * provide the information.
200 XpRegisterInitFunc( pScreen, RASTER_DRIV_NAME, RasterInitContext );
203 * Create and load the devPrivate for the printer layer.
205 AllocateRasterPrivates(pScreen);
207 pPriv = (RasterScreenPrivPtr)
208 pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
210 maxDim = MAX( pScreen->height, pScreen->width );
211 numBytes = maxDim + BITMAP_SCANLINE_PAD - 1; /* pixels per row */
212 numBytes *= maxDim;
213 numBytes /= 8; /* bytes per row */
214 xRes = pScreen->width / (pScreen->mmWidth / 25.4);
215 yRes = pScreen->height / (pScreen->mmHeight / 25.4);
216 maxRes = MAX( xRes, yRes );
218 pPriv->pBits = (char *)xalloc(numBytes);
221 * Have to allocate maxDim X maxDim to allow for landscape mode.
223 fbScreenInit(pScreen, pPriv->pBits, maxDim, maxDim, maxRes,
224 maxRes, maxDim, 1);
225 miInitializeBackingStore(pScreen);
226 pScreen->blackPixel = 1;
227 pScreen->whitePixel = 0;
228 if(fbCreateDefColormap(pScreen) == FALSE)
229 ; /* XXX what do I do if it fails? */
231 pScreen->SaveScreen = (SaveScreenProcPtr)_XpBoolNoop;
232 pPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
233 pScreen->ChangeWindowAttributes = RasterChangeWindowAttributes;
234 pPriv->CloseScreen = pScreen->CloseScreen;
235 pScreen->CloseScreen = RasterCloseScreen;
237 return TRUE;
241 * GetPropString searches the context's config database for a property
242 * by the name of propName. If found, it returns the property's
243 * value, otherwise it returns NULL unless the requested attribute
244 * is RASTER_PRINT_PAGE_COMMAND, in which case it returns a hard-coded
245 * default string to invoke xpr to produce a PostScript(tm) formatted
246 * raster.
249 static char *
250 GetPropString(
251 XpContextPtr pCon,
252 char *propName)
254 RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
255 pCon->devPrivates[RasterContextPrivateIndex].ptr;
256 char *type;
257 XrmValue val;
258 struct stat status;
259 int pclcomp_exists = 0;
261 if( XrmGetResource(pConPriv->config, propName, propName, &type, &val) ==
262 True )
263 return (char *)val.addr;
265 if( !strcmp( propName, RASTER_PRINT_PAGE_COMMAND ) )
266 if( doc_type == DOC_RASTER )
267 return "xpr -device ps %(InFile)% > %(OutFile)%";
268 else
270 XpOid orientation;
271 XpOid compression;
272 int pcl3_output_index = 0;
274 orientation = XpGetContentOrientation(pCon);
275 compression = XpGetAvailableCompression(pCon);
277 switch(orientation) {
278 case xpoid_val_content_orientation_landscape:
279 pcl3_output_index = 0;
280 break;
281 default:
282 pcl3_output_index += 9;
283 break;
286 if(stat(ABSOLUTE_PCLCOMP_PATH1, &status) != -1)
287 pclcomp_exists = 1;
288 else if(stat(ABSOLUTE_PCLCOMP_PATH2, &status) != -1)
289 pclcomp_exists = 1;
291 if(pclcomp_exists)
292 switch(compression) {
293 case xpoid_val_available_compressions_0:
294 pcl3_output_index += 0;
295 break;
296 case xpoid_val_available_compressions_01:
297 pcl3_output_index += 1;
298 break;
299 case xpoid_val_available_compressions_02:
300 pcl3_output_index += 2;
301 break;
302 case xpoid_val_available_compressions_03:
303 pcl3_output_index += 3;
304 break;
305 case xpoid_val_available_compressions_012:
306 pcl3_output_index += 4;
307 break;
308 case xpoid_val_available_compressions_013:
309 pcl3_output_index += 5;
310 break;
311 case xpoid_val_available_compressions_023:
312 pcl3_output_index += 6;
313 break;
314 default:
315 pcl3_output_index += 7;
316 break;
318 else
319 pcl3_output_index += 8;
321 return pcl3_output_cmds[pcl3_output_index];
323 else
324 return NULL;
327 static void
328 SetDocumentType(
329 XpContextPtr pCon)
331 XpOidList* attrs_supported;
334 * only validate attributes found in document-attributes-supported
336 attrs_supported =
337 XpGetListAttr(pCon, XPPrinterAttr,
338 xpoid_att_document_attributes_supported,
339 (const XpOidList*)NULL);
341 if(XpOidListHasOid(attrs_supported, xpoid_att_document_format))
343 const char* value_in;
344 XpOidDocFmt *f;
346 value_in = XpGetStringAttr(pCon, XPDocAttr, xpoid_att_document_format);
348 f = XpOidDocFmtNew( value_in );
350 if( f != NULL )
352 if( !strcmp( f->format, "PCL" ) )
353 doc_type = DOC_PCL;
354 else
355 doc_type = DOC_RASTER;
357 XpOidDocFmtDelete( f );
362 * clean up
364 XpOidListDelete(attrs_supported);
367 static int
368 StartJob(
369 XpContextPtr pCon,
370 Bool sendClientData,
371 ClientPtr client)
373 RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
374 pCon->devPrivates[RasterContextPrivateIndex].ptr;
376 SetDocumentType( pCon );
379 * Check for existing page file, and delete it if it exists.
381 if(pConPriv->pageFileName != (char *)NULL)
383 if(pConPriv->pPageFile != (FILE *)NULL)
385 fclose(pConPriv->pPageFile);
386 pConPriv->pPageFile = (FILE *)NULL;
388 unlink(pConPriv->pageFileName);
389 Xfree(pConPriv->pageFileName);
390 pConPriv->pageFileName = (char *)NULL;
394 * Create a temporary file to store the printer output.
396 if(!sendClientData)
399 * Create a temporary file to store the printer output.
401 if (!XpOpenTmpFile("w", &pConPriv->jobFileName, &pConPriv->pJobFile))
402 return BadAlloc;
405 return Success;
409 * StartDoc and EndDoc are just no-ops in this implementation, since
410 * our view of the spooler really doesn't recognize documents.
413 static int
414 StartDoc(
415 XpContextPtr pCon,
416 XPDocumentType type)
418 return Success;
421 static int EndDoc(
422 XpContextPtr pCon,
423 Bool cancel)
425 return Success;
428 #if 0
430 /* XXX Not used. */
433 * BuidArgVector takes a pointer to a comma-separated list of command
434 * options and splits it out into an array of argument pointers. The
435 * caller must not free the optionList after calling this function until
436 * the returned arg vector is no longer needed, at which time the arg
437 * vector should also be freed.
440 #define SEPARATOR_CHAR (char)','
442 static char **
443 BuildArgVector(
444 char *optionList,
445 char **argVector,
446 int argCount)
448 char *curArg, *lastChar, *endArg;
450 curArg = optionList;
451 lastChar = optionList + strlen(optionList); /* includes final NULL */
453 while(curArg != (char *)NULL && curArg < lastChar)
455 /* strip leading white space */
456 while(curArg < lastChar && isascii((int)*curArg) &&
457 isspace((int)*curArg))
458 curArg++;
460 if(curArg < lastChar)
462 argVector = (char **)Xrealloc(argVector,
463 sizeof(char *) * (argCount + 2));
464 argVector[argCount] = curArg;
465 argVector[++argCount] = (char *)NULL;
467 endArg = strchr(curArg, SEPARATOR_CHAR);
469 /* Should I strip trailing white space ??? */
471 if(endArg != (char *)NULL)
473 *endArg = (char)'\0';
474 curArg = endArg + 1;
476 else
477 curArg = (char *)NULL;
481 return argVector;
483 #endif
485 static int
486 EndJob(
487 XpContextPtr pCon,
488 Bool cancel)
490 RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
491 pCon->devPrivates[RasterContextPrivateIndex].ptr;
493 if( cancel == True )
495 if(pConPriv->getDocClient != (ClientPtr)NULL) {
496 XpFinishDocData(pConPriv->getDocClient);
498 pConPriv->getDocClient = (ClientPtr)NULL;
499 pConPriv->getDocBufSize = 0;
502 if(pConPriv->jobFileName != (char *)NULL)
504 unlink(pConPriv->jobFileName);
505 Xfree(pConPriv->jobFileName);
506 pConPriv->jobFileName = (char *)NULL;
509 return Success;
512 if(pConPriv->getDocClient != (ClientPtr)NULL&&pConPriv->getDocBufSize > 0)
514 XpFinishDocData(pConPriv->getDocClient);
516 pConPriv->getDocClient = (ClientPtr)NULL;
517 pConPriv->getDocBufSize = 0;
519 return Success;
522 if(pConPriv->pJobFile != (FILE *)NULL)
524 fclose(pConPriv->pJobFile);
525 pConPriv->pJobFile = (FILE *)NULL;
527 if(pConPriv->jobFileName != (char *)NULL)
529 XpSubmitJob( pConPriv->jobFileName, pCon );
530 unlink(pConPriv->jobFileName);
531 Xfree(pConPriv->jobFileName);
532 pConPriv->jobFileName = (char *)NULL;
536 return Success;
539 /* StartPage
541 * If page file exists
542 * close page file
543 * set page file pointer = NULL
544 * unlink page file
546 static int
547 StartPage(
548 XpContextPtr pCon,
549 WindowPtr pWin)
551 RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
552 pCon->devPrivates[RasterContextPrivateIndex].ptr;
554 if(pConPriv->pPageFile != (FILE *)NULL)
556 fclose(pConPriv->pPageFile);
557 pConPriv->pPageFile = (FILE *)NULL;
559 if(pConPriv->pageFileName != (char *)NULL)
561 unlink(pConPriv->pageFileName);
562 pConPriv->pageFileName = (char *)NULL;
565 return Success;
568 #include "X11/XWDFile.h"
571 #define lowbit(x) ((x) & (~(x) + 1))
574 * Get the XWDColors of all pixels in colormap - returns # of colors
576 static XWDColor *
577 Get_XWDColors(
578 ColormapPtr pCmap)
580 int i, ncolors;
581 xrgb *prgbList;
582 Pixel *pPixels;
583 XWDColor *colors;
585 ncolors = pCmap->pVisual->ColormapEntries;
586 if (!(colors = (XWDColor *) malloc (sizeof(XWDColor) * ncolors)))
587 return (XWDColor *) NULL;
588 if (!(prgbList = (xrgb*) malloc(sizeof(xrgb) * ncolors)))
590 Xfree(colors);
591 return (XWDColor *) NULL;
593 if (!(pPixels = (Pixel*) malloc(sizeof(Pixel) * ncolors)))
595 Xfree(colors);
596 Xfree(prgbList);
597 return (XWDColor *) NULL;
600 if (pCmap->pVisual->class == DirectColor ||
601 pCmap->pVisual->class == TrueColor) {
602 Pixel red, green, blue, red1, green1, blue1;
604 red = green = blue = 0;
605 red1 = lowbit(pCmap->pVisual->redMask);
606 green1 = lowbit(pCmap->pVisual->greenMask);
607 blue1 = lowbit(pCmap->pVisual->blueMask);
608 for (i=0; i<ncolors; i++) {
609 colors[i].pixel = red|green|blue;
610 colors[i].pad = 0;
611 red += red1;
612 if (red > pCmap->pVisual->redMask)
613 red = 0;
614 green += green1;
615 if (green > pCmap->pVisual->greenMask)
616 green = 0;
617 blue += blue1;
618 if (blue > pCmap->pVisual->blueMask)
619 blue = 0;
621 } else {
622 for (i=0; i<ncolors; i++) {
623 colors[i].pixel = i;
624 colors[i].pad = 0;
628 for(i = 0; i < ncolors; i++)
629 pPixels[i] = colors[i].pixel;
631 QueryColors(pCmap, ncolors, pPixels, prgbList);
632 Xfree(pPixels);
634 for(i = 0; i < ncolors; i++)
636 colors[i].red = prgbList[i].red;
637 colors[i].green = prgbList[i].green;
638 colors[i].blue = prgbList[i].blue;
640 Xfree(prgbList);
642 return(colors);
645 static void
646 _swapshort (
647 register char *bp,
648 register unsigned n)
650 register char c;
651 register char *ep = bp + n;
653 while (bp < ep) {
654 c = *bp;
655 *bp = *(bp + 1);
656 bp++;
657 *bp++ = c;
661 static void
662 _swaplong (
663 register char *bp,
664 register unsigned n)
666 register char c;
667 register char *ep = bp + n;
668 register char *sp;
670 while (bp < ep) {
671 sp = bp + 3;
672 c = *sp;
673 *sp = *bp;
674 *bp++ = c;
675 sp = bp + 1;
676 c = *sp;
677 *sp = *bp;
678 *bp++ = c;
679 bp += 2;
682 static int
683 WriteWindowRaster(
684 WindowPtr pWin,
685 FILE *pRasterFile)
687 long widthBytesLine, length;
688 int nlines, linesPerBuf, height, linesDone;
689 char *pBuf;
690 DrawablePtr pDraw = &pWin->drawable;
691 XWDFileHeader header;
692 int win_name_size;
693 int header_size;
694 int ncolors, i;
695 char *win_name;
696 VisualPtr pVisual;
697 ColormapPtr pCmap;
698 XWDColor *pColors;
699 unsigned long swaptest = 1;
701 widthBytesLine = PixmapBytePad(pWin->drawable.width, pWin->drawable.depth);
702 length = widthBytesLine * pWin->drawable.height;
703 height = pWin->drawable.height;
705 if(length <= 0)
706 return Success;
708 if (widthBytesLine >= IMAGE_BUFSIZE)
709 linesPerBuf = 1;
710 else
712 linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
713 if (linesPerBuf > height)
714 linesPerBuf = height;
716 length = linesPerBuf * widthBytesLine;
717 if (linesPerBuf < height)
719 /* we have to make sure intermediate buffers don't need padding */
720 while ((linesPerBuf > 1) && (length & 3))
722 linesPerBuf--;
723 length -= widthBytesLine;
725 while (length & 3)
727 linesPerBuf++;
728 length += widthBytesLine;
731 if(!(pBuf = (char *) Xalloc(length)))
732 return (BadAlloc);
735 * Start of Xwd header code.
739 * XXX - Should we use the real window name???
741 win_name = "xwdump";
742 /* sizeof(char) is included for the null string terminator. */
743 win_name_size = strlen(win_name) + sizeof(char);
745 pCmap = (ColormapPtr)LookupIDByType(wColormap (pWin), RT_COLORMAP);
746 pVisual = pCmap->pVisual;
747 if((pColors = Get_XWDColors(pCmap)) == (XWDColor *)NULL)
749 Xfree(pBuf);
750 return (BadAlloc);
754 * Write out header information.
756 header_size = sizeof(header) + win_name_size;
757 header.header_size = (CARD32) header_size;
758 header.file_version = (CARD32) XWD_FILE_VERSION;
759 header.pixmap_format = (CARD32) ZPixmap; /* Must match GetImage below */
760 header.pixmap_depth = (CARD32) pDraw->depth;
761 header.pixmap_width = (CARD32) pDraw->width;
762 header.pixmap_height = (CARD32) pDraw->height;
763 header.xoffset = (CARD32) 0;
764 header.byte_order = (CARD32) screenInfo.imageByteOrder;
765 header.bitmap_unit = (CARD32) screenInfo.bitmapScanlineUnit;
766 header.bitmap_bit_order = (CARD32) screenInfo.bitmapBitOrder;
767 header.bitmap_pad = (CARD32) screenInfo.bitmapScanlinePad;
768 header.bits_per_pixel = (CARD32) pDraw->bitsPerPixel;
769 header.bytes_per_line = (CARD32) widthBytesLine;
770 header.visual_class = (CARD32) pVisual->class;
771 header.red_mask = (CARD32) pVisual->redMask;
772 header.green_mask = (CARD32) pVisual->greenMask;
773 header.blue_mask = (CARD32) pVisual->blueMask;
774 header.bits_per_rgb = (CARD32) pVisual->bitsPerRGBValue;
775 header.colormap_entries = (CARD32) pVisual->ColormapEntries;
776 header.ncolors = ncolors = (CARD32) pVisual->ColormapEntries;
777 header.window_width = (CARD32) pDraw->width;
778 header.window_height = (CARD32) pDraw->height;
779 header.window_x = 0;
780 header.window_y = 0;
781 header.window_bdrwidth = (CARD32) 0;
783 if (*(char *) &swaptest) {
784 _swaplong((char *) &header, sizeof(header));
785 for (i = 0; i < ncolors; i++) {
786 _swaplong((char *) &pColors[i].pixel, sizeof(long));
787 _swapshort((char *) &pColors[i].red, 3 * sizeof(short));
791 (void) fwrite((char *)&header, sizeof(header), 1, pRasterFile);
792 (void) fwrite(win_name, win_name_size, 1, pRasterFile);
793 (void) fwrite((char *) pColors, sizeof(XWDColor), ncolors, pRasterFile);
795 Xfree(pColors);
798 * End of Xwd header code.
801 linesDone = 0;
802 while(height - linesDone > 0)
804 nlines = min(linesPerBuf, height - linesDone);
805 (*pDraw->pScreen->GetImage) (pDraw,
807 linesDone,
808 pWin->drawable.width,
809 nlines,
810 ZPixmap,
812 pBuf);
814 if(fwrite(pBuf, sizeof(char), (size_t)(nlines * widthBytesLine),
815 pRasterFile) !=
816 (size_t)(nlines * widthBytesLine))
818 Xfree(pBuf);
819 return BadAlloc;
821 linesDone += nlines;
823 Xfree(pBuf);
824 return Success;
828 static int
829 SendPage( XpContextPtr pCon )
831 struct stat statBuf;
832 RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
833 pCon->devPrivates[RasterContextPrivateIndex].ptr;
835 if(stat(pConPriv->pageFileName, &statBuf) < 0)
836 return BadAlloc;
838 return XpSendDocumentData(pConPriv->getDocClient,
839 pConPriv->pPageFile, (int)statBuf.st_size,
840 pConPriv->getDocBufSize);
844 * EndPage:
846 * If page file doesn't exist:
848 * Create page file
849 * Open page file
850 * Write page header to page file
851 * if(preRasterFile exists)
852 * copy preRasterFile contents to page file
853 * if(noRasterFile exists)
854 * write noRasterFile contents to page file
855 * else
856 * Create raster image file
857 * Open raster image file
858 * GetImage data
859 * Write Image data to raster image file
860 * invoke page_command on raster image file
861 * Write raster image file contents to page file
862 * Unlink tempPage file
863 * if(postRasterFile exists)
864 * write postRasterFile contents to page file
865 * Write page trailer to page file
867 * Write page file to job file
869 static int
870 EndPage(
871 XpContextPtr pCon,
872 WindowPtr pWin)
874 RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
875 pCon->devPrivates[RasterContextPrivateIndex].ptr;
876 struct stat statBuf;
877 char *rasterFileName = (char *)NULL, *pCommand = (char *)NULL;
878 FILE *pRasterFile = (FILE *)NULL;
880 if(pConPriv->pageFileName == (char *)NULL)
883 * Open the page file.
885 if (!XpOpenTmpFile("w+", &pConPriv->pageFileName,
886 &pConPriv->pPageFile))
887 goto BAD_PAGE_ALLOC;
890 * Copy any pre-raster document data to the page file.
892 if(pConPriv->pPreRasterFile != (FILE *)NULL)
894 if(CopyContentsAndDelete(&pConPriv->pPreRasterFile,
895 &pConPriv->preRasterFileName,
896 pConPriv->pPageFile) == FALSE)
897 goto BAD_PAGE_ALLOC;
901 * Copy either the no-raster document data, or the raster
902 * data itself to the page file.
903 * If the no-raster file exists, then we don't process the
904 * actual window raster bits.
906 if(pConPriv->pNoRasterFile != (FILE *)NULL)
908 if(CopyContentsAndDelete(&pConPriv->pNoRasterFile,
909 &pConPriv->noRasterFileName,
910 pConPriv->pPageFile) == FALSE)
911 goto BAD_PAGE_ALLOC;
913 else
916 * Open the raster image file.
918 if (!XpOpenTmpFile("w", &rasterFileName, &pRasterFile))
919 goto BAD_PAGE_ALLOC;
922 * Write the page image data to the raster image file.
924 if(WriteWindowRaster(pWin, pRasterFile) != Success)
925 goto BAD_PAGE_ALLOC;
928 * Invoke the page_command on the raster image file.
930 if((pCommand = GetPropString(pCon, RASTER_PRINT_PAGE_COMMAND)) !=
931 (char *)NULL)
933 char *outFileName;
934 FILE *pOutFile;
936 if (!XpOpenTmpFile("w", &outFileName, &pOutFile))
937 goto BAD_PAGE_ALLOC;
938 fclose(pOutFile);
940 pCommand = ReplaceFileString(strdup(pCommand), rasterFileName,
941 outFileName);
942 fclose(pRasterFile);
943 SystemCmd(pCommand);
944 free(pCommand);
946 * Delete the unprocessed raster file.
948 unlink(rasterFileName);
949 Xfree(rasterFileName);
950 rasterFileName = outFileName;
951 if((pRasterFile = fopen(rasterFileName, "r")) == (FILE *)NULL)
952 goto BAD_PAGE_ALLOC;
954 else
956 fclose(pRasterFile);
957 if((pRasterFile = fopen(rasterFileName, "r")) == (FILE *)NULL)
958 goto BAD_PAGE_ALLOC;
962 * Copy the raster image file contents to the page file.
963 * Note that pRasterFile must be set to the start of the
964 * raster file.
966 if(CopyContentsAndDelete(&pRasterFile,
967 &rasterFileName,
968 pConPriv->pPageFile) == FALSE)
969 goto BAD_PAGE_ALLOC;
973 * Copy any post-raster document data to the page file.
975 if(pConPriv->pPostRasterFile != (FILE *)NULL)
977 if(CopyContentsAndDelete(&pConPriv->pPostRasterFile,
978 &pConPriv->postRasterFileName,
979 pConPriv->pPageFile) == FALSE)
980 goto BAD_PAGE_ALLOC;
986 * Write the page file contents to the job file or to the client
987 * performing GetDocumentData.
988 * pConPriv->pPageFile must first be set to the start of the page file.
990 rewind(pConPriv->pPageFile);
991 if(stat(pConPriv->pageFileName, &statBuf) < 0)
992 goto BAD_PAGE_ALLOC;
995 * Send the page data to whatever client has called GetDocumentData.
997 if(pConPriv->getDocClient != (ClientPtr)NULL&&pConPriv->getDocBufSize > 0)
999 int retval;
1001 * We should do something like the following: suspend the
1002 * caller until we can gracefully write all the data in small
1003 * chunks to the receiver, but for now we'll just call WriteToClient
1004 * on the huge chunk
1006 retval = SendPage(pCon);
1007 fclose(pConPriv->pPageFile);
1008 pConPriv->pPageFile = (FILE *)NULL;
1009 unlink(pConPriv->pageFileName);
1010 free(pConPriv->pageFileName);
1011 pConPriv->pageFileName = (char *)NULL;
1012 return retval;
1015 if(pConPriv->pJobFile == (FILE *)NULL)
1018 * This shouldn't be necessary. I believe we only get here if
1019 * someone calls "EndPage" prior to "StartJob". This error
1020 * condition should probably be trapped at a higher level.
1023 if(pConPriv->jobFileName != (char *)NULL)
1024 Xfree(pConPriv->jobFileName);
1026 * Create a temporary file to store the printer output.
1028 if (!XpOpenTmpFile("w", &pConPriv->jobFileName, &pConPriv->pJobFile))
1029 goto BAD_PAGE_ALLOC;
1032 if(TransferBytes(pConPriv->pPageFile, pConPriv->pJobFile,
1033 (int)statBuf.st_size) != (int)statBuf.st_size)
1034 goto BAD_PAGE_ALLOC;
1036 fclose(pConPriv->pPageFile);
1037 pConPriv->pPageFile = (FILE *)NULL;
1038 unlink(pConPriv->pageFileName);
1039 free(pConPriv->pageFileName);
1040 pConPriv->pageFileName = (char *)NULL;
1042 return Success;
1044 BAD_PAGE_ALLOC:
1046 FreePageFiles(pConPriv);
1048 if(pRasterFile != (FILE *)NULL)
1049 fclose(pRasterFile);
1050 if(rasterFileName != (char *)NULL)
1052 unlink(rasterFileName);
1053 Xfree(rasterFileName);
1055 return BadAlloc;
1058 static int
1059 DocumentData(
1060 XpContextPtr pCon,
1061 DrawablePtr pDraw,
1062 char *pData,
1063 int len_data,
1064 char *pDoc_fmt,
1065 int len_fmt,
1066 char *pOptions,
1067 int len_options,
1068 ClientPtr client)
1070 RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
1071 pCon->devPrivates[RasterContextPrivateIndex].ptr;
1072 char *preRasterStr = PRE_RASTER, *postRasterStr = POST_RASTER,
1073 *noRasterStr = NO_RASTER;
1076 * Check that options equals either PRE_RASTER or POST_RASTER.
1078 if(len_options == strlen(preRasterStr) &&
1079 strncmp(pOptions, preRasterStr, strlen(preRasterStr)) == 0)
1081 if(pConPriv->pPreRasterFile == (FILE *)NULL)
1083 if (!XpOpenTmpFile("w+", &pConPriv->preRasterFileName,
1084 &pConPriv->pPreRasterFile))
1085 return BadAlloc;
1087 if(fwrite(pData, sizeof(char), (size_t)len_data,
1088 pConPriv->pPreRasterFile) != (size_t)len_data)
1089 return BadAlloc;
1090 fflush(pConPriv->pPreRasterFile);
1092 else if(len_options == strlen(postRasterStr) &&
1093 strncmp(pOptions, postRasterStr, strlen(postRasterStr)) == 0)
1095 if(pConPriv->pPostRasterFile == (FILE *)NULL)
1097 if (!XpOpenTmpFile("w+", &pConPriv->postRasterFileName,
1098 &pConPriv->pPostRasterFile))
1099 return BadAlloc;
1101 if(fwrite(pData, sizeof(char), (size_t)len_data,
1102 pConPriv->pPostRasterFile) != (size_t)len_data)
1103 return BadAlloc;
1104 fflush(pConPriv->pPostRasterFile);
1106 else if(len_options == strlen(noRasterStr) &&
1107 strncmp(pOptions, noRasterStr, strlen(noRasterStr)) == 0)
1109 if(pConPriv->pNoRasterFile == (FILE *)NULL)
1111 if (!XpOpenTmpFile("w+", &pConPriv->noRasterFileName,
1112 &pConPriv->pNoRasterFile))
1113 return BadAlloc;
1115 if(fwrite(pData, sizeof(char), (size_t)len_data,
1116 pConPriv->pNoRasterFile) != (size_t)len_data)
1117 return BadAlloc;
1118 fflush(pConPriv->pNoRasterFile);
1120 else
1121 return BadValue;
1123 return Success;
1127 * GetDocumentData notes which client is requesting the document data for
1128 * a particular context. The Raster driver's EndPage function causes the
1129 * data to be written to the proper client.
1131 static int
1132 GetDocumentData(
1133 XpContextPtr pContext,
1134 ClientPtr client,
1135 int maxBufferSize)
1137 RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
1138 pContext->devPrivates[RasterContextPrivateIndex].ptr;
1140 pConPriv->getDocClient = client;
1141 pConPriv->getDocBufSize = maxBufferSize;
1142 return Success;
1145 static void
1146 AllocateRasterPrivates(
1147 ScreenPtr pScreen)
1149 if(RasterGeneration != serverGeneration)
1151 RasterScreenPrivateIndex = AllocateScreenPrivateIndex();
1152 RasterContextPrivateIndex = XpAllocateContextPrivateIndex();
1153 XpAllocateContextPrivate( RasterContextPrivateIndex,
1154 sizeof( RasterContextPrivRec ) );
1156 RasterGeneration = serverGeneration;
1158 pScreen->devPrivates[RasterScreenPrivateIndex].ptr = (pointer)Xalloc(
1159 sizeof(RasterScreenPrivRec));
1163 * RasterChangeWindowAttributes - Make sure that the window's backing
1164 * store is turned on.
1166 static Bool
1167 RasterChangeWindowAttributes(
1168 WindowPtr pWin,
1169 unsigned long mask)
1171 Bool status = Success;
1172 ScreenPtr pScreen = pWin->drawable.pScreen;
1173 RasterScreenPrivPtr pScreenPriv = (RasterScreenPrivPtr)
1174 pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
1176 if(pWin->backingStore == NotUseful)
1178 pWin->backingStore = WhenMapped;
1179 mask |= CWBackingStore;
1182 if(pScreenPriv->ChangeWindowAttributes != NULL)
1184 pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
1185 status = pScreen->ChangeWindowAttributes(pWin, mask);
1186 pScreen->ChangeWindowAttributes = RasterChangeWindowAttributes;
1188 return status;
1192 * RasterValidateDocFormats - Inspects the files available in the
1193 * ddx-config/XP-RASTER directory to find the names of PDLs for which
1194 * we have processing commands. These names are then intersected with
1195 * the contents of the printer's document-formats-supported attribute,
1196 * and the result is stored back into document-formats-supported.
1197 * We have hard-coded knowledge of how to produce PS, so we always
1198 * leave that in, if it's listed in document-formats-supported,
1199 * even if we don't have a configuration file. If there is a
1200 * configuration file for PS, then its contents will override our default.
1202 static void
1203 RasterValidateDocFormats(
1204 XpContextPtr pCon)
1209 * RasterValidateAttrs - Inspects and Corrects the attribute values
1210 * in the specified context.
1212 static void
1213 RasterValidateAttrs(
1214 XpContextPtr pCon)
1216 RasterValidateDocFormats(pCon);
1217 XpValidatePrinterPool(pCon, &RasterValidatePoolsRec);
1218 XpValidateJobPool(pCon, &RasterValidatePoolsRec);
1219 XpValidateDocumentPool(pCon, &RasterValidatePoolsRec);
1223 * RasterInitContext - Establish the appropriate values for a
1224 * PrintContext used with the Raster Driver.
1226 static char DOC_ATT_SUPP[]="document-attributes-supported:\tdefault-medium document-format";
1227 static char JOB_ATT_SUPP[]="job-attributes-supported:\t";
1228 static char DDX_DIR[]="ddx-config";
1230 static int
1231 RasterInitContext(
1232 XpContextPtr pCon)
1234 char *configFileName, *val, *attrStr;
1235 RasterContextPrivPtr pConPriv;
1236 XpDriverFuncsPtr pFuncs;
1239 * Initialize the attribute store for this printer.
1241 XpInitAttributes( pCon );
1244 * Validate the attributes
1246 RasterValidateAttrs( pCon );
1250 * Initialize the function pointers
1252 pFuncs = &( pCon->funcs );
1253 pFuncs->StartJob = StartJob;
1254 pFuncs->EndJob = EndJob;
1255 pFuncs->StartDoc = StartDoc;
1256 pFuncs->EndDoc = EndDoc;
1257 pFuncs->StartPage = StartPage;
1258 pFuncs->EndPage = EndPage;
1259 pFuncs->PutDocumentData = DocumentData;
1260 pFuncs->GetDocumentData = GetDocumentData;
1261 pFuncs->DestroyContext = RasterDestroyContext;
1262 pFuncs->GetAttributes = RasterGetAttributes;
1263 pFuncs->GetOneAttribute = RasterGetOneAttribute;
1264 pFuncs->SetAttributes = RasterSetAttributes;
1265 pFuncs->AugmentAttributes = RasterAugmentAttributes;
1266 pFuncs->GetMediumDimensions = RasterMediumDimensions;
1267 pFuncs->GetReproducibleArea = RasterReproducibleArea;
1270 * Set up the context privates
1272 pConPriv = (RasterContextPrivPtr)
1273 pCon->devPrivates[RasterContextPrivateIndex].ptr;
1275 pConPriv->jobFileName = (char *)NULL;
1276 pConPriv->pageFileName = (char *)NULL;
1277 pConPriv->preRasterFileName = (char *)NULL;
1278 pConPriv->postRasterFileName = (char *)NULL;
1279 pConPriv->noRasterFileName = (char *)NULL;
1280 pConPriv->pJobFile = (FILE *)NULL;
1281 pConPriv->pPageFile = (FILE *)NULL;
1282 pConPriv->pPreRasterFile = (FILE *)NULL;
1283 pConPriv->pPostRasterFile = (FILE *)NULL;
1284 pConPriv->pNoRasterFile = (FILE *)NULL;
1286 pConPriv->getDocClient = (ClientPtr)NULL;
1287 pConPriv->getDocBufSize = 0;
1290 * Get the configuration information for the context's printer
1292 configFileName = XpGetOneAttribute( pCon, XPPrinterAttr,
1293 "xp-ddx-config-file-name" );
1294 if(configFileName && strlen(configFileName))
1296 if( configFileName[0] == '/' )
1297 pConPriv->config = XrmGetFileDatabase( configFileName );
1298 else
1300 char *configDir, *configFilePath;
1302 configDir = XpGetConfigDir(FALSE);
1303 configFilePath = (char *)malloc((strlen(configDir) +
1304 strlen(DDX_DIR) +
1305 strlen(RASTER_DRIV_NAME) +
1306 strlen(configFileName) +
1307 4)* sizeof(char));
1308 sprintf(configFilePath, "%s/%s/%s/%s", configDir, DDX_DIR,
1309 RASTER_DRIV_NAME, configFileName);
1310 pConPriv->config = XrmGetFileDatabase(configFilePath);
1311 free(configDir);
1312 free(configFilePath);
1315 else
1316 pConPriv->config = (XrmDatabase)NULL;
1319 * Add our own attribute initialization
1322 * document-attributes-supported
1324 val = XpGetOneAttribute(pCon, XPServerAttr, "document-attributes-supported");
1325 if((attrStr = (char *)xalloc(strlen(val) + strlen(DOC_ATT_SUPP) + 4)) ==
1326 (char *)NULL)
1327 return BadAlloc;
1328 sprintf(attrStr, "*%s %s", DOC_ATT_SUPP, val);
1329 XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
1330 xfree(attrStr);
1333 * job-attributes-supported
1335 val = XpGetOneAttribute(pCon, XPServerAttr, "job-attributes-supported");
1336 if((attrStr = (char *)xalloc(strlen(val) + strlen(JOB_ATT_SUPP) + 4)) ==
1337 (char *)NULL)
1338 return BadAlloc;
1339 sprintf(attrStr, "*%s %s", JOB_ATT_SUPP, val);
1340 XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
1341 xfree(attrStr);
1344 * PageAttributesSupported
1346 XpAugmentAttributes(pCon, XPPrinterAttr, "*xp-page-attributes-supported:");
1348 return Success;
1353 static Bool
1354 RasterDestroyContext(
1355 XpContextPtr pCon)
1357 RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
1358 pCon->devPrivates[RasterContextPrivateIndex].ptr;
1361 * Clean up the temporary files
1363 FreePageFiles( pConPriv );
1365 if( pConPriv->pJobFile != (FILE *)NULL )
1367 fclose( pConPriv->pJobFile );
1368 pConPriv->pJobFile = (FILE *)NULL;
1370 if( pConPriv->jobFileName != (char *)NULL )
1372 unlink( pConPriv->jobFileName );
1373 Xfree( pConPriv->jobFileName );
1375 if(pConPriv->config)
1377 XrmDestroyDatabase(pConPriv->config);
1378 pConPriv->config = (XrmDatabase)NULL;
1381 XpDestroyAttributes( pCon );
1382 return Success;
1385 static char *
1386 RasterGetAttributes(
1387 XpContextPtr pContext,
1388 XPAttributes class)
1390 return XpGetAttributes( pContext, class );
1393 static char *
1394 RasterGetOneAttribute(
1395 XpContextPtr pContext,
1396 XPAttributes class,
1397 char *attr)
1399 return XpGetOneAttribute( pContext, class, attr );
1402 static int
1403 RasterSetAttributes(XpContextPtr pCon,
1404 XPAttributes class,
1405 char *attributes)
1407 return XpSetAttributes( pCon, class, attributes );
1410 static int
1411 RasterAugmentAttributes(
1412 XpContextPtr pCon,
1413 XPAttributes class,
1414 char *attributes)
1416 return XpAugmentAttributes( pCon, class, attributes );
1419 static void
1420 FreePageFiles(
1421 RasterContextPrivPtr pConPriv)
1423 if(pConPriv->pPageFile != (FILE *)NULL)
1425 fclose(pConPriv->pPageFile);
1426 pConPriv->pPageFile = (FILE *)NULL;
1428 if(pConPriv->pageFileName != (char *)NULL)
1430 unlink(pConPriv->pageFileName);
1431 Xfree(pConPriv->pageFileName);
1432 pConPriv->pageFileName = (char *)NULL;
1434 if(pConPriv->pPreRasterFile != (FILE *)NULL)
1436 fclose(pConPriv->pPreRasterFile);
1437 pConPriv->pPreRasterFile = (FILE *)NULL;
1439 if(pConPriv->preRasterFileName != (char *)NULL)
1441 unlink(pConPriv->preRasterFileName);
1442 Xfree(pConPriv->preRasterFileName);
1443 pConPriv->preRasterFileName = (char *)NULL;
1445 if(pConPriv->pPostRasterFile != (FILE *)NULL)
1447 fclose(pConPriv->pPostRasterFile);
1448 pConPriv->pPostRasterFile = (FILE *)NULL;
1450 if(pConPriv->postRasterFileName != (char *)NULL)
1452 unlink(pConPriv->postRasterFileName);
1453 Xfree(pConPriv->postRasterFileName);
1454 pConPriv->postRasterFileName = (char *)NULL;
1456 if(pConPriv->pNoRasterFile != (FILE *)NULL)
1458 fclose(pConPriv->pNoRasterFile);
1459 pConPriv->pNoRasterFile = (FILE *)NULL;
1461 if(pConPriv->noRasterFileName != (char *)NULL)
1463 unlink(pConPriv->noRasterFileName);
1464 Xfree(pConPriv->noRasterFileName);
1465 pConPriv->noRasterFileName = (char *)NULL;
1470 * RasterCloseScreen - Call any wrapped CloseScreen function,
1471 * and free the screen memory.
1473 static Bool
1474 RasterCloseScreen(
1475 int index,
1476 ScreenPtr pScreen)
1478 Bool status = Success;
1479 RasterScreenPrivPtr pScreenPriv = (RasterScreenPrivPtr)
1480 pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
1483 * Call any wrapped CloseScreen proc.
1485 if(pScreenPriv->CloseScreen != NULL)
1487 pScreen->CloseScreen = pScreenPriv->CloseScreen;
1488 status = pScreen->CloseScreen(index, pScreen);
1489 pScreen->CloseScreen = RasterCloseScreen;
1492 Xfree(pScreenPriv->pBits);
1493 Xfree(pScreenPriv);
1495 return status;
1498 #include <signal.h>
1500 /* ARGSUSED */
1501 static void SigchldHndlr (int dummy)
1503 int status;
1504 int olderrno = errno;
1505 struct sigaction act;
1506 sigfillset(&act.sa_mask);
1507 act.sa_flags = 0;
1508 act.sa_handler = SigchldHndlr;
1510 (void) wait (&status);
1513 * Is this really necessary?
1515 sigaction(SIGCHLD, &act, (struct sigaction *)NULL);
1516 errno = olderrno;
1520 * SystemCmd provides a wrapper for the 'system' library call. The call
1521 * appears to be sensitive to the handling of SIGCHLD, so this wrapper
1522 * sets the status to SIG_DFL, and then resets the established handler
1523 * after system returns.
1525 static int
1526 SystemCmd(char *cmdStr)
1528 int status;
1529 struct sigaction newAct, oldAct;
1530 sigfillset(&newAct.sa_mask);
1531 newAct.sa_flags = 0;
1532 newAct.sa_handler = SIG_DFL;
1533 sigfillset(&oldAct.sa_mask);
1534 oldAct.sa_flags = 0;
1535 oldAct.sa_handler = SigchldHndlr;
1538 * get the old handler, and set the action to IGN
1540 sigaction(SIGCHLD, &newAct, &oldAct);
1542 status = system (cmdStr);
1544 sigaction(SIGCHLD, &oldAct, (struct sigaction *)NULL);
1545 return status;
1549 * RasterMediumDimensions is installed in the GetMediumDimensions field
1550 * of each raster-initialized context.
1552 static int
1553 RasterMediumDimensions(XpContextPtr pCon,
1554 CARD16 *width,
1555 CARD16 *height)
1557 XpGetMediumDimensions(pCon, width, height);
1558 return Success;
1562 * RasterReproducibleArea is installed in the GetReproducibleArea field
1563 * of each raster-initialized context.
1565 static int
1566 RasterReproducibleArea(XpContextPtr pCon,
1567 xRectangle *pRect)
1569 XpGetReproductionArea(pCon, pRect);
1570 return Success;