From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 18-SEP-1992 01:57:34.32
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: Q: VMS mailboxes and XtAppAddInput... (Short one)



To get XtAddInput to work on the VMS side do the following:

read through the qio stuff on the vms books...  

then do this:

add this to the file that will use pipe and xtaddinput...

#ifdef VMS

#  include <stdlib.h>
#  include <unixio.h>
#  include <iodef.h>
#  include <descrip.h>

extern sys$clref();

  static short     IOSB[4];
  static           int event;
  char             szIOBuffer[4096]; /* this is the current size of the io
                                        buffer allocated in the caller*/
  static           int channel;
  unsigned long   _status;
#endif

note, the caller should (on VMS), if using a pipe, specify the size of the pipe, 
see the documentation...

in the routine that performs the xtaddinput, add:

#ifdef VMS
  struct   dsc$descriptor_s MBox;
  char     szMBox[256];
#endif

then...

#ifdef VMS
  event = 3;
  getname( event, szMBox );

/*  printf( "Using MailBox %s\n", szMBox );*/

  MBox.dsc$w_length  = strlen( szMBox );
  MBox.dsc$b_dtype   = DSC$K_DTYPE_T;
  MBox.dsc$b_class   = DSC$K_CLASS_S;
  MBox.dsc$a_pointer = szMBox;

  _status = sys$assign( &MBox, &channel, 0, &MBox, 0 );
  if( _status != 1 ) ReportError( _status );

  /*Allocate an event flag.  Use flags only from cluster 0 */

  _status = sys$clref(event);
  if( _status != 1 ) ReportError( _status );

  /* register asynchronous completion routine */

  XtAddInput( event, IOSB, _MsgCallback, &Msg );

  _status = sys$qio( event, channel, IO$_READVBLK, &IOSB, 0, 0,
          &szIOBuffer, sizeof( szIOBuffer ), 0, 0, 0, 0);

  if( _status != 1 ) ReportError( _status );

#else

  XtAddInput(3, XtInputReadMask, _MsgCallback, &Msg);

#endif

next, in _MsgCallback (see XtAddInput above)

#ifdef VMS
  if( IOSB[1] == 0 )
    {
      *pfEof = TRUE;
      fSuccess = TRUE;
      goto end;
    }

  szIOBuffer[IOSB[1]] = 0;

/* out message has 2 bytes of size, then the message, the total size is
** duplicated in IOSB[1]..  be sure to COPY that message
*/

  pMsg->usCurSize = IOSB[1] - 2;
  memcpy( pMsg->pch, &szIOBuffer[2], pMsg->usCurSize );

  fSuccess = TRUE;

  _status = sys$qio( event, channel, IO$_READVBLK, &IOSB, 0, 0,
                     &szIOBuffer, sizeof( szIOBuffer ), 0, 0, 0, 0);

  if( _status != 1 ) ReportError( _status );

  goto end;
#endif



--
+-----------------------------------------------------------------------------+
+ Dave Marra                            X           TMF Engineering           +
+ Software Validation Suites            X          37  Carlene Drive          +
+ X Window System / Motif / VMS         X        Nashua, NH 03062-1480        +
+-----------------------------------------------------------------------------+
+     Currently working at Digital Equipment Corporation, Littleton, MA       +
+-----------------------------------------------------------------------------+

