l3.libnazgul/src/ids.c
2020-03-03 23:46:32 +01:00

161 lines
3.5 KiB
C

#ifndef _NZG_IDS
#define _NZG_IDS 1
#include "libnazgul.h"
#include "ids.h"
int msgSpaceIdIntern(msgSpaceId dest,const msgSpaceId src ){
if (strlen(src)>MSGSPACE_ID_LEN){
return -1;
}
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgSpace%s",(char *)src);
#else
sprintf(dest,"/nzgSpace%s",(char *)src);
#endif
return 0;
}
int msgPoolDataTabSemIdIntern(
msgPoolSemId destSemId,
const msgSpaceId externId){
if (strlen(externId)>MSGSPACE_ID_LEN*4){
return -1;
}
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID
sprintf(destSemId,"/tmp/nzgPoolDTSem-%s",(char *)externId);
#else
sprintf(destSemId,"/nzgPoolDTSem-%s",(char *)externId);
#endif
return 0;
}
int msgPoolSemIdIntern(
msgPoolSemId destSemId,
const msgSpaceId srcPoolId,
int poolIdx){
if (strlen(srcPoolId)>MSGSPACE_ID_LEN*4){
return -1;
}
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID
sprintf(destSemId,"/tmp/nzgPoolSem-%s-%d",(char *)srcPoolId,poolIdx);
#else
sprintf(destSemId,"/nzgPoolSem-%s-%d",(char *)srcPoolId,poolIdx);
#endif
return 0;
}
int msgPoolDataIdIntern(msgPoolDataTabId dest,const msgSpaceId src ){
if (strlen(src)>MSGSPACE_ID_LEN){
return -1;
}
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgPoolData-%s",(char *)src);
#else
sprintf(dest,"/nzgPoolData-%s",(char *)src);
#endif
return 0;
}
int msgPoolIdIntern(msgPoolId dest,msgPoolId src, int num){
if (strlen(src)>MSGSPACE_ID_LEN){
return -1;
}
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgPool-%s-%d",(char *)src,num);
#else
sprintf(dest,"/nzgPool-%s-%d",(char *)src,num);
#endif
return 0;
}
int msgBufferInfoTabIdIntern(
msgBufferInfoTabId dest,
msgSpaceId src,
int num){
if (strlen(src)>MSGSPACE_ID_LEN){
return -1;
}
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgBufferInfo-%s-%d",(char *)src,num);
#else
sprintf(dest,"/nzgBufferInfo-%s-%d",(char *)src,num);
#endif
return 0;
}
int msgQueueProtSemIdIntern(
msgQueueSemId dest,
msgSpaceId externId,
int queueIdx){
if (strlen(externId)>MSGSPACE_ID_LEN){
return -1;
}
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgQueueProtSem-%s-%d",(char *)externId,queueIdx);
#else
sprintf(dest,"/nzgQueueProtSem-%s-%d",(char *)externId,queueIdx);
#endif
return 0;
}
int msgQueueReadSemIdIntern(
msgQueueSemId dest,
msgSpaceId externId,
int queueIdx){
if (strlen(externId)>MSGSPACE_ID_LEN){
return -1;
}
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgQueueReadSem-%s-%d",(char *)externId,queueIdx);
#else
sprintf(dest,"/nzgQueueReadSem-%s-%d",(char *)externId,queueIdx);
#endif
return 0;
}
int msgQueueIdIntern(
msgQueueId dest,
msgSpaceId externId,
int queueIdx){
if (strlen(externId)>MSGSPACE_ID_LEN){
return -1;
}
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgQueue-%s-%d",(char *)externId,queueIdx);
#else
sprintf(dest,"/nzgQueue-%s-%d",(char *)externId,queueIdx);
#endif
return 0;
}
int msgQueueElemIdIntern(
msgQueueElemId dest,
msgQueueId src,
int counter){
if (strlen(src)>MSGSPACE_ID_LEN){
return -1;
}
sprintf(dest,"%s-%d",(char *)src,counter);
return 0;
}
int spaceListElemIdIntern(msgSpaceListElemId elemListId,msgSpaceId externId){
if (strlen(externId)>MSGSPACE_ID_LEN){
return -1;
}
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID
sprintf(elemListId,"/tmp/nzgSpaceListElem-%s",(char *)externId);
#else
sprintf(elemListId,"/nzgSpaceListElem-%s",(char *)externId);
#endif
return 0;
}
#endif