diff --git a/src/nzg_create.c b/src/nzg_create.c index 3413207..de2a9c7 100644 --- a/src/nzg_create.c +++ b/src/nzg_create.c @@ -1,4 +1,10 @@ +#include /* POSIX et al */ +#include #include +#include +#include /* pour O_RDWR */ +#include +#include #include "nzg_iface.h" #include "nzg_proto.h" @@ -16,7 +22,20 @@ msgSpace * msgSpaceCreate( msgPool * queueNbCar // tableau de caracteristiques des different pool ){ + printf("PAGESIZE : %d\n",(int)PAGESIZE); // on créee + char * nzgId; + int slen; + int shmId; + slen=strlen(spaceId); + nzgId = (char *)malloc(sizeof(char)*(slen+4)); + sprintf(nzgId,"/NZG%s",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 @@ -32,7 +51,17 @@ msgSpace * msgSpaceCreate( } -void msgSpaceOpen(msgSpaceId){ +msgSpace * msgSpaceOpen(msgSpaceId spaceId){ + char * nzgId; + int slen; + int shmId; + slen=strlen(spaceId); + nzgId = (char *)malloc(sizeof(char)*(slen+4)); + sprintf(nzgId,"/NZG%s",spaceId); + if ((shmId=shm_open(nzgId,O_RDWR,MSGSPACE_DEFAULT_MODE)) < 0){ + perror("shm_open"); + return NULL; + } return NULL; } diff --git a/src/nzg_global.h b/src/nzg_global.h new file mode 100644 index 0000000..2a5f0e4 --- /dev/null +++ b/src/nzg_global.h @@ -0,0 +1,3 @@ +#include + +#define PAGESIZE sysconf(_SC_PAGESIZE) diff --git a/src/nzg_iface.h b/src/nzg_iface.h index 0737813..c8fb611 100644 --- a/src/nzg_iface.h +++ b/src/nzg_iface.h @@ -1,4 +1,5 @@ -#include "types.h" +#include "nzg_global.h" +#define MSGSPACE_DEFAULT_MODE 0600 typedef char * msgSpaceId; diff --git a/src/nzg_main.c b/src/nzg_main.c deleted file mode 100644 index 13a2c23..0000000 --- a/src/nzg_main.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "nzg_iface.h" -#include "nzg_proto.h" - -int main(void) { - // msgSpaceId mSID=msgSpaceIdGet(""); //renvoie un ID propre au programme - // msgSpace mS=0; - return 0; -} diff --git a/src/nzg_show.c b/src/nzg_show.c deleted file mode 100644 index 991f6b0..0000000 --- a/src/nzg_show.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "nzg_iface.h" -#include "nzg_proto.h" - -int main(void) { - //show existing MsgSpaces - char ** msID=msgSpaceIdList(); //renvoie un msgSpaceId - msID=msID; - return 0; -} diff --git a/src/types.h b/src/types.h deleted file mode 100644 index e69de29..0000000