From 8f8715e27be0c31310763947aec4305af6dbc715 Mon Sep 17 00:00:00 2001 From: glenux Date: Mon, 23 Feb 2004 21:41:20 +0000 Subject: [PATCH] *** empty log message *** --- src/proto.h | 8 ++++++-- src/queueAdd.c | 33 ++++++++++++++++++++++++++++++++- src/queueElemCreate.c | 6 +++--- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/proto.h b/src/proto.h index e173b05..058ea4f 100644 --- a/src/proto.h +++ b/src/proto.h @@ -27,29 +27,33 @@ int msgPoolDataIdIntern(msgPoolDataTabId dest, const msgSpaceId src); int msgPoolIdIntern(msgPoolId dest, msgPoolId src, int num); int msgBufferInfoTabIdIntern(msgBufferInfoTabId dest, msgSpaceId src, int num); int msgQueueSemIdIntern(msgQueueSemId dest, msgSpaceId externId, int queueIdx); +int msgQueueIdIntern(msgQueueId dest, msgSpaceId externId, int queueIdx); +int msgQueueElemIdIntern(msgQueueElemId dest, msgQueueId src, int counter); /* list.c */ /* poolCreate.c */ int msgPoolCreate(msgSpaceId externId, int poolIdx, int buffNb, int buffSize); /* poolDelete.c */ int msgPoolDelete(msgSpaceId spaceId, int poolIdx); /* queueAdd.c */ -/* queueAddElem.c */ +int msgQueueElemAdd(msgQueue *queue, msgQueueElemId newElemId); /* queueClose.c */ int msgQueueClose(msgQueue *queue); /* queueDelete.c */ int msgQueueElemDelete(msgQueueElemId queueElemId); /* queueElemClose.c */ int msgQueueElemClose(msgQueueElem *queueElem); +/* queueElemCreate.c */ +int msgQueueElemCreate(msgQueueElemId finalQueueElemId, msgQueueId queueId, int counter); /* queueElemDelete.c */ int msgQueueElemDelete(msgQueueElemId queueElemId); /* queueElemOpen.c */ void *msgQueueElemOpen(msgQueueElemId queueElemId); /* queueInit.c */ +msgQueue *queueInit(msgSpaceId externId, int queueIdx); /* queueLock.c */ int queueLock(msgSpaceId externId, int queueIdx); /* queueOpen.c */ void *msgQueueOpen(msgQueueId queueId); -/* queueRemElem.c */ /* queueUnlock.c */ int queueUnlock(msgSpaceId externId, int queueIdx); /* spaceCreate.c */ diff --git a/src/queueAdd.c b/src/queueAdd.c index 563b2a5..96d286c 100644 --- a/src/queueAdd.c +++ b/src/queueAdd.c @@ -2,6 +2,37 @@ // on ajoute en fin de queue... -int msgQueueElemAdd(msgQueue * queue, msgQueueElemId){ +int msgQueueElemAdd(msgQueue * queue, msgQueueElemId newElemId){ + msgQueueElem * queueOldTailElem; + msgQueueElem * queueNewTailElem; + + // on informe l'element qu'il est le dernier + queueNewTailElem=msgQueueElemOpen(newElemId); + if (queueNewTailElem == NULL){ + NZG_ERROR("msgQueueElemOpen",newElemId); + goto ERROR; + } + strcpy(queueNewTailElem->next,newElemId); + if (msgQueueElemClose(queueNewTailElem)){ + NZG_ERROR("msgQueueElemClose",newElemId); + goto ERROR; + } + /* TODO: verifier si la liste n'est pas vide... */ + /* on informe son prédecesseur qu'il a un suivant */ + queueOldTailElem=msgQueueElemOpen(queue->tailId); + if (queueOldTailElem == NULL){ + NZG_ERROR("msgQueueElemOpen",queue->tailId); + goto ERROR; + } + strcpy(queueOldTailElem->next,newElemId); + if (msgQueueElemClose(queueOldTailElem)){ + NZG_ERROR("msgQueueElemClose",queue->tailId); + goto ERROR; + } + // on donne a la queue l'id du dernier element + strcpy(queue->tailId,newElemId); + +ERROR: + return -1; } diff --git a/src/queueElemCreate.c b/src/queueElemCreate.c index f3ae7d0..62769d9 100644 --- a/src/queueElemCreate.c +++ b/src/queueElemCreate.c @@ -1,8 +1,8 @@ #include "libnazgul.h" #include "ids.h" -int msgQueueElemCreate(msgQueueElemId, - finalQueueElemId, +int msgQueueElemCreate( + msgQueueElemId finalQueueElemId , msgQueueId queueId, int counter){ msgQueueElemId queueElemId; @@ -24,7 +24,7 @@ int msgQueueElemCreate(msgQueueElemId, goto ERROR; } - close(queueElem_Fd); + close(queueElemFd); return 0; ERROR: return -1;