/*
* dpsXclient.c -- Implementation of the Display PostScript Client Library.
*
* (c) Copyright 1988-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$ */
#include <stdlib.h>
#include <unistd.h> /* sleep() */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifdef VMS
/* Xlib does not like UNIX defined to any value under VMS. */
#include <decw$include/X.h>
#else /* VMS */
#endif /* VMS */
#include "publictypes.h"
#include "DPS/dpsclient.h"
#include "dpsprivate.h"
#include "dpsXpriv.h"
#include "DPS/dpsXclient.h"
#include "dpsdict.h"
#include "DPS/dpsexcept.h"
#include "dpsXint.h"
long int cid)
{
return (cc);
return (NIL);
}
int cid)
{
}
int contextID,
{
if (!c) return NIL;
*c = *oldc;
c->eofReceived = false;
ss->firstContext = c;
/* Note: there's no way to determine whether the new context id was obtained
** as a result of a fork operation or from another application. so, it must
** be assumed that the application is the creator of the new context.
** Otherwise, it would have called the XDPSContextFromSharedID.
*/
c->creator = true;
c->zombie = false;
c->numstringOffsets = NULL;
return (DPSContext)c;
}
{
(unsigned long) ctxt, 0);
}
return true;
}
return false;
}
static void procFlushContext(
{
}
/* ARGSUSED */
char *arg)
{
return XDPSIsDPSEvent(event);
}
{
/* Output currently goes only to creator! */
if (!c->creator)
{
c->resultTable = NIL;
c->resultTableLength = 0;
return;
}
if (c->resultTable != NIL)
{
c->resultTable = NIL;
c->resultTableLength = 0;
return;
}
while (c->resultTable != NIL)
{
/* We may block indefinitely if the context is frozen or it
somehow needs more input. */
if (c->zombie)
{
c->resultTable = NIL;
c->resultTableLength = 0;
}
/* Someone could conceivably change the event delivery mode in the
middle of this...best to check every time */
}
}
/* update space's name map.
space->lastNameIndex is the highest index known to be known to the
server for this space.
c->lastNameIndex is the highest index sent so far to the context
*/
}
void DPSinnerProcWriteData(
char *buf,
unsigned int count)
{
/* ASSERT: safe to call with chain */
/* No local buffering */
} /* DPSinnerProcWriteData */
{
int currStatus;
int retries = 0;
/* First make sure context isn't frozen, try to unfreeze. */
{
/* Okay if context is PSRUNNING, since the EOF will
be handled at the next PSNEEDSINPUT */
}
/* Remove events from Xlib Qs before sending the reset request. */
if (currStatus == PSSTATUSERROR)
/* +++ report error? */;
else /* Didn't become zombie. */
{
currStatus = 0;
/* Be optmistic for the first try. Assume the app set up a status mask
correctly, we should get a status event without asking the
server for status. */
currStatus = c->statusFromEvent;
{
if (currStatus == PSFROZEN)
{
/* Optimism failed. App probably didn't set up a status mask.
Ask the server for status. */
retries = 0;
continue;
}
else
++retries;
currStatus = c->statusFromEvent;
}
}
c->eofReceived = false;
}
{
if (c->creator)
else
/* Don't free the space's wh out from under it */
}
{
}
{
/* let procAwaitReturnValues generate error */
}
/* ARGSUSED */
{
} /* DPSServicePostScript */
{
}
void DPSDefaultPrivateHandler(
long unsigned int arg1,
long unsigned int arg2,
char *prefix,
char *suffix)
{
switch (errorCode) {
case dps_err_invalidAccess:
{
char m[100];
}
break;
case dps_err_encodingCheck:
{
char m[100];
}
break;
case dps_err_closedDisplay:
{
char m[100];
(void) sprintf (m, "%sBroken display connection %d.%s",
}
break;
case dps_err_deadContext:
{
char m[100];
}
break;
case dps_err_warning:
{
msg = "\n";
/* flush convention */
}
break;
case dps_err_fatal:
{
msg = ".\nAborting ...\n";
/* flush convention */
abort();
}
break;
case dps_err_recursiveWait:
{
char m[100];
(void) sprintf (m,
"%sRecursive wait for return values, display 0x%x.%s",
}
break;
}
}
{
s->creator = true;
}
{
c->creator = true;
c->zombie = false;
if (!s->creator) {
c->procs = XDPSconvProcs;
c->nameEncoding = dps_strings;
}
}
{
c->creator = true;
c->zombie = false;
c->next = s->firstContext;
s->firstContext = c;
}
long int DPSLastUserObjectIndex = 0;
long int DPSNewUserObjectIndex (void)
{
return (DPSLastUserObjectIndex++);
}
void XDPSSetProcs (void)
{
if (!textCtxProcs)
{
}
if (!ctxProcs)
{
}
if (!XDPSconvProcs)
if (!XDPSrawProcs)
*XDPSconvProcs = *ctxProcs;
}
{
p->FlushContext = procFlushContext;
p->ResetContext = procResetContext;
}
int x,
int y,
{
0, DefaultStdCMap,
DefaultStdCMap, 0, false);
return (NIL);
else
{
return (newCtxt);
}
}
int x,
int y,
unsigned int eventmask,
int actual,
{
return (NIL);
else
{
return (newCtxt);
}
}
int x,
int y,
unsigned int eventmask,
int actual,
{
return (NIL);
else
{
return (newCtxt);
}
}
{
DPSPrivSpace s;
if (DPSInitialize () != 0)
return (NIL);
if (c != NIL)
return ((DPSContext) c);
return (NIL);
{
return (NIL);
}
if (spaceProcs == NIL)
{
}
s = spaces;
while (s != NIL)
break;
else
s = s->next;
if (s == NIL) /* Create new space record. */
{
s->procs = spaceProcs;
s->lastNameIndex = -1;
s->creator = false;
spaces = s;
}
c->procs = XDPSconvProcs;
c->nameEncoding = dps_strings;
c->next = s->firstContext;
s->firstContext = c;
c->lastNameIndex = s->lastNameIndex;
c->numstringOffsets = NULL;
c->creator = false;
c->zombie = false;
return ((DPSContext) c);
}
{
{
{
(unsigned long) newNameEncoding,
(unsigned long) newProgEncoding);
return;
}
{
}
else
}
}
{
DPSPrivSpace s;
if (DPSInitialize () != 0)
return (NIL);
if (spaceProcs == NIL)
{
}
s = spaces;
while (s != NIL)
break;
else
s = s->next;
if (s == NIL) /* Create new space record. */
{
return (NIL);
s->procs = spaceProcs;
s->lastNameIndex = -1;
s->creator = false;
spaces = s;
}
return ((DPSSpace) s);
}
{
}
{
{
return (0);
}
else
{
}
}
{
{
}
else
{
return (0);
}
}
{
return ((DPSContext) c);
return (NIL);
}
{
return (NIL);
}
{
return old;
}
{
return old;
}
{
}
{
else
return (0);
}
{
int i[4];
i[0] = i0;
i[1] = i1;
i[2] = i2;
i[3] = i3;
}
void XDPSStatusEventHandler (e)
XDPSLStatusEvent *e;
{
if (c == NIL)
return;
c->statusFromEvent = e->status;
{
c->zombie = true;
XDPSQuitBlocking = true;
}
if (c->statusProc != NIL)
}
void XDPSReadyEventHandler (e)
XDPSLReadyEvent *e;
{
if (c == NIL)
return;
}
void DPSWarnProc(
char *msg)
{
if (DPSInitialize() != 0) return;
}
void DPSFatalProc(
char *msg)
{
if (DPSInitialize() != 0) return;
}
void DPSCantHappen(void)
{
static int locked = 0;
++locked;
/* Fatal proc shouldn't return, but client can override and do anything. */
--locked;
}
/* Procedures for delayed event dispatching */
{
switch (newMode) {
case dps_event_pass_through:
break;
break;
default:
break;
}
if (old) return dps_event_pass_through;
else return dps_event_internal_dispatch;
}
int *status)
{
XExtCodes *c = XDPSLGetCodes(d);
must be False */
if (!c->first_event) /* Check CSDPS first */
{
{ /* Check CSDPS first */
return True;
}
else
return False;
}
return True;
}
{
XExtCodes *c = XDPSLGetCodes(d);
must be False */
if (!c->first_event) /* Check CSDPS first */
{
|| t == csdps_output_with_len)
return True;
else
return False;
}
}
{
XExtCodes *c = XDPSLGetCodes(d);
must be False */
if (!c->first_event) /* Check CSDPS first */
{
return True;
else
return False;
}
}
{
XExtCodes *c = XDPSLGetCodes(d);
must be False */
if (!c->first_event) /* Check CSDPS first */
{
return(XDPSLDispatchCSDPSFakeEvent(d, event, t));
else
return False;
}
} else return False;
return True;
}
int *val)
{
XExtCodes *c = XDPSLGetCodes(d);
must be False */
if (!c->first_event) /* Check CSDPS first */
{
{
return True;
}
else
return False;
}
}
return True;
}
{
return XDPSLGetVersion(dpy);
}