home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / AppKit.framework / Versions / B / Headers / dpsclient.h < prev    next >
Text File  |  1996-10-17  |  11KB  |  296 lines

  1.  
  2. /*
  3.   dpsclient.h
  4.     Application interface to the Display PostScript Library.
  5.  
  6.   This header file is intended to be identical across all
  7.   implementations of the Display PostScript System. It defines types
  8.   and procedures needed by DPS applications to access DPS. It does not
  9.   include operations for creating new DPSContexts.
  10.  
  11.   Copyright (c) 1988 Adobe Systems Incorporated.
  12.   All rights reserved.
  13.   
  14. */
  15.  
  16. #ifndef DPSCLIENT_H
  17. #define DPSCLIENT_H
  18.  
  19. #import <AppKit/dpsfriends.h>
  20. #import <AppKit/AppKitDefines.h>
  21.  
  22. /*=== TYPES ===*/
  23.  
  24. /* Standard error codes (type DPSErrorCode)
  25.  * These are intended to be used with dpsexcept.h
  26.  * System-specific extensions can be made. Codes 1000 through 1099 are
  27.  * reserved for use by Adobe.
  28.  *
  29.  * Codes 1100-1999 are reserved by NeXT.
  30.  */
  31.  
  32. #define DPS_ERROR_BASE        1000
  33. #define DPS_OPENSTEP_ERROR_BASE    1100
  34.  
  35. typedef enum _DPSErrorCode {
  36.     dps_err_ps = DPS_ERROR_BASE,
  37.     dps_err_nameTooLong,
  38.     dps_err_resultTagCheck,
  39.     dps_err_resultTypeCheck,
  40.     dps_err_invalidContext,
  41.     dps_err_select = DPS_OPENSTEP_ERROR_BASE,
  42.     dps_err_connectionClosed,
  43.     dps_err_read,
  44.     dps_err_write,
  45.     dps_err_invalidFD,
  46.     dps_err_invalidTE,
  47.     dps_err_invalidPort,
  48.     dps_err_outOfMemory,
  49.     dps_err_cantConnect
  50. } DPSErrorCode;
  51.  
  52.   /* The above definitions specify the error codes passed to a DPSErrorProc:
  53.  
  54.        dps_err_ps identifies standard PostScript language interpreter
  55.        errors. The arg1 argument to the errorProc is the address of the
  56.        binary object sequence sent by the handleerror (or resynchandleerror)
  57.        operator to report the error. The sequence has 1 object, which is an
  58.        array of 4 objects. See the language extensions document for details
  59.        on the contents of this sequence. arg2 is the number of bytes in the
  60.        entire binary object sequence.
  61.  
  62.        dps_err_nameTooLong flags user names that are too long. 128 chars
  63.        is the maximum length for PostScript language names. The name and its
  64.        length are passed as arg1 and arg2 to the error proc.
  65.  
  66.        dps_err_resultTagCheck flags erroneous result tags, most likely
  67.        due to erroneous explicit use of the printobject operator. The
  68.        pointer to the binary object sequence and its length are passed
  69.        as arg1 and arg2 to the error proc. There is one object in the
  70.        sequence.
  71.  
  72.        dps_err_resultTypeCheck flags incompatible result types. A pointer
  73.        to the offending binary object is passed as arg1; arg2 is unused.
  74.  
  75.        dps_err_invalidContext flags an invalid DPSContext argument. An
  76.        attempt to send PostScript language code to a context that has
  77.        terminated is the most likely cause of this error. arg1 to the
  78.        DPSErrorProc is the context id (see the fork operator); arg2 is
  79.        unused.
  80.  
  81.        dps_err_select, dps_err_read and dps_err_write signal communication
  82.        errors in the connection.  The OS return code is passed in arg1;
  83.        arg2 is unused.
  84.  
  85.        dps_err_connectionClosed indicates the connection to a windowserver
  86.        went away.  arg1 and arg2 are unused.
  87.  
  88.        dps_err_invalidFD, dps_err_invalidTE and dps_err_invalidPort 
  89.        indicate a illegal item of the given type was passed to a DPS
  90.        routine.  The illegal item is passed in arg1; arg2 is unused.
  91.  
  92.        dps_err_outOfMemory indicates a storage allocation failure.  The size
  93.        of the block requested is passed in arg1; arg2 is unused.
  94.  
  95.        dps_err_cantConnect signals an error during the creation of a
  96.        connection to a window server.  The host that was being connected
  97.        to is passed in arg1; arg2 is unused. 
  98.   */
  99.  
  100. typedef void (*DPSTextProc)(
  101.   DPSContext ctxt,
  102.   const char *buf,
  103.   long unsigned int count );
  104.  
  105.   /* Call-back procedure to handle text from the PostScript interpreter.
  106.      'buf' contains 'count' bytes of ASCII text. */
  107.  
  108. typedef void (*DPSErrorProc)(
  109.   DPSContext ctxt,
  110.   DPSErrorCode errorCode,
  111.   long unsigned int arg1, 
  112.   long unsigned int arg2 );
  113.   
  114.   /* Call-back procedure to report errors from the PostScript interpreter.
  115.      The meaning of arg1 and arg2 depend on 'errorCode', as described above.
  116.      See DPSDefaultErrorProc, below.
  117.    */
  118.  
  119.  
  120. /*=== PROCEDURES ===*/
  121.  
  122. APPKIT_EXTERN void DPSDefaultErrorProc(
  123.   DPSContext ctxt,
  124.   DPSErrorCode errorCode,
  125.   long unsigned int arg1,
  126.   long unsigned int arg2 );
  127.   
  128.   /* This is the default error proc that is used for both contexts'
  129.      individual errors and the global error backstop.  It raises an
  130.      exception using NS_RAISE.  For all DPS errors, the context is the
  131.      first piece of data put in the NSHandler record.  The second
  132.      data field is value passed to this routine in arg1.
  133.      */
  134.  
  135. APPKIT_EXTERN void DPSSetTextBackstop( DPSTextProc textProc );
  136.  
  137.   /* Call this to establish textProc as the handler for text output from
  138.      DPSDefaultErrorProc or from contexts created by the 'fork' operator but
  139.      not made known to the dps client library. NULL will be passed as the ctxt
  140.      argument to textProc in the latter case. */
  141.  
  142. APPKIT_EXTERN DPSTextProc DPSGetCurrentTextBackstop(void);
  143.  
  144.   /* Returns the textProc passed most recently to DPSSetTextBackstop, or NULL
  145.      if none */
  146.  
  147. APPKIT_EXTERN void DPSSetErrorBackstop( DPSErrorProc errorProc );
  148.  
  149.   /* Call this to establish errorProc as the handler for PostScript interpreter
  150.      errors from contexts created by the 'fork' operator but not made
  151.      known to the dps client library. NULL will be passed as the ctxt
  152.      argument to errorProc. */
  153.  
  154. APPKIT_EXTERN DPSErrorProc DPSGetCurrentErrorBackstop(void);
  155.  
  156.   /* Returns the errorProc passed most recently to DPSSetErrorBackstop, or NULL
  157.      if none */
  158.  
  159. #define DPSWritePostScript(ctxt, buf, count)\
  160.   (*(ctxt)->procs->WritePostScript)((ctxt), (buf), (count))
  161.  
  162.   /* Send as input to 'ctxt' 'count' bytes of PostScript language contained
  163.      in 'buf'. The code may be in either of the 3 encodings for PostScript
  164.      language programs: plain text, encoded tokens, or binary object sequence.
  165.      If the form is encoded tokens or binary object sequence, an entire
  166.      one of these must be sent (perhaps in a series of calls on
  167.      DPSWritePostScript) before PostScript language in a different encoding
  168.      can be sent.
  169.      
  170.      DPSWritePostScript may transform the PostScript language to a different
  171.      encoding, depending on the characteristics established for 'ctxt' when
  172.      it was created. For example, a context created to store its PostScript
  173.      in an ASCII file would convert binary object sequences to ASCII.
  174.  
  175.      If 'ctxt' represents an invalid context, for example because
  176.      the context has terminated in the server, the dps_err_invalidContext
  177.      error will be reported via ctxt's error proc.
  178.      
  179.      If 'ctxt' is incapable of accepting more PostScript language, for example
  180.      because it is backlogged with code that was sent earlier to be executed,
  181.      this will block until transmission of 'count' bytes can be completed. */
  182.  
  183. APPKIT_EXTERN void DPSPrintf( DPSContext ctxt, const char *fmt, ... );
  184.  
  185.   /* Write string 'fmt' to ctxt with the optional arguments converted,
  186.      formatted and logically inserted into the string in a manner
  187.      identical to the C library routine printf.
  188.  
  189.      If 'ctxt' represents an invalid context, for example because
  190.      the context has terminated in the server, the dps_err_invalidContext
  191.      error will be reported via ctxt's error proc.
  192.      
  193.      If 'ctxt' is incapable of accepting more PostScript language, for example
  194.      because it is backlogged with code that was sent earlier to be executed,
  195.      this will block until transmission of the string can be completed. */
  196.  
  197. #define DPSWriteData(ctxt, buf, count)\
  198.   (*(ctxt)->procs->WriteData)((ctxt), (buf), (count))
  199.   
  200.   /* Write 'count' bytes of data from 'buf' to 'ctxt'. This will not
  201.      change the data.
  202.  
  203.      If 'ctxt' represents an invalid context, for example because
  204.      the context has terminated in the server, the dps_err_invalidContext
  205.      error will be reported via ctxt's error proc.
  206.      
  207.      If 'ctxt' is incapable of accepting more PostScript language, for example
  208.      because it is backlogged with code that was sent earlier to be executed,
  209.      this will block until transmission of 'count' bytes can be completed. */
  210.   
  211. #define DPSFlushContext(ctxt) (*(ctxt)->procs->FlushContext)((ctxt))
  212.   
  213.   /* Force any buffered data to be sent to ctxt.
  214.  
  215.      If 'ctxt' represents an invalid context, for example because
  216.      the context has terminated in the server, the dps_err_invalidContext
  217.      error will be reported via ctxt's error proc.
  218.      
  219.      If 'ctxt' is incapable of accepting more PostScript language, for example
  220.      because it is backlogged with code that was sent earlier to be executed,
  221.      this will block until transmission of all buffered bytes can be completed.
  222.      */
  223.   
  224. APPKIT_EXTERN int DPSChainContext( DPSContext parent, DPSContext child );
  225.  
  226.   /* This links child and all of child's children onto parent's 'chainChild'
  227.      list. The 'chainChild' list threads those contexts that automatically
  228.      receive copies of any PostScript code sent to parent. A context may
  229.      appear on only one such list.
  230.      
  231.      Normally, DPSChainContext returns 0. It returns -1 if child already
  232.      appears on some other context's 'chainChild' list. */
  233.  
  234. APPKIT_EXTERN void DPSUnchainContext( DPSContext ctxt );
  235.  
  236.   /* This unlinks ctxt from the chain that it is on, if any. It leaves
  237.     ctxt->chainParent == ctxt->chainChild == NULL
  238.    */
  239.  
  240. #define DPSResetContext(ctxt) (*(ctxt)->procs->ResetContext)((ctxt))
  241.   
  242.   /* This routine is unimplemented in the NeXT implementation of
  243.      Display PostScript.  See the documentation. */
  244.   
  245. #define DPSWaitContext(ctxt) (*(ctxt)->procs->WaitContext)(ctxt)
  246.  
  247.   /* Waits until the PostScript interpreter is ready for more input to
  248.      this context.  This is useful for synchronizing an application
  249.      with the DPS server.
  250.  
  251.      If 'ctxt' represents an invalid context, for example because
  252.      the context has terminated in the server, the dps_err_invalidContext
  253.      error will be reported via ctxt's error proc. */
  254.  
  255. #define DPSSetTextProc(ctxt, tp) ((ctxt)->textProc = (tp))
  256.  
  257.   /* Change ctxt's textProc. */
  258.   
  259. #define DPSSetErrorProc(ctxt, ep) ((ctxt)->errorProc = (ep))
  260.  
  261.   /* Change ctxt's errorProc. */
  262.   
  263. #define DPSInterruptContext(ctxt) (*(ctxt)->procs->Interrupt)((ctxt))
  264.  
  265.   /* This routine is unimplemented in the NeXT implementation of
  266.      Display PostScript. */
  267.  
  268. #define DPSDestroyContext(ctxt) (*(ctxt)->procs->DestroyContext)((ctxt))
  269.  
  270.   /* This calls DPSUnchainContext, then (for an interpreter context) sends a
  271.      request to the interpreter to terminate ctxt, then frees the storage
  272.      referenced by ctxt. The termination request is ignored by the
  273.      server if the context is invalid, for example if it has already
  274.      terminated. */
  275.   
  276. #define DPSSpaceFromContext(ctxt) ((ctxt)->space)
  277.  
  278.   /* Extract space handle from context. */
  279.  
  280. #define DPSDestroySpace(spc) (*(spc)->procs->DestroySpace)((spc))
  281.  
  282.   /* Calls DPSDestroyContext for each of the contexts in the space, then
  283.      sends a request to the server to terminate the space, then frees the
  284.      storage referenced by spc. */
  285.  
  286. APPKIT_EXTERN int DPSSetWrapSynchronization(DPSContext ctxt, int flag);
  287.  
  288.   /* Causes a DPSWaitContext to be done after each wrap.  Used during
  289.      debugging to isolate the cause of PS errors. */
  290.  
  291.  
  292. #import <AppKit/dpsOpenStep.h>
  293.  
  294. #endif DPSCLIENT_H
  295.  
  296.