PSI update

r1464 | ffr | 2007-02-12 12:20:21 +1100 (Mon, 12 Feb 2007) | 2 lines
This commit is contained in:
Ferdi Franceschini
2007-02-12 12:20:21 +11:00
committed by Douglas Clowes
parent 634f2023b1
commit 3168325921
157 changed files with 29053 additions and 910 deletions

View File

@@ -175,6 +175,43 @@ static pDynString locateBatchBuffer(pExeMan self, char *name){
DeleteDynString(result);
return NULL;
}
/*-------------------------------------------------------------------
* Generate a full path name for the argument in the first
* directory of batch path
* -------------------------------------------------------------------*/
static int makeExePath(pExeMan self, SConnection *pCon, int argc, char *argv[]){
char buffer[512], *pPtr = NULL, pPath[132];
if(argc < 3) {
SCWrite(pCon,"ERROR: require a file name for makepath",eError);
return 0;
}
strcpy(buffer,"exe.makepath = ");
/*
* do nothing to absolute path
*/
if(argv[2][0] == '/'){
strncat(buffer,argv[2],511-strlen(buffer));
SCWrite(pCon,buffer,eValue);
return 1;
}
pPtr = self->batchPath;
pPtr = stptok(pPtr,pPath,131,":");
strncat(buffer,pPath,511-strlen(buffer));
strncat(buffer,"/",511-strlen(buffer));
strncat(buffer,argv[2],511-strlen(buffer));
SCWrite(pCon,buffer,eValue);
return 1;
}
/*--------------------------------------------------------------------*/
pDynString findBatchFile(SicsInterp *pSics, char *name){
pExeMan self = (pExeMan)FindCommandData(pSics,"exe","ExeManager");
if(self == NULL){
return NULL;
}
return locateBatchBuffer(self,name);
}
/*--------------------------------------------------------------------*/
static int runBatchBuffer(pExeMan self, SConnection *pCon,
SicsInterp *pSics, char *name){
@@ -937,6 +974,7 @@ int ExeManagerWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
char pBufferName[256];
int status;
pDynString dirList = NULL;
pDynString fullPath = NULL;
self = (pExeMan)pData;
assert(self != NULL);
@@ -1012,6 +1050,24 @@ int ExeManagerWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon,"Nothing found",eValue);
}
return 1;
}else if(strcmp(argv[1],"fullpath") == 0){
if(argc < 2){
SCWrite(pCon,"ERROR: not enough arguments to exe fullpath",eError);
return 0;
}
fullPath = locateBatchBuffer(self,argv[2]);
if(fullPath == NULL){
SCWrite(pCon,"ERROR: buffer NOT found",eError);
return 0;
} else {
DynStringInsert(fullPath,"exe.fullpath=",0);
SCWrite(pCon,GetCharArray(fullPath),eValue);
DeleteDynString(fullPath);
return 1;
}
return 1;
}else if(strcmp(argv[1],"makepath") == 0){
return makeExePath(self,pCon,argc,argv);
}else if(strcmp(argv[1],"clear") == 0){
clearQueue(self);
SCSendOK(pCon);