824N/A/*
824N/A * XDPSshare.c
824N/A *
824N/A * (c) Copyright 1990-1994 Adobe Systems Incorporated.
824N/A * All rights reserved.
824N/A *
824N/A * Permission to use, copy, modify, distribute, and sublicense this software
824N/A * and its documentation for any purpose and without fee is hereby granted,
824N/A * provided that the above copyright notices appear in all copies and that
824N/A * both those copyright notices and this permission notice appear in
824N/A * supporting documentation and that the name of Adobe Systems Incorporated
824N/A * not be used in advertising or publicity pertaining to distribution of the
824N/A * software without specific, written prior permission. No trademark license
824N/A * to use the Adobe trademarks is hereby granted. If the Adobe trademark
824N/A * "Display PostScript"(tm) is used to describe this software, its
824N/A * functionality or for any other purpose, such use shall be limited to a
824N/A * statement that this software works in conjunction with the Display
824N/A * PostScript system. Proper trademark attribution to reflect Adobe's
824N/A * ownership of the trademark shall be given whenever any such reference to
824N/A * the Display PostScript system is made.
824N/A *
824N/A * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
824N/A * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
824N/A * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
824N/A * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
824N/A * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
824N/A * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
824N/A * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
824N/A * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
824N/A * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
824N/A * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
824N/A *
824N/A * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
824N/A * Incorporated which may be registered in certain jurisdictions
824N/A *
824N/A * Author: Adobe Systems Incorporated
824N/A */
824N/A/* $XFree86: xc/lib/dpstk/XDPSshare.c,v 1.2 2000/06/07 22:03:01 tsi Exp $ */
824N/A
824N/A#include <stdio.h>
824N/A#include <stdlib.h>
824N/A
824N/A#include <X11/Xlib.h>
824N/A
824N/A#include <DPS/dpsXclient.h>
824N/A#include <DPS/dpsops.h>
824N/A#include <DPS/XDPSlib.h>
824N/A#include <DPS/dpsXshare.h>
824N/A
824N/A#include "XDPSswraps.h"
824N/A#include "dpsXcommonI.h"
824N/A
824N/Astatic int extensionId = 0;
824N/A
824N/A/*
824N/A Alloc...Info allocates an info entry and stores it at the head of the list.
824N/A Find...Info looks for an info entry and returns NULL if not found.
824N/A Lookup...Info looks for an info entry and creates one if not found.
824N/A*/
824N/A
824N/Atypedef struct _ContextInfoRec {
824N/A int extensionId;
824N/A DPSContextExtensionRec next;
824N/A DPSContext text;
824N/A Bool enableText;
824N/A unsigned long initFlags;
824N/A struct _DisplayInfoRec *displayInfo;
824N/A} ContextInfoRec, *ContextInfo;
824N/A
824N/Atypedef enum {ext_yes, ext_no, ext_no_idea} ExtensionStatus;
824N/A
824N/Atypedef struct _DisplayInfoRec {
824N/A Display *display;
824N/A ExtensionStatus extensionPresent;
824N/A DPSContext defaultContext;
824N/A int *depthsForScreen;
824N/A int **validDepths;
824N/A GC **gcForDepth;
824N/A struct _DisplayInfoRec *next;
824N/A} DisplayInfoRec, *DisplayInfo;
824N/A
824N/A/* If a display is in displayList, it means that we have looked to see if
824N/A the extension exists on the display. If context is not NULL, the
824N/A display has a default context associated with it. */
824N/A
824N/Astatic DisplayInfo displayList = NULL;
824N/A
824N/Astatic DisplayInfo LookupDisplayInfo(Display *display);
824N/A
824N/Astatic ContextInfo AllocContextInfo(DPSContext context)
824N/A{
824N/A ContextInfo c = (ContextInfo) calloc(1, sizeof(ContextInfoRec));
824N/A
824N/A if (extensionId == 0) extensionId = DPSGenerateExtensionRecID();
824N/A
824N/A c->extensionId = extensionId;
824N/A DPSAddContextExtensionRec(context, (DPSContextExtensionRec *) c);
824N/A
824N/A return c;
824N/A}
824N/A
824N/Astatic ContextInfo FindContextInfo(DPSContext context)
824N/A{
824N/A if (extensionId == 0) extensionId = DPSGenerateExtensionRecID();
824N/A
824N/A return (ContextInfo) DPSGetContextExtensionRec(context, extensionId);
824N/A}
824N/A
824N/Astatic ContextInfo RemoveContextInfo(DPSContext context)
824N/A{
824N/A return (ContextInfo) DPSRemoveContextExtensionRec(context,
824N/A extensionId);
824N/A}
824N/A
824N/A/* May only be called for a display in the display list. */
824N/A
824N/Astatic ContextInfo LookupContext(
824N/A Display *display,
824N/A DPSContext context)
824N/A{
824N/A ContextInfo c = FindContextInfo(context);
824N/A
824N/A if (c != NULL) return c;
824N/A
824N/A /* Create one */
824N/A
824N/A c = AllocContextInfo(context);
824N/A c->displayInfo = LookupDisplayInfo(display);
824N/A return c;
824N/A}
824N/A
824N/Astatic DisplayInfo AllocDisplayInfo(
824N/A Display *display,
824N/A DPSContext context)
824N/A{
824N/A DisplayInfo d = (DisplayInfo) malloc(sizeof(DisplayInfoRec));
824N/A register int i;
824N/A
824N/A if (d == NULL) return NULL;
824N/A d->next = displayList;
824N/A displayList = d;
824N/A
824N/A d->display = display;
824N/A d->defaultContext = context;
824N/A d->extensionPresent = (context == NULL) ? ext_no_idea : ext_yes;
824N/A
824N/A d->depthsForScreen = (int *) calloc(ScreenCount(display), sizeof(int));
824N/A d->validDepths = (int **) calloc(ScreenCount(display), sizeof(int *));
824N/A d->gcForDepth = (GC **) calloc(ScreenCount(display), sizeof(GC *));
824N/A
824N/A for (i = 0; i < ScreenCount(display); i++) {
824N/A d->validDepths[i] = XListDepths(display, i, &d->depthsForScreen[i]);
824N/A d->gcForDepth[i] = (GC *) calloc(d->depthsForScreen[i], sizeof(GC));
824N/A }
824N/A
824N/A return d;
824N/A}
824N/A
824N/Astatic DisplayInfo FindDisplayInfo(Display *display)
824N/A{
824N/A DisplayInfo d = displayList;
824N/A
824N/A while (d != NULL && d->display != display) d = d->next;
824N/A return d;
824N/A}
824N/A
824N/Astatic DisplayInfo LookupDisplayInfo(Display *display)
824N/A{
824N/A DisplayInfo d = FindDisplayInfo(display);
824N/A
824N/A if (d == NULL) d = AllocDisplayInfo(display, (DPSContext) NULL);
824N/A
824N/A return d;
824N/A}
824N/A
824N/Aint _XDPSSetComponentInitialized(DPSContext context, unsigned long bit)
824N/A{
824N/A ContextInfo c = FindContextInfo(context);
824N/A
824N/A if (c == NULL) return dps_status_unregistered_context;
824N/A c->initFlags |= bit;
824N/A return dps_status_success;
824N/A}
824N/A
824N/Aint _XDPSTestComponentInitialized(
824N/A DPSContext context,
824N/A unsigned long bit,
824N/A Bool *result)
824N/A{
824N/A ContextInfo c = FindContextInfo(context);
824N/A
824N/A if (c == NULL) {
824N/A *result = False;
824N/A return dps_status_unregistered_context;
824N/A }
824N/A *result = ((c->initFlags & bit) != 0);
824N/A return dps_status_success;
824N/A}
824N/A
824N/Aint XDPSSetContextDepth(
824N/A DPSContext context,
824N/A Screen *screen,
824N/A int depth)
824N/A{
824N/A return XDPSSetContextParameters(context, screen, depth, None, 0,
824N/A (XDPSStandardColormap *) NULL,
824N/A (XDPSStandardColormap *) NULL,
824N/A XDPSContextScreenDepth);
824N/A}
824N/A
824N/Aint XDPSSetContextDrawable(
824N/A DPSContext context,
824N/A Drawable drawable,
824N/A int height)
824N/A{
824N/A if (drawable != None && height <= 0) return dps_status_illegal_value;
824N/A _DPSSSetContextDrawable(context, drawable, height);
824N/A return dps_status_success;
824N/A}
824N/A
824N/Aint XDPSSetContextRGBMap(
824N/A DPSContext context,
824N/A XDPSStandardColormap *map)
824N/A{
824N/A return XDPSSetContextParameters(context, (Screen *) NULL, 0, None, 0,
824N/A map, (XDPSStandardColormap *) NULL,
824N/A XDPSContextRGBMap);
824N/A}
824N/A
824N/Aint XDPSSetContextGrayMap(
824N/A DPSContext context,
824N/A XDPSStandardColormap *map)
824N/A{
824N/A return XDPSSetContextParameters(context, (Screen *) NULL, 0, None, 0,
824N/A map, (XDPSStandardColormap *) NULL,
824N/A XDPSContextGrayMap);
824N/A}
824N/A
824N/Astatic GC DisplayInfoSharedGC(DisplayInfo d, Screen *screen, int depth)
824N/A{
824N/A int s = XScreenNumberOfScreen(screen);
824N/A register int i;
824N/A XGCValues v;
824N/A Pixmap p;
824N/A
824N/A if (s >= ScreenCount(DisplayOfScreen(screen))) return NULL;
824N/A
824N/A for (i = 0; i < d->depthsForScreen[s] &&
824N/A d->validDepths[s][i] != depth; i++) {}
824N/A
824N/A if (i >= d->depthsForScreen[s]) return NULL;
824N/A
824N/A if (d->gcForDepth[s][i] == 0) { /* Not "None" -- used calloc */
824N/A if (depth == DefaultDepthOfScreen(screen)) {
824N/A d->gcForDepth[s][i] = XCreateGC(d->display,
824N/A RootWindowOfScreen(screen), 0, &v);
824N/A } else {
824N/A p = XCreatePixmap(d->display,
824N/A RootWindowOfScreen(screen),
824N/A 1, 1, depth);
824N/A d->gcForDepth[s][i] = XCreateGC(d->display, p, 0, &v);
824N/A XFreePixmap(d->display, p);
824N/A }
824N/A }
824N/A
824N/A return d->gcForDepth[s][i];
824N/A}
824N/A
824N/Aint XDPSSetContextParameters(
824N/A DPSContext context,
824N/A Screen *screen,
824N/A int depth,
824N/A Drawable drawable,
824N/A int height,
824N/A XDPSStandardColormap *rgbMap,
824N/A XDPSStandardColormap *grayMap,
824N/A unsigned int flags)
824N/A{
824N/A ContextInfo c = FindContextInfo(context);
824N/A Bool doDepth = False, doDrawable = False, doRGB = False, doGray = False;
824N/A Colormap map = None;
824N/A XStandardColormap cmap;
824N/A GC gc;
824N/A GContext gctx = None;
824N/A DisplayInfo d;
824N/A Display *dpy;
824N/A int rgb_base_pixel = 0;
824N/A int red_max = 0;
824N/A int red_mult = 0;
824N/A int green_max = 0;
824N/A int green_mult = 0;
824N/A int blue_max = 0;
824N/A int blue_mult = 0;
824N/A int gray_base_pixel = 0;
824N/A int gray_max = 0;
824N/A int gray_mult = 0;
824N/A
824N/A if (c == NULL) return dps_status_unregistered_context;
824N/A d = c->displayInfo;
824N/A
824N/A (void) XDPSXIDFromContext(&dpy, context);
824N/A
824N/A if (flags & XDPSContextScreenDepth) {
824N/A doDepth = True;
824N/A
824N/A if (DisplayOfScreen(screen) != dpy) {
824N/A return dps_status_illegal_value;
824N/A }
824N/A
824N/A gc = DisplayInfoSharedGC(d, screen, depth);
824N/A if (gc == NULL) return dps_status_illegal_value;
824N/A
824N/A gctx = XGContextFromGC(gc);
824N/A }
824N/A
824N/A if (flags & XDPSContextDrawable) {
824N/A doDrawable = True;
824N/A if (drawable != None && height <= 0) return dps_status_illegal_value;
824N/A }
824N/A
824N/A if (flags & XDPSContextRGBMap) {
824N/A doRGB = True;
824N/A if (rgbMap == NULL) {
824N/A XDPSGetDefaultColorMaps(dpy, screen, drawable, &cmap,
824N/A (XStandardColormap *) NULL);
824N/A rgb_base_pixel = cmap.base_pixel;
824N/A red_max = cmap.red_max;
824N/A red_mult = cmap.red_mult;
824N/A green_max = cmap.green_max;
824N/A green_mult = cmap.green_mult;
824N/A blue_max = cmap.blue_max;
824N/A blue_mult = cmap.blue_mult;
824N/A map = cmap.colormap;
824N/A } else {
824N/A rgb_base_pixel = rgbMap->base_pixel;
824N/A red_max = rgbMap->red_max;
824N/A red_mult = rgbMap->red_mult;
824N/A green_max = rgbMap->green_max;
824N/A green_mult = rgbMap->green_mult;
824N/A blue_max = rgbMap->blue_max;
824N/A blue_mult = rgbMap->blue_mult;
824N/A map = rgbMap->colormap;
824N/A }
824N/A }
824N/A
824N/A if (flags & XDPSContextGrayMap) {
824N/A doGray = True;
824N/A if (grayMap == NULL) {
824N/A XDPSGetDefaultColorMaps(dpy, screen, drawable,
824N/A (XStandardColormap *) NULL, &cmap);
824N/A gray_base_pixel = cmap.base_pixel;
824N/A gray_max = cmap.red_max;
824N/A gray_mult = cmap.red_mult;
824N/A if (doRGB && map != cmap.colormap) {
824N/A return dps_status_illegal_value;
824N/A } else map = cmap.colormap;
824N/A } else {
824N/A gray_base_pixel = grayMap->base_pixel;
824N/A gray_max = grayMap->red_max;
824N/A gray_mult = grayMap->red_mult;
824N/A if (doRGB && map != grayMap->colormap) {
824N/A return dps_status_illegal_value;
824N/A } else map = grayMap->colormap;
824N/A }
824N/A }
824N/A
824N/A if (doDepth || doDrawable || doRGB || doGray) {
824N/A _DPSSSetContextParameters(context, gctx, drawable, height, map,
824N/A rgb_base_pixel, red_max, red_mult,
824N/A green_max, green_mult, blue_max, blue_mult,
824N/A gray_base_pixel, gray_max, gray_mult,
824N/A doDepth, doDrawable, doRGB, doGray);
824N/A }
824N/A return dps_status_success;
824N/A}
824N/A
824N/Aint XDPSPushContextParameters(
824N/A DPSContext context,
824N/A Screen *screen,
824N/A int depth,
824N/A Drawable drawable,
824N/A int height,
824N/A XDPSStandardColormap *rgbMap,
824N/A XDPSStandardColormap *grayMap,
824N/A unsigned int flags,
824N/A DPSPointer *pushCookieReturn)
824N/A{
824N/A ContextInfo c = FindContextInfo(context);
824N/A int status;
824N/A
824N/A if (c == NULL) return dps_status_unregistered_context;
824N/A
824N/A DPSgsave(context);
824N/A
824N/A status = XDPSSetContextParameters(context, screen, depth, drawable, height,
824N/A rgbMap, grayMap, flags);
824N/A
824N/A *pushCookieReturn = (DPSPointer) context;
824N/A return status;
824N/A}
824N/A
824N/Aint XDPSPopContextParameters(DPSPointer pushCookie)
824N/A{
824N/A DPSContext context = (DPSContext) pushCookie;
824N/A ContextInfo c = FindContextInfo(context);
824N/A
824N/A if (c == NULL) return dps_status_illegal_value;
824N/A
824N/A DPSgrestore(context);
824N/A
824N/A return dps_status_success;
824N/A}
824N/A
824N/Aint XDPSCaptureContextGState(DPSContext context, DPSGState *gsReturn)
824N/A{
824N/A *gsReturn = DPSNewUserObjectIndex();
824N/A /* We want to keep 0 as an unassigned value */
824N/A if (*gsReturn == 0) *gsReturn = DPSNewUserObjectIndex();
824N/A
824N/A _DPSSCaptureGState(context, *gsReturn);
824N/A
824N/A return dps_status_success;
824N/A}
824N/A
824N/Aint XDPSUpdateContextGState(DPSContext context, DPSGState gs)
824N/A{
824N/A _DPSSUpdateGState(context, gs);
824N/A
824N/A return dps_status_success;
824N/A}
824N/A
824N/Aint XDPSFreeContextGState(DPSContext context, DPSGState gs)
824N/A{
824N/A _DPSSUndefineUserObject(context, gs);
824N/A
824N/A return dps_status_success;
824N/A}
824N/A
824N/Aint XDPSSetContextGState(
824N/A DPSContext context,
824N/A DPSGState gs)
824N/A{
824N/A _DPSSRestoreGState(context, gs);
824N/A
824N/A return dps_status_success;
824N/A}
824N/A
824N/Aint XDPSPushContextGState(
824N/A DPSContext context,
824N/A DPSGState gs,
824N/A DPSPointer *pushCookieReturn)
824N/A{
824N/A int status;
824N/A
824N/A DPSgsave(context);
824N/A
824N/A status = XDPSSetContextGState(context, gs);
824N/A *pushCookieReturn = (DPSPointer) context;
824N/A return status;
824N/A}
824N/A
824N/Aint XDPSPopContextGState(DPSPointer pushCookie)
824N/A{
824N/A DPSContext context = (DPSContext) pushCookie;
824N/A
824N/A DPSgrestore(context);
824N/A return dps_status_success;
824N/A}
824N/A
824N/Avoid XDPSRegisterContext(DPSContext context, Bool makeSharedContext)
824N/A{
824N/A Display *display;
824N/A Bool inited;
824N/A ContextInfo c;
824N/A
824N/A /* Get the display */
824N/A (void) XDPSXIDFromContext(&display, context);
824N/A
824N/A if (makeSharedContext) { /* Install as shared ctxt for this display */
824N/A c = LookupContext(display, context);
824N/A c->displayInfo->defaultContext = context;
824N/A } else { /* Just add to the context list */
824N/A c = LookupContext(display, context);
824N/A }
824N/A
824N/A c->displayInfo->extensionPresent = ext_yes;
824N/A
824N/A (void) _XDPSTestComponentInitialized(context, dps_init_bit_share, &inited);
824N/A if (!inited) {
824N/A (void) _XDPSSetComponentInitialized(context, dps_init_bit_share);
824N/A _DPSSInstallDPSlibDict(context);
824N/A }
824N/A}
824N/A
824N/ADPSContext XDPSGetSharedContext(Display *display)
824N/A{
824N/A DisplayInfo d = LookupDisplayInfo(display);
824N/A ContextInfo c;
824N/A DPSContext context;
824N/A
824N/A if (d->extensionPresent == ext_no) return NULL;
824N/A
824N/A if (d->defaultContext != NULL) context = d->defaultContext;
824N/A else {
824N/A context = XDPSCreateSimpleContext(display,
824N/A None, None, 0, 0,
824N/A DPSDefaultTextBackstop,
824N/A DPSDefaultErrorProc, NULL);
824N/A if (context != NULL) {
824N/A c = AllocContextInfo(context);
824N/A d->defaultContext = context;
824N/A c->displayInfo = d;
824N/A (void) _XDPSSetComponentInitialized(context, dps_init_bit_share);
824N/A _DPSSInstallDPSlibDict(context);
824N/A (void) XDPSSetContextDepth(context,
824N/A DefaultScreenOfDisplay(display),
824N/A DefaultDepth(display,
824N/A DefaultScreen(display)));
824N/A }
824N/A }
824N/A
824N/A if (context == NULL) d->extensionPresent = ext_no;
824N/A else d->extensionPresent = ext_yes;
824N/A
824N/A return context;
824N/A}
824N/A
824N/Avoid XDPSDestroySharedContext(DPSContext context)
824N/A{
824N/A ContextInfo c = RemoveContextInfo(context);
824N/A
824N/A if (c == NULL) return;
824N/A
824N/A if (c->displayInfo->defaultContext == context) {
824N/A c->displayInfo->defaultContext = NULL;
824N/A }
824N/A DPSDestroySpace(DPSSpaceFromContext(context)); /* Also gets context */
824N/A if (c->text != NULL) DPSDestroySpace(DPSSpaceFromContext(c->text));
824N/A free((char *) c);
824N/A}
824N/A
824N/Avoid XDPSUnregisterContext(DPSContext context)
824N/A{
824N/A ContextInfo c = RemoveContextInfo(context);
824N/A
824N/A if (c == NULL) return;
824N/A
824N/A if (c->displayInfo->defaultContext == context) {
824N/A c->displayInfo->defaultContext = NULL;
824N/A }
824N/A if (c->text != NULL) DPSDestroySpace(DPSSpaceFromContext(c->text));
824N/A free((char *) c);
824N/A}
824N/A
824N/Avoid XDPSFreeDisplayInfo(Display *display)
824N/A{
824N/A DisplayInfo *dp = &displayList;
824N/A DisplayInfo d;
824N/A register int i, j;
824N/A
824N/A while (*dp != NULL && (*dp)->display != display) dp = &((*dp)->next);
824N/A
824N/A if (*dp == NULL) return;
824N/A
824N/A d = *dp;
824N/A *dp = d->next; /* remove from list */
824N/A
824N/A for (i = 0; i < ScreenCount(display); i++) {
824N/A#ifdef NO_XLISTDEPTHS
824N/A free((char *) d->validDepths[i]);
824N/A#else
824N/A XFree((char *) d->validDepths[i]);
824N/A#endif
824N/A for (j = 0; j < d->depthsForScreen[i]; j++) {
824N/A if (d->gcForDepth[i][j] != 0) {
824N/A XFreeGC(display, d->gcForDepth[i][j]);
824N/A }
824N/A }
824N/A }
824N/A
824N/A free((char *) d->depthsForScreen);
824N/A free((char *) d->validDepths);
824N/A free((char *) d->gcForDepth);
824N/A free((char *) d);
824N/A}
824N/A
824N/Aint XDPSChainTextContext(DPSContext context, Bool enable)
824N/A{
824N/A ContextInfo c = FindContextInfo(context);
824N/A
824N/A if (c == NULL) return dps_status_unregistered_context;
824N/A
824N/A /* Check if already in desired state */
824N/A
824N/A if (c->enableText == enable) return dps_status_success;
824N/A
824N/A if (enable) {
824N/A if (c->text == NULL) {
824N/A c->text = DPSCreateTextContext(DPSDefaultTextBackstop,
824N/A DPSDefaultErrorProc);
824N/A if (c->text == NULL) return dps_status_no_extension;
824N/A }
824N/A DPSChainContext(context, c->text);
824N/A c->enableText = True;
824N/A return dps_status_success;
824N/A }
824N/A
824N/A /* disabling, currently enabled */
824N/A
824N/A DPSUnchainContext(c->text);
824N/A c->enableText = False;
824N/A return dps_status_success;
824N/A}
824N/A
824N/ABool XDPSExtensionPresent(Display *display)
824N/A{
824N/A DisplayInfo d = LookupDisplayInfo(display);
824N/A
824N/A if (d->extensionPresent != ext_no_idea) {
824N/A return (d->extensionPresent == ext_yes);
824N/A }
824N/A
824N/A /* Check if the extension is present by trying to initialize it */
824N/A
824N/A if (XDPSLInit(display, (int *) NULL, (char **) NULL) == -1) {
824N/A d->extensionPresent = ext_no;
824N/A } else d->extensionPresent = ext_yes;
824N/A
824N/A return (d->extensionPresent == ext_yes);
824N/A}
824N/A
824N/Aint PSDefineAsUserObj(void)
824N/A{
824N/A return DPSDefineAsUserObj(DPSGetCurrentContext());
824N/A}
824N/A
824N/Avoid PSRedefineUserObj(int uo)
824N/A{
824N/A DPSRedefineUserObj(DPSGetCurrentContext(), uo);
824N/A}
824N/A
824N/Avoid PSUndefineUserObj(int uo)
824N/A{
824N/A DPSUndefineUserObj(DPSGetCurrentContext(), uo);
824N/A}
824N/A
824N/Aint DPSDefineAsUserObj(DPSContext ctxt)
824N/A{
824N/A int out = DPSNewUserObjectIndex();
824N/A /* We want to keep 0 as an unassigned value */
824N/A if (out == 0) out = DPSNewUserObjectIndex();
824N/A
824N/A _DPSSDefineUserObject(ctxt, out);
824N/A return out;
824N/A}
824N/A
824N/Avoid DPSRedefineUserObj(DPSContext ctxt, int uo)
824N/A{
824N/A _DPSSDefineUserObject(ctxt, uo);
824N/A}
824N/A
824N/Avoid DPSUndefineUserObj(DPSContext ctxt, int uo)
824N/A{
824N/A _DPSSUndefineUserObject(ctxt, uo);
824N/A}
824N/A
824N/Aint PSReserveUserObjIndices(int number)
824N/A{
824N/A return DPSReserveUserObjIndices(DPSGetCurrentContext(), number);
824N/A}
824N/A
824N/Aint DPSReserveUserObjIndices(DPSContext ctxt, int number)
824N/A{
824N/A int out = DPSNewUserObjectIndex();
824N/A
824N/A /* We want to keep 0 as an unassigned value */
824N/A if (out == 0) out = DPSNewUserObjectIndex();
824N/A
824N/A number--;
824N/A while (number-- > 0) (void) DPSNewUserObjectIndex();
824N/A return out;
824N/A}
824N/A
824N/Avoid PSReturnUserObjIndices(int start, int number)
824N/A{
824N/A DPSReturnUserObjIndices(DPSGetCurrentContext(), start, number);
824N/A}
824N/A
824N/Avoid DPSReturnUserObjIndices(DPSContext ctxt, int start, int number)
824N/A{
824N/A /* Nothing left any more */
824N/A}
824N/A
824N/A#ifdef NO_XLISTDEPTHS
824N/A/* This function copyright 1989 Massachusetts Institute of Technology */
824N/A
824N/A/*
824N/A * XListDepths - return info from connection setup
824N/A */
824N/Aint *XListDepths (
824N/A Display *dpy,
824N/A int scrnum,
824N/A int *countp)
824N/A{
824N/A Screen *scr;
824N/A int count;
824N/A int *depths;
824N/A
824N/A if (scrnum < 0 || scrnum >= dpy->nscreens) return NULL;
824N/A
824N/A scr = &dpy->screens[scrnum];
824N/A if ((count = scr->ndepths) > 0) {
824N/A register Depth *dp;
824N/A register int i;
824N/A
824N/A depths = (int *) malloc (count * sizeof(int));
824N/A if (!depths) return NULL;
824N/A for (i = 0, dp = scr->depths; i < count; i++, dp++)
824N/A depths[i] = dp->depth;
824N/A } else {
824N/A /* a screen must have a depth */
824N/A return NULL;
824N/A }
824N/A *countp = count;
824N/A return depths;
824N/A}
824N/A#endif /* NO_XLISTDEPTHS */