Merge commit 'refs/merge-requests/1' of ssh://gitorious.psi.ch/sinqdev/sics into merge-requests/1
First merge with ANSTO which compiles Conflicts: SICSmain.c asynnet.c confvirtualmot.c counter.c devexec.c drive.c exebuf.c hipadaba.c interface.h make_gen motor.c nserver.c nwatch.c ofac.c protocol.c sicshipadaba.c
This commit is contained in:
126
nxdict.c
126
nxdict.c
@ -173,9 +173,9 @@ static void NXDIParse(char *pBuffer, pStringDict pDict)
|
||||
char *pPtr;
|
||||
int iToken;
|
||||
int iMode;
|
||||
char pAlias[132];
|
||||
char pDefinition[1024]; /* this is > 10 lines of definition */
|
||||
char pWord[132];
|
||||
char pAlias[1024];
|
||||
char pDefinition[8192]; /* this is > 10 lines of definition */
|
||||
char pWord[1024];
|
||||
|
||||
assert(pBuffer);
|
||||
assert(pDict);
|
||||
@ -1490,6 +1490,126 @@ NXstatus NXDinfoalias(NXhandle hFil, NXdict dict, char *pAlias, int *rank,
|
||||
return iRet;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
NXstatus NXDdefnamedlink(NXhandle hFil, NXdict dict,
|
||||
char *pTarget, char *pVictim, char *newname)
|
||||
{
|
||||
NXdict pDict;
|
||||
ParDat pParseT, pParseV;
|
||||
int iRet, i, iStat;
|
||||
NXlink sLink;
|
||||
|
||||
pDict = NXDIAssert(dict);
|
||||
|
||||
|
||||
#ifdef DEFDEBUG
|
||||
printf("Linking: %s\n", pVictim);
|
||||
printf("To: %s\n", pTarget);
|
||||
#endif
|
||||
|
||||
|
||||
/* parse Victim */
|
||||
pParseV.iMayCreate = 0;
|
||||
pParseV.pPtr = pVictim;
|
||||
pParseV.iDepth = 0;
|
||||
iRet = NXDIDefParse(hFil, pDict, &pParseV);
|
||||
if (iRet == NX_ERROR) {
|
||||
/* unwind and throw up */
|
||||
NXDIUnwind(hFil, pParseV.iDepth);
|
||||
return NX_ERROR;
|
||||
}
|
||||
/* get link data */
|
||||
if (pParseV.iTerminal == TERMSDS) {
|
||||
NXgetdataID(hFil, &sLink);
|
||||
iRet = NXclosedata(hFil);
|
||||
if (iRet != NX_OK) {
|
||||
/* unwind and throw up */
|
||||
NXDIUnwind(hFil, pParseV.iDepth);
|
||||
return NX_ERROR;
|
||||
}
|
||||
} else if (pParseV.iTerminal == TERMVG) {
|
||||
NXgetgroupID(hFil, &sLink);
|
||||
} else {
|
||||
assert(0); /* serious programming error */
|
||||
}
|
||||
/* Unwind */
|
||||
iRet = NXDIUnwind(hFil, pParseV.iDepth);
|
||||
if (iRet != NX_OK) {
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
/* parse Target */
|
||||
pParseT.iMayCreate = 1;
|
||||
pParseT.pPtr = pTarget;
|
||||
pParseT.iDepth = 0;
|
||||
iRet = NXDIDefParse(hFil, pDict, &pParseT);
|
||||
if (iRet == NX_ERROR) {
|
||||
/* unwind and throw up */
|
||||
NXDIUnwind(hFil, pParseT.iDepth);
|
||||
return NX_ERROR;
|
||||
}
|
||||
/* check it being a vGroup! */
|
||||
if (pParseT.iTerminal != TERMVG) {
|
||||
NXReportError("ERROR: can link only into a vGroup");
|
||||
NXDIUnwind(hFil, pParseT.iDepth);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
/* link, finally */
|
||||
iRet = NXmakenamedlink(hFil, newname, &sLink);
|
||||
/* Unwind anyway */
|
||||
iStat = NXDIUnwind(hFil, pParseT.iDepth);
|
||||
if (iStat != NX_OK) {
|
||||
return NX_ERROR;
|
||||
}
|
||||
return iStat;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
NXstatus NXDaliasnamedlink(NXhandle hFil, NXdict dict,
|
||||
char *pTarget, char *pVictim, char *newname)
|
||||
{
|
||||
char pTargetDef[2048], pVictimDef[2048];
|
||||
int iRet;
|
||||
NXdict pDict;
|
||||
pDynString pRep1 = NULL, pRep2 = NULL;
|
||||
|
||||
pDict = NXDIAssert(dict);
|
||||
|
||||
/* get Target Definition String */
|
||||
iRet = NXDget(pDict, pTarget, pTargetDef, 2047);
|
||||
if (iRet != NX_OK) {
|
||||
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
|
||||
NXReportError(pTargetDef);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
/* get Victim definition string */
|
||||
iRet = NXDget(pDict, pVictim, pVictimDef, 2047);
|
||||
if (iRet != NX_OK) {
|
||||
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
|
||||
NXReportError(pTargetDef);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
/* do replacements */
|
||||
pRep1 = NXDItextreplace(dict, pTargetDef);
|
||||
pRep2 = NXDItextreplace(dict, pVictimDef);
|
||||
if ((!pRep1) || (!pRep2)) {
|
||||
if (pRep1)
|
||||
DeleteDynString(pRep1);
|
||||
if (pRep2)
|
||||
DeleteDynString(pRep2);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
/* call NXdeflin */
|
||||
iRet = NXDdefnamedlink(hFil, pDict, GetCharArray(pRep1), GetCharArray(pRep2), newname);
|
||||
DeleteDynString(pRep1);
|
||||
DeleteDynString(pRep2);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
NXstatus NXDdeflink(NXhandle hFil, NXdict dict,
|
||||
char *pTarget, char *pVictim)
|
||||
|
Reference in New Issue
Block a user