/*
* dpsclient.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 <stdio.h>
#include <ctype.h>
#include <string.h>
#include "dpsXpriv.h"
#include "DPS/dpsclient.h"
#include "dpsprivate.h"
#include "dpsdict.h"
#include "DPS/dpsexcept.h"
#include "dpsassert.h"
#ifdef XDPS
#include "dpsXint.h"
#endif /* XDPS */
#else
#endif
#if !IEEEFLOAT
extern void IEEEHighToNative(/* FloatRep *from, real *to */);
/* Converts from IEEE high-byte-first real to native real. */
extern void NativeToIEEEHigh(/* real *from, FloatRep *to */);
/* Converts from native real to IEEE high-byte-first real. */
extern void IEEELowToNative(/* FloatRep *from, real *to */);
/* Converts from IEEE low-byte-first real to native real. */
extern void NativeToIEEELow(/* real *from, FloatRep *to */);
/* Converts from native real to IEEE low-byte-first real. */
#endif /* !IEEEFLOAT */
typedef union { /* 32 bit number representations */
unsigned int u;
int i;
float f;
/* raw bytes, in whatever order they appear in memory */
} Swap32Rec;
typedef union { /* 16 bit number representations */
unsigned short u;
short i;
} Swap16Rec;
#if SWAPBITS
#else /* SWAPBITS */
#endif /* SWAPBITS */
{
char *p;
while (!(p = (char *)calloc(e, n))) {
}
return p;
}
{
/* we're about to call the error handler, so roll back the
lastNameIndex to the last known valid index */
}
void DPSCheckInitClientGlobals(void)
{
if (!DPSglobals) {
globLastNameIndex = -1;
}
}
/**************************************************************/
/* Procedures that support the DPSCreateContext context procs */
/**************************************************************/
/* ARGSUSED */
static void ReleaseInput(
{
contextBuffers = cb;
}
/* ARGSUSED */
static void StuffResultVal(
{
/* check if array */
if (nObjs < 1) return;
return;
}
}
do {
case dps_tBoolean:
bump = sizeof(int);
}
break;
case dps_tFloat: {
bump = sizeof(float);
}
bump = sizeof(float);
}
break;
}
case dps_tDouble: {
bump = sizeof(double);
}
bump = sizeof(double);
}
break;
}
case dps_tShort:
bump = sizeof(short);
}
break;
case dps_tUShort:
bump = sizeof(unsigned short);
}
break;
case dps_tInt:
bump = sizeof(int);
}
break;
case dps_tUInt:
bump = sizeof(unsigned int);
}
break;
case dps_tLong:
bump = sizeof(long int);
}
break;
case dps_tULong:
bump = sizeof(unsigned long);
}
break;
case dps_tChar:
case dps_tUChar:
if (nObjs != 1) {
}
else if (type == DPS_STRING) {
/* char * result, copy first, ignore subsequent, null terminate */
}
else {
unsigned slen;
/* copy entire string into char array */
}
/* copy partial string into char array */
}
else return; /* ignore string result, no room left */
}
return;
}
break;
default:
} /* switch (result->type) */
if (bump == 0) {
return;
}
}
obj += 1;
nObjs--;
} while (nObjs > 0); /* do */
} /* StuffResultVal */
static void NumFormatFromTokenType(
unsigned char t,
{
switch (t) {
case DPS_HI_IEEE:
break;
case DPS_LO_IEEE:
break;
case DPS_HI_NATIVE:
*numFormat = dps_native;
break;
case DPS_LO_NATIVE:
*numFormat = dps_native;
break;
default: DPSCantHappen();
}
}
#if !IEEEFLOAT
/* called to deal with results from the server */
char *base;
unsigned char tokenType;
{
while (nObjs--) {
integer i;
switch (t) {
case DPS_REAL: {
float f;
if (DPSDefaultByteOrder == dps_hiFirst)
else
}
else break; /* switch */
break;
}
case DPS_ARRAY:
break;
case DPS_NAME:
case DPS_STRING:
break;
default:;
} /* end switch */
++currObj;
} /* end while */
}
#endif /* !IEEEFLOAT */
{
if (cc == c) return true;
return false;
}
{
if (ss == s) return true;
return false;
}
void DPSclientPrintProc (
char *buf,
unsigned nch)
{
if (nch == 0) { /* this is an EOF */
cc->eofReceived = true;
/* we were buffering; drop buffered chars on the floor */
cc->nObjBufChars = 0;
}
}
while (nch > 0) {
unsigned oldNch = 0;
unsigned n;
unsigned long int m;
if (nch == 0) return;
*b++ = *buf++;
++cc->nObjBufChars;
--nch;
}
return;
}
else {
}
}
if (minSize == DPS_HEADER_SIZE) {
m = *sizeP;
}
else {
m = *extSizeP;
}
/* here with m = BOS total length in bytes, b = cc->objBuf */
return;
}
else {
cc->nObjBufChars = m;
}
/* we're here only if cc->objBuf contains a complete BOS */
cc->nObjBufChars = 0;
} /* if we're buffering */
/* dispose of any plain text. If no binary conversion, all output
is plain text */
else {
for (n = 0; n < nch &&
}
}
buf += n;
nch -= n;
if (nch != 0) {
/* here with the next binary object sequence from a server */
unsigned t;
unsigned long int m;
unsigned minSize;
if (nch < DPS_SEQ_MIN) {
/* gotta buffer it */
return;
}
/* check for quadbyte alignment */
/* not aligned, we gotta copy the buffer */
/* we assert that we can't have an oldBuf if we're not aligned,
since we only get an oldBuf if we copied to a new buffer,
and we have already tested nch to be at least DPS_SEQ_MIN */
/* copy DPS_SEQ_MIN bytes, so we can use existing buffering code */
buf += DPS_SEQ_MIN;
nch -= DPS_SEQ_MIN;
/* now go to top of loop and go through the buffer update code */
continue;
}
/* gotta buffer it */
char *tb;
return;
}
else if (minSize == DPS_HEADER_SIZE) {
/* this is not an extended BOS */
}
if (nch < m) {
/* gotta buffer it */
return;
}
#if !IEEEFLOAT
if (t != DPS_DEF_TOKENTYPE)
#endif /* !IEEEFLOAT */
if (t == DPS_ERR_TAG) {
}
else { /* dispatch this result */
}
}
else if (t == cc->resultTableLength) {
}
else {
}
}
if (!oldBuf)
buf += m;
nch -= m;
} /* if (nch != 0) ... the next binary object sequence from a server */
if (oldBuf) {
}
} /* while (nch > 0) */
} /* DPSclientPrintProc */
/**************************************/
/* Context procs for DPSCreateContext */
/**************************************/
{
typedef struct {
unsigned char tokenType;
unsigned char topLevelCount;
unsigned short int nBytes;
} DPSQ;
}; /* DPSQ */
if (DPSPrivateCheckWait(ctxt)) return;
}
{
integer i;
/* unlink context from chain temporarily, so DPSPrintf can be called */
/* update any children */
}
}
static void procWriteData(
char *buf,
unsigned int count)
{
/* safe to call with chain */
}
static void procBinObjSeqWrite(
char *buf,
unsigned int count)
{
}
static void procWriteStringChars(
char *buf,
unsigned int count)
{
}
static void procWritePostScript(
char *buf,
unsigned int count)
{
}
static void innerProcWriteNumstring(
char *data,
unsigned int size,
int scale,
void (*writeProc)(DPSContext, char *, unsigned))
{
register int i;
HNumHeader[0] = 149;
switch (type) {
case dps_tLong:
break;
case dps_tInt:
break;
case dps_tShort:
break;
case dps_tFloat:
break;
default:
break;
}
switch (type) {
case dps_tLong:
if (sizeof(long) == 4) {
} else {
while (size > 0) {
}
}
}
break;
case dps_tInt:
break;
case dps_tShort:
break;
case dps_tFloat:
default:
break;
}
} /* innerProcWriteNumstring */
static void procWriteNumstring(
char *data,
unsigned int size,
int scale)
{
}
static void writeTypedObjectArray(
char *array,
unsigned int length)
{
unsigned int i;
{DPS_LITERAL | DPS_BOOL, 0,0,0},
{DPS_LITERAL | DPS_BOOL, 0,0,0},
{DPS_LITERAL | DPS_BOOL, 0,0,0},
{DPS_LITERAL | DPS_BOOL, 0,0,0},
{DPS_LITERAL | DPS_BOOL, 0,0,0},
{DPS_LITERAL | DPS_BOOL, 0,0,0},
{DPS_LITERAL | DPS_BOOL, 0,0,0},
{DPS_LITERAL | DPS_BOOL, 0,0,0},
{DPS_LITERAL | DPS_BOOL, 0,0,0},
{DPS_LITERAL | DPS_BOOL, 0,0,0},
};
{DPS_LITERAL | DPS_REAL, 0,0,0},
{DPS_LITERAL | DPS_REAL, 0,0,0},
{DPS_LITERAL | DPS_REAL, 0,0,0},
{DPS_LITERAL | DPS_REAL, 0,0,0},
{DPS_LITERAL | DPS_REAL, 0,0,0},
{DPS_LITERAL | DPS_REAL, 0,0,0},
{DPS_LITERAL | DPS_REAL, 0,0,0},
{DPS_LITERAL | DPS_REAL, 0,0,0},
{DPS_LITERAL | DPS_REAL, 0,0,0},
{DPS_LITERAL | DPS_REAL, 0,0,0},
};
{DPS_LITERAL | DPS_INT, 0,0,0},
{DPS_LITERAL | DPS_INT, 0,0,0},
{DPS_LITERAL | DPS_INT, 0,0,0},
{DPS_LITERAL | DPS_INT, 0,0,0},
{DPS_LITERAL | DPS_INT, 0,0,0},
{DPS_LITERAL | DPS_INT, 0,0,0},
{DPS_LITERAL | DPS_INT, 0,0,0},
{DPS_LITERAL | DPS_INT, 0,0,0},
{DPS_LITERAL | DPS_INT, 0,0,0},
{DPS_LITERAL | DPS_INT, 0,0,0},
};
if (DPSCheckShared(c)) return;
switch (type) {
case dps_tChar:
case dps_tUChar:
break;
case dps_tBoolean: {
while (length > 0) {
array += sizeof(int);
}
length -= i;
}
break;
}
case dps_tFloat: {
while (length > 0) {
array += sizeof(float);
}
length -= i;
}
break;
}
case dps_tDouble: {
while (length > 0) {
array += sizeof(double);
}
length -= i;
}
break;
}
case dps_tShort: {
while (length > 0) {
array += sizeof(short);
}
length -= i;
}
break;
}
case dps_tUShort: {
while (length > 0) {
array += sizeof(unsigned short);
}
length -= i;
}
break;
}
case dps_tInt: {
while (length > 0) {
array += sizeof(int);
}
length -= i;
}
break;
}
case dps_tUInt: {
while (length > 0) {
array += sizeof(unsigned int);
}
length -= i;
}
break;
}
case dps_tLong: {
while (length > 0) {
array += sizeof(long);
}
length -= i;
}
break;
}
case dps_tULong: {
while (length > 0) {
array += sizeof(unsigned long);
}
length -= i;
}
break;
}
default:;
}
} /* writeTypedObjectArray */
{
b->next = contextBuffers;
contextBuffers = b;
}
}
else {
}
free(c);
}
{
else {
}
}
{
}
/****************************************************************/
/* Procedures that support the DPSCreateTextContext context procs */
/****************************************************************/
/* precondition: (c >= 129 && c <= 159), which means that c is the
first byte of either a binary token or a binary object sequence */
{
return (c != DPS_HI_IEEE && c != DPS_LO_IEEE
&& c != DPS_HI_NATIVE && c != DPS_LO_NATIVE);
}
/* returns the number of initial bytes of a given goody that are
required to figure out how many bytes are needed for the entire goody */
static unsigned GetHdrNBytes(unsigned char *t)
{
if (!IsBinaryToken(*t)) {
if (*(++t) == 0) return DPS_EXT_HEADER_SIZE;
else return DPS_HEADER_SIZE;
}
switch (*t) {
case 137:
case 142:
return(2);
case 143:
case 144:
return(3);
case 149:
return(4);
default:
if (*t > 149 && *t < 160) return(1); /* unassigned */
else return(1);
}
}
static void WriteHomogeneousArrayAsASCII(
register unsigned char *buf)
{
register unsigned char *b;
unsigned char r = *buf++;
float f;
if (!hi) r -= 128;
buf += 2;
if (r < 32) /* 32-bit fixed */
while (n16.u--) {
if (r == 0)
else {
f = n32.i; /* convert to float */
}
buf += 4;
}
else if (r < 48) { /* 16-bit fixed */
unsigned l = n16.u;
r -= 32;
while (l--) {
if (r == 0)
else {
f = n16.i; /* convert to float */
}
buf += 2;
}
}
else if (r == 48) /* 32-bit IEEE */
while (n16.u--) {
#if IEEEFLOAT
#else /* IEEEFLOAT */
#endif /* IEEEFLOAT */
buf += 4;
}
else if (r == 49) /* 32-bit native */
while (n16.u--) {
}
else DPSCantHappen();
} /* WriteHomogeneousArrayAsASCII */
/* returns the number of bytes needed for the entire goody. buf points
to enough initial bytes of the goody to figure this out (see above). */
{
unsigned short int nBytes;
register unsigned char *r = (unsigned char *)&nBytes;
switch (*buf) {
case DPS_HI_IEEE:
case DPS_HI_NATIVE:
if (*(buf+1) == 0) {
unsigned int nb;
r = (unsigned char *)&nb;
buf += 4;
Copy4SrcHi(buf, r);
return(nb);
}
else {
buf += 2;
Copy2SrcHi(buf, r);
}
break;
case DPS_LO_IEEE:
case DPS_LO_NATIVE:
if (*(buf+1) == 0) {
unsigned int nb;
r = (unsigned char *)&nb;
buf += 4;
Copy4SrcLo(buf, r);
return(nb);
}
else {
buf += 2;
Copy2SrcLo(buf, r);
}
break;
case 132:
case 133:
case 138:
case 139:
case 140:
nBytes = 5; break;
case 134:
case 135:
nBytes = 3; break;
case 136:
case 141:
case 145:
case 146:
case 147:
case 148:
nBytes = 2; break;
case 137: {
unsigned int l = *(buf+1);
}
case 142:
nBytes += 2;
break;
case 143:
buf++;
Copy2SrcHi(buf, r);
nBytes += 3;
break;
case 144:
buf++;
Copy2SrcLo(buf, r);
nBytes += 3;
break;
case 149: {
buf += 2;
if (scale < 128)
Copy2SrcHi(buf, r);
else {
scale -= 128;
Copy2SrcLo(buf, r);
}
if (scale < 32)
nBytes *= 4;
else if (scale < 48)
nBytes *= 2;
else
nBytes *= 4;
nBytes += 4;
break;
}
}
return(nBytes);
}
static void WriteSeqAsAscii(
char *base,
unsigned int nObjs,
unsigned char tokenType,
int *numstringOffsets)
{
float f;
long int i;
unsigned short int length;
/* NOTE: It's ok to call DPSPrintf (which calls DPSWritePostScript)
from here since we are only sending text, so there's no problem
with re-entering DPSWritePostScript. Caller guarantees
that this context has no children. */
while (nObjs--) {
switch (type) {
case DPS_NULL:
break;
case DPS_BOOL:
if (i)
else
break;
case DPS_INT:
break;
case DPS_REAL:
#if IEEEFLOAT
#else /* IEEEFLOAT */
if (numFormat != DPSDefaultNumFormat)
#if SWAPBITS
#else /* SWAPBITS */
#endif /* SWAPBITS */
else
#endif /* IEEEFLOAT */
break;
case DPS_NAME: {
char *p = 0;
if (index <= DPS_LAST_COMMON_SYSNAME) {
p = DPSGetSysnameAbbrev(index);
} else p = DPSSysNames[index];
} else if (DPS_FIRST_AUX_SYSNAME <= index
&& index <= DPS_LAST_AUX_SYSNAME)
else DPSCantHappen();
}
else if (length == 0) { /* user name index */
p = DPSNameFromIndex(index);
}
else
break;
}
case DPS_ARRAY:
ctxt,
base,
break;
case DPS_MARK:
if (lit)
else
break;
case DPS_STRING: {
char *p;
int j;
p = base + i;
if (numstringOffsets != NULL) {
numstringOffsets[j] != i; j++) ;
if (numstringOffsets[j] == i) {
DPSAssert(*(unsigned char *) p++ == 149);
WriteHomogeneousArrayAsASCII(ctxt, (unsigned char *) p);
break;
}
}
#ifdef VMS
#else /* VMS */
/* render string bytes correctly */
while (length--) {
char c = *p++;
if (c == '(' || c == ')' || c == '\\')
else if (c == '\n')
}
#endif /* VMS */
break;
}
default: DPSCantHappen();
}
currObj++;
if (++nLineObjs == 15) {
nLineObjs = 0;
}
} /* end while */
} /* WriteSeqAsAscii */
static void ConvertAndWriteSeqAsData(
char *bosBuf,
int pass)
{
unsigned int nameOffset;
unsigned int len = 0;
char *seqBase;
if (*(bosBuf+1) != 0) {
/* not an extended BOS */
}
else {
}
/* Caller guarantees that this context has no children,
so it is okay to call DPSWriteData */
/* Pass 0: If we're expanding name indices, find all name objects,
lookup their strings, sum the lengths.
Write the modified sequence header regardless.
converting numbers. Write each modified object, and
subsidiary strings.
Pass 2: Find all name objects, lookup and write the strings. */
/* we're just converting numbers, so skip while loop */
else
offset = 0;
while (offset < firstCharOffset) {
#if !IEEEFLOAT
if (DPSDefaultByteOrder == dps_loFirst)
else
}
else { /* numFormat is native */
if (DPSDefaultByteOrder == dps_loFirst)
else
}
}
}
#endif /* !IEEEFLOAT */
/* keep track of where strings start */
}
}
switch (pass) {
case 1:
}
break;
default:;
}
}
else { /* name is already a string */
/* keep track of where strings start */
}
} /* end if type == DPS_NAME */
if (pass == 1) {
}
++currObj;
} /* end while */
/* finish pass */
switch (pass) {
case 0: {
unsigned char t;
/* write modified seqHead */
t = DPS_HI_IEEE;
t = DPS_LO_IEEE;
t = DPS_HI_NATIVE;
else
t = DPS_LO_NATIVE;
if (headSize == DPS_HEADER_SIZE) {
unsigned short int nBytes;
unsigned char c = bos->nTopElements;
/* write top level count */
/* write nBytes */
}
else {
unsigned int nBytes;
/* write escape code & top level count */
/* write nBytes */
}
break;
}
case 1: {
break;
}
default:;
}
} /* ConvertAndWriteSeqAsData */
/* TestHomogeneous will return a non-negative representation code 'r'
if all of the array elements are "integers", or all are "reals".
Will return -1 for any other case. */
unsigned short length,
{
while (length--) {
case DPS_INT:
#if SWAPBITS
#else /* SWAPBITS */
#endif /* SWAPBITS */
r = tmp; /* first element, or was 16-bit => bump to 32-bit */
goto bump_obj; /* is 32-bit => stay 32-bit */
else if (r != tmp)
return(-1);
/* else fall thru, r == tmp */
break;
case DPS_REAL:
#if SWAPBITS
#else /* SWAPBITS */
#endif /* SWAPBITS */
if (r == -1)
r = tmp;
else if (r != tmp) return(-1);
break;
default: return(-1);
}
++aryObj;
}
return(r);
} /* TestHomogeneous */
static void WriteSeqAsTokens(
char *base,
unsigned int nObjs,
unsigned char tokenType,
int *numstringOffsets)
{
int nLineObjs = 0;
unsigned short length;
unsigned char c;
#if SWAPBITS
#else /* SWAPBITS */
#endif /* SWAPBITS */
while (nObjs--) {
switch (type) {
case DPS_NULL:
break;
case DPS_BOOL:
PB(true);
else
PB(false);
break;
case DPS_INT:
}
}
else {
}
break;
case DPS_REAL:
#if IEEEFLOAT
#else /* IEEEFLOAT */
if (numFormat != DPSDefaultNumFormat)
/* then it must be IEEE */
else
#endif /* IEEEFLOAT */
break;
case DPS_NAME: {
char *p = 0;
if (lit)
else
goto next_obj;
}
else if (DPS_FIRST_AUX_SYSNAME <= index
&& index <= DPS_LAST_AUX_SYSNAME)
else DPSCantHappen();
}
else if (length == 0) { /* user name index */
if (lit)
else
goto next_obj;
}
else {
p = DPSNameFromIndex(index);
}
}
else
break;
}
case DPS_ARRAY: {
integer r;
PB(r);
if (r > 127) r -= 128;
while (length--) {
switch (r) {
case 0:
break;
case 32:
break;
case 48:
case 49:
break;
default: DPSCantHappen();
}
++aryObj;
}
}
else {
}
break; }
case DPS_MARK:
if (lit)
else
break;
case DPS_STRING: {
int i;
if (numstringOffsets != NULL) {
DPSAssert(*(unsigned char *) p == 149);
break;
}
}
if (length < 256) {
}
else {
}
break;
}
default: DPSCantHappen();
}
++currObj;
if (++nLineObjs == 15) {
nLineObjs = 0;
}
} /* end while */
} /* WriteSeqAsTokens */
static void WriteTokenAsAscii(
register unsigned char *buf)
{
register unsigned char *b;
switch (*buf++) {
case 132: /* 32-bit int, hi */
Copy4SrcHi(buf, b);
break;
case 133: /* 32-bit int, lo */
Copy4SrcLo(buf, b);
break;
case 134: /* 16-bit int, hi */
Copy2SrcHi(buf, b);
break;
case 135: /* 16-bit int, lo */
Copy2SrcLo(buf, b);
break;
case 136: /* 8-bit int, signed */
break;
case 137: { /* 16 or 32-bit fixed */
unsigned char r = *buf++;
float f = 0.0;
if (!hi) r -= 128;
if (r < 32) { /* 32-bit */
if (r == 0) {
break;
}
else {
f = n32.i; /* convert to float */
goto do_scale;
}
}
else if (r < 48) { /* 16-bit */
if (r == 0) {
break;
}
else {
r -= 32;
f = n16.i; /* convert to float */
goto do_scale;
}
}
else DPSCantHappen();
break;
}
case 138: /* 32-bit IEEE float, hi */
#if IEEEFLOAT
Copy4SrcHi(buf, b);
#else /* IEEEFLOAT */
#endif /* IEEEFLOAT */
break;
case 139: /* 32-bit IEEE float, lo */
#if IEEEFLOAT
Copy4SrcLo(buf, b);
#else /* IEEEFLOAT */
#endif /* IEEEFLOAT */
break;
case 140: /* 32-bit native float */
break;
case 141: /* boolean */
if (*buf)
else
break;
case 142: /* short string */
goto share_str_code;
case 143: /* long string, hi */
Copy2SrcHi(buf, b);
buf += 2;
goto share_str_code;
case 144: /* long string, lo */
Copy2SrcLo(buf, b);
buf += 2;
#ifdef VMS
#else /* VMS */
/* render string bytes correctly */
while (n16.u--) {
unsigned char c = *buf++;
if (c == '(' || c == ')' || c == '\\')
else if (c == '\n')
}
#endif /* VMS */
break;
case 145: /* literal system name index */
break;
case 146: /* executable system name index */
break;
case 147: /* literal user name index */
break;
case 148: /* executable user name index */
break;
case 149: { /* homogeneous number array */
break;
}
default:; /* unassigned */
}
} /* WriteTokenAsAscii */
/* WriteEntireGoody converts an entire binary token or binary object
sequence as specified by ctxt's encoding parameters. Write the
converted bytes via DPSWriteData. buf points to the complete goody. */
static void WriteEntireGoody(
unsigned char *buf,
int *numstringOffsets)
{
if (IsBinaryToken(*buf)) {
/* only supported conversion is binary token to ASCII */
return;
}
/* not extended BOS */
}
switch (ctxt->programEncoding) {
case dps_binObjSeq:
/* takes three passes to do conversions */
}
/* first pass just writes modified seqHead */
/* second pass converts numbers and writes the sequence */
}
break;
case dps_ascii:
case dps_encodedTokens: {
{
}
else
break;
}
default:;
}
} /* WriteEntireGoody */
/**************************************/
/* Context procs for DPSCreateTextContext */
/**************************************/
{
}
{
}
{
}
{
free(c);
}
static void textInnerWritePostScript(
{
while (nch > 0) {
unsigned n;
unsigned m;
}
/* # bytes needed to determine size */
return;
}
free(b);
}
/* here with size of entire goody in m and outBuf set up */
return;
}
cc->nOutBufChars = m;
cc->nOutBufChars = 0;
} /* if (cc->outBuf) */
/* dispose of any plain text. If no binary conversion, all output
is plain text */
else {
for (n = 0; n < nch &&
}
if (n > 0) {
/* Assumes below that any error proc called uses dpsexcept.h
if it rips control away */
}
buf += n;
nch -= n;
if (nch != 0) {
/* here with the next binary object sequence or encoded token */
unsigned m = 0;
/* gotta buffer it */
DPSAssertWarn(nch == 1 && !oldBuf, cc, "problem converting binary token/sequence (nch!=1||oldBuf)");
return;
}
/* gotta buffer it */
}
else {
}
return;
}
/* Assumes below that any error proc called uses dpsexcept.h
if it rips control away */
if (oldBuf) {
DPSAssertWarn(nch == m, cc, "some converted PostScript language may be lost during error recovery (nch!=m)");
}
if (oldBuf) {
}
else {
buf += m;
nch -= m;
}
} /* if (nch != 0) */
} /* while (nch > 0) */
} /* textInnerWritePostScript */
static void textWritePostScript(
{
/* disconnect temporarily so that high level procs can
be called safely */
}
}
static void textWriteStringChars(
{
/* disconnect temporarily so that high level procs can
be called safely */
}
}
static void textBinObjSeqWrite(
{
if (DPSCheckShared(c)) return;
if (c->lastNameIndex < globLastNameIndex)
/* disconnect temporarily so that high level procs can
be called safely */
}
}
static void textWriteNumstring(
char *data,
unsigned int size,
int scale)
{
BUFFER_GROW + 2);
sizeof(int)* cc->numstringOffsets[0]);
}
/* Subtract 4 because of binary object sequence header */
}
} /* textWriteNumstring */
/*********************/
/* Public procedures */
/*********************/
/********************************************/
/* Public procs for dealing with user names */
{
|| userNameDict == NIL)
return NIL;
}
void DPSMapNames(
unsigned int nNames,
char **names,
int **indices)
{
unsigned i;
if (userNameDict == NIL) {
}
for (i = 0; i < nNames; i++) {
integer j;
char *n = names[i];
DPSContext c;
if (n == NIL)
n = last;
else
last = n;
if (strlen(n) > 128) {
return;
}
j = DPSWDictLookup(userNameDict, n);
if (j >= 0) {
*(indices[i]) = j;
/* handle the case where another context in another space has
defined this name */
}
else {
/* handle other cases where another context in another
space has defined names */
char **t = (char **)DPScalloc(sizeof(char *),
for (j = 0; j < userNamesLength; j++) {
t[j] = userNames[j];
}
userNames = t;
}
userNames[globLastNameIndex] = n;
*(indices[i]) = globLastNameIndex;
}
} /* for */
}
/**********************/
/* Other public procs */
void DPSDefaultErrorProc(
{
switch (errorCode) {
case dps_err_ps: {
}
}
#if 0 /* Postpone the raise 'til later to avoid RAISEing through Xlib */
#else
#endif
}
break;
}
case dps_err_nameTooLong:
}
break;
case dps_err_invalidContext:
char m[100];
}
break;
case dps_err_resultTagCheck:
char m[100];
}
break;
case dps_err_resultTypeCheck:
char m[100];
}
break;
default:
break;
}
} /* DPSDefaultErrorProc */
{
RAISE(dps_err_ps, (char *) c);
}
}
/**************************************/
/* Public procs for creating contexts */
/* dps_err_invalidAccess is now defined for all clients. */
{
}
static void Noop(void)
{
}
{
if (!textCtxProcs) {
}
c->procs = textCtxProcs;
c->programEncoding = dps_ascii;
c->numFormat = DPSDefaultNumFormat;
c->numstringOffsets = NULL;
c->lastNameIndex = -1;
/* Setup a dummy space */
{
}
return (DPSContext)c;
} /* DPSCreateTextContext */
{
if (!dummyCtxProcs) {
}
c->procs = dummyCtxProcs;
c->numFormat = DPSDefaultNumFormat;
c->lastNameIndex = -1;
c->numstringOffsets = NULL;
return (DPSContext)c;
} /* CreateDummyContext */
{
}
{
}
{
}
{
}
{
initFailed = -1;
}
int DPSInitialize(void)
{
if (!clientStarted) {
clientStarted = true;
initFailed = 0;
/* textProc will not be used unless DPS initialization fails */
}
return initFailed;
}
char *wh,
{
if (DPSInitialize() != 0) return NIL;
if (!ctxProcs) {
}
if (!spaceProcs) {
}
}
c->lastNameIndex = -1;
c->numstringOffsets = NULL;
ss->firstContext = c;
(DPSContext)c,
(ContextPSID *)&c->cid,
{ /* can't create the context */
}
free(c);
return NIL;
}
else return (DPSContext)c;
} /* DPSCreateContext */
char *DPSSetWh(
char *newWh)
{
return(tmp);
}
/*
The chainParent field is non-NIL if this context automatically receives
a copy of the PostScript code sent to the referenced (parent) context.
The chainChild field is non-NIL if this context automatically sends along
to the referenced (child) context a copy of any PostScript code received.
*/
{
return -1; /* report an error */
/* insert new child between parent and existing children */
DPSAssertWarn(parent->chainChild->chainParent == parent, (DPSPrivContext)parent, "attempting to chain context on invalid chain");
}
/* if child has children, recursively chain them */
}
return 0;
}
{
if (p != NIL) { /* remove ctxt from parent's chain */
DPSAssertWarn(p->chainChild == ctxt, (DPSPrivContext)p, "attempting to unchain context from wrong chain (parent)");
p->chainChild = c;
}
if (c != NIL) { /* remove ctxt's child (if any) from ctxt's chain */
DPSAssertWarn(c->chainParent == ctxt, (DPSPrivContext)c, "attempting to unchain context from wrong chain (child)");
c->chainParent = p;
}
}
/****************/
/* Veneer procs */
{
}
{
}
{
}
{
}
{
}
{
}
void DPSSetResultTable(
register DPSContext ctxt,
unsigned int len)
{
}
void DPSSetContext(
{
}
void DPSUpdateNameMap(
{
}
void DPSWaitContext(
{
}
void DPSBinObjSeqWrite(
char *buf,
unsigned int count)
{
}
void DPSWriteData(
char *buf,
unsigned int count)
{
}
void DPSWritePostScript(
char *buf,
unsigned int count)
{
}
void DPSWriteStringChars(
char *buf,
unsigned int count)
{
}
char *data;
unsigned int size;
int scale;
{
}
char *array;
unsigned int length; {
}
{
p->WriteData = textWriteData;
p->FlushContext = textFlushContext;
}
{
p->WaitContext = procWaitContext;
p->WriteData = procWriteData;
p->Interrupt = procInterrupt;
}
{
p->DestroySpace = procDestroySpace;
}
int flag;
{
}
int flag;
{
}
int flag;
{
}
int flag;
{
}
int extensionId;
{
return r;
}
{
}
int extensionId;
{
r = &(*r)->next;
}
rret = *r;
return rret;
}
int DPSGenerateExtensionRecID(void)
{
return id++;
}
{
else return dps_context_execution;
}