int main(int argc, char *argv[]) { static struct WSAData wsa_state; TCHAR *c, stunnel_exe_path[MAX_PATH]; /* set current working directory and engine path */ GetModuleFileName(0, stunnel_exe_path, MAX_PATH); c=_tcsrchr(stunnel_exe_path, TEXT('\\')); /* last backslash */ if(c) /* found */ c[1]=TEXT('\0'); /* truncate program name */ #ifndef _WIN32_WCE if(!SetCurrentDirectory(stunnel_exe_path)) { /* log to stderr, as s_log() is not initialized */ _ftprintf(stderr, TEXT("Cannot set directory to %s"), stunnel_exe_path); return 1; } #endif _tputenv_s(TEXT("OPENSSL_ENGINES"), stunnel_exe_path); str_init(); /* initialize per-thread string management */ if(WSAStartup(MAKEWORD(1, 1), &wsa_state)) return 1; resolver_init(); main_init(); if(!main_configure(argc>1 ? argv[1] : NULL, argc>2 ? argv[2] : NULL)) daemon_loop(); main_cleanup(); return 0; }
BOOL CGit::CheckMsysGitDir() { static BOOL bInitialized = FALSE; if (bInitialized) { return TRUE; } TCHAR *oldpath,*home; size_t size; // set HOME if not set already _tgetenv_s(&size, NULL, 0, _T("HOME")); if (!size) { _tdupenv_s(&home,&size,_T("USERPROFILE")); _tputenv_s(_T("HOME"),home); free(home); } //setup ssh client CRegString sshclient=CRegString(_T("Software\\TortoiseGit\\SSH")); CString ssh=sshclient; if(!ssh.IsEmpty()) { _tputenv_s(_T("GIT_SSH"),ssh); }else { _tputenv_s(_T("GIT_SSH"),_T("")); } // search PATH if git/bin directory is alredy present if ( FindGitPath() ) { bInitialized = TRUE; return TRUE; } // add git/bin path to PATH CRegString msysdir=CRegString(REG_MSYSGIT_PATH,_T(""),FALSE,HKEY_LOCAL_MACHINE); CString str=msysdir; if(str.IsEmpty()) { CRegString msysinstalldir=CRegString(REG_MSYSGIT_INSTALL,_T(""),FALSE,HKEY_LOCAL_MACHINE); str=msysinstalldir; if ( !str.IsEmpty() ) { str += (str[str.GetLength()-1] != '\\') ? "\\bin" : "bin"; msysdir=str; msysdir.write(); } else { return false; } } //CGit::m_MsysGitPath=str; //set path _tdupenv_s(&oldpath,&size,_T("PATH")); CString path; path.Format(_T("%s;%s"),oldpath,str); _tputenv_s(_T("PATH"),path); CString sOldPath = oldpath; free(oldpath); if( !FindGitPath() ) { return false; } else { #ifdef _TORTOISESHELL l_processEnv = GetEnvironmentStrings(); // updated environment is now duplicated for use in CreateProcess, restore original PATH for current process _tputenv_s(_T("PATH"),sOldPath); #endif bInitialized = TRUE; return true; } }