Annotation of coherent/b/lib/libc/sys/msgop.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * libc/sys/msgop.c
                      3:  * User Message Functions.
                      4:  * Note: msgget() must be first function called.
                      5:  */
                      6: 
                      7: #include <sys/msg.h>
                      8: #include <errno.h>
                      9: 
                     10: static int  msgfno   = -1;
                     11: static char msgdev[] = "/dev/msg";
                     12: 
                     13: /*
                     14:  * Message Control Operations.
                     15:  */
                     16: msgctl(msqid, cmd, buf) int msqid, cmd; struct msqid_ds * buf;
                     17: {
                     18:        int parm[4];
                     19: 
                     20:        if (msgfno < 0) {
                     21:                errno = ENODEV;
                     22:                return -1;
                     23:        }
                     24: 
                     25:        parm[0] = -1;
                     26:        parm[1] = msqid;
                     27:        parm[2] = cmd;
                     28:        parm[3] = (int) buf;
                     29: 
                     30:        ioctl(msgfno, MSGCTL, parm);
                     31:        return parm[0];
                     32: }
                     33: 
                     34: /*
                     35:  * Get Message Queue.
                     36:  */
                     37: msgget(key, msgflg) key_t key; int msgflg;
                     38: {
                     39:        int parm[4];
                     40: 
                     41:        if (msgfno < 0) {
                     42:                if ((msgfno = open(msgdev, 0)) < 0) {
                     43:                        perror(msgdev);
                     44:                        errno = ENODEV;
                     45:                        return -1;
                     46:                }
                     47:        }
                     48: 
                     49:        parm[0] = -1;
                     50:        parm[1] = key;
                     51:        parm[2] = key >> 16;
                     52:        parm[3] = msgflg;
                     53: 
                     54:        ioctl(msgfno, MSGGET, parm);
                     55:        return parm[0];
                     56: }
                     57: 
                     58: /*
                     59:  * Send Message.
                     60:  */
                     61: msgsnd(msqid, msgp, msgsz, msgflg) int msqid; struct msgbuf *msgp; int msgsz, msgflg;
                     62: {
                     63:        int parm[5];
                     64: 
                     65:        if (msgfno < 0) {
                     66:                errno = ENODEV;
                     67:                return -1;
                     68:        }
                     69: 
                     70:        parm[0] = -1;
                     71:        parm[1] = msqid;
                     72:        parm[2] = (int) msgp;
                     73:        parm[3] = msgsz;
                     74:        parm[4] = msgflg;
                     75: 
                     76:        ioctl(msgfno, MSGSND, parm);
                     77:        return parm[0];
                     78: }
                     79: 
                     80: /*
                     81:  * Receive Message.
                     82:  */
                     83: msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)
                     84: int msqid; struct msgbuf *msgp; int msgsz; long msgtyp; int msgflg;
                     85: {
                     86:        int parm[7];
                     87: 
                     88:        if (msgfno < 0) {
                     89:                errno = ENODEV;
                     90:                return -1;
                     91:        }
                     92: 
                     93:        parm[0] = -1;
                     94:        parm[1] = msqid;
                     95:        parm[2] = (int) msgp;
                     96:        parm[3] = msgsz;
                     97:        parm[4] = (int) msgtyp;
                     98:        parm[5] = (int) (msgtyp >> 16);
                     99:        parm[6] = msgflg;
                    100: 
                    101:        ioctl(msgfno, MSGRCV, parm);
                    102:        return parm[0];
                    103: }
                    104: 
                    105: /* end of msgop.c */

unix.superglobalmegacorp.com

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