2020-03-03 22:41:24 +00:00
|
|
|
|
#include "nzg_global.h"
|
2004-02-16 21:25:11 +00:00
|
|
|
|
#include "nzg_iface.h"
|
|
|
|
|
#include "nzg_proto.h"
|
2020-03-03 22:41:24 +00:00
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/mman.h>
|
2004-02-16 21:25:11 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* spaceId : identifiant externe de l'espace de msg
|
|
|
|
|
* queueNb : nombre de files de messages
|
|
|
|
|
* poolNb : nombre de pool de buffers
|
|
|
|
|
* queueNbCar : tableau de caracteristiques des different pool
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
msgSpace * msgSpaceCreate(
|
|
|
|
|
msgSpaceId spaceId, // identifiant externe de l'espace de msg
|
|
|
|
|
int queueNb, // nombre de files de messages
|
|
|
|
|
int poolNb, // nombre de pool de buffers
|
|
|
|
|
msgPool * queueNbCar // tableau de caracteristiques des different pool
|
|
|
|
|
){
|
2019-09-16 14:54:52 +00:00
|
|
|
|
int shmId;
|
2020-03-03 22:42:59 +00:00
|
|
|
|
printf("PAGESIZE : %d\n",(int)PAGESIZE);
|
2019-09-16 14:43:39 +00:00
|
|
|
|
// on cr<63>ee
|
2019-09-16 14:54:52 +00:00
|
|
|
|
msgSpaceId nzgId=msgSp2nzgId(spaceId);
|
2020-03-03 22:42:59 +00:00
|
|
|
|
if ((shmId=shm_open(nzgId,O_RDWR,MSGSPACE_DEFAULT_MODE)) < 0){
|
|
|
|
|
perror("shm_open");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-02-16 21:25:11 +00:00
|
|
|
|
// on ajoute spaceId a la liste des msgSpace connus
|
|
|
|
|
|
|
|
|
|
// on cr<63>e queueNb files de messages
|
|
|
|
|
|
|
|
|
|
// on cr<63>er poolNb pool de buffers
|
|
|
|
|
|
|
|
|
|
// on attache tout ce beau monde au spaceId
|
|
|
|
|
|
|
|
|
|
// on renvoie un pointeur sur le bon spaceId
|
|
|
|
|
|
|
|
|
|
msgSpace * result=NULL;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-03-03 22:42:59 +00:00
|
|
|
|
msgSpace * msgSpaceOpen(msgSpaceId spaceId){
|
|
|
|
|
int shmId;
|
2019-09-16 14:54:52 +00:00
|
|
|
|
char * nzgId=msgSp2nzgId(spaceId);
|
2020-03-03 22:42:59 +00:00
|
|
|
|
if ((shmId=shm_open(nzgId,O_RDWR,MSGSPACE_DEFAULT_MODE)) < 0){
|
|
|
|
|
perror("shm_open");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2019-09-16 14:43:39 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void msgSpaceDelete(msgSpaceId spaceId){
|
2020-03-03 22:41:24 +00:00
|
|
|
|
//int shmId;
|
2019-09-16 14:54:52 +00:00
|
|
|
|
msgSpaceId nzgId=msgSp2nzgId(spaceId);
|
|
|
|
|
int er;
|
|
|
|
|
if ((er=shm_unlink(nzgId))<0){
|
|
|
|
|
perror("shm_unlink");
|
|
|
|
|
};
|
2019-09-16 14:43:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-16 14:54:52 +00:00
|
|
|
|
msgSpaceId msgSp2nzgId(msgSpaceId spaceId){
|
|
|
|
|
char * resNzgId;
|
|
|
|
|
int slen;
|
|
|
|
|
slen=strlen(spaceId);
|
|
|
|
|
resNzgId = (char *)malloc(sizeof(char)*(slen+4));
|
|
|
|
|
sprintf(resNzgId,"/NZG%s",(char *)spaceId);
|
|
|
|
|
return ((msgSpaceId)resNzgId);
|
|
|
|
|
}
|