/*	@(#)msg.h	13.1 (RC International) 91/02/02	*/

#ifndef _MSG_H
#define _MSG_H

/*
**	IPC Message Facility.
*/

/*
**	Permission Definitions.
*/

#define	MSG_R	0400	/* read permission */
#define	MSG_W	0200	/* write permission */

/*
**	Message Operation Flags.
*/

#define	MSG_NOERROR	010000	/* no error if big message */

/*
**	Structure Definitions.
*/

/*
**	There is one msg queue id data structure for each q in the system.
*/

struct msqid_ds {
	struct ipc_perm	msg_perm;	/* operation permission struct */
	int		msg_cbytes;	/* current # bytes on q */
	int		msg_qnum;	/* # of messages on q */
	int		msg_qbytes;	/* max # of bytes on q */
	pid_t		msg_lspid;	/* pid of last msgsnd */
	pid_t		msg_lrpid;	/* pid of last msgrcv */
	time_t		msg_stime;	/* last msgsnd time */
	time_t		msg_rtime;	/* last msgrcv time */
	time_t		msg_ctime;	/* last change time */
};

/*
**	User message buffer template for msgsnd and msgrecv system calls.
*/

struct msgbuf {
	long	mtype;		/* message type */
	char	mtext[1];	/* message text */
};

#if defined(__STDC__)

int msgctl(int, int, ...);
int msgget(key_t, int);
int msgrcv(int, void *, size_t, long, int);
int msgsnd(int, void *, size_t, int);

#else /* Not __STDC__ */

int	msgctl(), msgget(), msgrcv(), msgsnd();

#endif /* __STDC__ */

#endif /* _MSG_H */
