File:  [MW Coherent from dump] / coherent / b / lib / libc / sys / i8086 / msgop.c,v
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

head     1.3;
access   ;
symbols  ;
locks    bin:1.3;
comment  @ * @;


1.3
date     91.06.03.21.46.56;  author bin;  state Exp;
branches ;
next	1.2;

1.2
date     91.05.30.00.06.23;  author bin;  state Exp;
branches ;
next	1.1;

1.1
date     91.05.29.23.57.18;  author bin;  state Exp;
branches ;
next	;


desc
@steve 5/29/91
Initial MWC RCS revision.
@


1.3
log
@steve 6/3/91
Corrected bug introduced by last source revision: key is 4 bytes, not 2.
@
text
@/*
 * libc/sys/msgop.c
 * User Message Functions.
 * Note: msgget() must be first function called.
 */

#include <sys/msg.h>
#include <errno.h>

static int  msgfno   = -1;
static char msgdev[] = "/dev/msg";

/*
 * Message Control Operations.
 */
msgctl(msqid, cmd, buf) int msqid, cmd; struct msqid_ds * buf;
{
	int parm[4];

	if (msgfno < 0) {
		errno = ENODEV;
		return -1;
	}

	parm[0] = -1;
	parm[1] = msqid;
	parm[2] = cmd;
	parm[3] = (int) buf;

	ioctl(msgfno, MSGCTL, parm);
	return parm[0];
}

/*
 * Get Message Queue.
 */
msgget(key, msgflg) key_t key; int msgflg;
{
	int parm[4];

	if (msgfno < 0) {
		if ((msgfno = open(msgdev, 0)) < 0) {
			perror(msgdev);
			errno = ENODEV;
			return -1;
		}
	}

	parm[0] = -1;
	parm[1] = key;
	parm[2] = key >> 16;
	parm[3] = msgflg;

	ioctl(msgfno, MSGGET, parm);
	return parm[0];
}

/*
 * Send Message.
 */
msgsnd(msqid, msgp, msgsz, msgflg) int msqid; struct msgbuf *msgp; int msgsz, msgflg;
{
	int parm[5];

	if (msgfno < 0) {
		errno = ENODEV;
		return -1;
	}

	parm[0] = -1;
	parm[1] = msqid;
	parm[2] = (int) msgp;
	parm[3] = msgsz;
	parm[4] = msgflg;

	ioctl(msgfno, MSGSND, parm);
	return parm[0];
}

/*
 * Receive Message.
 */
msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)
int msqid; struct msgbuf *msgp; int msgsz; long msgtyp; int msgflg;
{
	int parm[7];

	if (msgfno < 0) {
		errno = ENODEV;
		return -1;
	}

	parm[0] = -1;
	parm[1] = msqid;
	parm[2] = (int) msgp;
	parm[3] = msgsz;
	parm[4] = (int) msgtyp;
	parm[5] = (int) (msgtyp >> 16);
	parm[6] = msgflg;

	ioctl(msgfno, MSGRCV, parm);
	return parm[0];
}

/* end of msgop.c */
@


1.2
log
@steve 5/29/91
Added changes from hal.
Nonsubstantive changes to whitespace.
@
text
@d6 1
a6 1
 
d39 1
a39 1
	int parm[3];
d51 2
a52 1
	parm[2] = msgflg;
d61 1
a61 2
msgsnd(msqid, msgp, msgsz, msgflg)
int msqid; struct msgbuf *msgp; int msgsz, msgflg;
@


1.1
log
@Initial revision
@
text
@d2 1
d4 1
a4 5
 *
 *	Note: msgget() must be first function called.
 *
 *	91/02/07	Hal Snyder	mwchwc!/u/libc/sys/msgop.c
 *	msgget():  sizeof(key_t) is 4, not 2.
d6 1
d16 1
a16 7

msgctl( msqid, cmd, buf )

int msqid;
int cmd;
struct msqid_ds * buf;

d20 1
a20 1
	if ( msgfno < 0 ) {
d30 1
a30 1
	ioctl( msgfno, MSGCTL, parm );
d37 3
d41 2
a42 13
msgget( key, msgflg )

key_t key;
int msgflg;

{
	int parm[4];

	if ( msgfno < 0 ) {

		msgfno = open(msgdev, 0);

		if ( msgfno < 0 ) {
d51 1
a51 2
	parm[2] = key >> 16;
	parm[3] = msgflg;
d53 1
a53 1
	ioctl( msgfno, MSGGET, parm );
d60 2
a61 8
 
msgsnd( msqid, msgp, msgsz, msgflg )

int msqid;
struct msgbuf *msgp;
int msgsz;
int msgflg;

d65 1
a65 1
	if ( msgfno < 0 ) {
d76 1
a76 1
	ioctl( msgfno, MSGSND, parm );
d83 2
a84 9
 
msgrcv( msqid, msgp, msgsz, msgtyp, msgflg )

int msqid;
struct msgbuf *msgp;
int msgsz;
long msgtyp;
int msgflg;

d88 1
a88 1
	if ( msgfno < 0 ) {
d101 1
a101 1
	ioctl( msgfno, MSGRCV, parm );
d104 2
@

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.