71 lines
1.5 KiB
C
71 lines
1.5 KiB
C
#include "nzg_global.h"
|
|
#include "nzg_iface.h"
|
|
#include "nzg_proto.h"
|
|
#include <sys/types.h>
|
|
#include <sys/mman.h>
|
|
|
|
/*
|
|
* 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,
|
|
int queueNb,
|
|
int poolNb,
|
|
msgPool * queueNbCar ){
|
|
msgSpace * result;
|
|
int shmId;
|
|
msgSpaceId nzgId;
|
|
/* on créee */
|
|
printf("PAGESIZE : %d\n",(int)PAGESIZE);
|
|
nzgId=msgSp2nzgId(spaceId);
|
|
if ((shmId=shm_open(nzgId,O_RDWR,MSGSPACE_DEFAULT_MODE)) < 0){
|
|
perror("shm_open");
|
|
return NULL;
|
|
}
|
|
|
|
|
|
/* on ajoute spaceId a la liste des msgSpace connus */
|
|
|
|
/* on crée queueNb files de messages */
|
|
|
|
/* on créer poolNb pool de buffers */
|
|
|
|
/* on attache tout ce beau monde au spaceId */
|
|
|
|
/* on renvoie un pointeur sur le bon spaceId */
|
|
result=NULL;
|
|
return result;
|
|
}
|
|
|
|
|
|
msgSpace * msgSpaceOpen(msgSpaceId spaceId){
|
|
int shmId;
|
|
char * nzgId=msgSp2nzgId(spaceId);
|
|
if ((shmId=shm_open(nzgId,O_RDWR,MSGSPACE_DEFAULT_MODE)) < 0){
|
|
perror("shm_open");
|
|
return NULL;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void msgSpaceDelete(msgSpaceId spaceId){
|
|
//int shmId;
|
|
msgSpaceId nzgId=msgSp2nzgId(spaceId);
|
|
int er;
|
|
if ((er=shm_unlink(nzgId))<0){
|
|
perror("shm_unlink");
|
|
};
|
|
}
|
|
|
|
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);
|
|
}
|