aboutsummaryrefslogtreecommitdiff
path: root/libX11/src/xcms
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-07-08 08:36:18 +0000
committermarha <marha@users.sourceforge.net>2010-07-08 08:36:18 +0000
commit29c7981777a6fa7d962977d2a7bdce68c116206d (patch)
tree78ed3f1b4d5c559fa6fa0e8fc3dbdc51c8c1f321 /libX11/src/xcms
parentc23b5379fd9f4da7bcd627e973abb6868274fc75 (diff)
parentd1e8cd61e0fa02a5b415a5c161b355c95f45ae14 (diff)
downloadvcxsrv-29c7981777a6fa7d962977d2a7bdce68c116206d.tar.gz
vcxsrv-29c7981777a6fa7d962977d2a7bdce68c116206d.tar.bz2
vcxsrv-29c7981777a6fa7d962977d2a7bdce68c116206d.zip
svn merge ^/branches/released .
Diffstat (limited to 'libX11/src/xcms')
-rw-r--r--libX11/src/xcms/cmsAllNCol.c397
-rw-r--r--libX11/src/xcms/cmsCmap.c988
-rw-r--r--libX11/src/xcms/cmsInt.c825
-rw-r--r--libX11/src/xcms/cmsLkCol.c387
4 files changed, 1296 insertions, 1301 deletions
diff --git a/libX11/src/xcms/cmsAllNCol.c b/libX11/src/xcms/cmsAllNCol.c
index 105e8bd98..79e1bfe7f 100644
--- a/libX11/src/xcms/cmsAllNCol.c
+++ b/libX11/src/xcms/cmsAllNCol.c
@@ -1,199 +1,198 @@
-
-/*
- * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
- * All Rights Reserved
- *
- * This file is a component of an X Window System-specific implementation
- * of Xcms based on the TekColor Color Management System. Permission is
- * hereby granted to use, copy, modify, sell, and otherwise distribute this
- * software and its documentation for any purpose and without fee, provided
- * that this copyright, permission, and disclaimer notice is reproduced in
- * all copies of this software and in supporting documentation. TekColor
- * is a trademark of Tektronix, Inc.
- *
- * Tektronix makes no representation about the suitability of this software
- * for any purpose. It is provided "as is" and with all faults.
- *
- * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
- * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
- *
- *
- * NAME
- * XcmsAlNCol.c
- *
- * DESCRIPTION
- * Source for XcmsAllocNamedColor
- *
- *
- */
-
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include "Xlibint.h"
-#include "Xcmsint.h"
-#include "Cv.h"
-
-
-/*
- * NAME
- * XcmsAllocNamedColor -
- *
- * SYNOPSIS
- */
-Status
-XcmsAllocNamedColor (
- Display *dpy,
- Colormap cmap,
- _Xconst char *colorname,
- XcmsColor *pColor_scrn_return,
- XcmsColor *pColor_exact_return,
- XcmsColorFormat result_format)
-/*
- * DESCRIPTION
- * Finds the color specification associated with the color
- * name in the Device-Independent Color Name Database, then
- * converts that color specification to an RGB format. This
- * RGB value is then used in a call to XAllocColor to allocate
- * a read-only color cell.
- *
- * RETURNS
- * 0 if failed to parse string or find any entry in the database.
- * 1 if succeeded in converting color name to XcmsColor.
- * 2 if succeeded in converting color name to another color name.
- *
- */
-{
- long nbytes;
- xAllocNamedColorReply rep;
- xAllocNamedColorReq *req;
- XColor hard_def;
- XColor exact_def;
- Status retval1 = 1;
- Status retval2 = XcmsSuccess;
- XcmsColor tmpColor;
- XColor XColor_in_out;
- XcmsCCC ccc;
-
- /*
- * 0. Check for invalid arguments.
- */
- if (dpy == NULL || colorname[0] == '\0' || pColor_scrn_return == 0
- || pColor_exact_return == NULL) {
- return(XcmsFailure);
- }
-
- if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
- return(XcmsFailure);
- }
-
- /*
- * 1. Convert string to a XcmsColor using Xcms and i18n mechanism
- */
- if ((retval1 = _XcmsResolveColorString(ccc, &colorname,
- &tmpColor, result_format)) == XcmsFailure) {
- return(XcmsFailure);
- }
- if (retval1 == _XCMS_NEWNAME) {
- goto PassToServer;
- }
- memcpy((char *)pColor_exact_return, (char *)&tmpColor, sizeof(XcmsColor));
-
- /*
- * 2. Convert tmpColor to RGB
- * Assume pColor_exact_return is now adjusted to Client White Point
- */
- if ((retval2 = XcmsConvertColors(ccc, &tmpColor,
- 1, XcmsRGBFormat, (Bool *) NULL)) == XcmsFailure) {
- return(XcmsFailure);
- }
-
- /*
- * 3. Convert to XColor and call XAllocColor
- */
- _XcmsRGB_to_XColor(&tmpColor, &XColor_in_out, 1);
- if (XAllocColor(ccc->dpy, cmap, &XColor_in_out) == 0) {
- return(XcmsFailure);
- }
-
- /*
- * 4. pColor_scrn_return
- *
- * Now convert to the target format.
- * We can ignore the return value because we're already in a
- * device-dependent format.
- */
- _XColor_to_XcmsRGB(ccc, &XColor_in_out, pColor_scrn_return, 1);
- if (result_format != XcmsRGBFormat) {
- if (result_format == XcmsUndefinedFormat) {
- result_format = pColor_exact_return->format;
- }
- if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
- (Bool *) NULL) == XcmsFailure) {
- return(XcmsFailure);
- }
- }
-
- return(retval1 > retval2 ? retval1 : retval2);
-
-PassToServer:
- /*
- * All previous methods failed, so lets pass it to the server
- * for parsing.
- */
- dpy = ccc->dpy;
- LockDisplay(dpy);
- GetReq(AllocNamedColor, req);
-
- req->cmap = cmap;
- nbytes = req->nbytes = strlen(colorname);
- req->length += (nbytes + 3) >> 2; /* round up to mult of 4 */
-
- _XSend(dpy, colorname, nbytes);
- /* _XSend is more efficient that Data, since _XReply follows */
-
- if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return (0);
- }
-
- exact_def.red = rep.exactRed;
- exact_def.green = rep.exactGreen;
- exact_def.blue = rep.exactBlue;
-
- hard_def.red = rep.screenRed;
- hard_def.green = rep.screenGreen;
- hard_def.blue = rep.screenBlue;
-
- exact_def.pixel = hard_def.pixel = rep.pixel;
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- /*
- * Now convert to the target format.
- */
- _XColor_to_XcmsRGB(ccc, &exact_def, pColor_exact_return, 1);
- _XColor_to_XcmsRGB(ccc, &hard_def, pColor_scrn_return, 1);
- if (result_format != XcmsRGBFormat
- && result_format != XcmsUndefinedFormat) {
- if (XcmsConvertColors(ccc, pColor_exact_return, 1, result_format,
- (Bool *) NULL) == XcmsFailure) {
- return(XcmsFailure);
- }
- if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
- (Bool *) NULL) == XcmsFailure) {
- return(XcmsFailure);
- }
- }
-
- return(XcmsSuccess);
-}
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsAlNCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsAllocNamedColor
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/*
+ * NAME
+ * XcmsAllocNamedColor -
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsAllocNamedColor (
+ Display *dpy,
+ Colormap cmap,
+ _Xconst char *colorname,
+ XcmsColor *pColor_scrn_return,
+ XcmsColor *pColor_exact_return,
+ XcmsColorFormat result_format)
+/*
+ * DESCRIPTION
+ * Finds the color specification associated with the color
+ * name in the Device-Independent Color Name Database, then
+ * converts that color specification to an RGB format. This
+ * RGB value is then used in a call to XAllocColor to allocate
+ * a read-only color cell.
+ *
+ * RETURNS
+ * 0 if failed to parse string or find any entry in the database.
+ * 1 if succeeded in converting color name to XcmsColor.
+ * 2 if succeeded in converting color name to another color name.
+ *
+ */
+{
+ long nbytes;
+ xAllocNamedColorReply rep;
+ xAllocNamedColorReq *req;
+ XColor hard_def;
+ XColor exact_def;
+ Status retval1 = 1;
+ Status retval2 = XcmsSuccess;
+ XcmsColor tmpColor;
+ XColor XColor_in_out;
+ XcmsCCC ccc;
+
+ /*
+ * 0. Check for invalid arguments.
+ */
+ if (dpy == NULL || colorname[0] == '\0' || pColor_scrn_return == 0
+ || pColor_exact_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 1. Convert string to a XcmsColor using Xcms and i18n mechanism
+ */
+ if ((retval1 = _XcmsResolveColorString(ccc, &colorname,
+ &tmpColor, result_format)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (retval1 == _XCMS_NEWNAME) {
+ goto PassToServer;
+ }
+ memcpy((char *)pColor_exact_return, (char *)&tmpColor, sizeof(XcmsColor));
+
+ /*
+ * 2. Convert tmpColor to RGB
+ * Assume pColor_exact_return is now adjusted to Client White Point
+ */
+ if ((retval2 = XcmsConvertColors(ccc, &tmpColor,
+ 1, XcmsRGBFormat, (Bool *) NULL)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 3. Convert to XColor and call XAllocColor
+ */
+ _XcmsRGB_to_XColor(&tmpColor, &XColor_in_out, 1);
+ if (XAllocColor(ccc->dpy, cmap, &XColor_in_out) == 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 4. pColor_scrn_return
+ *
+ * Now convert to the target format.
+ * We can ignore the return value because we're already in a
+ * device-dependent format.
+ */
+ _XColor_to_XcmsRGB(ccc, &XColor_in_out, pColor_scrn_return, 1);
+ if (result_format != XcmsRGBFormat) {
+ if (result_format == XcmsUndefinedFormat) {
+ result_format = pColor_exact_return->format;
+ }
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(retval1 > retval2 ? retval1 : retval2);
+
+PassToServer:
+ /*
+ * All previous methods failed, so lets pass it to the server
+ * for parsing.
+ */
+ dpy = ccc->dpy;
+ LockDisplay(dpy);
+ GetReq(AllocNamedColor, req);
+
+ req->cmap = cmap;
+ nbytes = req->nbytes = strlen(colorname);
+ req->length += (nbytes + 3) >> 2; /* round up to mult of 4 */
+
+ _XSend(dpy, colorname, nbytes);
+ /* _XSend is more efficient that Data, since _XReply follows */
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+
+ exact_def.red = rep.exactRed;
+ exact_def.green = rep.exactGreen;
+ exact_def.blue = rep.exactBlue;
+
+ hard_def.red = rep.screenRed;
+ hard_def.green = rep.screenGreen;
+ hard_def.blue = rep.screenBlue;
+
+ exact_def.pixel = hard_def.pixel = rep.pixel;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ /*
+ * Now convert to the target format.
+ */
+ _XColor_to_XcmsRGB(ccc, &exact_def, pColor_exact_return, 1);
+ _XColor_to_XcmsRGB(ccc, &hard_def, pColor_scrn_return, 1);
+ if (result_format != XcmsRGBFormat
+ && result_format != XcmsUndefinedFormat) {
+ if (XcmsConvertColors(ccc, pColor_exact_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/libX11/src/xcms/cmsCmap.c b/libX11/src/xcms/cmsCmap.c
index f93a25b1f..2f14cdb25 100644
--- a/libX11/src/xcms/cmsCmap.c
+++ b/libX11/src/xcms/cmsCmap.c
@@ -1,495 +1,493 @@
-
-/*
- * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
- * All Rights Reserved
- *
- * This file is a component of an X Window System-specific implementation
- * of Xcms based on the TekColor Color Management System. Permission is
- * hereby granted to use, copy, modify, sell, and otherwise distribute this
- * software and its documentation for any purpose and without fee, provided
- * that this copyright, permission, and disclaimer notice is reproduced in
- * all copies of this software and in supporting documentation. TekColor
- * is a trademark of Tektronix, Inc.
- *
- * Tektronix makes no representation about the suitability of this software
- * for any purpose. It is provided "as is" and with all faults.
- *
- * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
- * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
- *
- *
- * NAME
- * XcmsCmap.c - Client Colormap Management Routines
- *
- * DESCRIPTION
- * Routines that store additional information about
- * colormaps being used by the X Client.
- *
- *
- */
-
-#define NEED_EVENTS
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "Xcmsint.h"
-#include "Xutil.h"
-#include "Cmap.h"
-#include "Cv.h"
-
-/*
- * FORWARD DECLARATIONS
- */
-static void _XcmsFreeClientCmaps(Display *dpy);
-
-
-/************************************************************************
- * *
- * PRIVATE INTERFACES *
- * *
- ************************************************************************/
-
-/*
- * NAME
- * CmapRecForColormap
- *
- * SYNOPSIS
- */
-static XcmsCmapRec *
-CmapRecForColormap(
- Display *dpy,
- Colormap cmap)
-/*
- * DESCRIPTION
- * Find the corresponding XcmsCmapRec for cmap. In not found
- * this routines attempts to create one.
- *
- * RETURNS
- * Returns NULL if failed; otherwise the address to
- * the corresponding XcmsCmapRec.
- *
- */
-{
- XcmsCmapRec *pRec;
- int nScrn;
- int i, j;
- XVisualInfo visualTemplate; /* Template of the visual we want */
- XVisualInfo *visualList; /* List for visuals that match */
- int nVisualsMatched; /* Number of visuals that match */
- Window tmpWindow;
- Visual *vp;
- unsigned long border = 0;
- _XAsyncHandler async;
- _XAsyncErrorState async_state;
-
- for (pRec = (XcmsCmapRec *)dpy->cms.clientCmaps; pRec != NULL;
- pRec = pRec->pNext) {
- if (pRec->cmapID == cmap) {
- return(pRec);
- }
- }
-
- /*
- * Can't find an XcmsCmapRec associated with cmap in our records.
- * Let's try to see if its a default colormap
- */
- nScrn = ScreenCount(dpy);
- for (i = 0; i < nScrn; i++) {
- if (cmap == DefaultColormap(dpy, i)) {
- /* It is ... lets go ahead and store that info */
- if ((pRec = _XcmsAddCmapRec(dpy, cmap, RootWindow(dpy, i),
- DefaultVisual(dpy, i))) == NULL) {
- return((XcmsCmapRec *)NULL);
- }
- pRec->ccc = XcmsCreateCCC(
- dpy,
- i, /* screenNumber */
- DefaultVisual(dpy, i),
- (XcmsColor *)NULL, /* clientWhitePt */
- (XcmsCompressionProc)NULL, /* gamutCompProc */
- (XPointer)NULL, /* gamutCompClientData */
- (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
- (XPointer)NULL /* whitePtAdjClientData */
- );
- return(pRec);
- }
- }
-
- /*
- * Nope, its not a default colormap, so it's probably a foreign color map
- * of which we have no specific details. Let's go through the
- * rigorous process of finding this colormap:
- * for each screen
- * for each screen's visual types
- * create a window with cmap specified as the colormap
- * if successful
- * Add a CmapRec
- * Create an XcmsCCC
- * return the CmapRec
- * else
- * continue
- */
-
- async_state.error_code = 0; /* don't care */
- async_state.major_opcode = X_CreateWindow;
- async_state.minor_opcode = 0;
- for (i = 0; i < nScrn; i++) {
- visualTemplate.screen = i;
- visualList = XGetVisualInfo(dpy, VisualScreenMask, &visualTemplate,
- &nVisualsMatched);
- if (visualList == NULL) {
- continue;
- }
-
- /*
- * Attempt to create a window with cmap
- */
- j = 0;
- do {
- vp = (visualList+j)->visual;
- LockDisplay(dpy);
- {
- register xCreateWindowReq *req;
-
- GetReq(CreateWindow, req);
- async_state.min_sequence_number = dpy->request;
- async_state.max_sequence_number = dpy->request;
- async_state.error_count = 0;
- async.next = dpy->async_handlers;
- async.handler = _XAsyncErrorHandler;
- async.data = (XPointer)&async_state;
- dpy->async_handlers = &async;
- req->parent = RootWindow(dpy, i);
- req->x = 0;
- req->y = 0;
- req->width = 1;
- req->height = 1;
- req->borderWidth = 0;
- req->depth = (visualList+j)->depth;
- req->class = CopyFromParent;
- req->visual = vp->visualid;
- tmpWindow = req->wid = XAllocID(dpy);
- req->mask = CWBorderPixel | CWColormap;
- req->length += 2;
- Data32 (dpy, (long *) &border, 4);
- Data32 (dpy, (long *) &cmap, 4);
- }
- {
- xGetInputFocusReply rep;
- register xReq *req;
-
- GetEmptyReq(GetInputFocus, req);
- (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
- }
- DeqAsyncHandler(dpy, &async);
- UnlockDisplay(dpy);
- SyncHandle();
- } while (async_state.error_count > 0 && ++j < nVisualsMatched);
-
- Xfree((char *)visualList);
-
- /*
- * if successful
- */
- if (j < nVisualsMatched) {
- if ((pRec = _XcmsAddCmapRec(dpy, cmap, tmpWindow, vp)) == NULL)
- return((XcmsCmapRec *)NULL);
- pRec->ccc = XcmsCreateCCC(
- dpy,
- i, /* screenNumber */
- vp,
- (XcmsColor *)NULL, /* clientWhitePt */
- (XcmsCompressionProc)NULL, /* gamutCompProc */
- (XPointer)NULL, /* gamutCompClientData */
- (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
- (XPointer)NULL /* whitePtAdjClientData */
- );
- XDestroyWindow(dpy, tmpWindow);
- return(pRec);
- }
- }
-
- return(NULL);
-}
-
-
-
-/************************************************************************
- * *
- * API PRIVATE INTERFACES *
- * *
- ************************************************************************/
-
-/*
- * NAME
- * _XcmsAddCmapRec
- *
- * SYNOPSIS
- */
-XcmsCmapRec *
-_XcmsAddCmapRec(
- Display *dpy,
- Colormap cmap,
- Window windowID,
- Visual *visual)
-/*
- * DESCRIPTION
- * Create an XcmsCmapRec for the specified cmap, windowID,
- * and visual, then adds it to its list of CmapRec's.
- *
- * RETURNS
- * Returns NULL if failed; otherwise the address to
- * the added XcmsCmapRec.
- *
- */
-{
- XcmsCmapRec *pNew;
-
- if ((pNew = (XcmsCmapRec *) Xcalloc(1, (unsigned) sizeof(XcmsCmapRec)))
- == NULL) {
- return((XcmsCmapRec *)NULL);
- }
-
- pNew->cmapID = cmap;
- pNew->dpy = dpy;
- pNew->windowID = windowID;
- pNew->visual = visual;
- pNew->pNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
- dpy->cms.clientCmaps = (XPointer)pNew;
- dpy->free_funcs->clientCmaps = _XcmsFreeClientCmaps;
-
- /*
- * Note, we don't create the XcmsCCC for pNew->ccc here because
- * it may require the use of XGetWindowAttributes (a round trip request)
- * to determine the screen.
- */
- return(pNew);
-}
-
-
-/*
- * NAME
- * _XcmsCopyCmapRecAndFree
- *
- * SYNOPSIS
- */
-XcmsCmapRec *
-_XcmsCopyCmapRecAndFree(
- Display *dpy,
- Colormap src_cmap,
- Colormap copy_cmap)
-/*
- * DESCRIPTION
- * Augments Xlib's XCopyColormapAndFree() to copy
- * XcmsCmapRecs.
- *
- * RETURNS
- * Returns NULL if failed; otherwise the address to
- * the copy XcmsCmapRec.
- *
- */
-{
- XcmsCmapRec *pRec_src;
- XcmsCmapRec *pRec_copy;
-
- if ((pRec_src = CmapRecForColormap(dpy, src_cmap)) != NULL) {
- pRec_copy =_XcmsAddCmapRec(dpy, copy_cmap, pRec_src->windowID,
- pRec_src->visual);
- if (pRec_copy != NULL && pRec_src->ccc) {
- pRec_copy->ccc = (XcmsCCC)Xcalloc(1, (unsigned) sizeof(XcmsCCCRec));
- memcpy((char *)pRec_copy->ccc, (char *)pRec_src->ccc,
- sizeof(XcmsCCCRec));
- }
- return(pRec_copy);
- }
- return((XcmsCmapRec *)NULL);
-}
-
-
-/*
- * NAME
- * _XcmsDeleteCmapRec
- *
- * SYNOPSIS
- */
-void
-_XcmsDeleteCmapRec(
- Display *dpy,
- Colormap cmap)
-/*
- * DESCRIPTION
- * Removes and frees the specified XcmsCmapRec structure
- * from the linked list of structures.
- *
- * RETURNS
- * void
- *
- */
-{
- XcmsCmapRec **pPrevPtr;
- XcmsCmapRec *pRec;
- int scr;
-
- /* If it is the default cmap for a screen, do not delete it,
- * because the server will not actually free it */
- for (scr = ScreenCount(dpy); --scr >= 0; ) {
- if (cmap == DefaultColormap(dpy, scr))
- return;
- }
-
- /* search for it in the list */
- pPrevPtr = (XcmsCmapRec **)&dpy->cms.clientCmaps;
- while ((pRec = *pPrevPtr) && (pRec->cmapID != cmap)) {
- pPrevPtr = &pRec->pNext;
- }
-
- if (pRec) {
- if (pRec->ccc) {
- XcmsFreeCCC(pRec->ccc);
- }
- *pPrevPtr = pRec->pNext;
- Xfree((char *)pRec);
- }
-}
-
-
-/*
- * NAME
- * _XcmsFreeClientCmaps
- *
- * SYNOPSIS
- */
-static void
-_XcmsFreeClientCmaps(
- Display *dpy)
-/*
- * DESCRIPTION
- * Frees all XcmsCmapRec structures in the linked list
- * and sets dpy->cms.clientCmaps to NULL.
- *
- * RETURNS
- * void
- *
- */
-{
- XcmsCmapRec *pRecNext, *pRecFree;
-
- pRecNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
- while (pRecNext != NULL) {
- pRecFree = pRecNext;
- pRecNext = pRecNext->pNext;
- if (pRecFree->ccc) {
- /* Free the XcmsCCC structure */
- XcmsFreeCCC(pRecFree->ccc);
- }
- /* Now free the XcmsCmapRec structure */
- Xfree((char *)pRecFree);
- }
- dpy->cms.clientCmaps = (XPointer)NULL;
-}
-
-
-
-/************************************************************************
- * *
- * PUBLIC INTERFACES *
- * *
- ************************************************************************/
-
-/*
- * NAME
- * XcmsCCCOfColormap
- *
- * SYNOPSIS
- */
-XcmsCCC
-XcmsCCCOfColormap(
- Display *dpy,
- Colormap cmap)
-/*
- * DESCRIPTION
- * Finds the XcmsCCC associated with the specified colormap.
- *
- * RETURNS
- * Returns NULL if failed; otherwise the address to
- * the associated XcmsCCC structure.
- *
- */
-{
- XWindowAttributes windowAttr;
- XcmsCmapRec *pRec;
- int nScrn = ScreenCount(dpy);
- int i;
-
- if ((pRec = CmapRecForColormap(dpy, cmap)) != NULL) {
- if (pRec->ccc) {
- /* XcmsCmapRec already has a XcmsCCC */
- return(pRec->ccc);
- }
-
- /*
- * The XcmsCmapRec does not have a XcmsCCC yet, so let's create
- * one. But first, we need to know the screen associated with
- * cmap, so use XGetWindowAttributes() to extract that
- * information. Unless, of course there is only one screen!!
- */
- if (nScrn == 1) {
- /* Assume screenNumber == 0 */
- return(pRec->ccc = XcmsCreateCCC(
- dpy,
- 0, /* screenNumber */
- pRec->visual,
- (XcmsColor *)NULL, /* clientWhitePt */
- (XcmsCompressionProc)NULL, /* gamutCompProc */
- (XPointer)NULL, /* gamutCompClientData */
- (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
- (XPointer)NULL /* whitePtAdjClientData */
- ));
- } else {
- if (XGetWindowAttributes(dpy, pRec->windowID, &windowAttr)) {
- for (i = 0; i < nScrn; i++) {
- if (ScreenOfDisplay(dpy, i) == windowAttr.screen) {
- return(pRec->ccc = XcmsCreateCCC(
- dpy,
- i, /* screenNumber */
- pRec->visual,
- (XcmsColor *)NULL, /* clientWhitePt */
- (XcmsCompressionProc)NULL, /* gamutCompProc */
- (XPointer)NULL, /* gamutCompClientData */
- (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
- (XPointer)NULL /* whitePtAdjClientData */
- ));
- }
- }
- }
- }
- }
-
- /*
- * No such cmap
- */
- return(NULL);
-}
-
-XcmsCCC XcmsSetCCCOfColormap(
- Display *dpy,
- Colormap cmap,
- XcmsCCC ccc)
-{
- XcmsCCC prev_ccc = NULL;
- XcmsCmapRec *pRec;
-
- pRec = CmapRecForColormap(dpy, cmap);
- if (pRec) {
- prev_ccc = pRec->ccc;
- pRec->ccc = ccc;
- }
- return prev_ccc;
-}
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsCmap.c - Client Colormap Management Routines
+ *
+ * DESCRIPTION
+ * Routines that store additional information about
+ * colormaps being used by the X Client.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Xutil.h"
+#include "Cmap.h"
+#include "Cv.h"
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static void _XcmsFreeClientCmaps(Display *dpy);
+
+
+/************************************************************************
+ * *
+ * PRIVATE INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CmapRecForColormap
+ *
+ * SYNOPSIS
+ */
+static XcmsCmapRec *
+CmapRecForColormap(
+ Display *dpy,
+ Colormap cmap)
+/*
+ * DESCRIPTION
+ * Find the corresponding XcmsCmapRec for cmap. In not found
+ * this routines attempts to create one.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the corresponding XcmsCmapRec.
+ *
+ */
+{
+ XcmsCmapRec *pRec;
+ int nScrn;
+ int i, j;
+ XVisualInfo visualTemplate; /* Template of the visual we want */
+ XVisualInfo *visualList; /* List for visuals that match */
+ int nVisualsMatched; /* Number of visuals that match */
+ Window tmpWindow;
+ Visual *vp;
+ unsigned long border = 0;
+ _XAsyncHandler async;
+ _XAsyncErrorState async_state;
+
+ for (pRec = (XcmsCmapRec *)dpy->cms.clientCmaps; pRec != NULL;
+ pRec = pRec->pNext) {
+ if (pRec->cmapID == cmap) {
+ return(pRec);
+ }
+ }
+
+ /*
+ * Can't find an XcmsCmapRec associated with cmap in our records.
+ * Let's try to see if its a default colormap
+ */
+ nScrn = ScreenCount(dpy);
+ for (i = 0; i < nScrn; i++) {
+ if (cmap == DefaultColormap(dpy, i)) {
+ /* It is ... lets go ahead and store that info */
+ if ((pRec = _XcmsAddCmapRec(dpy, cmap, RootWindow(dpy, i),
+ DefaultVisual(dpy, i))) == NULL) {
+ return((XcmsCmapRec *)NULL);
+ }
+ pRec->ccc = XcmsCreateCCC(
+ dpy,
+ i, /* screenNumber */
+ DefaultVisual(dpy, i),
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ );
+ return(pRec);
+ }
+ }
+
+ /*
+ * Nope, its not a default colormap, so it's probably a foreign color map
+ * of which we have no specific details. Let's go through the
+ * rigorous process of finding this colormap:
+ * for each screen
+ * for each screen's visual types
+ * create a window with cmap specified as the colormap
+ * if successful
+ * Add a CmapRec
+ * Create an XcmsCCC
+ * return the CmapRec
+ * else
+ * continue
+ */
+
+ async_state.error_code = 0; /* don't care */
+ async_state.major_opcode = X_CreateWindow;
+ async_state.minor_opcode = 0;
+ for (i = 0; i < nScrn; i++) {
+ visualTemplate.screen = i;
+ visualList = XGetVisualInfo(dpy, VisualScreenMask, &visualTemplate,
+ &nVisualsMatched);
+ if (visualList == NULL) {
+ continue;
+ }
+
+ /*
+ * Attempt to create a window with cmap
+ */
+ j = 0;
+ do {
+ vp = (visualList+j)->visual;
+ LockDisplay(dpy);
+ {
+ register xCreateWindowReq *req;
+
+ GetReq(CreateWindow, req);
+ async_state.min_sequence_number = dpy->request;
+ async_state.max_sequence_number = dpy->request;
+ async_state.error_count = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XAsyncErrorHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ req->parent = RootWindow(dpy, i);
+ req->x = 0;
+ req->y = 0;
+ req->width = 1;
+ req->height = 1;
+ req->borderWidth = 0;
+ req->depth = (visualList+j)->depth;
+ req->class = CopyFromParent;
+ req->visual = vp->visualid;
+ tmpWindow = req->wid = XAllocID(dpy);
+ req->mask = CWBorderPixel | CWColormap;
+ req->length += 2;
+ Data32 (dpy, (long *) &border, 4);
+ Data32 (dpy, (long *) &cmap, 4);
+ }
+ {
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ }
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ } while (async_state.error_count > 0 && ++j < nVisualsMatched);
+
+ Xfree((char *)visualList);
+
+ /*
+ * if successful
+ */
+ if (j < nVisualsMatched) {
+ if ((pRec = _XcmsAddCmapRec(dpy, cmap, tmpWindow, vp)) == NULL)
+ return((XcmsCmapRec *)NULL);
+ pRec->ccc = XcmsCreateCCC(
+ dpy,
+ i, /* screenNumber */
+ vp,
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ );
+ XDestroyWindow(dpy, tmpWindow);
+ return(pRec);
+ }
+ }
+
+ return(NULL);
+}
+
+
+
+/************************************************************************
+ * *
+ * API PRIVATE INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsAddCmapRec
+ *
+ * SYNOPSIS
+ */
+XcmsCmapRec *
+_XcmsAddCmapRec(
+ Display *dpy,
+ Colormap cmap,
+ Window windowID,
+ Visual *visual)
+/*
+ * DESCRIPTION
+ * Create an XcmsCmapRec for the specified cmap, windowID,
+ * and visual, then adds it to its list of CmapRec's.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the added XcmsCmapRec.
+ *
+ */
+{
+ XcmsCmapRec *pNew;
+
+ if ((pNew = (XcmsCmapRec *) Xcalloc(1, (unsigned) sizeof(XcmsCmapRec)))
+ == NULL) {
+ return((XcmsCmapRec *)NULL);
+ }
+
+ pNew->cmapID = cmap;
+ pNew->dpy = dpy;
+ pNew->windowID = windowID;
+ pNew->visual = visual;
+ pNew->pNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
+ dpy->cms.clientCmaps = (XPointer)pNew;
+ dpy->free_funcs->clientCmaps = _XcmsFreeClientCmaps;
+
+ /*
+ * Note, we don't create the XcmsCCC for pNew->ccc here because
+ * it may require the use of XGetWindowAttributes (a round trip request)
+ * to determine the screen.
+ */
+ return(pNew);
+}
+
+
+/*
+ * NAME
+ * _XcmsCopyCmapRecAndFree
+ *
+ * SYNOPSIS
+ */
+XcmsCmapRec *
+_XcmsCopyCmapRecAndFree(
+ Display *dpy,
+ Colormap src_cmap,
+ Colormap copy_cmap)
+/*
+ * DESCRIPTION
+ * Augments Xlib's XCopyColormapAndFree() to copy
+ * XcmsCmapRecs.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the copy XcmsCmapRec.
+ *
+ */
+{
+ XcmsCmapRec *pRec_src;
+ XcmsCmapRec *pRec_copy;
+
+ if ((pRec_src = CmapRecForColormap(dpy, src_cmap)) != NULL) {
+ pRec_copy =_XcmsAddCmapRec(dpy, copy_cmap, pRec_src->windowID,
+ pRec_src->visual);
+ if (pRec_copy != NULL && pRec_src->ccc) {
+ pRec_copy->ccc = (XcmsCCC)Xcalloc(1, (unsigned) sizeof(XcmsCCCRec));
+ memcpy((char *)pRec_copy->ccc, (char *)pRec_src->ccc,
+ sizeof(XcmsCCCRec));
+ }
+ return(pRec_copy);
+ }
+ return((XcmsCmapRec *)NULL);
+}
+
+
+/*
+ * NAME
+ * _XcmsDeleteCmapRec
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsDeleteCmapRec(
+ Display *dpy,
+ Colormap cmap)
+/*
+ * DESCRIPTION
+ * Removes and frees the specified XcmsCmapRec structure
+ * from the linked list of structures.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ XcmsCmapRec **pPrevPtr;
+ XcmsCmapRec *pRec;
+ int scr;
+
+ /* If it is the default cmap for a screen, do not delete it,
+ * because the server will not actually free it */
+ for (scr = ScreenCount(dpy); --scr >= 0; ) {
+ if (cmap == DefaultColormap(dpy, scr))
+ return;
+ }
+
+ /* search for it in the list */
+ pPrevPtr = (XcmsCmapRec **)&dpy->cms.clientCmaps;
+ while ((pRec = *pPrevPtr) && (pRec->cmapID != cmap)) {
+ pPrevPtr = &pRec->pNext;
+ }
+
+ if (pRec) {
+ if (pRec->ccc) {
+ XcmsFreeCCC(pRec->ccc);
+ }
+ *pPrevPtr = pRec->pNext;
+ Xfree((char *)pRec);
+ }
+}
+
+
+/*
+ * NAME
+ * _XcmsFreeClientCmaps
+ *
+ * SYNOPSIS
+ */
+static void
+_XcmsFreeClientCmaps(
+ Display *dpy)
+/*
+ * DESCRIPTION
+ * Frees all XcmsCmapRec structures in the linked list
+ * and sets dpy->cms.clientCmaps to NULL.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ XcmsCmapRec *pRecNext, *pRecFree;
+
+ pRecNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
+ while (pRecNext != NULL) {
+ pRecFree = pRecNext;
+ pRecNext = pRecNext->pNext;
+ if (pRecFree->ccc) {
+ /* Free the XcmsCCC structure */
+ XcmsFreeCCC(pRecFree->ccc);
+ }
+ /* Now free the XcmsCmapRec structure */
+ Xfree((char *)pRecFree);
+ }
+ dpy->cms.clientCmaps = (XPointer)NULL;
+}
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCCCOfColormap
+ *
+ * SYNOPSIS
+ */
+XcmsCCC
+XcmsCCCOfColormap(
+ Display *dpy,
+ Colormap cmap)
+/*
+ * DESCRIPTION
+ * Finds the XcmsCCC associated with the specified colormap.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the associated XcmsCCC structure.
+ *
+ */
+{
+ XWindowAttributes windowAttr;
+ XcmsCmapRec *pRec;
+ int nScrn = ScreenCount(dpy);
+ int i;
+
+ if ((pRec = CmapRecForColormap(dpy, cmap)) != NULL) {
+ if (pRec->ccc) {
+ /* XcmsCmapRec already has a XcmsCCC */
+ return(pRec->ccc);
+ }
+
+ /*
+ * The XcmsCmapRec does not have a XcmsCCC yet, so let's create
+ * one. But first, we need to know the screen associated with
+ * cmap, so use XGetWindowAttributes() to extract that
+ * information. Unless, of course there is only one screen!!
+ */
+ if (nScrn == 1) {
+ /* Assume screenNumber == 0 */
+ return(pRec->ccc = XcmsCreateCCC(
+ dpy,
+ 0, /* screenNumber */
+ pRec->visual,
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ ));
+ } else {
+ if (XGetWindowAttributes(dpy, pRec->windowID, &windowAttr)) {
+ for (i = 0; i < nScrn; i++) {
+ if (ScreenOfDisplay(dpy, i) == windowAttr.screen) {
+ return(pRec->ccc = XcmsCreateCCC(
+ dpy,
+ i, /* screenNumber */
+ pRec->visual,
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ ));
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * No such cmap
+ */
+ return(NULL);
+}
+
+XcmsCCC XcmsSetCCCOfColormap(
+ Display *dpy,
+ Colormap cmap,
+ XcmsCCC ccc)
+{
+ XcmsCCC prev_ccc = NULL;
+ XcmsCmapRec *pRec;
+
+ pRec = CmapRecForColormap(dpy, cmap);
+ if (pRec) {
+ prev_ccc = pRec->ccc;
+ pRec->ccc = ccc;
+ }
+ return prev_ccc;
+}
diff --git a/libX11/src/xcms/cmsInt.c b/libX11/src/xcms/cmsInt.c
index b48036522..47c54a701 100644
--- a/libX11/src/xcms/cmsInt.c
+++ b/libX11/src/xcms/cmsInt.c
@@ -1,413 +1,412 @@
-
-/*
- * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
- * All Rights Reserved
- *
- * This file is a component of an X Window System-specific implementation
- * of Xcms based on the TekColor Color Management System. Permission is
- * hereby granted to use, copy, modify, sell, and otherwise distribute this
- * software and its documentation for any purpose and without fee, provided
- * that this copyright, permission, and disclaimer notice is reproduced in
- * all copies of this software and in supporting documentation. TekColor
- * is a trademark of Tektronix, Inc.
- *
- * Tektronix makes no representation about the suitability of this software
- * for any purpose. It is provided "as is" and with all faults.
- *
- * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
- * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
- *
- *
- * NAME
- * XcmsInt.c - Xcms API utility routines
- *
- * DESCRIPTION
- * Xcms Application Program Interface (API) utility
- * routines for hanging information directly onto
- * the Display structure.
- *
- *
- */
-
-/* #define NEED_EVENTS */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include "Xlibint.h"
-#include "Xcmsint.h"
-#include "Cv.h"
-
-#ifndef XCMSCOMPPROC
-# define XCMSCOMPPROC XcmsTekHVCClipC
-#endif
-
-/* forward/static */
-static void _XcmsFreeDefaultCCCs(Display *dpy);
-
-
-/************************************************************************
- * *
- * API PRIVATE ROUTINES *
- * *
- ************************************************************************/
-
-/*
- * NAME
- * _XcmsCopyPointerArray
- *
- * SYNOPSIS
- */
-XPointer *
-_XcmsCopyPointerArray(
- XPointer *pap)
-/*
- * DESCRIPTION
- * Copies an array of NULL terminated pointers.
- *
- * RETURNS
- * Returns NULL if failed; otherwise the address to
- * the copy.
- *
- */
-{
- XPointer *newArray;
- char **tmp;
- int n;
-
- for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
- n++; /* add 1 to include the NULL pointer */
-
- if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
- memcpy((char *)newArray, (char *)pap,
- (unsigned)(n * sizeof(XPointer)));
- }
- return((XPointer *)newArray);
-}
-
-/*
- * NAME
- * _XcmsFreePointerArray
- *
- * SYNOPSIS
- */
-void
-_XcmsFreePointerArray(
- XPointer *pap)
-/*
- * DESCRIPTION
- * Frees an array of NULL terminated pointers.
- *
- * RETURNS
- * void
- *
- */
-{
- Xfree(pap);
-}
-
-/*
- * NAME
- * _XcmsPushPointerArray
- *
- * SYNOPSIS
- */
-XPointer *
-_XcmsPushPointerArray(
- XPointer *pap,
- XPointer p,
- XPointer *papNoFree)
-/*
- * DESCRIPTION
- * Places the specified pointer at the head of an array of NULL
- * terminated pointers.
- *
- * RETURNS
- * Returns NULL if failed; otherwise the address to
- * the head of the array.
- *
- */
-{
- XPointer *newArray;
- char **tmp;
- int n;
-
- for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
-
- /* add 2: 1 for the new pointer and another for the NULL pointer */
- n += 2;
-
- if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
- memcpy((char *)(newArray+1),(char *)pap,
- (unsigned)((n-1) * sizeof(XPointer)));
- *newArray = p;
- }
- if (pap != papNoFree) {
- _XcmsFreePointerArray(pap);
- }
- return((XPointer *)newArray);
-}
-
-/*
- * NAME
- * _XcmsInitDefaultCCCs
- *
- * SYNOPSIS
- */
-int
-_XcmsInitDefaultCCCs(
- Display *dpy)
-/*
- * DESCRIPTION
- * Initializes the Xcms per Display Info structure
- * (XcmsPerDpyInfo).
- *
- * RETURNS
- * Returns 0 if failed; otherwise non-zero.
- *
- */
-{
- int nScrn = ScreenCount(dpy);
- int i;
- XcmsCCC ccc;
-
- if (nScrn <= 0) {
- return(0);
- }
-
- /*
- * Create an array of XcmsCCC structures, one for each screen.
- * They serve as the screen's default CCC.
- */
- if (!(ccc = (XcmsCCC)
- Xcalloc((unsigned)nScrn, (unsigned) sizeof(XcmsCCCRec)))) {
- return(0);
- }
- dpy->cms.defaultCCCs = (XPointer)ccc;
- dpy->free_funcs->defaultCCCs = _XcmsFreeDefaultCCCs;
-
- for (i = 0; i < nScrn; i++, ccc++) {
- ccc->dpy = dpy;
- ccc->screenNumber = i;
- ccc->visual = DefaultVisual(dpy, i);
- /*
- * Used calloc to allocate memory so:
- * ccc->clientWhitePt->format == XcmsUndefinedFormat
- * ccc->gamutCompProc == NULL
- * ccc->whitePtAdjProc == NULL
- * ccc->pPerScrnInfo = NULL
- *
- * Don't need to create XcmsPerScrnInfo and its functionSet and
- * pScreenData components until the default CCC is accessed.
- * Note that the XcmsDefaultCCC routine calls _XcmsInitScrnInto
- * to do this.
- */
- ccc->gamutCompProc = XCMSCOMPPROC;
- }
-
- return(1);
-}
-
-
-/*
- * NAME
- * _XcmsFreeDefaultCCCs - Free Default CCCs and its PerScrnInfo
- *
- * SYNOPSIS
- */
-static void
-_XcmsFreeDefaultCCCs(
- Display *dpy)
-/*
- * DESCRIPTION
- * This routine frees the default XcmsCCC's associated with
- * each screen and its associated substructures as neccessary.
- *
- * RETURNS
- * void
- *
- *
- */
-{
- int nScrn = ScreenCount(dpy);
- XcmsCCC ccc;
- int i;
-
- /*
- * Free Screen data in each DefaultCCC
- * Do not use XcmsFreeCCC here because it will not free
- * DefaultCCC's.
- */
- ccc = (XcmsCCC)dpy->cms.defaultCCCs;
- for (i = nScrn; i--; ccc++) {
- /*
- * Check if XcmsPerScrnInfo exists.
- *
- * This is the only place where XcmsPerScrnInfo structures
- * are freed since there is only one allocated per Screen.
- * It just so happens that we place its reference in the
- * default CCC.
- */
- if (ccc->pPerScrnInfo) {
- /* Check if SCCData exists */
- if (ccc->pPerScrnInfo->state != XcmsInitNone
- && ccc->pPerScrnInfo->screenData) {
- (*((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->screenFreeProc)
- (ccc->pPerScrnInfo->screenData);
- }
- Xfree(ccc->pPerScrnInfo);
- }
- }
-
- /*
- * Free the array of XcmsCCC structures
- */
- Xfree(dpy->cms.defaultCCCs);
- dpy->cms.defaultCCCs = (XPointer)NULL;
-}
-
-
-
-/*
- * NAME
- * _XcmsInitScrnInfo
- *
- * SYNOPSIS
- */
-int
-_XcmsInitScrnInfo(
- register Display *dpy,
- int screenNumber)
-/*
- * DESCRIPTION
- * Given a display and screen number, this routine attempts
- * to initialize the Xcms per Screen Info structure
- * (XcmsPerScrnInfo).
- *
- * RETURNS
- * Returns zero if initialization failed; non-zero otherwise.
- */
-{
- XcmsFunctionSet **papSCCFuncSet = _XcmsSCCFuncSets;
- XcmsCCC defaultccc;
-
- /*
- * Check if the XcmsCCC's for each screen has been created.
- * Really dont need to be created until some routine uses the Xcms
- * API routines.
- */
- if ((XcmsCCC)dpy->cms.defaultCCCs == NULL) {
- if (!_XcmsInitDefaultCCCs(dpy)) {
- return(0);
- }
- }
-
- defaultccc = (XcmsCCC)dpy->cms.defaultCCCs + screenNumber;
-
- /*
- * For each SCCFuncSet, try its pInitScrnFunc.
- * If the function succeeds, then we got it!
- */
-
- if (!defaultccc->pPerScrnInfo) {
- /*
- * This is one of two places where XcmsPerScrnInfo structures
- * are allocated. There is one allocated per Screen that is
- * shared among visuals that do not have specific intensity
- * tables. Other XcmsPerScrnInfo structures are created
- * for the latter (see XcmsCreateCCC). The ones created
- * here are referenced by the default CCC.
- */
- if (!(defaultccc->pPerScrnInfo = (XcmsPerScrnInfo *)
- Xcalloc(1, (unsigned) sizeof(XcmsPerScrnInfo)))) {
- return(0);
- }
- defaultccc->pPerScrnInfo->state = XcmsInitNone;
- }
-
- while (*papSCCFuncSet != NULL) {
- if ((*(*papSCCFuncSet)->screenInitProc)(dpy, screenNumber,
- defaultccc->pPerScrnInfo)) {
- defaultccc->pPerScrnInfo->state = XcmsInitSuccess;
- return(1);
- }
- papSCCFuncSet++;
- }
-
- /*
- * Use Default SCCData
- */
- return(_XcmsLRGB_InitScrnDefault(dpy, screenNumber, defaultccc->pPerScrnInfo));
-}
-
-
-/*
- * NAME
- * _XcmsFreeIntensityMaps
- *
- * SYNOPSIS
- */
-void
-_XcmsFreeIntensityMaps(
- Display *dpy)
-/*
- * DESCRIPTION
- * Frees all XcmsIntensityMap structures in the linked list
- * and sets dpy->cms.perVisualIntensityMaps to NULL.
- *
- * RETURNS
- * void
- *
- */
-{
- XcmsIntensityMap *pNext, *pFree;
-
- pNext = (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
- while (pNext != NULL) {
- pFree = pNext;
- pNext = pNext->pNext;
- (*pFree->pFreeScreenData)(pFree->screenData);
- /* Now free the XcmsIntensityMap structure */
- Xfree(pFree);
- }
- dpy->cms.perVisualIntensityMaps = (XPointer)NULL;
-}
-
-
-/*
- * NAME
- * _XcmsGetIntensityMap
- *
- * SYNOPSIS
- */
-XcmsIntensityMap *
-_XcmsGetIntensityMap(
- Display *dpy,
- Visual *visual)
-/*
- * DESCRIPTION
- * Attempts to return a per-Visual intensity map.
- *
- * RETURNS
- * Pointer to the XcmsIntensityMap structure if found;
- * otherwise NULL
- *
- */
-{
- VisualID targetID = visual->visualid;
- XcmsIntensityMap *pNext;
-
- pNext = (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
- while (pNext != NULL) {
- if (targetID == pNext->visualID) {
- return(pNext);
- }
- pNext = pNext->pNext;
- }
- return((XcmsIntensityMap *)NULL);
-}
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsInt.c - Xcms API utility routines
+ *
+ * DESCRIPTION
+ * Xcms Application Program Interface (API) utility
+ * routines for hanging information directly onto
+ * the Display structure.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+#ifndef XCMSCOMPPROC
+# define XCMSCOMPPROC XcmsTekHVCClipC
+#endif
+
+/* forward/static */
+static void _XcmsFreeDefaultCCCs(Display *dpy);
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsCopyPointerArray
+ *
+ * SYNOPSIS
+ */
+XPointer *
+_XcmsCopyPointerArray(
+ XPointer *pap)
+/*
+ * DESCRIPTION
+ * Copies an array of NULL terminated pointers.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the copy.
+ *
+ */
+{
+ XPointer *newArray;
+ char **tmp;
+ int n;
+
+ for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
+ n++; /* add 1 to include the NULL pointer */
+
+ if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
+ memcpy((char *)newArray, (char *)pap,
+ (unsigned)(n * sizeof(XPointer)));
+ }
+ return((XPointer *)newArray);
+}
+
+/*
+ * NAME
+ * _XcmsFreePointerArray
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsFreePointerArray(
+ XPointer *pap)
+/*
+ * DESCRIPTION
+ * Frees an array of NULL terminated pointers.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ Xfree(pap);
+}
+
+/*
+ * NAME
+ * _XcmsPushPointerArray
+ *
+ * SYNOPSIS
+ */
+XPointer *
+_XcmsPushPointerArray(
+ XPointer *pap,
+ XPointer p,
+ XPointer *papNoFree)
+/*
+ * DESCRIPTION
+ * Places the specified pointer at the head of an array of NULL
+ * terminated pointers.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the head of the array.
+ *
+ */
+{
+ XPointer *newArray;
+ char **tmp;
+ int n;
+
+ for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
+
+ /* add 2: 1 for the new pointer and another for the NULL pointer */
+ n += 2;
+
+ if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
+ memcpy((char *)(newArray+1),(char *)pap,
+ (unsigned)((n-1) * sizeof(XPointer)));
+ *newArray = p;
+ }
+ if (pap != papNoFree) {
+ _XcmsFreePointerArray(pap);
+ }
+ return((XPointer *)newArray);
+}
+
+/*
+ * NAME
+ * _XcmsInitDefaultCCCs
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsInitDefaultCCCs(
+ Display *dpy)
+/*
+ * DESCRIPTION
+ * Initializes the Xcms per Display Info structure
+ * (XcmsPerDpyInfo).
+ *
+ * RETURNS
+ * Returns 0 if failed; otherwise non-zero.
+ *
+ */
+{
+ int nScrn = ScreenCount(dpy);
+ int i;
+ XcmsCCC ccc;
+
+ if (nScrn <= 0) {
+ return(0);
+ }
+
+ /*
+ * Create an array of XcmsCCC structures, one for each screen.
+ * They serve as the screen's default CCC.
+ */
+ if (!(ccc = (XcmsCCC)
+ Xcalloc((unsigned)nScrn, (unsigned) sizeof(XcmsCCCRec)))) {
+ return(0);
+ }
+ dpy->cms.defaultCCCs = (XPointer)ccc;
+ dpy->free_funcs->defaultCCCs = _XcmsFreeDefaultCCCs;
+
+ for (i = 0; i < nScrn; i++, ccc++) {
+ ccc->dpy = dpy;
+ ccc->screenNumber = i;
+ ccc->visual = DefaultVisual(dpy, i);
+ /*
+ * Used calloc to allocate memory so:
+ * ccc->clientWhitePt->format == XcmsUndefinedFormat
+ * ccc->gamutCompProc == NULL
+ * ccc->whitePtAdjProc == NULL
+ * ccc->pPerScrnInfo = NULL
+ *
+ * Don't need to create XcmsPerScrnInfo and its functionSet and
+ * pScreenData components until the default CCC is accessed.
+ * Note that the XcmsDefaultCCC routine calls _XcmsInitScrnInto
+ * to do this.
+ */
+ ccc->gamutCompProc = XCMSCOMPPROC;
+ }
+
+ return(1);
+}
+
+
+/*
+ * NAME
+ * _XcmsFreeDefaultCCCs - Free Default CCCs and its PerScrnInfo
+ *
+ * SYNOPSIS
+ */
+static void
+_XcmsFreeDefaultCCCs(
+ Display *dpy)
+/*
+ * DESCRIPTION
+ * This routine frees the default XcmsCCC's associated with
+ * each screen and its associated substructures as neccessary.
+ *
+ * RETURNS
+ * void
+ *
+ *
+ */
+{
+ int nScrn = ScreenCount(dpy);
+ XcmsCCC ccc;
+ int i;
+
+ /*
+ * Free Screen data in each DefaultCCC
+ * Do not use XcmsFreeCCC here because it will not free
+ * DefaultCCC's.
+ */
+ ccc = (XcmsCCC)dpy->cms.defaultCCCs;
+ for (i = nScrn; i--; ccc++) {
+ /*
+ * Check if XcmsPerScrnInfo exists.
+ *
+ * This is the only place where XcmsPerScrnInfo structures
+ * are freed since there is only one allocated per Screen.
+ * It just so happens that we place its reference in the
+ * default CCC.
+ */
+ if (ccc->pPerScrnInfo) {
+ /* Check if SCCData exists */
+ if (ccc->pPerScrnInfo->state != XcmsInitNone
+ && ccc->pPerScrnInfo->screenData) {
+ (*((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->screenFreeProc)
+ (ccc->pPerScrnInfo->screenData);
+ }
+ Xfree(ccc->pPerScrnInfo);
+ }
+ }
+
+ /*
+ * Free the array of XcmsCCC structures
+ */
+ Xfree(dpy->cms.defaultCCCs);
+ dpy->cms.defaultCCCs = (XPointer)NULL;
+}
+
+
+
+/*
+ * NAME
+ * _XcmsInitScrnInfo
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsInitScrnInfo(
+ register Display *dpy,
+ int screenNumber)
+/*
+ * DESCRIPTION
+ * Given a display and screen number, this routine attempts
+ * to initialize the Xcms per Screen Info structure
+ * (XcmsPerScrnInfo).
+ *
+ * RETURNS
+ * Returns zero if initialization failed; non-zero otherwise.
+ */
+{
+ XcmsFunctionSet **papSCCFuncSet = _XcmsSCCFuncSets;
+ XcmsCCC defaultccc;
+
+ /*
+ * Check if the XcmsCCC's for each screen has been created.
+ * Really dont need to be created until some routine uses the Xcms
+ * API routines.
+ */
+ if ((XcmsCCC)dpy->cms.defaultCCCs == NULL) {
+ if (!_XcmsInitDefaultCCCs(dpy)) {
+ return(0);
+ }
+ }
+
+ defaultccc = (XcmsCCC)dpy->cms.defaultCCCs + screenNumber;
+
+ /*
+ * For each SCCFuncSet, try its pInitScrnFunc.
+ * If the function succeeds, then we got it!
+ */
+
+ if (!defaultccc->pPerScrnInfo) {
+ /*
+ * This is one of two places where XcmsPerScrnInfo structures
+ * are allocated. There is one allocated per Screen that is
+ * shared among visuals that do not have specific intensity
+ * tables. Other XcmsPerScrnInfo structures are created
+ * for the latter (see XcmsCreateCCC). The ones created
+ * here are referenced by the default CCC.
+ */
+ if (!(defaultccc->pPerScrnInfo = (XcmsPerScrnInfo *)
+ Xcalloc(1, (unsigned) sizeof(XcmsPerScrnInfo)))) {
+ return(0);
+ }
+ defaultccc->pPerScrnInfo->state = XcmsInitNone;
+ }
+
+ while (*papSCCFuncSet != NULL) {
+ if ((*(*papSCCFuncSet)->screenInitProc)(dpy, screenNumber,
+ defaultccc->pPerScrnInfo)) {
+ defaultccc->pPerScrnInfo->state = XcmsInitSuccess;
+ return(1);
+ }
+ papSCCFuncSet++;
+ }
+
+ /*
+ * Use Default SCCData
+ */
+ return(_XcmsLRGB_InitScrnDefault(dpy, screenNumber, defaultccc->pPerScrnInfo));
+}
+
+
+/*
+ * NAME
+ * _XcmsFreeIntensityMaps
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsFreeIntensityMaps(
+ Display *dpy)
+/*
+ * DESCRIPTION
+ * Frees all XcmsIntensityMap structures in the linked list
+ * and sets dpy->cms.perVisualIntensityMaps to NULL.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ XcmsIntensityMap *pNext, *pFree;
+
+ pNext = (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
+ while (pNext != NULL) {
+ pFree = pNext;
+ pNext = pNext->pNext;
+ (*pFree->pFreeScreenData)(pFree->screenData);
+ /* Now free the XcmsIntensityMap structure */
+ Xfree(pFree);
+ }
+ dpy->cms.perVisualIntensityMaps = (XPointer)NULL;
+}
+
+
+/*
+ * NAME
+ * _XcmsGetIntensityMap
+ *
+ * SYNOPSIS
+ */
+XcmsIntensityMap *
+_XcmsGetIntensityMap(
+ Display *dpy,
+ Visual *visual)
+/*
+ * DESCRIPTION
+ * Attempts to return a per-Visual intensity map.
+ *
+ * RETURNS
+ * Pointer to the XcmsIntensityMap structure if found;
+ * otherwise NULL
+ *
+ */
+{
+ VisualID targetID = visual->visualid;
+ XcmsIntensityMap *pNext;
+
+ pNext = (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
+ while (pNext != NULL) {
+ if (targetID == pNext->visualID) {
+ return(pNext);
+ }
+ pNext = pNext->pNext;
+ }
+ return((XcmsIntensityMap *)NULL);
+}
diff --git a/libX11/src/xcms/cmsLkCol.c b/libX11/src/xcms/cmsLkCol.c
index 776fffd75..02e48462e 100644
--- a/libX11/src/xcms/cmsLkCol.c
+++ b/libX11/src/xcms/cmsLkCol.c
@@ -1,194 +1,193 @@
-
-/*
- * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
- * All Rights Reserved
- *
- * This file is a component of an X Window System-specific implementation
- * of Xcms based on the TekColor Color Management System. Permission is
- * hereby granted to use, copy, modify, sell, and otherwise distribute this
- * software and its documentation for any purpose and without fee, provided
- * that this copyright, permission, and disclaimer notice is reproduced in
- * all copies of this software and in supporting documentation. TekColor
- * is a trademark of Tektronix, Inc.
- *
- * Tektronix makes no representation about the suitability of this software
- * for any purpose. It is provided "as is" and with all faults.
- *
- * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
- * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
- *
- *
- * NAME
- * XcmsLkCol.c
- *
- * DESCRIPTION
- * Source for XcmsLookupColor
- *
- *
- */
-
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include "Xlibint.h"
-#include "Xcmsint.h"
-#include "Cv.h"
-
-
-/*
- * NAME
- * XcmsLookupColor -
- *
- * SYNOPSIS
- */
-Status
-XcmsLookupColor (
- Display *dpy,
- Colormap cmap,
- _Xconst char *colorname,
- XcmsColor *pColor_exact_return,
- XcmsColor *pColor_scrn_return,
- XcmsColorFormat result_format)
-/*
- * DESCRIPTION
- * The XcmsLookupColor function finds the color specification
- * associated with a color name in the Device-Independent Color
- * Name Database.
- * RETURNS
- * This function returns both the color specification found in the
- * database (db specification) and the color specification for the
- * color displayable by the specified screen (screen
- * specification). The calling routine sets the format for these
- * returned specifications in the XcmsColor format component.
- * If XcmsUndefinedFormat, the specification is returned in the
- * format used to store the color in the database.
- */
-{
- Status retval1 = XcmsSuccess;
- Status retval2 = XcmsSuccess;
- XcmsCCC ccc;
- register int n;
- xLookupColorReply reply;
- register xLookupColorReq *req;
- XColor def, scr;
-
-/*
- * 0. Check for invalid arguments.
- */
- if (dpy == NULL || colorname[0] == '\0' || pColor_scrn_return == 0
- || pColor_exact_return == NULL) {
- return(XcmsFailure);
- }
-
- if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
- return(XcmsFailure);
- }
-
-/*
- * 1. Convert string to a XcmsColor
- */
- if ((retval1 = _XcmsResolveColorString(ccc, &colorname,
- pColor_exact_return, result_format)) == XcmsFailure) {
- return(XcmsFailure);
- }
- if (retval1 == _XCMS_NEWNAME) {
- goto PassToServer;
- }
-
-/*
- * 2. pColor_scrn_return
- * Assume the pColor_exact_return has already been adjusted to
- * the Client White Point.
- *
- */
- /*
- * Convert to RGB, adjusting for white point differences if necessary.
- */
- memcpy((char *)pColor_scrn_return, (char *)pColor_exact_return,
- sizeof(XcmsColor));
- if (pColor_scrn_return->format == XcmsRGBFormat) {
- retval2 = XcmsSuccess;
- } else if ((retval2 = XcmsConvertColors(ccc, pColor_scrn_return, 1,
- XcmsRGBFormat, (Bool *)NULL)) == XcmsFailure) {
- return(XcmsFailure);
- }
-
- /*
- * Then, convert XcmsColor structure to the target specification
- * format. Note that we must use NULL instead of passing
- * pCompressed.
- */
-
- if (result_format == XcmsUndefinedFormat) {
- result_format = pColor_exact_return->format;
- }
- if (result_format == XcmsRGBFormat) {
- _XcmsUnresolveColor(ccc, pColor_scrn_return);
- } else {
- _XcmsResolveColor(ccc, pColor_scrn_return);
- if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
- (Bool *) NULL) == XcmsFailure) {
- return(XcmsFailure);
- }
- }
-
- return(retval1 > retval2 ? retval1 : retval2);
-
-PassToServer:
- /*
- * Xcms and i18n methods failed, so lets pass it to the server
- * for parsing.
- */
-
- LockDisplay(dpy);
- GetReq (LookupColor, req);
- req->cmap = cmap;
- req->nbytes = n = strlen(colorname);
- req->length += (n + 3) >> 2;
- Data (dpy, colorname, (long)n);
- if (!_XReply (dpy, (xReply *) &reply, 0, xTrue)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return (XcmsFailure);
- }
- def.red = reply.exactRed;
- def.green = reply.exactGreen;
- def.blue = reply.exactBlue;
-
- scr.red = reply.screenRed;
- scr.green = reply.screenGreen;
- scr.blue = reply.screenBlue;
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- _XColor_to_XcmsRGB(ccc, &def, pColor_exact_return, 1);
- _XColor_to_XcmsRGB(ccc, &scr, pColor_scrn_return, 1);
-
- /*
- * Then, convert XcmsColor structure to the target specification
- * format. Note that we must use NULL instead of passing
- * pCompressed.
- */
-
- if (result_format != XcmsRGBFormat
- && result_format != XcmsUndefinedFormat) {
- if (XcmsConvertColors(ccc, pColor_exact_return, 1, result_format,
- (Bool *) NULL) == XcmsFailure) {
- return(XcmsFailure);
- }
- if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
- (Bool *) NULL) == XcmsFailure) {
- return(XcmsFailure);
- }
- }
-
- return(XcmsSuccess);
-}
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsLkCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsLookupColor
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Cv.h"
+
+
+/*
+ * NAME
+ * XcmsLookupColor -
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsLookupColor (
+ Display *dpy,
+ Colormap cmap,
+ _Xconst char *colorname,
+ XcmsColor *pColor_exact_return,
+ XcmsColor *pColor_scrn_return,
+ XcmsColorFormat result_format)
+/*
+ * DESCRIPTION
+ * The XcmsLookupColor function finds the color specification
+ * associated with a color name in the Device-Independent Color
+ * Name Database.
+ * RETURNS
+ * This function returns both the color specification found in the
+ * database (db specification) and the color specification for the
+ * color displayable by the specified screen (screen
+ * specification). The calling routine sets the format for these
+ * returned specifications in the XcmsColor format component.
+ * If XcmsUndefinedFormat, the specification is returned in the
+ * format used to store the color in the database.
+ */
+{
+ Status retval1 = XcmsSuccess;
+ Status retval2 = XcmsSuccess;
+ XcmsCCC ccc;
+ register int n;
+ xLookupColorReply reply;
+ register xLookupColorReq *req;
+ XColor def, scr;
+
+/*
+ * 0. Check for invalid arguments.
+ */
+ if (dpy == NULL || colorname[0] == '\0' || pColor_scrn_return == 0
+ || pColor_exact_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
+ return(XcmsFailure);
+ }
+
+/*
+ * 1. Convert string to a XcmsColor
+ */
+ if ((retval1 = _XcmsResolveColorString(ccc, &colorname,
+ pColor_exact_return, result_format)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (retval1 == _XCMS_NEWNAME) {
+ goto PassToServer;
+ }
+
+/*
+ * 2. pColor_scrn_return
+ * Assume the pColor_exact_return has already been adjusted to
+ * the Client White Point.
+ *
+ */
+ /*
+ * Convert to RGB, adjusting for white point differences if necessary.
+ */
+ memcpy((char *)pColor_scrn_return, (char *)pColor_exact_return,
+ sizeof(XcmsColor));
+ if (pColor_scrn_return->format == XcmsRGBFormat) {
+ retval2 = XcmsSuccess;
+ } else if ((retval2 = XcmsConvertColors(ccc, pColor_scrn_return, 1,
+ XcmsRGBFormat, (Bool *)NULL)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Then, convert XcmsColor structure to the target specification
+ * format. Note that we must use NULL instead of passing
+ * pCompressed.
+ */
+
+ if (result_format == XcmsUndefinedFormat) {
+ result_format = pColor_exact_return->format;
+ }
+ if (result_format == XcmsRGBFormat) {
+ _XcmsUnresolveColor(ccc, pColor_scrn_return);
+ } else {
+ _XcmsResolveColor(ccc, pColor_scrn_return);
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(retval1 > retval2 ? retval1 : retval2);
+
+PassToServer:
+ /*
+ * Xcms and i18n methods failed, so lets pass it to the server
+ * for parsing.
+ */
+
+ LockDisplay(dpy);
+ GetReq (LookupColor, req);
+ req->cmap = cmap;
+ req->nbytes = n = strlen(colorname);
+ req->length += (n + 3) >> 2;
+ Data (dpy, colorname, (long)n);
+ if (!_XReply (dpy, (xReply *) &reply, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XcmsFailure);
+ }
+ def.red = reply.exactRed;
+ def.green = reply.exactGreen;
+ def.blue = reply.exactBlue;
+
+ scr.red = reply.screenRed;
+ scr.green = reply.screenGreen;
+ scr.blue = reply.screenBlue;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ _XColor_to_XcmsRGB(ccc, &def, pColor_exact_return, 1);
+ _XColor_to_XcmsRGB(ccc, &scr, pColor_scrn_return, 1);
+
+ /*
+ * Then, convert XcmsColor structure to the target specification
+ * format. Note that we must use NULL instead of passing
+ * pCompressed.
+ */
+
+ if (result_format != XcmsRGBFormat
+ && result_format != XcmsUndefinedFormat) {
+ if (XcmsConvertColors(ccc, pColor_exact_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(XcmsSuccess);
+}