#ifndef XM_QUEUE_H_
/*
                   +--------------------------------+
                   | THIS FILE MUST MATCH queue.inc |
                   +--------------------------------+

  Include files for lower level routines using the message queue, contains
  structure definitions and mask bits for modifying message GETs and SENDs

  Author:  based on X-Midas queue.idl,v 1.1.1.1 2003/03/20 19:58:49 hawk
  Version: $Id: queue.h,v 1.1 2009/08/11 00:25:53 ntn Exp $
*/

/*
  M$MSGFUNC() argument definitions
*/

#include "cdefs.h"
#include "fcinterface.h"

#define MSGF_INIT 1
#define MSGF_QUEUED 2
#define MSGF_INPTR 3
#define MSGF_OUTPTR 4
#define MSGF_MAP 5
#define MSGF_READERS 6
#define MSGF_BCREADERS 7

/*
  M$GET_MSG and M$SEND_MSG mask values by bit number
*/

#define MQB_SENDER 1
#define MQB_READER 2
#define MQB_NAME 3
#define MQB_MODE 4
#define MQB_ANYREADER 5
#define MQB_LAST 6
#define MQB_CLEAR 7
#define MQB_NOWARN 8
#define MQB_TOP 9
#define MQB_PEEK 10
#define MQB_KEEP 11
#define MQB_ADVANCE 12
#define MQB_NOLOCK 13
#define MQB_UPDATE 14

/*
  M$GET_MSG and M$SEND_MSG mask values (use +)
*/

#define MQK_SENDER 2
#define MQK_READER 4
#define MQK_NAME 8
#define MQK_MODE 16
#define MQK_ANYREADER 32
#define MQK_LAST 64
#define MQK_CLEAR 128
#define MQK_NOWARN 256
#define MQK_TOP 512
#define MQK_PEEK 1024
#define MQK_KEEP 2048
#define MQK_ADVANCE 4096
#define MQK_NOLOCK 8192
#define MQK_UPDATE 16384

#define BYTES_PER_SLOT 8
#define SLOTS_PER_HOM_MQH 4
#define SLOTS_PER_HET_MQH 15
#define MAX_MESSAGE_ID 4095
#define MAX_BROADCAST_ID 127
#define SLOTS_PER_BROADCAST 2

typedef struct {
  int_4 reader;        /* who's the msg to ? */
  int_2 nslots;        /* total # slots in the msg */
  char type;           /* msg type (A,D,F,L,I,B or H) */
  int_1 nhslots;       /* # slots in just the header */
} MQ_QUEUESLOT;

typedef struct {
  int_4 reader;        /* who the message is to */
  int_2 nslots;        /* msg to id, # slots for entire msg */
  char type;           /* message type */
  int_1 nhslots;       /* # slots for msg header only */
  int_4 sender;        /* who the message is for */
  int_4 ndata;         /* # data values */
  int_4 info;          /* extra mesg data, mode field */
  int_4 mode;          /* extra mesg data, mode field */
  FSTRING(name, 8);    /* message name string */
  int_2 ntype;         /* length of types string */
  FSTRING(types, 86);  /* non-homogeneous types string */
} MQ_HEADER;

#ifndef __cplusplus
/* For backwards compatibility with C interface */
typedef MQ_HEADER mq_HEADER;
#endif

#define XM_QUEUE_H_
#endif /* XM_QUEUE_H_ */
