u32t _std mod_searchload(const char *name, u32t flags, qserr *error) { char path[QS_MAXPATH+1], mname[E32MODNAME+5], *epos; strncpy(mname,name,E32MODNAME); mname[E32MODNAME] = 0; epos = strrchr(mname,'.'); if (!epos||strlen(epos)>4) { epos = mname + strlen(mname); strcpy(epos,".DLL"); } else epos = 0; strupr(mname); if (error) *error = 0; *path=0; _searchenv(mname,"LIBPATH",path); if (!*path) _searchenv(mname,"PATH",path); if (!*path) _searchenv(name,"LIBPATH",path); if (!*path) _searchenv(name,"PATH",path); if (!*path&&epos) { strcpy(epos,".EXE"); _searchenv(mname,"PATH",path); } if (!*path) return 0; return mod_load(path, flags, error, 0); }
char *dos4g_path( void ) { int i; char *dos4gpath; static char fullpath[_MAX_PATH]; /* If DOS4GPATH points to an executable file name, don't bother searching any paths for DOS4GW.EXE. */ if( dos4gpath = getenv( "DOS4GPATH" ) ) { strlwr( strcpy( fullpath, dos4gpath ) ); if( strstr( fullpath, ".exe" ) ) return( fullpath ); } for( i = 0; i < sizeof( paths_to_check ) / sizeof( paths_to_check[0] ); i++ ) { _searchenv( "dos4gw.exe", paths_to_check[i], fullpath ); if( fullpath[0] ) return( fullpath ); } for( i = 0; i < sizeof( paths_to_check ) / sizeof( paths_to_check[0] ); i++ ) { _searchenv( "dos4g.exe", paths_to_check[i], fullpath ); if( fullpath[0] ) return( fullpath ); } /* Don't bother returning current directory since _searchenv covers this case */ return( "\\dos4gw.exe" ); }
/* * GetFromEnv - get file name from environment */ static void GetFromEnv( char *what, char *path ) { _searchenv( what, "EDPATH", path ); if( path[0] != 0 ) { return; } _searchenv( what, "PATH", path ); } /* GetFromEnv */
/* * WWinHelp - open an WinHelp file */ bool WWinHelp( HWND hwnd, LPCSTR helpFile, UINT fuCommand, HELP_DATA data ) { char buff[_MAX_PATH]; static bool open = false; if( fuCommand == HELP_QUIT && !open ) { return( false ); } open = true; if( helpFile != NULL ) { #if !defined( _WIN64 ) if( __IsDBCS ) { /* Look for Japanese version of help file first */ char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; char new_filename[_MAX_PATH]; _splitpath( helpFile, drive, dir, fname, ext ); if( strlen( fname ) < 8 ) { strcat( fname, "j" ); } else { fname[7] = 'j'; } _makepath( new_filename, drive, dir, fname, ext ); if( new_filename != NULL ) { _searchenv( new_filename, "WWINHELP", buff ); if( buff[0] != '\0' ) { helpFile = buff; return( WinHelp( hwnd, helpFile, fuCommand, data ) != 0 ); } _searchenv( new_filename, "PATH", buff ); if( buff[0] != '\0' ) { helpFile = buff; return( WinHelp( hwnd, helpFile, fuCommand, data ) != 0 ); } } } #endif /* Can't find the Japanese version, just look for the english one */ _searchenv( helpFile, "WWINHELP", buff ); if( buff[0] != '\0' ) { helpFile = buff; } } return( WinHelp( hwnd, helpFile, fuCommand, data ) != 0 ); } /* WWinHelp */
mad_status MADSysLoad( const char *path, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { mad_sys_handle shlib; mad_init_func *init_func; char newpath[_MAX_PATH]; char full_path[_MAX_PATH]; mad_status status; *sys_hdl = NULL_SYSHDL; strcpy( newpath, path ); strcat( newpath, ".so" ); shlib = dlopen( newpath, RTLD_NOW ); if( shlib == NULL ) { _searchenv( newpath, "PATH", full_path ); shlib = dlopen( full_path, RTLD_NOW ); if( shlib == NULL ) { return( MS_ERR | MS_FOPEN_FAILED ); } } status = MS_ERR | MS_INVALID_MAD; init_func = (mad_init_func *)dlsym( shlib, "MADLOAD" ); if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { *sys_hdl = shlib; return( MS_OK ); } dlclose( shlib ); return( status ); }
mad_status MADSysLoad( const char *path, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { HMODULE dll; mad_init_func *init_func; mad_status status; char madname[CCHMAXPATH] = ""; char madpath[CCHMAXPATH] = ""; /* To prevent conflicts with the 16-bit MAD DLLs, the 32-bit versions have the "D32" * extension. We will search for them along the PATH (not in LIBPATH); */ strcpy( madname, path ); strcat( madname, ".D32" ); _searchenv( madname, "PATH", madpath ); if( madpath[0] == '\0' || DosLoadModule( NULL, 0, madpath, &dll ) != 0 ) { return( MS_ERR|MS_FOPEN_FAILED ); } status = MS_ERR|MS_INVALID_MAD; if( DosQueryProcAddr( dll, 0, "MADLOAD", (PFN FAR *)&init_func ) == 0 && (*imp = init_func( &status, cli )) != NULL ) { *sys_hdl = dll; return( MS_OK ); } DosFreeModule( dll ); return( status ); }
char *xfind( char *fname, char *rundir ) { static char fpath[ LINE_MAX ]; assert( fname != NULL ); assert( rundir != NULL ); /* where call cl386 */ make_path( fname, rundir, fpath ); /*#if DEBUG printf( "*** 1.FindFile '%s'\n", fpath ); #endif*/ if ( access( fpath , F_OK ) == 0 ) return fpath; /*#if DEBUG printf( "*** 2.FindFile in %%PATH%% '%s'\n", fname ); #endif*/ /* in PATH */ _searchenv( fname, "PATH", fpath ); /*#if DEBUG printf( "*** 3.FindFile found '%s'\n", fpath ); #endif*/ if ( fpath[0] ) return fpath; strcpy(fpath,fname);; return fpath; }
RcStatus OpenTable( char *fname, char *path ) { WResFileID handle; RcStatus ret; ret = RS_OK; _searchenv( fname, "PATH", path ); if( path[0] == '\0' ) return( RS_FILE_NOT_FOUND ); handle = RCOPEN( path, O_RDONLY | O_BINARY, PMODE_RW ); if( handle == NIL_HANDLE ) { ret = RS_OPEN_ERROR; } if( ret == RS_OK ) ret = readDBHeader( handle ); if( ret == RS_OK ) ret = readDBRanges( handle ); if( ret == RS_OK ) ret = readDBIndex( handle ); if( ret == RS_OK ) ret = readDBTable( handle ); if( ret != RS_OPEN_ERROR ) RCCLOSE( handle ); if( ret == RS_OK ) { ConvToUnicode = DBStringToUnicode; } return( ret ); }
void find_libdir (void) { const char searchfile[] = "Colour.pal"; /* default_dir will be something like "C:\\LINCITY1.11" */ const char default_dir[] = "C:\\LINCITY" VERSION; // const char default_dir[] = "D:\\LINCITY"; /* For GCS's use */ /* Check 1: environment variable */ _searchenv (searchfile, "LINCITY_HOME", LIBDIR); if (*LIBDIR != '\0') { int endofpath_offset = strlen (LIBDIR) - strlen (searchfile) - 1; LIBDIR[endofpath_offset] = '\0'; return; } /* Check 2: default location */ if ((_access (default_dir, 0)) != -1) { strcpy (LIBDIR, default_dir); return; } /* Finally give up */ HandleError (_("Error. Can't find LINCITY_HOME"), FATAL); }
static bool MsgReadErrArray( void ) #endif { int i; char buffer[128]; unsigned msg_shift; msg_shift = _WResLanguage() * MSG_LANG_SPACING; for( i = ERR_FIRST_MESSAGE; i <= ERR_LAST_MESSAGE; i++ ) { #if !defined(__WINDOWS__) if( WResLoadString( &hInstance, i + msg_shift, (lpstr)buffer, sizeof( buffer ) ) <= 0 ) { #else if( LoadString( inst, i + msg_shift, (LPSTR)buffer, sizeof( buffer ) ) <= 0 ) { #endif if( i == ERR_FIRST_MESSAGE ) return( false ); buffer[0] = '\0'; } MsgArray[i - ERR_FIRST_MESSAGE] = my_alloc( strlen( buffer ) + 1 ); if( MsgArray[i - ERR_FIRST_MESSAGE] == NULL ) return( false ); _fstrcpy( MsgArray[i - ERR_FIRST_MESSAGE], buffer ); } return( true ); } #if !defined(__WINDOWS__) bool MsgInit( void ) { char buffer[_MAX_PATH]; #if defined(_PLS) char *fname; char fullpath[_MAX_PATH]; #endif bool rc; hInstance.status = 0; if( _cmdname( buffer ) != NULL ) { rc = OpenResFile( &hInstance, buffer ); #if defined(_PLS) if( !rc ) { _splitpath2( buffer, fullpath, NULL, NULL, &fname, NULL ); _makepath( buffer, NULL, NULL, fname, ".exp" ); _searchenv( buffer, "PATH", fullpath ); if( fullpath[0] != '\0' ) { rc = OpenResFile( &hInstance, fullpath ); } } #endif if( rc ) { MsgReadErrArray(); CloseResFile( &hInstance ); return( true ); } } CloseResFile( &hInstance ); posix_write( STDOUT_FILENO, NO_RES_MESSAGE, NO_RES_SIZE ); return( false ); }
char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char trpfile[CCHMAXPATH]; unsigned len; const char *ptr; APIRET rc; char trpname[CCHMAXPATH] = ""; char trppath[CCHMAXPATH] = ""; trap_init_func *init_func; if( parms == NULL || *parms == '\0' ) parms = "std"; for( ptr = parms; *ptr != '\0' && *ptr != TRAP_PARM_SEPARATOR; ++ptr ) ; len = ptr - parms; memcpy( trpfile, parms, len ); trpfile[len] = '\0'; /* To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32" * extension. We will search for them along the PATH (not in LIBPATH); */ strcpy( trpname, trpfile ); strcat( trpname, ".D32" ); _searchenv( trpname, "PATH", trppath ); if( trppath[0] == '\0' ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trpname ); return( buff ); } rc = DosLoadModule( NULL, 0, trppath, &TrapFile ); if( rc != 0 ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trppath ); return( buff ); } strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); if( DosQueryProcAddr( TrapFile, 1, NULL, (PFN*)&init_func ) == 0 && DosQueryProcAddr( TrapFile, 2, NULL, (PFN*)&FiniFunc ) == 0 && DosQueryProcAddr( TrapFile, 3, NULL, (PFN*)&ReqFunc ) == 0 ) { if( DosQueryProcAddr( TrapFile, 4, NULL, (PFN*)&InfoFunc ) != 0 ) { InfoFunc = NULL; } if( DosQueryProcAddr( TrapFile, 5, NULL, (PFN*)&HardFunc ) != 0 ) { HardFunc = NULL; } parms = ptr; if( *parms != '\0' ) ++parms; *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; return( NULL ); } strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } KillTrap(); return( buff ); }
static void FindPath( char *name, char *buf ) { //================================================= _searchenv( name, "PATH", buf ); if( buf[0] == '\0' ) { PrintMsg( CL_UNABLE_TO_FIND, name ); wfl_exit( 1 ); } }
void searchenv( const char * name, const char * env, char * buf ) { const char *src; char *dst; char *tmp; src = getenv( env ); if( src == (char *)0 ) { _searchenv( name, env, buf ); return; } strcpy( __pathbuff, FUNKY_ENVNAME "=" ); dst = &__pathbuff[ FUNKY_ENVNAME_LEN + 1 ]; for( ;; ) { if( *src == '\0' ) break; if( *src == '%' && *++src != '%' ) { tmp = dst; for( ;; ) { *dst = *src; if( *src == '\0' ) break; if( *src++ == '%' ) break; ++dst; } *dst = '\0'; dst = getenv( tmp ); if( dst == (char *)0 ) { dst = tmp; } else { strcpy( tmp, dst ); dst = &tmp[strlen(tmp)]; } } else { *dst++ = *src++; } } *dst = '\0'; putenv( __pathbuff ); _searchenv( name, FUNKY_ENVNAME, buf ); __pathbuff[ FUNKY_ENVNAME_LEN + 1 ] = '\0'; putenv( __pathbuff ); }
char *dos4g_path() { static char fullpath[80]; int i; for( i = 0; i < sizeof( paths_to_check ) / sizeof( paths_to_check[0] ); i++ ) { _searchenv( "dos4gw.exe", paths_to_check[i], fullpath ); if( fullpath[0] ) return( &fullpath ); } return( "\dos4gw.exe" ); }
static int openUnicodeFile( char *filename ) { int fh; char fullpath[ _MAX_PATH ]; #if defined(__QNX__) _searchenv( filename, "ETC_PATH", fullpath ); if( fullpath[0] == '\0' ) { #define ETC "/usr/watcom" strcpy( fullpath, ETC ); strcpy( &fullpath[ sizeof( ETC ) - 1 ], filename ); } #else _searchenv( filename, "PATH", fullpath ); #endif fh = -1; if( fullpath[0] != '\0' ) { fh = open( fullpath, O_RDONLY | O_BINARY ); } return( fh ); }
static FILE *OpenUnicodeFile( const char *filename ) { FILE *fp; char fullpath[_MAX_PATH]; #if defined(__QNX__) _searchenv( filename, "ETC_PATH", fullpath ); if( fullpath[0] == '\0' ) { #define ETC "/etc/" memcpy( fullpath, ETC, sizeof( ETC ) - 1 ); strcpy( fullpath + sizeof( ETC ) - 1, filename ); } #else _searchenv( filename, "PATH", fullpath ); #endif fp = NULL; if( fullpath[0] != '\0' ) { fp = fopen( fullpath, "r" ); } return( fp ); }
int main(int argc, char *argv[]) { char path[256]; _wildcard(&argc, &argv); /* Search in current dir and then in directories on PATH */ _searchenv(EXE_NAME, "PATH", path); if(path[0] == 0) { /* Search directories in HFSUTILS variable */ _searchenv(EXE_NAME, "HFSUTILS", path); } if(path[0] == 0) { fprintf(stderr, "Cannot find the hfsutil executable.\n" "Please set the HFSUTIL variable.\n"); return -1; } return spawnv(P_WAIT, path, argv); }
void main() { FILE *help_file; char full_path[ _MAX_PATH ]; _searchenv( "watcomc.hlp", "PATH", full_path ); if( full_path[0] == '\0' ) { printf( "Unable to find help file\n" ); } else { help_file = fopen( full_path, "r" ); display_help( help_file ); fclose( help_file ); } }
dig_fhandle DIGPathOpen( const char *name, unsigned name_len, const char *exts, char *result, unsigned max_result ) { bool has_ext; bool has_path; const char *src; char *dst; char trpfile[256]; tiny_ret_t rc; char c; result = result; max_result = max_result; has_ext = FALSE; has_path = FALSE; src = name; dst = trpfile; while( name_len-- > 0 ) { c = *src++; *dst++ = c; switch( c ) { case '.': has_ext = TRUE; break; case '/': case '\\': has_ext = FALSE; /* fall through */ case ':': has_path = TRUE; break; } } if( !has_ext ) { *dst++ = '.'; name_len = strlen( exts ); memcpy( dst, exts, name_len ); dst += name_len; } *dst = '\0'; if( has_path ) { rc = TinyOpen( trpfile, TIO_READ ); } else { _searchenv( trpfile, "PATH", RWBuff ); rc = TinyOpen( RWBuff, TIO_READ ); } return( TINY_ERROR( rc ) ? DIG_NIL_HANDLE : TINY_INFO( rc ) ); }
BOOL CMainUIDlg::IsAppRun(CString AppName) { char pPath[_MAX_PATH]; pPath[0]=0; const char *cExeName = CStrToChar(AppName); _searchenv(cExeName, "PATH ",pPath); VERIFY(pPath); DWORD id=GetProcessIdFromName(AppName);//这样查杀AppName if(id!=NULL) { HANDLE myhandle=OpenProcess(PROCESS_ALL_ACCESS,TRUE,id); DWORD exitcode=0; TerminateProcess(myhandle,exitcode); return TRUE; } return FALSE; }
char *LocateCfgFile(const char *filename, char *paths_to_check[]) // 喘ergabe: filename == string im 8.3 format // R…kgabe: vollst. Pfad zur gefundenen Datei (current dir first) { int i = 0; static char fullpath[_MAX_PATH]; while (paths_to_check[i] != NULL) { _searchenv(filename, paths_to_check[i], fullpath); if (fullpath[0]) break; i++; } if (fullpath[0]) return &fullpath; else return NULL; } // LocateCfgFile()
/* * WHtmlHelp - open an HTML Help file */ bool WHtmlHelp( HWND hwnd, LPCSTR helpFile, UINT fuCommand, HELP_DATA data ) { #ifdef __NT__ char buff[_MAX_PATH]; if( pfnHtmlHelp == NULL ) { HINSTANCE hInstance = LoadLibrary( "HHCTRL.OCX" ); if( hInstance == NULL ) { return( false ); } pfnHtmlHelp = (PFNHH)GetProcAddress( hInstance, "HtmlHelpA" ); if( pfnHtmlHelp == NULL ) { return( false ); } } switch( fuCommand ) { case HELP_CONTENTS: fuCommand = HH_DISPLAY_TOC; break; case HELP_CONTEXT: fuCommand = HH_HELP_CONTEXT; break; case HELP_PARTIALKEY: case HELP_KEY: fuCommand = HH_DISPLAY_INDEX; break; default: return( false ); } _searchenv( helpFile, "WHTMLHELP", buff ); if( buff[0] != '\0' ) { helpFile = buff; } return( pfnHtmlHelp( hwnd, helpFile, fuCommand, data ) != NULL ); #else hwnd = hwnd; helpFile = helpFile; fuCommand = fuCommand; data = data; return( false ); #endif } /* WHtmlHelp */
RcStatus OpenTable( char *fname, char *path ) { int fp; RcStatus status; status = RS_OK; _searchenv( fname, "PATH", path ); if( path[0] == '\0' ) return( RS_FILE_NOT_FOUND ); fp = RcOpen( path, O_RDONLY | O_BINARY ); if( fp == -1 ) { status = RS_OPEN_ERROR; } if( status == RS_OK ) status = readDBHeader( fp ); if( status == RS_OK ) status = readDBRanges( fp ); if( status == RS_OK ) status = readDBIndex( fp ); if( status == RS_OK ) status = readDBTable( fp ); if( status != RS_OPEN_ERROR ) RcClose( fp ); if( status == RS_OK ) { ConvToUnicode = DBStringToUnicode; } return( status ); }
void findpath(char const *filename, char *fullpathname) // return full pathnames { char fname[FILE_MAX_FNAME]; char ext[FILE_MAX_EXT]; char temp_path[FILE_MAX_PATH]; splitpath(filename ,nullptr,nullptr,fname,ext); makepath(temp_path,"" ,"" ,fname,ext); if (checkcurdir && access(temp_path,0) == 0) // file exists { strcpy(fullpathname,temp_path); return; } strcpy(temp_path,filename); // avoid side effect changes to filename if (temp_path[0] == SLASHC || (temp_path[0] && temp_path[1] == ':')) { if (access(temp_path,0) == 0) // file exists { strcpy(fullpathname,temp_path); return; } else { splitpath(temp_path ,nullptr,nullptr,fname,ext); makepath(temp_path,"" ,"" ,fname,ext); } } fullpathname[0] = 0; // indicate none found _searchenv(temp_path,"PATH",fullpathname); if (fullpathname[0] != 0) // found it! { if (strncmp(&fullpathname[2],SLASHSLASH,2) == 0) // stupid klooge! { strcpy(&fullpathname[3],temp_path); } } }
char *FindOld( char *name ) { char temp[_MAX_PATH]; int retcode; _splitpath( name, drive, dir, fname, ext ); _makepath( temp, "", "", fname, ext ); retcode = 1; #if defined( INSTALL_PROGRAM ) { retcode = SecondaryPatchSearch( name, path ); } #endif if( retcode && path[0] == '\0' ) { _searchenv( temp, "PATH", path ); } if( path[ 0 ] == '\0' ) { FilePatchError( ERR_CANT_OPEN, temp ); return( NULL ); } return( path ); }
void FindExtender( char *extname, char *winext ) { char *watcom; _searchenv( extname, "PATH", winext ); if( winext[0] == '\0' ) { watcom = getenv( "WATCOM" ); if( watcom != NULL ) { strcpy( winext, watcom ); #if defined( __UNIX__ ) strcat( winext, "/binw/" ); #else strcat( winext, "\\binw\\" ); #endif strcat( winext, extname ); if( access( winext, R_OK ) == -1 ) { winext[0] = '\0'; // indicate file not found } } if( winext[0] == '\0' ) { doError( "Could not find \"%s\" in your path", extname ); } } }
dig_fhandle PathOpen( char *name, unsigned len, char *ext ) { char path[ _MAX_PATH ]; char *realname; char *filename; len = len; if( ext == NULL || *ext == '\0' ) { realname = name; } else { realname = MemAlloc( _MAX_PATH ); filename = MemAlloc( _MAX_FNAME ); _splitpath( name, NULL, NULL, filename, NULL ); _makepath( realname, NULL, NULL, filename, ext ); MemFree( realname ); MemFree( filename ); } _searchenv( realname, "PATH", path ); if( *path == '\0' ) { return( -1 ); } else { return( DIGCliOpen( path, DIG_READ ) ); } }
void WWIV_make_abs_cmd(std::string& out) { // pszOutBuffer must be at least MAX_PATH in size. char s[MAX_PATH], s1[MAX_PATH], s2[MAX_PATH], *ss1; char szTempBuf[MAX_PATH]; strncpy(s1, out.c_str(), MAX_PATH); if (s1[1] == ':') { if (s1[2] != '\\') { _getdcwd(wwiv::UpperCase<char>(s1[0]) - 'A' + 1, s, MAX_PATH); if (s[0]) { _snprintf(s1, sizeof(s1), "%c:\\%s\\%s", s1[0], s, out.substr(2).c_str()); } else { _snprintf(s1, sizeof(s1), "%c:\\%s", s1[0], out.substr(2).c_str()); } } } else if (s1[0] == '\\') { _snprintf(s1, sizeof(s1), "%c:%s", GetApplication()->GetHomeDir()[0], out.c_str()); } else { strncpy(s2, s1, sizeof(s2)); strtok(s2, " \t"); if (strchr(s2, '\\')) { _snprintf(s1, sizeof(s1), "%s%s", GetApplication()->GetHomeDir().c_str(), out.c_str()); } } char* ss = strchr(s1, ' '); if (ss) { *ss = '\0'; _snprintf(s2, sizeof(s2), " %s", ss + 1); } else { s2[0] = '\0'; } for (int i = 0; exts[i]; i++) { if (i == 0) { ss1 = strrchr(s1, '\\'); if (!ss1) { ss1 = s1; } if (strchr(ss1, '.') == 0) { continue; } } _snprintf(s, sizeof(s), "%s%s", s1, exts[i]); if (s1[1] == ':') { if (WFile::Exists(s)) { std::ostringstream os; os << s << s2; out = os.str(); return; } } else { if (WFile::Exists(s)) { std::ostringstream os; os << GetApplication()->GetHomeDir() << s << s2; out = os.str(); } else { _searchenv(s, "PATH", szTempBuf); ss1 = szTempBuf; if (ss1 && strlen(ss1) > 0) { std::ostringstream os; os << ss1 << s2; out = os.str(); return; } } } } std::ostringstream os; os << GetApplication()->GetHomeDir() << s1 << s2; out = os.str(); }
void GetProg( char *cmd, char *eoc ) { char save; char prog_name[_MAX_PATH]; char buff1[_MAX_PATH2]; char buff2[_MAX_PATH2]; char *drive; char *dir; char *fname; char *ext; char *sfname; #ifdef __WINDOWS__ unsigned a,b; char **drivep; char **dirp; char buff3[_MAX_DRIVE+MAX_PATH+5]; #endif save = *eoc; *eoc = '\0'; _splitpath2( (char *)cmd, (char *)buff1, (char **)&drive, (char **)&dir, (char **)&fname, (char **)&ext ); *eoc = save; #ifdef __NETWARE__ if( ext[0] == '\0' ) ext = ".nlm"; #elif defined( __DOS__ ) && defined( _PLS ) if( ext[0] == '\0' ) ext = ".exp"; #elif !defined( __UNIX__ ) if( ext[0] == '\0' ) ext = ".exe"; #endif _makepath( (char *)prog_name, (char *)drive, (char *)dir, (char *)fname, (char *)ext ); if( drive[0] == '\0' && dir[0] == '\0' ) { _searchenv( (char *)prog_name, "PATH", ExeName ); } else if( access( (char *)prog_name, R_OK ) == 0 ) { strcpy( ExeName, (char *)prog_name ); } if( ExeName[0] == '\0' ) { Output( MsgArray[MSG_PROGRAM - ERR_FIRST_MESSAGE] ); Output( (char *)prog_name ); Output( "\r\n" ); fatal(); } #ifdef __WINDOWS__ /* * for windows, we need to make our current directory the * same as that for the EXE, since windows moves our current directory * to that of the sampler */ _splitpath2( ExeName, buff2, &drive, &dir, NULL, NULL ); a = tolower( drive[0] ) - 'a' + 1; _dos_setdrive( a, &b ); dir[strlen( dir ) - 1] = '\0'; chdir( dir ); #endif _splitpath2( SampName, (char *)buff2, (char **)&drive, (char **)&dir, (char **)&sfname, (char **)&ext ); /* * for windows, we need to give the sample file an absolute * path name so that both threads of the sampler can write * to the sample file */ #ifdef __WINDOWS__ drivep = (drive[0] == '\0') ? &drive : NULL; dirp = (dir[0] == '\0') ? &dir : NULL; if( drivep != NULL || dirp != NULL ) { _splitpath2( ExeName, buff3, drivep, dirp, NULL, NULL ); } #endif _makepath( SampName, (char *)drive, (char *)dir, (char *)(sfname[0] == '\0' ? fname : sfname), ext[0] == '\0' ? (char *)"smp" : (char *)ext ); #ifdef __WINDOWS__ _fstrcpy( SharedMemory->SampName, SampName ); #endif }
HELPIO void HelpSearchEnv( char *name, char *env_var, char *buf ) { _searchenv( name, env_var, buf ); }