46 lines
1.0 KiB
C
46 lines
1.0 KiB
C
|
#include <custom_msgq.h>
|
||
|
#include <sys/msg.h>
|
||
|
|
||
|
void msgRcv(void *msgp, size_t size, long mtype) {
|
||
|
if (msgrcv(_MSGQID, msgp, size, mtype, 0) == -1) {
|
||
|
errExitMsg("msgrcv");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void rcvMsg(msg_t *msg) {
|
||
|
msgRcv(msg, sizeof(msg_t) - sizeof(long), MSG);
|
||
|
}
|
||
|
|
||
|
void rcvMove(move_t *move) {
|
||
|
msgRcv(move, sizeof(move_t) - sizeof(long), MOVE);
|
||
|
}
|
||
|
void rcvPlayer(player_ds *player) {
|
||
|
msgRcv(player, sizeof(player_ds) - sizeof(long), PLAYER);
|
||
|
}
|
||
|
void rcvGame_end(game_end_t *game) {
|
||
|
msgRcv(game, sizeof(game_end_t) - sizeof(long), GAME_END);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void msgSnd(void *msgp, size_t size) {
|
||
|
if (msgsnd(_MSGQID, msgp, size, 0) == -1) {
|
||
|
errExitMsg("msgsnd");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void sndMsg(msg_t *msg) {
|
||
|
msgSnd(msg, sizeof(msg_t) - sizeof(long));
|
||
|
}
|
||
|
|
||
|
void sndMove(move_t *move) {
|
||
|
msgSnd(move, sizeof(move_t) - sizeof(long));
|
||
|
}
|
||
|
|
||
|
void sndPlayer(player_ds *player) {
|
||
|
msgSnd(player, sizeof(player_ds) - sizeof(long));
|
||
|
}
|
||
|
|
||
|
void sndGame_end(game_end_t *game) {
|
||
|
msgSnd(game, sizeof(game_end_t) - sizeof(long));
|
||
|
}
|