*** empty log message ***

This commit is contained in:
glenux 2004-02-25 17:54:51 +00:00
parent 19943dc5d3
commit 5ecb38599b
7 changed files with 94 additions and 34 deletions

View file

@ -1,6 +1,3 @@
#ifndef _NZG_IDS
#define _NZG_IDS 1
#include "libnazgul.h"
#include "ids.h"
@ -143,7 +140,7 @@ int msgQueueElemIdIntern(
return 0;
}
int spaceListElemIdIntern(msgSpaceListElemId elemListId,msgSpaceId externId){
int msgSpaceListElemIdIntern(msgSpaceListElemId elemListId,msgSpaceId externId){
if (strlen(externId)>MSGSPACE_ID_LEN){
return -1;
}
@ -158,4 +155,4 @@ int spaceListElemIdIntern(msgSpaceListElemId elemListId,msgSpaceId externId){
}
#endif

View file

@ -1,8 +1,14 @@
#ifndef _NZG_IDS
#define _NZG_IDS 1
#include "libnazgul.h"
#ifdef _NZG_REALFILEID
#define msgSpaceListId "/tmp/nzgSpaceList"
#else
#define msgSpaceListId "/nzgSpaceList"
#endif
/* nzg_ids.c */
int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src);
int msgPoolSemIdIntern(msgPoolSemId destSemId, const msgSpaceId srcPoolId, int poolIdx);

View file

@ -59,15 +59,18 @@ typedef struct MsgSpace {
typedef struct MsgSpaceListElem {
int ownerPid;
msgSpaceListElemId id;
msgSpaceId spaceId;
msgSpaceListElemId next;
} msgSpaceListElem;
typedef struct MsgSpaceList {
msgSpaceListId id;
int elemCounter;
msgSpaceListElemId first;
msgSpaceListElemId last;
msgSpaceListElemId headId;
msgSpaceListElemId tailId;
} msgSpaceList;
typedef struct MsgQueueElem {

View file

@ -34,7 +34,7 @@ int msgQueueProtSemIdIntern(msgQueueSemId dest, msgSpaceId externId, int queueId
int msgQueueReadSemIdIntern(msgQueueSemId dest, msgSpaceId externId, int queueIdx);
int msgQueueIdIntern(msgQueueId dest, msgSpaceId externId, int queueIdx);
int msgQueueElemIdIntern(msgQueueElemId dest, msgQueueId src, int counter);
int spaceListElemIdIntern(msgSpaceListElemId elemListId, msgSpaceId externId);
int msgSpaceListElemIdIntern(msgSpaceListElemId elemListId, msgSpaceId externId);
/* list.c */
/* poolCreate.c */
int msgPoolCreate(msgSpaceId externId, int poolIdx, int buffNb, int buffSize);
@ -87,14 +87,23 @@ msgSpace *msgSpaceCreate(msgSpaceId externId, int queueNb, int poolNb, msgPool *
/* spaceDelete.c */
int msgSpaceDelete(msgSpaceId externId);
/* spaceListAdd.c */
int msgSpaceListAdd(msgSpaceListElemId newElemId);
/* spaceListClose.c */
int msgSpaceListClose(msgSpaceList *list);
/* spaceListElemClose.c */
int msgSpaceListElemClose(msgSpaceListElem *listElem);
/* spaceListElemCreate.c */
int msgSpaceListElemCreate(msgSpaceListElemId elemenListId, msgSpace *space);
/* spaceListElemLink.c */
/* spaceListElemOpen.c */
void *msgSpaceListElemOpen(msgSpaceListElemId listElemId);
/* spaceListInit.c */
int msgSpaceListInit(void);
/* spaceListLocking.c */
int msgSpaceListLock(void);
int msgSpaceListUnlock(void);
/* spaceListOpen.c */
void *msgSpaceListOpen(void);
/* spaceListRem.c */
/* spaceOpen.c */
msgSpace *msgSpaceOpen(msgSpaceId externId);

View file

@ -1,6 +1,5 @@
#include "libnazgul.h"
#include "ids.h"
#include "libnazgul.h"
int msgQueueClose(msgQueue * queue){
msgQueueId qId;

View file

@ -3,4 +3,50 @@
// ajoute un element en début de liste.
// fait pointer l'ancien dernier vers lui
// il s'enregistre en tant que dernier chez la liste
int msgSpaceListAdd(msgSpaceListElemId );
int msgSpaceListAdd(msgSpaceListElemId newElemId){
msgSpaceListElem * listOldTailElem;
msgSpaceListElem * listNewTailElem;
msgSpaceList * list=NULL;
list=msgSpaceListOpen();
// on informe l'element qui est le dernier
listNewTailElem=msgSpaceListElemOpen(newElemId);
if (listNewTailElem==NULL){
}
strcpy(listNewTailElem->next,newElemId);
if (msgSpaceListElemClose(listNewTailElem) <0 ){
NZG_ERROR("msgQueueElemClose",newElemId);
goto ERROR;
}
/* TODO: verifier si la liste n'est pas vide... */
if((strcmp(list->headId,list->id)==0)
&& (strcmp(list->tailId,list->id)==0)) {
printf("- premier elem de queue -\n");
// on donne a la queue l'id de l'element
strcpy(list->headId,newElemId);
strcpy(list->tailId,newElemId);
} else {
/* on informe son prédecesseur qu'il a un suivant */
listOldTailElem=msgSpaceListElemOpen(list->tailId);
if (listOldTailElem == NULL){
NZG_ERROR("msgQueueElemOpen",list->tailId);
goto ERROR;
}
strcpy(listOldTailElem->next,newElemId);
if (msgSpaceListElemClose(listOldTailElem) < 0){
NZG_ERROR("msgQueueElemClose",list->tailId);
goto ERROR;
}
// on donne a la queue l'id du dernier element
strcpy(list->tailId,newElemId);
}
// on incremente elemCounter
list->elemCounter++;
msgSpaceListClose(list);
return 0;
ERROR:
return -1;
}

View file

@ -2,31 +2,31 @@
#include "ids.h"
// cree un nouvel elemen
int msgSpaceListElemCreate(msgSpaceListElemId elemenListId,msgSpace * space){
int msgSpaceListElemCreate(
msgSpaceListElemId elemenListId,
msgSpace * space)
{
int shmElemenList;
msgSpaceId listElemId;
/*Creation de lid pour lespace de message*/
strcpy(listElemId,space->id);
int listElemFd;
spaceListElemIdIntern(elemenListId,space->externId);
if ((shmElemenList=shm_open(elemenListId,
listElemFd=shm_open(listElemId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
MSGSPACE_DEFAULT_MODE))==-1){
NZG_ERROR("shm_open:Space list creation",elemenListId);
SHM_DEFAULT_MODE);
if (listElemFd == -1 ) {
NZG_ERROR("shm_open : msgSpaceListElem creation",listElemId);
goto ERROR;
}
if(ftruncate(shmElemenList,sizeof(elemenListId) ) <0) {
NZG_ERROR("ftruncate",elemenListId);
if (ftruncate(listElemFd, sizeof(msgQueueElem)) < 0){
NZG_ERROR("ftruncate", listElemId);
goto ERROR;
};
}
close (shmElemenList);
//TODO: mapper le shm en mémoire et remplir avec des informations
//strcpy(spaceListElem->spaceId,space->id);
close(listElemFd);
return 0;
ERROR:
return -1;