l3.libnazgul/src/queueElemOpen.c
2020-03-03 23:46:32 +01:00

29 lines
572 B
C

#include "libnazgul.h"
#include "ids.h"
void * msgQueueElemOpen(msgQueueElemId queueElemId){
int queueElemFd;
void * queueElemAddr;
queueElemFd=shm_open(queueElemId,O_RDWR,SHM_DEFAULT_MODE);
if (queueElemFd == -1 ) {
NZG_ERROR("shm_open : msgQueue open",queueElemId);
goto ERROR;
}
queueElemAddr=mmap(NULL,
sizeof(msgQueueElem),
PROT_READ|PROT_WRITE,
MAP_SHARED,
queueElemFd,
0);
if( queueElemAddr == MAP_FAILED ) {
NZG_ERROR("mmap",queueElemId);
goto ERROR;
}
close(queueElemFd);
return queueElemAddr;
ERROR:
return NULL;
}