home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 355.lha / post_v1.0 / postmsg.h < prev   
Encoding:
C/C++ Source or Header  |  1990-03-06  |  7.3 KB  |  171 lines

  1. /* PostScript interpreter file "postmsg.h" - message header file (Amiga)
  2.  * (C) Adrian Aylward 1989, 1990.  Version 1.0
  3.  *
  4.  * You may freely copy and use this file.  It was written for Lattice C
  5.  * V5.04.
  6.  *
  7.  * This file defines the message interface, so that other programs can
  8.  * use the PostScript drawing machinery.  It is totally Amiga specific.
  9.  *
  10.  * To use the message interface to Post you first set up a named message
  11.  * port.  Then run Post using the MESSAGEPORT option to specify the name
  12.  * of the port you want it to accept commands from.  If Post loads
  13.  * successfully, it will send a message action PSACTOPEN, passing the
  14.  * address of its bitmap structure.  It then executes its startup file(s).
  15.  * If they all execute without error it sends PSACTCOMMAND to request a
  16.  * command.  If there is an error during startup it sends PSACTEXIT
  17.  * instead; you should reply with PSCOMQUIT.
  18.  *
  19.  * Whenever Post is ready to receive another command it sends PSACTCOMMAND.
  20.  * You can reply with one of the following:
  21.  *
  22.  *     PSCOMQUIT     Quit
  23.  *     PSCOMRESTART  Restart - reinitialise and rerun startup file(s)
  24.  *     PSCOMFILEL    Load a file
  25.  *     PSCOMFILER    Run a file
  26.  *     PSCOMSTRING   Execute a string
  27.  *
  28.  * (The other commands are for internal use).
  29.  *
  30.  * File names are null terminated strings.  Strings to be executed may be
  31.  * null terminated, in which case you should set the length to -1, or may
  32.  * have an explicit length.  You must not free the memory until the command
  33.  * has finished; i.e. when you get the next PSACTCOMMAND message.
  34.  *
  35.  * There are two other messages that Post sends:
  36.  *
  37.  *     PSACTFLUSH    Flush out the bitmap, rows y1 ... y2 - 1
  38.  *     PSACTPAUSE    Pause at the end of a page
  39.  *
  40.  * These may be sent any time Post is executing a startup file or command.
  41.  * The command field of the reply is ignored.
  42.  *
  43.  * Not all the command line options are useful in conjunction with
  44.  * MESSAGEPORT.  The INTERACTIVE option is ignored.  The SCREEN option will
  45.  * cause the page buffer (i.e. bitmap) to be allocated from chip memory
  46.  * rather than fast memory.  You advised to set the page size explicitly
  47.  * instead of depending upon the defaults.
  48.  *
  49.  * You can either flush the bitmap into your own buffer whenever you receive
  50.  * a PSACTFLUSH, or you can read/write it directly at any time.  Post does
  51.  * not read the bitmap, nor does it write to it except to OR in or AND out
  52.  * the bits that is drawing, so you can safely update the bitmap using your
  53.  * own rendering routines.
  54.  *
  55.  * The default is for Post to allocate and initialise its own bitmap.  If
  56.  * you prefer you can supply you own, using the USERBITMAP option.  Then
  57.  * the PSACTOPEN message will supply a bitmap in which all fields but the
  58.  * bit planes are initialised; you can must in the bit planes, or if you
  59.  * prefer just change the pointer in the message to the address of your own
  60.  * bitmap - which must be at least as large as the one initialised by Post.
  61.  * It is your responsibility to zero the bit planes.  You must not free them
  62.  * until after receiving PSACTCLOSE.  Should you fail to allocate the
  63.  * memory, set the result field in the PSACTOPEN message to a non-zero
  64.  * value; this will cause Post to exit with an error.
  65.  *
  66.  * In each message sent by Post the result field is set to the current value
  67.  * of the return code; to zero if everything is OK, 10 if an interpreter
  68.  * error occurs, or 20 if an error occurs during program initialisation.
  69.  * When the reply is received, the return code is reset to the value in the
  70.  * reply.  The errnum field is set to the internal error number of the last
  71.  * interpreter error.
  72.  *
  73.  * The message structure bears a certain resemblance to an IDCMP message,
  74.  * and can easily be processed by the same handler task.  It can be
  75.  * distinguished from an IntuiMessage both by the class field being zero,
  76.  * and by the window field being zero.  Post uses only a single PSMessage
  77.  * structure, so its messages can also be identified by checking their
  78.  * addresses.
  79.  *
  80.  * When launching Post you can use either a CLI or a WorkBench style
  81.  * startup.  The CLI startup has standard input and output streams, which
  82.  * you can redirect.  But the standard error always goes to the default
  83.  * window, as Open'ed by "*".  The WorkBench startup has no standard streams,
  84.  * so error messages will not appear in the window, and the usual error
  85.  * requestors will be suppressed.  This may make it harder to work out what
  86.  * is happening if something goes wrong.  However, it has the advantage
  87.  * that the startup message is returned when the process exits, so if you
  88.  * get the message back before a PSACTOPEN, you know it has failed to load
  89.  * itself, and if you wait for PSACTOPEN you will wait forever.  In
  90.  * practice, by far the most likely cause of any problems is lack of memory,
  91.  * once you have checked that the required files (arp.library, ConMan device,
  92.  * and possibly init.ps) are present.
  93.  *
  94.  * Various applications of the message interface suggest themselves:
  95.  *
  96.  *     An ARexx message handler
  97.  *     An AmigaDOS PostScript device
  98.  *     Display Postscript, for use by drawing programs etc..
  99.  *
  100.  * An example of a simple message handler is distributed with the release,
  101.  * as the file "pmsg.c".
  102.  */
  103.  
  104. /* Message structure */
  105.  
  106. struct PSMessage
  107. {   struct Message ExecMessage;
  108.     long class;            /* Always zero */
  109.     short action;          /* Action - from Post to handler */
  110.     short command;         /* Command - from handler to Post */
  111.     struct BitMap *bitmap; /* The bitmap */
  112.     short y1, y2;          /* Min and max+1 y values to flush */
  113.     short result;          /* Result  (return code) */
  114.     short length;          /* Length of string */
  115.     char *string;          /* String */
  116.     long window;           /* Always zero */
  117.     short errnum;          /* Last error number */
  118.     short zero;            /* Reserved, presently always zero */
  119. };
  120.  
  121. /* Actions */
  122.  
  123. # define PSACTOPEN    1 /* Open */
  124. # define PSACTCLOSE   2 /* Close */
  125. # define PSACTFLUSH   3 /* Flush out the bitmap */
  126. # define PSACTPAUSE   4 /* Pause at the end of a page */
  127. # define PSACTCOMMAND 5 /* Get a command */
  128. # define PSACTEXIT    6 /* Exit */
  129.  
  130. /* Commands */
  131.  
  132. # define PSCOMQUIT    1 /* Quit */
  133. # define PSCOMRESTART 2 /* Restart */
  134. # define PSCOMFILEF   3 /* Load Font */
  135. # define PSCOMFILEL   4 /* Load File */
  136. # define PSCOMFILER   5 /* Run File */
  137. # define PSCOMINTER   6 /* Interactive */
  138. # define PSCOMSTRING  7 /* String */
  139.  
  140. /* Errors */
  141.  
  142. /*define errdictfull             1
  143.  *define errdictstackoverflow    2
  144.  *define errdictstackunderflow   3
  145.  *define errexecstackoverflow    4
  146.  *define errinterrupt            5
  147.  *define errinvalidaccess        6
  148.  *define errinvalidexit          7
  149.  *define errinvalidfileaccess    8
  150.  *define errinvalidfont          9
  151.  *define errinvalidrestore      10
  152.  *define errinvalidstop         11
  153.  *define errioerror             12
  154.  *define errlimitcheck          13
  155.  *define errnocurrentpoint      14
  156.  *define errrangecheck          15
  157.  *define errstackoverflow       16
  158.  *define errstackunderflow      17
  159.  *define errsyntaxerror         18
  160.  *define errtimeout             19
  161.  *define errtypecheck           20
  162.  *define errundefined           21
  163.  *define errundefinedfilename   22
  164.  *define errundefinedresult     23
  165.  *define errunmatchedmark       24
  166.  *define errunregistered        25
  167.  *define errVMerror             26
  168.  */
  169.  
  170. /* End of file "postmsg.h" */
  171.