This is dpsfriends.h in view mode; [Download] [Up]
/* dpsfriends.h -- Low-level interface to the Display PostScript Library. Imported by the output of pswrap. This interface is intended to be identical across different implementations of the Display PostScript System, except for items explicitly identified below as system-dependent, and lists explicitly identified below as extensible. System-dependent items may be redefined, and items may be added to extensible lists, but existing items in these lists may not be changed or deleted. We expect there to be little if any need to make extensions. If you do feel the need, it is likely that you are doing something wrong. Such extensions hinder the portability of Display PostScript applications. Copyright (c) 1988 Adobe Systems Incorporated. All rights reserved. */ #ifndef DPSFRIENDS_H #define DPSFRIENDS_H #import <stdarg.h> /*=== CONSTANTS ===*/ /* TokenType values, used to specify the format of numeric values for the system on which the client library is built. See DPS language reference manual */ #define DPS_HI_IEEE 128 #define DPS_LO_IEEE 129 #define DPS_HI_NATIVE 130 #define DPS_LO_NATIVE 131 #ifndef DPS_DEF_TOKENTYPE #ifdef __BIG_ENDIAN__ #define DPS_DEF_TOKENTYPE DPS_HI_IEEE #else #define DPS_DEF_TOKENTYPE DPS_LO_IEEE #endif #endif /* DPS_DEF_TOKENTYPE is the specification code for the form of binary object sequences generated by PSWrap. The C code generated by pswrap references this name. DPS_DEF_TOKENTYPE is system-dependent. */ /* --- binary object sequence support --- */ /* Object attributes & types: Values for attributedTypes */ #define DPS_LITERAL 0 #define DPS_EXEC 0x080 /* Attribute masks */ #define DPS_NULL 0 #define DPS_INT 1 #define DPS_REAL 2 #define DPS_NAME 3 #define DPS_BOOL 4 #define DPS_STRING 5 #define DPS_IMMEDIATE 6 #define DPS_ARRAY 9 #define DPS_MARK 10 /* Type values */ /* Object sequence constants */ #define DPS_HEADER_SIZE 4 #define DPS_EXT_HEADER_SIZE 8 /*=== TYPES ===*/ typedef enum { dps_ascii, dps_binObjSeq, dps_encodedTokens } DPSProgramEncoding; /* Defines the 3 possible encodings of PostScript language programs. */ typedef enum { dps_indexed, dps_strings } DPSNameEncoding; /* Defines the 2 possible encodings for user names in the dps_binObjSeq and dps_encodedTokens forms of PostScript language programs. */ typedef enum { dps_tBoolean, dps_tChar, dps_tUChar, dps_tFloat, dps_tDouble, dps_tShort, dps_tUShort, dps_tInt, dps_tUInt, dps_tLong, dps_tULong } DPSDefinedType; /* Enumerates the C data types that can be used to describe wrap parameters. */ typedef enum { /* NeXT addition */ dps_machServer, /* a mach binary connection to a window server */ dps_fdServer, /* a socket binary connection to a window server */ dps_stream /* an ascii NXStream */ } DPSContextType; /* Enumerates the context types that we support. */ typedef struct { DPSDefinedType type; int count; char *value; } DPSResultsRec, *DPSResults; /* A DPSResultsRec defines one of the formal result args of a wrapped procedure. The 'type' field specifies the formal type of the return value. The 'count' field specifies the number of values expected (this supports array formals). The 'value' field points to the location of the first value; the storage beginning there must have room for count values of type. If 'count' == -1, then 'value' points to a scalar (single) result arg. */ typedef struct { int lastNameIndex; struct _t_DPSSpaceProcsRec const * procs; } DPSSpaceRec, *DPSSpace; /* A DPSSpaceRec provides a representation of a space. The DPSSpaceRec may be extended to include system-specific items. BEWARE an implementation of the DPS client library is also likely to extend the DPSSpaceRec to include implementation-dependent information in additional fields. */ typedef struct _t_DPSSpaceProcsRec { void (*DestroySpace)( DPSSpace space ); /* See DPSDestroySpace() in dpsclient.h */ } DPSSpaceProcsRec, *DPSSpaceProcs; /* The DPSSpaceProcsRec may be extended to include system-specific items */ typedef struct _t_DPSContextRec { char *priv; DPSSpace space; DPSProgramEncoding programEncoding; DPSNameEncoding nameEncoding; struct _t_DPSProcsRec const * procs; void (*textProc)(); void (*errorProc)(); DPSResults resultTable; unsigned int resultTableLength; struct _t_DPSContextRec *chainParent, *chainChild; DPSContextType type; /* NeXT addition - denotes type of context */ } DPSContextRec, *DPSContext; /* A DPSContextRec provides a representation of a context. The 'priv' field is provided for use by application code. It is initialized to NULL and is not touched thereafter by the client library implementation. The 'space' field is the space to which the context belongs. The 'programEncoding' and 'nameEncoding' fields describe the encodings preferred by the context (server). The values in these fields are established when the DPSContext is created and cannot be changed therafter. The 'procs' field points to a vector of procedures (in a DPSProcsRec) that implement the context operations. The 'textProc' and 'errorProc' are called by the client library implementation to dispose of ascii text and errors, respectively, that the PostScript interpreter produces. The 'resultTableLength' and 'resultTable' fields define the number, type and location of values expected back from the PostScript interpreter. They should be set up before writing any PostScript language that may return values. The chainParent field is non-NIL if this context automatically receives a copy of any PostScript language sent to the referenced (parent) context. The chainChild field is non-NIL if this context automatically sends a copy of any PostScript language it receives to the referenced (child) context. The type field is used by the client library to tag different types of contexts. NOTE the client library implementation extends the DPSContextRec to include implementation-dependent information in additional fields. You may read the fields of a DPSContextRec directly, but you should never modify them directly. Use the macros provided for that purpose. */ typedef struct _t_DPSProcsRec { void (*BinObjSeqWrite)( DPSContext ctxt, const void *buf, unsigned int count ); /* Begin a new binary object sequence. 'buf' contains 'count' bytes of a binary object sequence. 'buf' must point to the beginning of a sequence, which includes at least the header and the entire top-level sequence of objects. It may also include subsidiary array elements and/or string chars. Writes PostScript language as specified by the encoding variables of ctxt, doing appropriate conversions as needed. 'buf' and its contents must remain valid until the entire binary object sequence has been sent. */ void (*WriteTypedObjectArray)( DPSContext ctxt, DPSDefinedType type, const void *array, unsigned int length ); /* 'array' points at an array of 'length' elements of 'type'. 'array' contains the element values for the body of a subsidiary array in a binary object sequence. Writes PostScript language as specified by the 4 format and encoding variables of ctxt, doing appropriate conversions as needed. 'array' and its contents must remain valid until the entire binary object sequence has been sent. */ void (*WriteStringChars)( DPSContext ctxt, const char *buf, unsigned int count ); /* Used both to implement DPSWritePostScript and to send the bodies of strings in binary object sequences. 'buf' contains 'count' bytes. For the latter, 'buf' and its contents must remain valid until the entire binary object sequence has been sent.*/ void (*WriteData)( DPSContext ctxt, const void *buf, unsigned int count ); /* See DPSWriteData() in dpsclient.h */ void (*WritePostScript)( DPSContext ctxt, const void *buf, unsigned int count ); /* See DPSWritePostScript() in dpsclient.h */ void (*FlushContext)( DPSContext ctxt ); /* See DPSFlushContext() in dpsclient.h */ void (*ResetContext)( DPSContext ctxt ); /* See DPSResetContext() in dpsclient.h */ void (*UpdateNameMap)( DPSContext ctxt ); /* This routine is called if the context's space's name map is out-of-sync with that of the client library's name map. It may send a series of "defineusername" commands to the service. */ void (*AwaitReturnValues)( DPSContext ctxt ); /* Called to receive return values. ctxt->resultTableLength and ctxt->resultTable must have been set previously. Returns when all expected results are received. This is normally called from wraps. It is unusual for an application program to call this directly. See the definitions of DPSResultsRec and DPSContextRec for more info. */ void (*Interrupt)( DPSContext ctxt ); /* See DPSInterrupt() in dpsclient.h */ void (*DestroyContext)( DPSContext ctxt ); /* See DPSDestroyContext() in dpsclient.h */ void (*WaitContext)( DPSContext ctxt ); /* See DPSWaitContext() in dpsclient.h */ void (*Printf)( DPSContext ctxt, const char *fmt, va_list argList ); /* See DPSPrintf() in dpsclient.h */ void (*WriteNumString)( DPSContext ctxt, DPSDefinedType type, const void *array, unsigned int count, int scale ); /* Translates the arguments into an homogenous number array encoded as a string and writes the string to the context. */ } DPSProcsRec, *DPSProcs; /* The DPSProcsRec may be extended to include system-specific items */ /* -- binary object sequence support -- */ #define DPSSYSNAME 0x0FFFF /* unsigned rep. of -1 */ typedef struct { unsigned char attributedType; unsigned char tag; unsigned short length; long int val; } DPSBinObjGeneric; /* boolean, int, string, name and array */ typedef struct { unsigned char attributedType; unsigned char tag; unsigned short length; float realVal; } DPSBinObjReal; /* float */ typedef struct { unsigned char attributedType; unsigned char tag; unsigned short length; union { long int integerVal; float realVal; long int nameVal; /* offset or index */ long int booleanVal; long int stringVal; /* offset */ long int arrayVal; /* offset */ } val; } DPSBinObjRec, *DPSBinObj; typedef struct { unsigned char tokenType; unsigned char nTopElements; unsigned short length; DPSBinObjRec objects[1]; } DPSBinObjSeqRec, *DPSBinObjSeq; typedef struct { unsigned char tokenType; unsigned char escape; /* zero if this is an extended sequence */ unsigned short nTopElements; unsigned long length; DPSBinObjRec objects[1]; } DPSExtendedBinObjSeqRec, *DPSExtendedBinObjSeq; /*=== PROCEDURES ===*/ #define DPSAwaitReturnValues(ctxt)\ (*(ctxt)->procs->AwaitReturnValues)((ctxt)) #define DPSUpdateNameMap(ctxt)\ (*(ctxt)->procs->UpdateNameMap)((ctxt)) #define DPSBinObjSeqWrite(ctxt, buf, count)\ (*(ctxt)->procs->BinObjSeqWrite)((ctxt), (buf), (count)) #define DPSPrivCurrentContext() (DPSGetCurrentContext()) extern void DPSSetContext( DPSContext ctxt ); /* Set the default context. Used in conjunction with psops.h and with wraps that are defined without an explicit DPSContext argument. */ extern DPSContext DPSGetCurrentContext(void); /* Get the default context. Used in conjunction with psops.h and with wraps that are defined without an explicit DPSContext argument. Initially NULL. */ #define DPSWriteStringChars(ctxt, buf, count)\ (*(ctxt)->procs->WriteStringChars)((ctxt), (buf), (count)) #define DPSWriteTypedObjectArray(ctxt, type, array, length)\ (*(ctxt)->procs->WriteTypedObjectArray)((ctxt), (type), (array), (length)) #define DPSSetResultTable(ctxt, tbl, len)\ (ctxt)->resultTable = (tbl);\ (ctxt)->resultTableLength = (len) /* Support for user names */ extern void DPSMapNames( DPSContext ctxt, unsigned int nNames, const char * const *names, long int * const *indices ); /* This routine assigns indices to the given user names. It is called once for each wrapped procedure. The parameters 'nNames' and 'names' define an array of strings which are the user names. The parameter 'indices' is an array of (int *) which are the locations in which to store the indices. The caller must ensure that the string pointers remain valid after the return. As a storage optimization, DPSMapNames will interpret a NIL value in the names array as the previous valid string in the name array. Effectively, if names[n] == NIL, DPSMapNames will decrement n until names[] is non-NIL and use that string. names[0] must be non-NIL. */ extern const char *DPSNameFromIndex( int index ); /* This routine returns the text for the user name with the given index. The string returned is owned by the library (treat it as readonly). */ #define DPSWriteNumString(ctxt, type, array, count, scale)\ (*(ctxt)->procs->WriteNumString)((ctxt), (type), (array), (count), (scale)) #endif
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.