2004-02-26 00:08:11 +00:00
|
|
|
#include "libnazgul.h"
|
|
|
|
|
|
|
|
#define DEBUG 1
|
|
|
|
|
2004-02-26 10:21:55 +00:00
|
|
|
int msgSpaceListFindId(msgSpaceId externId){
|
2004-02-26 00:08:11 +00:00
|
|
|
msgSpaceList * list;
|
2004-02-26 10:21:55 +00:00
|
|
|
msgSpaceId spaceId;
|
2004-02-26 00:08:11 +00:00
|
|
|
msgSpaceListElemId listHeadElemId;
|
|
|
|
msgSpaceListElemId listTailElemId;
|
|
|
|
msgSpaceListId listId;
|
2004-02-26 11:36:30 +00:00
|
|
|
|
|
|
|
msgSpaceIdIntern(spaceId,externId);
|
2004-02-26 00:08:11 +00:00
|
|
|
list=msgSpaceListOpen();
|
|
|
|
if (list==NULL){
|
|
|
|
NZG_ERROR("msgSpaceListOpen","");
|
|
|
|
goto ERROR;
|
|
|
|
}
|
|
|
|
if (DEBUG) { printf("Before ListStrCpy\n"); }
|
|
|
|
strcpy(listHeadElemId,list->headId);
|
|
|
|
strcpy(listTailElemId,list->tailId);
|
|
|
|
strcpy(listId,list->id);
|
|
|
|
if (DEBUG) { printf("After ListStrCpy\n"); }
|
|
|
|
if ((strcmp(listHeadElemId,listId)==0)
|
|
|
|
&& strcmp(listTailElemId,listId)==0){
|
2004-02-26 07:19:08 +00:00
|
|
|
// si la liste est vide
|
2004-02-26 00:08:11 +00:00
|
|
|
if (DEBUG) { printf("SpaceList : vide\n"); }
|
|
|
|
return 1;
|
|
|
|
} else {
|
2004-02-26 08:00:56 +00:00
|
|
|
return msgSpaceListElemFindId(listHeadElemId,spaceId);
|
2004-02-26 00:08:11 +00:00
|
|
|
}
|
2004-02-26 07:19:08 +00:00
|
|
|
if (msgSpaceListClose(list) < 0){
|
|
|
|
NZG_ERROR("msgSpaceListClose","");
|
|
|
|
goto ERROR;
|
|
|
|
}
|
|
|
|
return 0;
|
2004-02-26 00:08:11 +00:00
|
|
|
ERROR:
|
2004-02-26 07:19:08 +00:00
|
|
|
return -1;
|
2004-02-26 00:08:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int msgSpaceListElemFindId(msgSpaceListElemId elemId,msgSpaceId spaceId){
|
|
|
|
msgSpaceListElem * listElem;
|
|
|
|
msgSpaceListElemId listElemIdNext;
|
|
|
|
msgSpaceId currentElemSpaceId;
|
|
|
|
|
2004-02-26 07:36:00 +00:00
|
|
|
listElem=msgSpaceListElemOpen(elemId);
|
|
|
|
if (listElem==NULL){
|
|
|
|
NZG_ERROR("msgSpaceListElemOpen",elemId);
|
|
|
|
goto ERROR;
|
|
|
|
}
|
2004-02-26 00:08:11 +00:00
|
|
|
strcpy(listElemIdNext,listElem->next);
|
|
|
|
strcpy(currentElemSpaceId,listElem->spaceId);
|
2004-02-26 07:36:00 +00:00
|
|
|
if (msgSpaceListElemClose(listElem) < 0){
|
|
|
|
NZG_ERROR("msgSpaceListElemClose",elemId);
|
|
|
|
goto ERROR;
|
|
|
|
}
|
|
|
|
|
2004-02-26 00:08:11 +00:00
|
|
|
printf("Current ListElem: Next:%s, Sid:%s\n",
|
|
|
|
listElemIdNext,currentElemSpaceId);
|
|
|
|
printf("comparisons...\n");
|
|
|
|
if (strcmp(currentElemSpaceId,spaceId)==0) {
|
|
|
|
printf("Found %s in spaceList !\n",spaceId);
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
if (strcmp(listElemIdNext,elemId)==0){
|
|
|
|
printf("End of spaceList reached.\n");
|
|
|
|
/* fin de liste ?? */
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
/* continuer sur l'element suivant */
|
|
|
|
return msgSpaceListElemFindId(listElemIdNext,spaceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
ERROR:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|