model_server/gala/dis_gala/deaddirs.cxx
/* ISO_CPP_HEADERS */
/* a function to build a list of dead discover directories.
* It returns them as a Tcl style space-separated list
* it doesn't work with long filenames
* buffer needs to be deleted after you are done
*/
ISO_CPP_HEADERS
a function to build a list of dead discover directories.
It returns them as a Tcl style space-separated list
it doesn't work with long filenames
buffer needs to be deleted after you are done
ISO_CPP_HEADERS a function to build a list of dead discover directories . It returns them as a Tcl style space - separated list it doesn ' t work with long filenames buffer needs to be deleted after you are done
int build_dead_dirs(char * &buffer )
{
	int retval=0;
	const char * pDiscover="DISCOVER";
	const char * pLock    ="Discover.lock";	
	const char * pTmpDir=NULL;
	parray  pDirs(32);
	parray * ppDirs=&pDirs;
	int x=-1;
	pTmpDir=pdgetenv("TMPDIR");
	if (pTmpDir==NULL)
		pTmpDir=pdgetenv("TMP");
	if (pTmpDir==NULL)
		pTmpDir=pdgetenv("TEMP");
	if (pTmpDir)
	{
		char * p=(char *)pTmpDir;
		while (*p)
		{if ( *p=='\\')  *p = '/';
		p++;}
		x=pdlsdir( (char * )pTmpDir, ppDirs);
		if (x>0)
		{
			cstring final;
			int i;
			int nDiscoverLen=pdstrlen(pDiscover);
			for ( i=0; i<x ; i++)
			{
				if (!strncmp(pDiscover, (const char *) pDirs[i], nDiscoverLen ))
				{
					cstring cF(pTmpDir);
					cF += '/';  
					cF += (const char *) pDirs[i];
					cF += '/';
					cF += pLock;
					char * test=pdloadfile(cF);
					if (test)
					{
						cstring t2(pTmpDir);
						t2+='/';
						t2+=(const char *)pDirs[i];
						final+=t2;
						final+=' ';
						retval++;
						FREE_MEMORY(test);
					}
				}
			}
			pdstring_delete(ppDirs);
			buffer=pdstrdup(final);
		}
	} else {
		buffer=NULL;
	}
	return retval;
}
int build_dead_dirs ( char * & buffer ) { int retval = 0 ; const char * pDiscover = " " ; const char * pLock = " " ; const char * pTmpDir = NULL ; parray pDirs ( 32 ) ; parray * ppDirs = & pDirs ; int x = -1 ; pTmpDir = pdgetenv ( " " ) ; if ( pTmpDir == NULL ) pTmpDir = pdgetenv ( " " ) ; if ( pTmpDir == NULL ) pTmpDir = pdgetenv ( " " ) ; if ( pTmpDir ) { char * p = ( char * ) pTmpDir ; while ( * p ) { if ( * p == ' \\ ' ) * p = ' ' ; p ++ ; } x = pdlsdir ( ( char * ) pTmpDir , ppDirs ) ; if ( x > 0 ) { cstring final ; int i ; int nDiscoverLen = pdstrlen ( pDiscover ) ; for ( i = 0 ; i < x ; i ++ ) { if ( ! strncmp ( pDiscover , ( const char * ) pDirs [ i ] , nDiscoverLen ) ) { cstring cF ( pTmpDir ) ; cF += ' ' ; cF += ( const char * ) pDirs [ i ] ; cF += ' ' ; cF += pLock ; char * test = pdloadfile ( cF ) ; if ( test ) { cstring t2 ( pTmpDir ) ; t2 += ' ' ; t2 += ( const char * ) pDirs [ i ] ; final += t2 ; final += ' ' ; retval ++ ; FREE_MEMORY ( test ) ; } } } pdstring_delete ( ppDirs ) ; buffer = pdstrdup ( final ) ; } } else { buffer = NULL ; } return retval ; }
ISO_CPP_HEADERS
a function to build a list of dead discover directories.
ISO_CPP_HEADERS a function to build a list of dead discover directories .
//figure out the temp dir  //pero says kill the backslashes... //TCL prefers '/' separated paths, even on NT //build dir without lockfilename at end //add it to the list of directories