#ifndef _CH_SYS_MSG_H_
#define _CH_SYS_MSG_H_

#include <sys/types.h>

typedef   unsigned long   msglen_t;
typedef   unsigned long   msgqnum_t;

/* msgrcv options */
#define MSG_NOERROR     010000          /* don't complain about too long msgs */

struct msqid_ds {
        struct  ipc_perm msg_perm;      /* msg queue permission bits */
        struct  msg *msg_first; /* first message in the queue */
        struct  msg *msg_last;  /* last message in the queue */
        msglen_t msg_cbytes;    /* number of bytes in use on the queue */
        msgqnum_t msg_qnum;     /* number of msgs in the queue */
        msglen_t msg_qbytes;    /* max # of bytes on the queue */
        pid_t   msg_lspid;      /* pid of last msgsnd() */
        pid_t   msg_lrpid;      /* pid of last msgrcv() */
        time_t  msg_stime;      /* time of last msgsnd() */
        long    msg_pad1;
        time_t  msg_rtime;      /* time of last msgrcv() */
        long    msg_pad2;
        time_t  msg_ctime;      /* time of last msgctl() */
        long    msg_pad3;
        long    msg_pad4[4];
};

/*
 * Structure describing a message.  The SVID doesn't suggest any
 * particular name for this structure.  There is a reference in the
 * msgop man page that reads "The structure mymsg is an example of what
 * this user defined buffer might look like, and includes the following
 * members:".  This sentence is followed by two lines equivalent
 * to the mtype and mtext field declarations below.  It isn't clear
 * if "mymsg" refers to the name of the structure type or the name of an
 * instance of the structure...
 */
struct mymsg {
        long    mtype;          /* message type (+ve integer) */
        char    mtext[1];       /* message body */
};

#endif
