/*
* cslibext.c -- DPSCAP client Xlib extension hookup
*
* (c) Copyright 1991-1994 Adobe Systems Incorporated.
* All rights reserved.
*
* Permission to use, copy, modify, distribute, and sublicense this software
* and its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notices appear in all copies and that
* both those copyright notices and this permission notice appear in
* supporting documentation and that the name of Adobe Systems Incorporated
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. No trademark license
* to use the Adobe trademarks is hereby granted. If the Adobe trademark
* "Display PostScript"(tm) is used to describe this software, its
* functionality or for any other purpose, such use shall be limited to a
* statement that this software works in conjunction with the Display
* PostScript system. Proper trademark attribution to reflect Adobe's
* ownership of the trademark shall be given whenever any such reference to
* the Display PostScript system is made.
*
* ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
* ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
* ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
* TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
* PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
*
* Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
* Incorporated which may be registered in certain jurisdictions
*
* Author: Adobe Systems Incorporated
*/
/* $XFree86: xc/lib/dps/cslibext.c,v 1.4tsi Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include "cslibint.h"
#include <DPS/XDPSproto.h>
#include <DPS/dpsXclient.h>
#include <DPS/dpsNXargs.h>
#include "DPSCAPClient.h"
#include "dpsassert.h"
#include "publictypes.h"
#include "dpsXpriv.h"
/* === DEFINES === */
#define DPSNXSYNCGCMODE_FLUSH 0
/* === GLOBALS === */
#ifdef DPSLNKL
#define ANXCYAN
#define ANXMAGENTA
#define ANXYELLOW
#define ANXBLACK
#define ANXSPOT
#include "dpslnkl.inc"
#endif /* DPSLNKL */
/* === PUBLIC PROCS === */
#ifdef MAHALO
static int
{
}
#endif
int
int *numberType, /* RETURN */
char **floatingName) /* RETURN */
{
register xCAPConnReplyPrefix *p;
register char *c;
union {
} reply;
int indian;
int rest;
/* To fix dps-nx #68, Motif too slow on HP */
if ((c = getenv("DPSNXGCMODE")) != 0)
{
gNXSyncGCMode = atoi(c);
}
/* We may have already called this routine via XDPSExtensionPresent,
so don't do it again! */
return(DPSCAPSUCCESS);
/* Try to create a window for ClientMessage communication */
dpy,
0, 0,
1, 1,
0,
if (clientWindow == None)
return(DPSCAPFAILED);
/* Try to open a connection to an agent */
{
return(DPSCAPFAILED);
}
/* DPSCAPOpenAgent only partially fills in extData, so finish it */
/* +++ Is this all we have to do here? */
/* Send opening handshake */
indian = 1;
if (*(char *) &indian)
else
setup.authProtoNameLength = 0;
setup.authProtoDataLength = 0;
setup.nodeStringLength = 0;
#ifndef DPSLNKL
#else /* DPSLNKL */
{
goto skip_read;
}
/* Read normal reply */
#endif /* DPSLNKL */
/* Read common reply prefix */
#ifdef DPSLNKL
#endif
if (!p->success)
{
/* read the rest */
if (!c) return(DPSCAPFAILED);
else
{
}
Xfree(c);
return(DPSCAPFAILED);
}
/* read the rest of the fixed length reply */
/* verify */
{
/* Fine, we downgrade the client */
sprintf(qbuf, "NX: server version %ld older than expected %d, client will downgrade", (long)reply.good.serverVersion, DPSPROTOCOLVERSION);
}
{
/* Fine, we downgrade the client */
sprintf(kbuf, "NX: agent version %d older than expected %d, client will downgrade", my->dpscapVersion, DPSCAPPROTOVERSION);
#ifdef XXX
/* Saving this code as a reminder about what needs to be
cleaned up if we exit here */
return(DPSCAPFAILED);
#endif
}
if (numberType)
/* read additional data */
if (floatingName)
*floatingName = c;
else
Xfree(c);
/* set library extension data */
/* Hook my extension data on the dpy */
/* Chain my data on global list */
#ifdef MAHALO
/* Set function that is called after every Xlib protocol proc */
/* All CSDPS protocol is auto-flushed */
#endif /* MAHALO */
/* set agent arguments, if needed */
/* must follow setting of ShuntMap at least, so safest to
do here when everything has been setup */
return(DPSCAPSUCCESS);
}
XExtData **
{
return(XEHeadOfExtensionList(object));
}
void
{
/* The primary utility of this function is for DPS NX correctness,
but it also helps DPS/X do less work in tracking GC changes. */
}
void
register DPSContext ctxt)
{
{
break; /* Skip text contexts */
}
}
{
return(!Success);
else
}
/* New for DPS NX 2.0 */
void
{
}
/* === SUPPORT PROCS === */
void
unsigned long valuemask,
{
/* ASSERT: called from within LockDisplay section */
/* Always include the clip_mask */
valuemask |= GCClipMask;
/* +++ HACK! Hide the gc->rects flag in arc_mode */
/* Stupid macro insists on Display being called 'dpy' */
{
}
{
/* Derived from MIT XCrGC.c, _XGenerateGCList:
Copyright 1985, 1986, 1987, 1988, 1989 by the
Massachusetts Institute of Technology
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of M.I.T. not be used in advertising or
publicity pertaining to distribution of the software without specific,
written prior permission. M.I.T. makes no representations about the
suitability of this software for any purpose. It is provided "as is"
without express or implied warranty.
*/
/* Warning! This code assumes that "unsigned int" is 32-bits wide */
long nvalues;
/*
* Note: The order of these tests are critical; the order must be the
* same as the GC mask bits in the word.
*/
/* +++ HACK! Hide gc->rects flag in GCArcMode */
/*
* note: Data is a macro that uses its arguments multiple
* times, so "nvalues" is changed in a separate assignment
* statement
*/
nvalues <<= 2;
}
/* ASSERT: SyncHandle called by caller */
}
{
dpy,
False);
dpy,
False);
dpy,
False);
dpy,
False);
dpy,
False);
dpy,
False);
dpy,
False);
dpy,
False);
return(my);
}
int
{
register DPSCAPData n;
/* my->extData->private_data = NIL; ???? +++ */
{
break;
}
/* extData freed by caller (e.g., _XFreeExtData) */
return(0);
}
void
DPSCAPStartUp(void)
{
}
void
char *buf,
unsigned len,
{
{
pad = 0;
}
if (bufMode == dpscap_insert)
{
}
{
}
}
/* === EXT CALLBACK HOOKS === */
int
{
#ifdef CSDPS
#endif
/* Although it seems that we should free codes here, we can't
because Xlib owns the storage */
return(0);
}
int
{
if (extData)
else
return(0);
/* We change the GC unconditionally, since friggin' XCopyGC
clears the dirty bits of the values that are copied! */
NULL, "DPS NX: XGetGCValues returned False\n");
/* We have to make sure that the agent completely processes
the change to the GC. If we allow the agent to update the
GC in its own sweet time, the stupid client may delete the
GC after the agent has already queued a request to, e.g.,
copy the GC, but before the request is flushed. */
return(1);
}
int
{
if (extData)
else
return(0);
/* Notify the agent that the client deleted a GC. Let the
agent figure out if it cares. */
/* ASSERT: called from within LockDisplay section */
return(0);
/* May need to sync changes to GC */
if (gNXSyncGCMode == DPSNXSYNCGCMODE_DELAYED)
{
}
/* Guarantee that everyone sees GC go away */
if (gNXSyncGCMode == DPSNXSYNCGCMODE_FLUSH)
{
}
else
/* ASSERT: SynchHandle called by caller */
return(1);
}
#ifdef CSDPSDEBUG
static unsigned int gcCountFlushedClean = 0;
static unsigned int gcCountFlushedDirty = 0;
#endif /* CSDPSDEBUG */
int
{
#ifdef CSDPSDEBUG
unsigned long int dirty;
#endif /* CSDPSDEBUG */
/* When GC is created, it is flushed with no dirty bits set,
so we have to notice that situation. */
{
return(0);
}
if (extData)
else
return(0);
/* HERE IF (gc->dirty & DPSGCBITS || !gc->dirty) */
#ifdef CSDPSDEBUG
#endif /* CSDPSDEBUG */
/* Must guarantee that gc change is registered by X server
before notification is sent to agent. */
/* We have to make sure that the agent completely processes
the change to the GC. If we allow the agent to update the
GC in its own sweet time, the stupid client may delete the
GC after the agent has already queued a request to, e.g.,
copy the GC, but before the request is flushed. */
if (gNXSyncGCMode == DPSNXSYNCGCMODE_SYNC)
else
#ifdef CSDPSDEBUG
if (dirty)
else
#endif /* CSDPSDEBUG */
return(1);
}