2004-02-23 09:42:25 +00:00
|
|
|
#include "libnazgul.h"
|
2004-02-23 22:19:28 +00:00
|
|
|
#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);
|
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;
|
|
|
|
}
|
|
|
|
|
2004-02-25 22:30:43 +00:00
|
|
|
if (ftruncate(listElemFd, sizeof(msgSpaceListElem)) < 0){
|
2004-02-25 17:54:51 +00:00
|
|
|
NZG_ERROR("ftruncate", listElemId);
|
|
|
|
goto ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
close(listElemFd);
|
2004-02-25 21:28:11 +00:00
|
|
|
msgSpaceListElem * listElem;
|
|
|
|
listElem=msgSpaceListElemOpen(listElemId);
|
2004-02-25 22:30:43 +00:00
|
|
|
if (listElem ==NULL){
|
|
|
|
NZG_ERROR("msgSpaceListElemOpen",listElemId);
|
|
|
|
goto ERROR;
|
|
|
|
}
|
2004-02-25 21:28:11 +00:00
|
|
|
strcpy(listElem->id,listElemId);
|
2004-02-25 22:30:43 +00:00
|
|
|
strcpy(listElem->next,listElemId);
|
2004-02-25 21:28:11 +00:00
|
|
|
strcpy(listElem->spaceId,space->id);
|
2004-02-25 22:30:43 +00:00
|
|
|
printf("[ ListElem : id %s,next: %s, Sid: %s ]\n",
|
|
|
|
listElem->id,
|
|
|
|
listElem->next,
|
|
|
|
listElem->spaceId);
|
|
|
|
if (msgSpaceListElemClose(listElem) <0){
|
|
|
|
NZG_ERROR("msgSpaceListElemClose",listElemId);
|
|
|
|
}
|
2004-02-25 17:54:51 +00:00
|
|
|
return 0;
|
2004-02-23 22:19:28 +00:00
|
|
|
ERROR:
|
2004-02-25 17:54:51 +00:00
|
|
|
return -1;
|
2004-02-23 22:19:28 +00:00
|
|
|
|
2004-02-23 09:42:25 +00:00
|
|
|
};
|