24 int send_message(
int qid,
int type,
char *msg,
int len,
short flag)
28 struct msqid_ds mqinfo;
36 for(n = 0; n < len; n++)
37 mqbuf.
mtext[n] = msg[n];
40 mqbuf.
mtext[n++] =
'\0';
50 while(((res = msgctl(qid, IPC_STAT, &mqinfo)) == 0) && ((mqinfo.__msg_cbytes + len + 1) > (mqinfo.msg_qbytes *
f / 100)))
54 error(
_(
"error in message control: %s"), strerror(errno));
60 res = msgctl(qid, IPC_STAT, &mqinfo);
63 error(
_(
"error in message control: %s"), strerror(errno));
67 if((mqinfo.__msg_cbytes + len + 1) > (mqinfo.msg_qbytes *
f / 100))
79 error(
_(
"cannot put message in queue: %s"), strerror(errno));
92 if((res = msgrcv(qid, &mqbuf,
MSGMAX, type, 0)) == -1)
94 error(
_(
"cannot receive message: %s"), strerror(errno));
98 ptr = *msg = (
char *)malloc(res);
101 *ptr++ = mqbuf.
mtext[n++];
108 if(msgctl(qid, IPC_RMID, 0) == -1)
110 error(
_(
"error in message control: %s"), strerror(errno));
118 return msgget(IPC_PRIVATE, 0660);
int send_message(int qid, int type, char *msg, int len, short flag)
#define str_len(s)
Shorthand for counting '\0' terminating strings. See _len for more info.
int remove_queue(int qid)
#define MSG_PRIORITY
Indicates a message as important.
int receive_message(int qid, int type, char **msg)