
/*
**
**  Opticks frame buffer PORT interface example.
**  CopyRight 1989 (c) by Brian Reed
**
**  This is a sample program to gain access to the MESSAGE PORTS
**  in Opticks.  This message port signals the PORT of a user selection
**  of 'EXTERNAL TRIGGER' in the DISPlay program.
**
*/

/*  MANX make's
 ----->  cc +l -s p.c
 ----->  ln p.o m32.lib c32.lib
*/


#include <exec/types.h>
#include <exec/ports.h>
#include <intuition/intuition.h>
#include <stdio.h>

/*  This is the OPTICKS end-of-line MESSAGE struct.  */
struct Disp_v1 {
  struct Message message;  /*  Intuition MESSAGE            */
  struct Screen *scr;      /*  Intuition screen pointer     */
  struct Window *wnd;      /*  Intuition window pointer     */
  ULONG size_x;            /*  Size of image in X           */
  ULONG size_y;            /*    and in Y                   */
  ULONG reserved1;         /*  future use                   */
  ULONG reserved2;         /*  future use                   */
  TEXT  *name;             /*  Pointer to ASCII image name  */
};

struct MsgPort *mp, *WaitPort(), *GetMsg();


main()
{
struct Message *msg=0;

  /*  Make a 'PORT'.  */
  if ( (mp=CreatePort("OPTICKS_Disp_v1", 0)) == NULL) {
    printf("Couldn't open port\n");
    exit(0);
  }

  printf("Port Waiting.....\n");

  /*  Wait for a message.  */
  msg = WaitPort(mp);
  msg = GetMsg(mp);




  /*                                                             */
  /*  PUT YOUR OWN CODE HERE !!!!                                */
  /*  Message data extracted here !                              */
  /*                                                             */
    printf("** OPTICKS_Disp_v1 MSG **   (RECEIVED...)\n");
    printf("Size %u %u -*- Scr Wnd %d %d\n",
      msg->size_x, msg->size_y, msg->scr, msg->wnd);
    printf("name = %s\n", msg->name);




  /*  Let 'R' program know we are done with message. OK to continue.  */
  ReplyMsg(msg);

  if (mp) {
    while (msg = GetMsg(mp))  /*  Eat up extra's for clean exit!  */
      ReplyMsg(msg);
    RemPort(mp);              /* Remove PORT.  */
  }
}

