l3.libnazgul/src/spaceListElemCreate.c

39 lines
820 B
C
Raw Normal View History

2004-02-23 09:42:25 +00:00
#include "libnazgul.h"
#include "ids.h"
2004-02-23 09:42:25 +00:00
// cree un nouvel elemen
2004-02-25 17:54:51 +00:00
int msgSpaceListElemCreate(
2004-02-25 18:33:06 +00:00
msgSpaceListElemId listElemId,
2004-02-25 17:54:51 +00:00
msgSpace * space)
{
2004-02-25 21:28:11 +00:00
msgSpaceListElemIdIntern(listElemId,space->externId);
printf("Creating ListElem %s",listElemId);
2004-02-25 17:54:51 +00:00
int listElemFd;
listElemFd=shm_open(listElemId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
SHM_DEFAULT_MODE);
if (listElemFd == -1 ) {
NZG_ERROR("shm_open : msgSpaceListElem creation",listElemId);
goto ERROR;
}
if (ftruncate(listElemFd, sizeof(msgQueueElem)) < 0){
NZG_ERROR("ftruncate", listElemId);
goto ERROR;
}
close(listElemFd);
2004-02-25 21:28:11 +00:00
msgSpaceListElem * listElem;
listElem=msgSpaceListElemOpen(listElemId);
strcpy(listElem->id,listElemId);
strcpy(listElem->spaceId,space->id);
msgSpaceListElemClose(listElem);
2004-02-25 17:54:51 +00:00
return 0;
ERROR:
2004-02-25 17:54:51 +00:00
return -1;
2004-02-23 09:42:25 +00:00
};