BOOL CBwchartApp::InitInstance() { // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. SetRegistryKey("bwchart"); // Enable drag/drop open //m_pMainWnd->DragAcceptFiles(); if(strstr(AfxGetApp()->m_lpCmdLine,"-korean")!=0) SetThreadLocale(MAKELCID(MAKELANGID(LANG_KOREAN,SUBLANG_KOREAN),SORT_DEFAULT )); else if(strstr(AfxGetApp()->m_lpCmdLine,"-english")!=0) SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT )); else if(strstr(AfxGetApp()->m_lpCmdLine,"-chinese")!=0) SetThreadLocale(MAKELCID(MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED),SORT_DEFAULT )); else DlgOptions::SetLanguage(); // corrupted file CString corrupted = AfxGetApp()->GetProfileString("LOG","LASTREP",""); if(!corrupted.IsEmpty()) { CString msg; msg.Format(IDS_CORRUPTED3,(const char*)corrupted); AfxMessageBox(msg,MB_OK|MB_ICONEXCLAMATION); AfxGetApp()->WriteProfileString("LOG","LASTREP",""); AfxGetApp()->WriteProfileString("MAIN","LASTREPLAY",""); } // command line mode? if(strstr(m_lpCmdLine,"/rep")!=0) { m_exitCode = /*m_msgCur.wParam =*/ _CommandLineMode(); } else { // windowed mode DlgBWChart dlg(m_lpCmdLine); m_pMainWnd = &dlg; dlg.DoModal(); } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
int __cdecl main(int argc, char *argv[]) { LCID lcid; if (PAL_Initialize(argc, argv)) { return FAIL; } lcid = GetUserDefaultLCID(); if (lcid == 0) { Fail("GetUserDefaultLCID failed!\n"); } if (!IsValidLocale(lcid, LCID_INSTALLED)) { Fail("GetUserDefaultLCID gave an invalid locale!\n"); } /* Make sure results consistent with using LOCALE_USER_DEFAULT */ if (!SetThreadLocale(LOCALE_USER_DEFAULT)) { Fail("Unexpected error testing GetUserDefaultLCID!\n"); } if (GetThreadLocale() != lcid) { Fail("Results from GetUserDefaultLCID inconsistent with " "LOCALE_USER_DEFAULT!\n"); } PAL_Terminate(); return PASS; }
STDMETHODIMP DDTaskManager::SetLocale(/* in */ LCID lcid) { if (!SetThreadLocale(lcid)) { _ASSERTE(!"Couldn't set thread-locale"); return HRESULT_FROM_WIN32(GetLastError()); } return S_OK; }
int __cdecl _tmain(int argc, TCHAR** argv) { int nErrors; //init the static g_szModuleName: if(GetModuleFileName(NULL, g_szModuleName, FC_ARRAY_LEN(g_szModuleName))==0) { FC_ASSERT_LASTERR(_T("GetModuleFileName")); return 1; } //do some core init: InitModuleCheckMemory(MODULE_NAME); if(FAILED(CoInitialize(NULL))) { _tprintf(CG_FATAL_MSGFMT,__FILE__,__LINE__,_T("CoInitialize failed")); nErrors = 1; goto Ende; } //always remove the module name. argv++; argc--; //get internal debug switches: if(argc>0 && !lstrcmpi(_T("-!bug"), argv[0])) { argv++;argc--; if(argc>0 && !lstrcmpi(_T("heap"), argv[0])) { argv++;argc--; if(argc>0) { FC_SetAllocBreak(_tcstoul(argv[0], NULL, 10)); argv++;argc--; } } } //TODO get from registry if(!SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),SORT_DEFAULT))) { FC_ASSERT_LASTERR("SetThreadLocale()"); //don't care any more... } //enter main backend routine: nErrors = CGPCmain(argc, argv); CoUninitialize(); Ende: ExitModuleCheckMemory(MODULE_NAME); return nErrors?1:0; }
bool CLanguageLocale::SetLanguage(int nID) { bool bFound = false; if(m_nDataSource == LOADSTRING_FROM_RC) { switch (nID) { /*case LANGUAGE_CHS: bFound = SetThreadLocale(MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED))==TRUE; break;*/ case LANGUAGE_PERSONAL: bFound = SetThreadLocale(MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_TRADITIONAL))==TRUE; break; case LANGUAGE_ENGLISH: bFound = SetThreadLocale(MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT))==TRUE; break; } } else { CFileFind find; BOOL bRet = find.FindFile(m_strPath + "\\*.ini"); bool bFound = false; int nLanguage = 0; gStrFileName.Empty(); while(bRet) { bRet = find.FindNextFile(); if(find.IsDots() || find.IsDirectory()) continue; CString szFilePath = find.GetFilePath(); nLanguage = GetPrivateProfileInt(_T("Setting"),_T("Language"),-1,szFilePath); if(nLanguage == nID) { gStrFileName = szFilePath; bFound = true; break; } } find.Close(); } return bFound; }
int __cdecl main(int argc, char *argv[]) { LCID lcid; if (PAL_Initialize(argc, argv)) { return FAIL; } /* * Passing LOCALE_USER_DEFAULT to IsValidLocale will fail, so instead * the current thread localed is changed to it, and that lcid is passed * to IsValidLocale (which should always pass) */ if (!SetThreadLocale(LOCALE_USER_DEFAULT)) { Fail("Unable to set locale to LOCALE_USER_DEFAULT!\n"); } lcid = GetThreadLocale(); if (!IsValidLocale(lcid, LCID_SUPPORTED)) { Fail("IsValidLocale found the default user locale unsupported!\n"); } if (!IsValidLocale(lcid, LCID_INSTALLED)) { Fail("IsValidLocale found the default user locale uninstalled!\n"); } /* * Test out bad parameters */ if (IsValidLocale(-1, LCID_SUPPORTED)) { Fail("IsValideLocale passed with an invalid LCID!\n"); } if (IsValidLocale(-1, LCID_INSTALLED)) { Fail("IsValideLocale passed with an invalid LCID!\n"); } if (IsValidLocale(LOCALE_USER_DEFAULT, LCID_SUPPORTED)) { Fail("IsValidLocale passed with LOCALE_USER_DEFAULT!\n"); } if (IsValidLocale(LOCALE_USER_DEFAULT, LCID_INSTALLED)) { Fail("IsValidLocale passed with LOCALE_USER_DEFAULT!\n"); } PAL_Terminate(); return PASS; }
CJbookletApp::CJbookletApp() { // TODO: この位置に構築用のコードを追加してください。 // ここに InitInstance 中の重要な初期化処理をすべて記述してください。 m_langCode = GetThreadLocale(); if ( m_langCode != 0x0411 ) m_langCode = 0x0409; // 「日本語」以外の場合は強制的に「英語」にする SetThreadLocale( m_langCode ); }
int __cdecl main(int argc, char *argv[]) { LCID lcid; LANGID LangID; if (PAL_Initialize(argc, argv)) { return FAIL; } LangID = GetSystemDefaultLangID(); if (LangID == 0) { Fail("GetSystemDefaultLangID failed!\n"); } /* Try using the langid (with default sort) as a locale */ if (!SetThreadLocale(MAKELCID(LangID, SORT_DEFAULT))) { Fail("Unable to use GetSystemDefaultLangID as a locale!\n"); } lcid = GetThreadLocale(); if (!IsValidLocale(lcid, LCID_INSTALLED)) { Fail("Unable to use GetSystemDefaultLangID as a locale!\n"); } /* Make sure results consistent with using LOCALE_USER_DEFAULT */ if (!SetThreadLocale(LOCALE_USER_DEFAULT)) { Fail("Unexpected error testing GetSystemDefaultLangID!\n"); } if (GetThreadLocale() != lcid) { Fail("Results from GetSystemDefaultLangID inconsistent with " "LOCALE_USER_DEFAULT!\n"); } PAL_Terminate(); return PASS; }
LanguageLock::~LanguageLock() { SetThreadLocale(old_lcid); HMODULE hKernel32 = GetModuleHandle(L"Kernel32.dll"); typedef LANGID (WINAPI *FP_SetThreadUILanguage)(LANGID LangId); FP_SetThreadUILanguage pSetThreadUILanguage = (FP_SetThreadUILanguage)GetProcAddress(hKernel32, "SetThreadUILanguage"); typedef LANGID (WINAPI *FP_GetThreadUILanguage)(); FP_GetThreadUILanguage pGetThreadUILanguage = (FP_GetThreadUILanguage)GetProcAddress(hKernel32, "GetThreadUILanguage"); if (pSetThreadUILanguage && pGetThreadUILanguage) pSetThreadUILanguage(old_langid); }
const char *Language::Translate(const char *lang, const char *string) { if (!string || !*string) return ""; if (!lang || !*lang) lang = Config->DefLanguage.c_str(); #ifdef _WIN32 SetThreadLocale(MAKELCID(MAKELANGID(WindowsGetLanguage(lang), SUBLANG_DEFAULT), SORT_DEFAULT)); #else /* First, set LANG and LANGUAGE env variables. * Some systems (Debian) don't care about this, so we must setlocale LC_ALL as well. * BUT if this call fails because the LANGUAGE env variable is set, setlocale resets * the locale to "C", which short circuits gettext and causes it to fail on systems that * use the LANGUAGE env variable. We must reset the locale to en_US (or, anything not * C or POSIX) then. */ setenv("LANG", lang, 1); setenv("LANGUAGE", lang, 1); if (setlocale(LC_ALL, lang) == NULL) setlocale(LC_ALL, "en_US"); #endif const char *translated_string = dgettext("anope", string); for (unsigned i = 0; translated_string == string && i < Domains.size(); ++i) translated_string = dgettext(Domains[i].c_str(), string); #ifdef _WIN32 SetThreadLocale(MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), SORT_DEFAULT)); #else unsetenv("LANGUAGE"); unsetenv("LANG"); setlocale(LC_ALL, ""); #endif return translated_string; }
static bool setLocaleWindows(USHORT usPrimaryLanguage, USHORT usSubLanguage) { bool success = SUCCEEDED( SetThreadLocale( MAKELCID( MAKELANGID(usPrimaryLanguage, usSubLanguage), SORT_DEFAULT ) ) ); if (!success) { info("Failed to set locale to \"%d\"", usPrimaryLanguage); } else { debug(LOG_WZ, "Requested locale \"%d\"", usPrimaryLanguage); } setlocale(LC_NUMERIC, "C"); // set radix character to the period (".") return success; }
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); wcscpy_s(g_exePath, _wpgmptr); auto c = wcsrchr(g_exePath, L'\\'); if (c) c[1] = L'\0'; LoadSettings(); SetThreadLocale(MAKELCID(languages[g_browserSettings.language], SORT_DEFAULT)); SetThreadUILanguage(languages[g_browserSettings.language]); InitMUILanguage(languages[g_browserSettings.language]); WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NOERROR) return FALSE; if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK) return FALSE; MyRegisterClass(hInstance); if (!InitInstance(hInstance, nCmdShow)) return FALSE; MSG msg; while (GetMessage(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } curl_global_cleanup(); WSACleanup(); return (int)msg.wParam; }
LanguageLock::LanguageLock( int app_language ) { HMODULE hKernel32 = GetModuleHandle(L"Kernel32.dll"); typedef LANGID (WINAPI *FP_SetThreadUILanguage)(LANGID LangId); FP_SetThreadUILanguage pSetThreadUILanguage = (FP_SetThreadUILanguage)GetProcAddress(hKernel32, "SetThreadUILanguage"); typedef LANGID (WINAPI *FP_GetThreadUILanguage)(); FP_GetThreadUILanguage pGetThreadUILanguage = (FP_GetThreadUILanguage)GetProcAddress(hKernel32, "GetThreadUILanguage"); old_lcid = GetThreadLocale(); SetThreadLocale(app_language); old_langid = 0; if (pSetThreadUILanguage && pGetThreadUILanguage) { old_langid = pGetThreadUILanguage(); pSetThreadUILanguage(app_language); } }
/* Set (or re-set) the language for the application. */ void set_language(int id) { LCID lcidNew = MAKELCID(id, dwSubLangID); if (lang_id != lcidNew) { /* Set our new language ID. */ lang_id = lcidNew; SetThreadLocale(lang_id); /* Load the strings table for this ID. */ LoadCommonStrings(); #if 0 /* Update the menus for this ID. */ MenuUpdate(); #endif } }
void I18N_Set_Language( const std::string &language ) { #ifdef _WIN32 int primary_language = Get_Windows_Primary_Language( language ); int sub_language = Get_Windows_Sub_Language( language ); bool success = SUCCEEDED( SetThreadLocale( MAKELCID( MAKELANGID( primary_language, sub_language ), SORT_DEFAULT ) ) ); if( !success ) { debug_print("Failed to set translation locale to %d %d\n", primary_language, sub_language); } else { debug_print("Translation locale set to %d %d\n", primary_language, sub_language); } //putenv(("LANG=" + std::string(_nl_locale_name_default())).c_str()); #else setenv( "LANGUAGE", language.c_str(), 1 ); #endif }
static DWORD WINAPI CreateViewPicWnd(void*bmp) { SetThreadLocale(locale_ID); HWND pic; MSG msg; pic=CreateWindowEx(0,_T("ShowPicClass"),_T("截图查看(双击保存)"), WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, 0,0,hInst,0); SendMessage(pic,STM_SETIMAGE,0,(LPARAM)bmp); SetWindowLong(pic,0,GetWindowLong(pic,0)|SHP_DELBMPONCLOSE); SendMessage(pic,WM_SETFLAG,0,0); SetScaling(pic,5.0); AnimateWindow(pic,500,AW_ACTIVATE|AW_VER_NEGATIVE|AW_SLIDE); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
void CLanguage::ParseLanguageFile( const CUString& strFileName ) { BOOL bResult = TRUE; DWORD dwRevision = 0; FILE* pFile = NULL; CUString strFullFileName = m_strLanguageDir + _W("\\lang\\") + strFileName + m_strLangFileExt; CUStringConvert strCnv; pFile = CDexOpenFile( strFullFileName, _W( "r" ) ); if ( NULL != pFile ) { CHAR lpszRead[ 1024 ]; int nStart = 0; int nStop = 0; CUString strRead; memset( lpszRead, 0, sizeof( lpszRead ) ); while ( fgets( lpszRead, sizeof( lpszRead ), pFile ) ) { bool bHasNumber = false; bool bIsMenu = false; bool bIsDialog = false; bool bHasString = false; DWORD nIndex = 0; CLangElement newElement; strRead = _T( "" ); for ( nIndex = 0; nIndex< strlen( lpszRead ); nIndex++ ) { if ( ( lpszRead[ nIndex ] != 0x0A ) && ( lpszRead[ nIndex ] != 0x0D ) ) { strRead += (TCHAR)lpszRead[ nIndex ]; } } TranslateTab( strRead ); nStart = strRead.Find( _T( '#' ) ); if ( nStart >= 0 ) { if ( ( nStart + 1 ) == strRead.Find( _T( 'M' ) ) ) { nStart++; bIsMenu = TRUE; } else if ( ( nStart + 1 ) == strRead.Find( _T( 'D' ) ) ) { nStart++; bIsDialog = TRUE; } nStop = strRead.Find( _T( '#' ), nStart + 1 ); if ( nStop > 2 ) { CUString strID ( strRead.Mid( nStart + 1, nStop - nStart -1 ) ); swscanf( strID, _W( "%x" ), &newElement.nID ); bHasNumber = true; } } else { if ( strRead.Find( CODEPAGETAG ) == 0 ) { m_dwCodePageID = _wtoi( strRead.Mid( CODEPAGETAG.GetLength() ) ); } else if ( strRead.Find( LANGTAG ) == 0 ) { m_dwLangID = _wtoi( strRead.Mid( LANGTAG.GetLength() ) ); } else if ( strRead.Find( SUBLANGTAG ) == 0 ) { m_dwSubLangID = _wtoi( strRead.Mid( SUBLANGTAG.GetLength() ) ); } else if ( strRead.Find( REVISIONTAG ) == 0 ) { int nPos; nPos = strRead.Find( _W( ",v " ) ); if ( nPos >= 0 ) { float fVersion = 1.0f; swscanf( strRead.Mid( nPos+3,4 ), _W( "%f" ), &fVersion ); dwRevision = (DWORD)( 100 * ( fVersion + 0.005 ) ); } } } nStart = strRead.Find( '"' ); if ( nStart >= 0 ) { nStop = strRead.Find( '"', nStart + 1 ); if ( nStop > 2 ) { lpszRead[ 0 ] = '\0'; for ( nIndex = nStart + 1; nIndex < (DWORD)nStop; nIndex++) { lpszRead[ nIndex - nStart - 1] = (CHAR)strRead.GetAt( nIndex ); lpszRead[ nIndex - nStart ] = '\0'; } newElement.strValue = CUString( lpszRead, m_dwCodePageID ); bHasString = true; } } if ( bHasString && bHasNumber ) { if ( bIsMenu ) { m_vMenus.push_back( newElement ); } else if ( bIsDialog ) { m_vDialogs.push_back( newElement ); } else { m_vStrings.push_back( newElement ); } } memset( lpszRead, 0, sizeof( lpszRead ) ); } fclose( pFile ); } #ifdef UNICODE TCHAR* pTest = _wsetlocale( LC_ALL, GetString( 99 ) ); #else TCHAR* pTest = setlocale( LC_ALL, strCnv.ToT( GetString( 99 ) ) ); #endif SetThreadLocale( MAKELCID( m_dwLangID, m_dwSubLangID ) ); setlocale( LC_NUMERIC, "English" ); }
BOOL CMultiLanguagesApp::InitInstance() { //SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), SORT_DEFAULT)); // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); AfxEnableControlContainer(); // 创建 shell 管理器,以防对话框包含 // 任何 shell 树视图控件或 shell 列表视图控件。 CShellManager *pShellManager = new CShellManager; // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); // 判断你是否存在配置文件,如果存在,从配置文件中读取语言设置 CString strFileName = _T("Language.ini"); if (PathFileExists(strFileName)) { LCID lcidThread = 0; CFile file; file.Open(strFileName, CFile::modeRead | CFile::typeBinary); file.Read(&lcidThread, sizeof(LCID)); file.Close(); SetThreadLocale(lcidThread); } CMultiLanguagesDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } // 删除上面创建的 shell 管理器。 if (pShellManager != NULL) { delete pShellManager; } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
int main (int argc, char **argv) { #ifdef G_OS_WIN32 extern void link_shutdown (void); #endif GConfClient *client; #if DEVELOPMENT gboolean skip_warning_dialog; #endif GnomeProgram *program; GnomeClient *master_client; GOptionContext *context; char *filename; /* Make ElectricFence work. */ free (malloc (10)); bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); context = g_option_context_new (_("- The Evolution PIM and Email Client")); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); #ifdef G_OS_WIN32 set_paths (); #endif program = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PROGRAM_STANDARD_PROPERTIES, GNOME_PARAM_GOPTION_CONTEXT, context, GNOME_PARAM_HUMAN_READABLE_NAME, _("Evolution"), NULL); #ifdef G_OS_WIN32 if (strcmp (_(""), "") == 0) { /* No message catalog installed for the current locale language, * so don't bother with the localisations provided by other things then * either. Reset thread locale to "en-US" and C library locale to "C". */ SetThreadLocale (MAKELCID (MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); setlocale (LC_ALL, "C"); } #endif if (start_online && start_offline) { fprintf (stderr, _("%s: --online and --offline cannot be used together.\n Use %s --help for more information.\n"), argv[0], argv[0]); exit (1); } if (killev) { filename = g_build_filename (EVOLUTION_TOOLSDIR, "killev", NULL); execl (filename, "killev", NULL); /* Not reached */ exit (0); } client = gconf_client_get_default (); #if DEVELOPMENT if (force_migrate) { destroy_config (client); } #endif if (disable_preview) { gconf_client_set_bool (client, "/apps/evolution/mail/display/show_preview", FALSE, NULL); gconf_client_set_bool (client, "/apps/evolution/mail/display/safe_list", TRUE, NULL); gconf_client_set_bool (client, "/apps/evolution/addressbook/display/show_preview", FALSE, NULL); gconf_client_set_bool (client, "/apps/evolution/calendar/display/show_task_preview", FALSE, NULL); } setup_segv_redirect (); if (evolution_debug_log) { int fd; fd = g_open (evolution_debug_log, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd != -1) { dup2 (fd, STDOUT_FILENO); dup2 (fd, STDERR_FILENO); close (fd); } else g_warning ("Could not set up debugging output file."); } master_client = gnome_master_client (); g_signal_connect (G_OBJECT (master_client), "save_yourself", G_CALLBACK (gnome_master_client_save_yourself_cb), NULL); g_signal_connect (G_OBJECT (master_client), "die", G_CALLBACK (gnome_master_client_die_cb), NULL); glade_init (); e_cursors_init (); e_icon_factory_init (); e_passwords_init(); gtk_window_set_default_icon_name ("evolution"); if (setup_only) exit (0); gnome_sound_init ("localhost"); if (!disable_eplugin) { e_plugin_register_type(e_plugin_lib_get_type()); e_plugin_hook_register_type(es_menu_hook_get_type()); e_plugin_hook_register_type(es_event_hook_get_type()); #ifdef ENABLE_PROFILING e_plugin_hook_register_type(e_profile_event_hook_get_type()); #endif e_plugin_hook_register_type(e_plugin_type_hook_get_type()); e_plugin_hook_register_type(e_import_hook_get_type()); e_plugin_hook_register_type(E_TYPE_PLUGIN_UI_HOOK); e_plugin_load_plugins(); } #if DEVELOPMENT skip_warning_dialog = gconf_client_get_bool ( client, SKIP_WARNING_DIALOG_KEY, NULL); if (!skip_warning_dialog && !getenv ("EVOLVE_ME_HARDER")) gconf_client_set_bool ( client, SKIP_WARNING_DIALOG_KEY, show_development_warning (), NULL); else g_idle_add ((GSourceFunc) idle_cb, remaining_args); #else g_idle_add ((GSourceFunc) idle_cb, remaining_args); #endif g_object_unref (client); bonobo_main (); e_icon_factory_shutdown (); g_object_unref (program); gnome_sound_shutdown (); e_cursors_shutdown (); #ifdef G_OS_WIN32 link_shutdown (); #endif return 0; }
void SetLocale(ScriptValue &s, ScriptValue *args) { CreateIntValue(s, 0!=SetThreadLocale(MAKELCID(MAKELANGID(args[0].i32, args[1].i32), args[2].i32))); }
void CPreferences::InitThreadLocale() { ASSERT( m_wLanguageID != 0 ); // NOTE: This function is for testing multi language support only. // NOTE: This function is *NOT* to be enabled in release builds nor to be offered by any Mod! if (theApp.GetProfileInt(_T("eMule"), _T("SetLanguageACP"), 0) != 0) { //LCID lcidUser = GetUserDefaultLCID(); // Installation, or altered by user in control panel (WinXP) // get the ANSI codepage which is to be used for all non-Unicode conversions. LANGID lidSystem = m_wLanguageID; // get user's sorting preferences //UINT uSortIdUser = SORTIDFROMLCID(lcidUser); //UINT uSortVerUser = SORTVERSIONFROMLCID(lcidUser); // we can't use the same sorting paramters for 2 different Languages.. UINT uSortIdUser = SORT_DEFAULT; UINT uSortVerUser = 0; // set thread locale, this is used for: // - MBCS->Unicode conversions (e.g. search results). // - Unicode->MBCS conversions (e.g. publishing local files (names) in network, or savint text files on local disk)... LCID lcid = MAKESORTLCID(lidSystem, uSortIdUser, uSortVerUser); SetThreadLocale(lcid); // if we set the thread locale (see comments above) we also have to specify the proper // codepage for the C-RTL, otherwise we may not be able to store some strings as MBCS // (Unicode->MBCS conversion may fail) SetRtlLocale(lcid); } else if (theApp.GetProfileInt(_T("eMule"), _T("SetSystemACP"), 0) != 0) { LCID lcidSystem = GetSystemDefaultLCID(); // Installation, or altered by user in control panel (WinXP) //LCID lcidUser = GetUserDefaultLCID(); // Installation, or altered by user in control panel (WinXP) // get the ANSI codepage which is to be used for all non-Unicode conversions. LANGID lidSystem = LANGIDFROMLCID(lcidSystem); // get user's sorting preferences //UINT uSortIdUser = SORTIDFROMLCID(lcidUser); //UINT uSortVerUser = SORTVERSIONFROMLCID(lcidUser); // we can't use the same sorting paramters for 2 different Languages.. UINT uSortIdUser = SORT_DEFAULT; UINT uSortVerUser = 0; // create a thread locale which gives full backward compability for users which had run ANSI emule on // a system where the system's code page did not match the user's language.. LCID lcid = MAKESORTLCID(lidSystem, uSortIdUser, uSortVerUser); LCID lcidThread = GetThreadLocale(); if (lcidThread != lcid) { TRACE("+++ Setting thread locale: 0x%08x\n", lcid); SetThreadLocale(lcid); // if we set the thread locale (see comments above) we also have to specify the proper // codepage for the C-RTL, otherwise we may not be able to store some strings as MBCS // (Unicode->MBCS conversion may fail) SetRtlLocale(lcid); } } }
LPSTR _setLocale32A(SHORT Category, LPCSTR localeName) { char codepage[7]; BOOL restoreC = FALSE; char* LocaleName = NULL; LCID Handle = 0; char* p; CPINFO cpinfo; if (localeName) LocaleName = strdup(localeName); _lock_locale(); if (__locale == NULL || __locale == &CLOCALE) { if (__locale == &CLOCALE) restoreC = TRUE; if ((__locale = (LPWIN32LOCALE) calloc(1, sizeof(WIN32LOCALE))) == NULL) { SetLastError(ERROR_OUTOFMEMORY); free(LocaleName); _unlock_locale(); return NULL; } } if (__locale->setLocaleReturn != NULL) { free(__locale->setLocaleReturn); __locale->setLocaleReturn = NULL; } if (LocaleName == NULL || LocaleName[0] == 0x0) { if (LocaleName == NULL) { if (restoreC) { _cleanCategories(__locale); free(__locale); __locale = &CLOCALE; } else { if ((Category & LC_MONETARY) == LC_MONETARY) _addCategoryName(__locale, "LC_MONETARY"); if ((Category & LC_NUMERIC) == LC_NUMERIC) _addCategoryName(__locale, "LC_NUMERIC"); if ((Category & LC_TIME) == LC_TIME) _addCategoryName(__locale, "LC_TIME"); if ((Category & LC_COLLATE) == LC_COLLATE) _addCategoryName(__locale, "LC_COLLATE"); if ((Category & LC_CTYPE) == LC_CTYPE) _addCategoryName(__locale, "LC_CTYPE"); free(LocaleName); _llocaleconv(); _unlock_locale(); return __locale->setLocaleReturn; } } else { Handle = GetUserDefaultLCID(); GetLocaleInfoA(Handle, LOCALE_IDEFAULTCODEPAGE, codepage, 7); __locale->codepage = atol(codepage); __locale->isCLocale = FALSE; } } else { if (strstr(localeName, "en_US")) { strcpy(LocaleName, "ENU"); if ((p = strchr(localeName, '.')) != NULL) strcpy(&LocaleName[3], p); } else if (strstr(localeName, "en_GB")) { strcpy(LocaleName, "ENG"); if ((p = strchr(localeName, '.')) != NULL) strcpy(&LocaleName[3], p); } else if (strstr(localeName, "fr_FR")) { strcpy(LocaleName, "FRA"); if ((p = strchr(localeName, '.')) != NULL) strcpy(&LocaleName[3], p); } else if (strstr(localeName, "de_DE")) { strcpy(LocaleName, "DEU"); if ((p = strchr(localeName, '.')) != NULL) strcpy(&LocaleName[3], p); } if (strcmp(localeName, "C") == 0) { _cleanCategories(__locale); free(__locale); __locale = &CLOCALE; } else if (LocaleName[0] == 'L' && LocaleName[1] == 'C' && LocaleName[2] == '_') { free(LocaleName); _unlock_locale(); return _setLocaleFromString(__locale, localeName); } else { __locale->isCLocale = FALSE; if ((Handle = _getLocale(__locale, (LPSTR)LocaleName)) == 0) { if (restoreC) { free(__locale); __locale = &CLOCALE; } _unlock_locale(); free(LocaleName); return NULL; } } } __locale->handle = Handle; free(LocaleName); if (!IsValidLocale(__locale->handle, LCID_INSTALLED) && !__locale->isCLocale) { SetLastError(ERROR_LOCALE_NOTINSTALLED); if (restoreC) { _cleanCategories(__locale); free(__locale); __locale = &CLOCALE; } _unlock_locale(); return NULL; } /* SetThreadLocale will only work under NT but it's best to do it in case the application uses OLE2 or some other functionnality requiring a Locale. */ SetThreadLocale(__locale->handle); if (!__locale->isCLocale) { _cleanCategories(__locale); if (_setNewCategories(__locale, Category) == 0) { SetLastError(ERROR_CATEGORY_INVALID); if (restoreC) { _cleanCategories(__locale); free(__locale); __locale = &CLOCALE; } _unlock_locale(); return NULL; } if (_setmbcp(__locale->codepage) != 0 || !GetCPInfo(__locale->codepage, &cpinfo)) { _unlock_locale(); SetLastError(ERROR_MBCS_CODEPAGE_INVALID); return NULL; } __mb_cur_max = cpinfo.MaxCharSize; _llocaleconv(); _unlock_locale(); return __locale->setLocaleReturn; } else { __mb_cur_max = 1; _llocaleconv(); _unlock_locale(); return __locale->setLocaleReturn; } }
LPSTR _setLocaleFromString(LPWIN32LOCALE _locale, LPCSTR LocaleName) { char* p = (LPSTR) LocaleName; char token[256]; char locale[256]; int tokenp; SHORT Category = 0; _lock_locale(); memset(token, 0, sizeof(token)); tokenp = 0; while (*p) { if (*p == '=') { if (strcmp(token, "LC_CTYPE") == 0) Category |= LC_CTYPE; if (strcmp(token, "LC_TIME") == 0) Category |= LC_TIME; if (strcmp(token, "LC_NUMERIC") == 0) Category |= LC_NUMERIC; if (strcmp(token, "LC_MONETARY") == 0) Category |= LC_MONETARY; if (strcmp(token, "LC_COLLATE") == 0) Category |= LC_COLLATE; memset(token, 0, sizeof(token)); tokenp = 0; } else if (*p == '\n') { strcpy(locale, token); memset(token, 0, sizeof(token)); tokenp = 0; } else token[tokenp++] = *p; p++; } _locale->handle = _getLocale(_locale, locale); if (!IsValidLocale(_locale->handle, LCID_INSTALLED) && !_locale->isCLocale) { SetLastError(ERROR_LOCALE_NOTINSTALLED); _unlock_locale(); return NULL; } /* SetThreadLocale will only work for NT but it's better to do it in case the application uses OLE2 or some other functionnality requiring a Locale. */ SetThreadLocale(__locale->handle); _cleanCategories(__locale); if (_setNewCategories(__locale, Category) == 0) { SetLastError(ERROR_CATEGORY_INVALID); _unlock_locale(); return NULL; } _unlock_locale(); return __locale->setLocaleReturn; }
BOOL CTortoiseGitBlameApp::InitInstance() { { DWORD len = GetCurrentDirectory(0, NULL); if (len) { std::unique_ptr<TCHAR[]> originalCurrentDirectory(new TCHAR[len]); if (GetCurrentDirectory(len, originalCurrentDirectory.get())) { sOrigCWD = originalCurrentDirectory.get(); sOrigCWD = CPathUtils::GetLongPathname(sOrigCWD); } } } //set the resource dll for the required language CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033); long langId = loc; CString langDll; HINSTANCE hInst = NULL; do { langDll.Format(_T("%sLanguages\\TortoiseGitBlame%ld.dll"), (LPCTSTR)CPathUtils::GetAppParentDirectory(), langId); hInst = LoadLibrary(langDll); CString sVer = _T(STRPRODUCTVER); CString sFileVer = CPathUtils::GetVersionFromFile(langDll); if (sFileVer.Compare(sVer)!=0) { FreeLibrary(hInst); hInst = NULL; } if (hInst != NULL) AfxSetResourceHandle(hInst); else { DWORD lid = SUBLANGID(langId); lid--; if (lid > 0) { langId = MAKELANGID(PRIMARYLANGID(langId), lid); } else langId = 0; } } while ((hInst == NULL) && (langId != 0)); TCHAR buf[6] = { 0 }; _tcscpy_s(buf, _T("en")); langId = loc; CString sHelppath; sHelppath = this->m_pszHelpFilePath; sHelppath = sHelppath.MakeLower(); sHelppath.Replace(_T(".chm"), _T("_en.chm")); free((void*)m_pszHelpFilePath); m_pszHelpFilePath=_tcsdup(sHelppath); sHelppath = CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseGitBlame_en.chm"); do { GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO639LANGNAME, buf, _countof(buf)); CString sLang = _T("_"); sLang += buf; sHelppath.Replace(_T("_en"), sLang); if (PathFileExists(sHelppath)) { free((void*)m_pszHelpFilePath); m_pszHelpFilePath=_tcsdup(sHelppath); break; } sHelppath.Replace(sLang, _T("_en")); GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, buf, _countof(buf)); sLang += _T("_"); sLang += buf; sHelppath.Replace(_T("_en"), sLang); if (PathFileExists(sHelppath)) { free((void*)m_pszHelpFilePath); m_pszHelpFilePath=_tcsdup(sHelppath); break; } sHelppath.Replace(sLang, _T("_en")); DWORD lid = SUBLANGID(langId); lid--; if (lid > 0) { langId = MAKELANGID(PRIMARYLANGID(langId), lid); } else langId = 0; } while (langId); setlocale(LC_ALL, ""); // We need to explicitly set the thread locale to the system default one to avoid possible problems with saving files in its original codepage // The problems occures when the language of OS differs from the regional settings // See the details here: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100887 SetThreadLocale(LOCALE_SYSTEM_DEFAULT); // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartup(&m_gdiplusToken,&gdiplusStartupInput,NULL); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored SetRegistryKey(_T("TortoiseGit")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_TORTOISE_GIT_BLAME_MAINFRAME, RUNTIME_CLASS(CTortoiseGitBlameDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CTortoiseGitBlameView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); CCmdLineParser parser = CCmdLineParser(this->m_lpCmdLine); g_sGroupingUUID = parser.GetVal(L"groupuuid"); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line. Will return FALSE if // app was launched with /RegServer, /Register, /Unregserver or /Unregister. if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand return TRUE; }
void LANG_LOAD(char* limit_to) { CWaitCursor wait; // extern int NewLangStrSz; extern coucal NewLangStr; extern int NewLangStrKeysSz; extern coucal NewLangStrKeys; // int selected_lang=LANG_T(-1); // if (!limit_to) { LANG_DELETE(); NewLangStr=coucal_new(NewLangStrSz); NewLangStrKeys=coucal_new(NewLangStrKeysSz); if ((NewLangStr==NULL) || (NewLangStrKeys==NULL)) { AfxMessageBox("Error in lang.h: not enough memory"); } else { coucal_value_is_malloc(NewLangStr,1); coucal_value_is_malloc(NewLangStrKeys,1); } } TCHAR ModulePath[MAX_PATH + 1]; ModulePath[0] = '\0'; ::GetModuleFileName(NULL, ModulePath, sizeof(ModulePath)/sizeof(TCHAR) - 1); TCHAR* pos = _tcsrchr(ModulePath, '\\'); if (pos != NULL) { * ( pos + 1) = '\0'; } else { ModulePath[0] = '\0'; } /* Load master file (list of keys and internal keys) */ CString app = ModulePath; if (!limit_to) { CString mname=app+"lang.def"; if (!fexist((char*)LPCTSTR(mname))) mname="lang.def"; FILE* fp=fopen(mname,"rb"); if (fp) { char intkey[8192]; char key[8192]; while(!feof(fp)) { linput_cpp(fp,intkey,8000); linput_cpp(fp,key,8000); if (strnotempty(intkey) && strnotempty(key)) { char* test=LANGINTKEY(key); /* Increment for multiple definitions */ if (strnotempty(test)) { int increment=0; size_t pos = strlen(key); do { increment++; sprintf(key+pos,"%d",increment); test=LANGINTKEY(key); } while (strnotempty(test)); } if (!strnotempty(test)) { // éviter doublons // conv_printf(key,key); size_t len; char* buff; len=strlen(intkey); buff=(char*)malloc(len+2); if (buff) { strcpybuff(buff,intkey); coucal_add(NewLangStrKeys,key,(intptr_t)buff); } } } // if } // while fclose(fp); } else { AfxMessageBox("FATAL ERROR\r\n'lang.def' file NOT FOUND!\r\nEnsure that the installation was complete!"); exit(0); } } /* Language Name? */ char* hashname; { char name[256]; sprintf(name,"LANGUAGE_%d",selected_lang+1); hashname=LANGINTKEY(name); } /* Get only language name */ if (limit_to) { if (hashname) strcpybuff(limit_to,hashname); else strcpybuff(limit_to,"???"); return; } /* Error */ if (!hashname) return; // xxc TEST /* setlocale( LC_ALL, "Japanese"); _setmbcp(932); // shift-jis setlocale( LC_ALL, ".932" ); setlocale( LC_ALL, "[.932]" ); CString st=""; int lid=SetThreadLocale(MAKELCID(MAKELANGID(LANG_JAPANESE,SUBLANG_NEUTRAL),SORT_DEFAULT )); */ /* Load specific language file */ { int loops; CString err_msg=""; // 2nd loop: load undefined strings for(loops=0;loops<2;loops++) { CString lbasename; { char name[256]; sprintf(name,"LANGUAGE_%d",(loops==0)?(selected_lang+1):1); hashname=LANGINTKEY(name); } lbasename.Format("lang/%s.txt",hashname); CString lname=app+lbasename; if (!fexist((char*)LPCTSTR(lname))) lname=lbasename; FILE* fp=fopen(lname,"rb"); if (fp) { char extkey[8192]; TCHAR value[8192]; while(!feof(fp)) { //int ssz; linput_cpp(fp,extkey,8000); linput_cpp(fp,value,8000); /* ssz=linput_cpp(fp,value,8000); CString st=value; AfxMessageBox(st); if (ssz>0) { int tst=0; int test=IsTextUnicode(value,ssz,&tst); unsigned short st2[1024]; int ret=MultiByteToWideChar(CP_UTF8,0,(char*)value,ssz,st2,1024); if (ret>0) { char st3[1024]=""; int ret2=WideCharToMultiByte(CP_THREAD_ACP,0,st2,ret,(char*)st3,1024,NULL,FALSE); if (ret2>0) { AfxMessageBox(st3); } } } */ if (strnotempty(extkey) && strnotempty(value)) { int len; char* buff; char* intkey; intkey=LANGINTKEY(extkey); if (strnotempty(intkey)) { /* Increment for multiple definitions */ { char* test=LANGSEL(intkey); if (strnotempty(test)) { if (loops == 0) { int increment=0; size_t pos=strlen(extkey); do { increment++; sprintf(extkey+pos,"%d",increment); intkey=LANGINTKEY(extkey); if (strnotempty(intkey)) test=LANGSEL(intkey); else test=""; } while (strnotempty(test)); } else intkey=""; } else { if (loops > 0) { err_msg += intkey; err_msg += " "; } } } /* Add key */ if (strnotempty(intkey)) { len = (int) strlen(value); buff = (char*)malloc(len+2); if (buff) { conv_printf(value,buff); coucal_add(NewLangStr,intkey,(intptr_t)buff); } } } } // if } // while fclose(fp); } else { AfxMessageBox("FATAL ERROR\r\n'lang.def' file NOT FOUND!\r\nEnsure that the installation was complete!"); exit(0); } } if (err_msg.GetLength()>0) { // AfxMessageBox("Error: undefined strings follows:\r\n"+err_msg); } } #if 0 app=app+"lang.h"; if (!fexist((char*)LPCTSTR(app))) app="lang.h"; FILE* fp=fopen(app,"rb"); if (fp) { char s[8192]; while(!feof(fp)) { linput_cpp(fp,s,8000); if (!strncmp(s,"#define ",8)) { char* a; char* name=s+8; a=name; while((*a!=' ') && (*a)) a++; if ((*a) && (strlen(name)>0) && (((int) a - (int) name)<64)) { *a++='\0'; if (limit_to) { if (strcmp(name,limit_to)) a=NULL; } if (a) { char* data; data=a; int toggle=0; char* start_str=NULL; int count=0; while(*a) { if (*a=='\"') { toggle++; if ((toggle%2)==1) { if (count==selected_lang) { start_str=a+1; } count++; } else { if (start_str) { char* buff; int len; len=(int) a - (int) start_str; if (len) { buff=(char*)malloc(len+2); if (buff) { int i=0,j=0; buff[0]='\0'; //strncatbuff(buff,start_str,len); while(i<len) { switch(start_str[i]) { case '\\': i++; switch(start_str[i]) { case 'a': buff[j]='\a'; break; case 'b': buff[j]='\b'; break; case 'f': buff[j]='\f'; break; case 'n': buff[j]='\n'; break; case 'r': buff[j]='\r'; break; case 't': buff[j]='\t'; break; case 'v': buff[j]='\v'; break; case '\'': buff[j]='\''; break; case '\"': buff[j]='\"'; break; case '\\': buff[j]='\\'; break; case '?': buff[j]='\?'; break; default: buff[j]=start_str[i]; break; } break; default: buff[j]=start_str[i]; break; } i++; j++; } buff[j++]='\0'; if (!limit_to) coucal_add(NewLangStr,name,(intptr_t)buff); else { strcpybuff(limit_to,buff); free(buff); return; } } } start_str=NULL; } } } a++; } } //NewLangStr.SetAt(sname,st); /* } else { CString info; info.Format("Error in lang.h: %s",name); AfxMessageBox(info); */ } } } fclose(fp); } else { AfxMessageBox("FATAL ERROR\r\n'lang.h' file NOT FOUND!\r\nEnsure that the installation was complete!"); exit(0); } #endif // Control limit_to if (limit_to) limit_to[0]='\0'; // Set locale if (!limit_to) { CString charset = LANGUAGE_CHARSET; charset.TrimLeft(); charset.TrimRight(); charset.MakeLower(); NewLangCP = CP_THREAD_ACP; NewLangFileCP = CP_THREAD_ACP; #if 0 if (charset.GetLength() > 0) { if (charset.Left(9) == "iso-8859-") { int iso = 0; int isoCP[] = {0, /* 0 */ 1252, /* ISO-8859-1 */ 1250, /* ISO-8859-2 */ 0, /* ISO-8859-3 */ 0, /* ISO-8859-4 */ 1251, /* ISO-8859-5 */ 1256, /* ISO-8859-6 */ 1253, /* ISO-8859-7 */ 1255, /* ISO-8859-8 */ 1254, /* ISO-8859-9 */ }; if (sscanf(charset.GetBuffer(0) + 9, "%d", &iso) == 1) { if (iso < sizeof(isoCP)/sizeof(isoCP[0])) { if (isoCP[iso] != 0) { NewLangFileCP = isoCP[iso]; } } } } else if (charset.Left(8) == "windows-") { int windows = 0; if (sscanf(charset.GetBuffer(0) + 8, "%d", &windows) == 1) { NewLangFileCP = windows; } } else if (charset == "shift-jis") { NewLangFileCP = 932; } else if (charset == "big5") { NewLangFileCP = 950; } else if (charset == "gb2312") { NewLangFileCP = 936; } else { NewLangFileCP = CP_THREAD_ACP; } } WORD acp = GetACP(); if (NewLangFileCP != CP_THREAD_ACP && NewLangFileCP != acp) { char* currName = LANGUAGE_WINDOWSID; LCID thl = GetThreadLocale(); WORD sid = SORTIDFROMLCID(thl); WORD lid = 0; WinLangid* lids; if (currName[0]) { for( lids = (WinLangid*)&WINDOWS_LANGID ; lids->name != NULL ; lids++ ) { if (strcmp(currName, lids->name) == 0) { lid = lids->langId; break; } } if (lid != 0) { SetThreadLocale(MAKELCID(lid, sid)); } } } #endif } }
static INT_PTR CALLBACK LocaleDlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { PSTATE pState; /* Retrieve pointer to the state */ pState = (PSTATE)GetWindowLongPtr (hwndDlg, GWL_USERDATA); switch (uMsg) { case WM_INITDIALOG: /* Save pointer to the global state */ pState = (PSTATE)lParam; SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pState); /* Center the dialog window */ CenterWindow (hwndDlg); CreateLanguagesList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST)); EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE); return FALSE; case WM_DRAWITEM: OnDrawItem((LPDRAWITEMSTRUCT)lParam, pState, IDC_LOCALELOGO); return TRUE; case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { switch (LOWORD(wParam)) { case IDOK: { LCID NewLcid; INT iCurSel; iCurSel = SendDlgItemMessageW(hwndDlg, IDC_LANGUAGELIST, CB_GETCURSEL, 0, 0); if (iCurSel == CB_ERR) break; NewLcid = SendDlgItemMessageW(hwndDlg, IDC_LANGUAGELIST, CB_GETITEMDATA, iCurSel, 0); if (NewLcid == (LCID)CB_ERR) break; SetThreadLocale(NewLcid); InitializeDefaultUserLocale(&NewLcid); } pState->NextPage = STARTPAGE; EndDialog(hwndDlg, 0); break; default: break; } } break; default: break; } return FALSE; }
gint main (gint argc, gchar **argv) { EShell *shell; GSettings *settings; #ifdef DEVELOPMENT gboolean skip_warning_dialog; #endif GError *error = NULL; #ifdef G_OS_WIN32 gchar *path; /* Reduce risks */ { typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName); t_SetDllDirectoryA p_SetDllDirectoryA; p_SetDllDirectoryA = GetProcAddress ( GetModuleHandle ("kernel32.dll"), "SetDllDirectoryA"); if (p_SetDllDirectoryA) (*p_SetDllDirectoryA) (""); } #ifndef _WIN64 { typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags); t_SetProcessDEPPolicy p_SetProcessDEPPolicy; p_SetProcessDEPPolicy = GetProcAddress ( GetModuleHandle ("kernel32.dll"), "SetProcessDEPPolicy"); if (p_SetProcessDEPPolicy) (*p_SetProcessDEPPolicy) ( PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION); } #endif if (fileno (stdout) != -1 && _get_osfhandle (fileno (stdout)) != -1) { /* stdout is fine, presumably redirected to a file or pipe */ } else { typedef BOOL (* WINAPI AttachConsole_t) (DWORD); AttachConsole_t p_AttachConsole = (AttachConsole_t) GetProcAddress ( GetModuleHandle ("kernel32.dll"), "AttachConsole"); if (p_AttachConsole && p_AttachConsole (ATTACH_PARENT_PROCESS)) { freopen ("CONOUT$", "w", stdout); dup2 (fileno (stdout), 1); freopen ("CONOUT$", "w", stderr); dup2 (fileno (stderr), 2); } } #endif /* Make ElectricFence work. */ free (malloc (10)); bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* do not require Gtk+ for --force-shutdown */ if (argc == 2 && argv[1] && g_str_equal (argv[1], "--force-shutdown")) { shell_force_shutdown (); return 0; } /* The contact maps feature uses clutter-gtk. */ #ifdef WITH_CONTACT_MAPS /* XXX This function is declared in gtk-clutter-util.h with an * unnecessary G_GNUC_WARN_UNUSED_RESULT attribute. But we * don't need the returned error code because we're checking * the GError directly. Just ignore this warning. */ gtk_clutter_init_with_args ( &argc, &argv, _("- The Evolution PIM and Email Client"), entries, (gchar *) GETTEXT_PACKAGE, &error); #else gtk_init_with_args ( &argc, &argv, _("- The Evolution PIM and Email Client"), entries, (gchar *) GETTEXT_PACKAGE, &error); #endif /* WITH_CONTACT_MAPS */ if (error != NULL) { g_printerr ("%s\n", error->message); g_error_free (error); exit (1); } #ifdef HAVE_ICAL_UNKNOWN_TOKEN_HANDLING ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN); #endif e_gdbus_templates_init_main_thread (); #ifdef G_OS_WIN32 path = g_build_path (";", _e_get_bindir (), g_getenv ("PATH"), NULL); if (!g_setenv ("PATH", path, TRUE)) g_warning ("Could not set PATH for Evolution and its child processes"); g_free (path); if (register_handlers || reinstall || show_icons) { _e_win32_register_mailer (); _e_win32_register_addressbook (); } if (register_handlers) exit (0); if (reinstall) { _e_win32_set_default_mailer (); exit (0); } if (show_icons) { _e_win32_set_default_mailer (); exit (0); } if (hide_icons) { _e_win32_unset_default_mailer (); exit (0); } if (unregister_handlers) { _e_win32_unregister_mailer (); _e_win32_unregister_addressbook (); exit (0); } if (strcmp (gettext (""), "") == 0) { /* No message catalog installed for the current locale * language, so don't bother with the localisations * provided by other things then either. Reset thread * locale to "en-US" and C library locale to "C". */ SetThreadLocale ( MAKELCID (MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); setlocale (LC_ALL, "C"); } #endif if (start_online && start_offline) { g_printerr ( _("%s: --online and --offline cannot be used " "together.\n Run '%s --help' for more " "information.\n"), argv[0], argv[0]); exit (1); } else if (force_online && start_offline) { g_printerr ( _("%s: --force-online and --offline cannot be used " "together.\n Run '%s --help' for more " "information.\n"), argv[0], argv[0]); exit (1); } if (force_shutdown) shell_force_shutdown (); if (disable_preview) { settings = g_settings_new ("org.gnome.evolution.mail"); g_settings_set_boolean (settings, "safe-list", TRUE); g_object_unref (settings); settings = g_settings_new ("org.gnome.evolution.addressbook"); g_settings_set_boolean (settings, "show-preview", FALSE); g_object_unref (settings); settings = g_settings_new ("org.gnome.evolution.calendar"); g_settings_set_boolean (settings, "show-memo-preview", FALSE); g_settings_set_boolean (settings, "show-task-preview", FALSE); g_object_unref (settings); } #ifdef G_OS_UNIX g_unix_signal_add_full ( G_PRIORITY_DEFAULT, SIGTERM, handle_term_signal, NULL, NULL); #endif e_passwords_init (); gtk_window_set_default_icon_name ("evolution"); if (setup_only) exit (0); categories_icon_theme_hack (); gtk_accel_map_load (e_get_accels_filename ()); #ifdef DEVELOPMENT settings = g_settings_new ("org.gnome.evolution.shell"); skip_warning_dialog = g_settings_get_boolean ( settings, "skip-warning-dialog"); if (!skip_warning_dialog && !getenv ("EVOLVE_ME_HARDER")) g_settings_set_boolean ( settings, "skip-warning-dialog", show_development_warning ()); g_object_unref (settings); #endif /* Workaround https://bugzilla.gnome.org/show_bug.cgi?id=683548 */ if (!quit) g_type_ensure (WEBKIT_TYPE_WEB_VIEW); shell = create_default_shell (); if (!shell) return 1; if (quit) { e_shell_quit (shell, E_SHELL_QUIT_OPTION); goto exit; } /* This routine converts the local mail store from mbox format to * Maildir format as needed. The reason the code is here and not * in the mail module is because we inform the user at startup of * the impending mail conversion by displaying a popup dialog and * waiting for confirmation before proceeding. * * This has to be done before we load modules because some of the * EShellBackends immediately add GMainContext sources that would * otherwise get dispatched during gtk_dialog_run(), and we don't * want them dispatched until after the conversion is complete. * * Addendum: We need to perform the XDG Base Directory migration * before converting the local mail store, because the * conversion is triggered by checking for certain key * files and directories under XDG_DATA_HOME. Without * this the mail conversion will not trigger for users * upgrading from Evolution 2.30 or older. */ e_migrate_base_dirs (shell); e_convert_local_mail (shell); e_shell_load_modules (shell); if (!disable_eplugin) { /* Register built-in plugin hook types. */ g_type_ensure (E_TYPE_IMPORT_HOOK); g_type_ensure (E_TYPE_PLUGIN_UI_HOOK); /* All EPlugin and EPluginHook subclasses should be * registered in GType now, so load plugins now. */ e_plugin_load_plugins (); } /* Attempt migration -after- loading all modules and plugins, * as both shell backends and certain plugins hook into this. */ e_shell_migrate_attempt (shell); e_shell_event (shell, "ready-to-start", NULL); g_idle_add ((GSourceFunc) idle_cb, remaining_args); gtk_main (); exit: /* Drop what should be the last reference to the shell. * That will cause e_shell_get_default() to henceforth * return NULL. Use that to check for reference leaks. */ g_object_unref (shell); if (e_shell_get_default () != NULL) g_warning ("Shell not finalized on exit"); gtk_accel_map_save (e_get_accels_filename ()); return 0; }
// CTortoiseMergeApp initialization BOOL CTortoiseMergeApp::InitInstance() { SetDllDirectory(L""); CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); CMFCButton::EnableWindowsTheming(); { DWORD len = GetCurrentDirectory(0, NULL); if (len) { auto_buffer<TCHAR> originalCurrentDirectory(len); if (GetCurrentDirectory(len, originalCurrentDirectory)) { sOrigCWD = originalCurrentDirectory; sOrigCWD = CPathUtils::GetLongPathname(sOrigCWD); } } } //set the resource dll for the required language CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033); long langId = loc; CString langDll; HINSTANCE hInst = NULL; do { langDll.Format(_T("%sLanguages\\TortoiseMerge%d.dll"), (LPCTSTR)CPathUtils::GetAppParentDirectory(), langId); hInst = LoadLibrary(langDll); CString sVer = _T(STRPRODUCTVER); CString sFileVer = CPathUtils::GetVersionFromFile(langDll); if (sFileVer.Compare(sVer)!=0) { FreeLibrary(hInst); hInst = NULL; } if (hInst != NULL) AfxSetResourceHandle(hInst); else { DWORD lid = SUBLANGID(langId); lid--; if (lid > 0) { langId = MAKELANGID(PRIMARYLANGID(langId), lid); } else langId = 0; } } while ((hInst == NULL) && (langId != 0)); TCHAR buf[6]; _tcscpy_s(buf, _T("en")); langId = loc; CString sHelppath; sHelppath = this->m_pszHelpFilePath; sHelppath = sHelppath.MakeLower(); sHelppath.Replace(_T(".chm"), _T("_en.chm")); free((void*)m_pszHelpFilePath); m_pszHelpFilePath=_tcsdup(sHelppath); sHelppath = CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseMerge_en.chm"); do { GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO639LANGNAME, buf, _countof(buf)); CString sLang = _T("_"); sLang += buf; sHelppath.Replace(_T("_en"), sLang); if (PathFileExists(sHelppath)) { free((void*)m_pszHelpFilePath); m_pszHelpFilePath=_tcsdup(sHelppath); break; } sHelppath.Replace(sLang, _T("_en")); GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, buf, _countof(buf)); sLang += _T("_"); sLang += buf; sHelppath.Replace(_T("_en"), sLang); if (PathFileExists(sHelppath)) { free((void*)m_pszHelpFilePath); m_pszHelpFilePath=_tcsdup(sHelppath); break; } sHelppath.Replace(sLang, _T("_en")); DWORD lid = SUBLANGID(langId); lid--; if (lid > 0) { langId = MAKELANGID(PRIMARYLANGID(langId), lid); } else langId = 0; } while (langId); setlocale(LC_ALL, ""); // We need to explicitly set the thread locale to the system default one to avoid possible problems with saving files in its original codepage // The problems occures when the language of OS differs from the regional settings // See the details here: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100887 SetThreadLocale(LOCALE_SYSTEM_DEFAULT); // InitCommonControls() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. InitCommonControls(); // Initialize all Managers for usage. They are automatically constructed // if not yet present InitContextMenuManager(); InitKeyboardManager(); CCmdLineParser parser = CCmdLineParser(this->m_lpCmdLine); if (parser.HasKey(_T("?")) || parser.HasKey(_T("help"))) { CString sHelpText; sHelpText.LoadString(IDS_COMMANDLINEHELP); MessageBox(NULL, sHelpText, _T("TortoiseMerge"), MB_ICONINFORMATION); return FALSE; } // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored SetRegistryKey(_T("TortoiseMerge")); if (CRegDWORD(_T("Software\\TortoiseMerge\\Debug"), FALSE)==TRUE) AfxMessageBox(AfxGetApp()->m_lpCmdLine, MB_OK | MB_ICONINFORMATION); // To create the main window, this code creates a new frame window // object and then sets it as the application's main window object CMainFrame* pFrame = new CMainFrame; if (pFrame == NULL) return FALSE; m_pMainWnd = pFrame; // create and load the frame with its resources pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); // Fill in the command line options pFrame->m_Data.m_baseFile.SetFileName(parser.GetVal(_T("base"))); pFrame->m_Data.m_baseFile.SetDescriptiveName(parser.GetVal(_T("basename"))); pFrame->m_Data.m_theirFile.SetFileName(parser.GetVal(_T("theirs"))); pFrame->m_Data.m_theirFile.SetDescriptiveName(parser.GetVal(_T("theirsname"))); pFrame->m_Data.m_yourFile.SetFileName(parser.GetVal(_T("mine"))); pFrame->m_Data.m_yourFile.SetDescriptiveName(parser.GetVal(_T("minename"))); pFrame->m_Data.m_mergedFile.SetFileName(parser.GetVal(_T("merged"))); pFrame->m_Data.m_mergedFile.SetDescriptiveName(parser.GetVal(_T("mergedname"))); pFrame->m_Data.m_sPatchPath = parser.HasVal(_T("patchpath")) ? parser.GetVal(_T("patchpath")) : _T(""); pFrame->m_Data.m_sPatchPath.Replace('/', '\\'); if (parser.HasKey(_T("patchoriginal"))) pFrame->m_Data.m_sPatchOriginal = parser.GetVal(_T("patchoriginal")); if (parser.HasKey(_T("patchpatched"))) pFrame->m_Data.m_sPatchPatched = parser.GetVal(_T("patchpatched")); pFrame->m_Data.m_sDiffFile = parser.GetVal(_T("diff")); pFrame->m_Data.m_sDiffFile.Replace('/', '\\'); if (parser.HasKey(_T("oneway"))) pFrame->m_bOneWay = TRUE; if (parser.HasKey(_T("diff"))) pFrame->m_bOneWay = FALSE; if (parser.HasKey(_T("reversedpatch"))) pFrame->m_bReversedPatch = TRUE; if (pFrame->m_Data.IsBaseFileInUse() && !pFrame->m_Data.IsYourFileInUse() && pFrame->m_Data.IsTheirFileInUse()) { pFrame->m_Data.m_yourFile.TransferDetailsFrom(pFrame->m_Data.m_theirFile); } if ((!parser.HasKey(_T("patchpath")))&&(parser.HasVal(_T("diff")))) { // a patchfile was given, but not folder path to apply the patch to // If the patchfile is located inside a working copy, then use the parent directory // of the patchfile as the target directory, otherwise ask the user for a path. if (parser.HasKey(_T("wc"))) pFrame->m_Data.m_sPatchPath = pFrame->m_Data.m_sDiffFile.Left(pFrame->m_Data.m_sDiffFile.ReverseFind('\\')); else { CBrowseFolder fbrowser; fbrowser.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; if (fbrowser.Show(NULL, pFrame->m_Data.m_sPatchPath)==CBrowseFolder::CANCEL) return FALSE; } } if ((parser.HasKey(_T("patchpath")))&&(!parser.HasVal(_T("diff")))) { // A path was given for applying a patchfile, but // the patchfile itself was not. // So ask the user for that patchfile OPENFILENAME ofn = {0}; // common dialog box structure TCHAR szFile[MAX_PATH] = {0}; // buffer for file name // Initialize OPENFILENAME ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = pFrame->m_hWnd; ofn.lpstrFile = szFile; ofn.nMaxFile = _countof(szFile); CString temp; temp.LoadString(IDS_OPENDIFFFILETITLE); if (temp.IsEmpty()) ofn.lpstrTitle = NULL; else ofn.lpstrTitle = temp; ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER; // check if there's a patchfile in the clipboard UINT cFormat = RegisterClipboardFormat(_T("TSVN_UNIFIEDDIFF")); if (cFormat) { if (OpenClipboard(NULL)) { UINT enumFormat = 0; do { if (enumFormat == cFormat) { // yes, there's a patchfile in the clipboard ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER; ofn.hInstance = AfxGetResourceHandle(); ofn.lpTemplateName = MAKEINTRESOURCE(IDD_PATCH_FILE_OPEN_CUSTOM); ofn.lpfnHook = CreatePatchFileOpenHook; } } while((enumFormat = EnumClipboardFormats(enumFormat))!=0); CloseClipboard(); } } CString sFilter; sFilter.LoadString(IDS_PATCHFILEFILTER); TCHAR * pszFilters = new TCHAR[sFilter.GetLength()+4]; _tcscpy_s (pszFilters, sFilter.GetLength()+4, sFilter); // Replace '|' delimiters with '\0's TCHAR *ptr = pszFilters + _tcslen(pszFilters); //set ptr at the NULL while (ptr != pszFilters) { if (*ptr == '|') *ptr = '\0'; ptr--; } ofn.lpstrFilter = pszFilters; ofn.nFilterIndex = 1; // Display the Open dialog box. CString tempfile; if (GetOpenFileName(&ofn)==FALSE) { delete [] pszFilters; return FALSE; } delete [] pszFilters; pFrame->m_Data.m_sDiffFile = ofn.lpstrFile; } if ( pFrame->m_Data.m_baseFile.GetFilename().IsEmpty() && pFrame->m_Data.m_yourFile.GetFilename().IsEmpty() ) { LPWSTR *szArglist; int nArgs; szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); if( NULL == szArglist ) { TRACE("CommandLineToArgvW failed\n"); } else { if ( nArgs==3 || nArgs==4 ) { // Four parameters: // [0]: Program name // [1]: BASE file // [2]: my file // [3]: THEIR file (optional) // This is the same format CAppUtils::StartExtDiff // uses if %base and %mine are not set and most // other diff tools use it too. if ( PathFileExists(szArglist[1]) && PathFileExists(szArglist[2]) ) { pFrame->m_Data.m_baseFile.SetFileName(szArglist[1]); pFrame->m_Data.m_yourFile.SetFileName(szArglist[2]); if ( nArgs == 4 && PathFileExists(szArglist[3]) ) { pFrame->m_Data.m_theirFile.SetFileName(szArglist[3]); } } } } // Free memory allocated for CommandLineToArgvW arguments. LocalFree(szArglist); } pFrame->m_bReadOnly = !!parser.HasKey(_T("readonly")); if (GetFileAttributes(pFrame->m_Data.m_yourFile.GetFilename()) & FILE_ATTRIBUTE_READONLY) pFrame->m_bReadOnly = true; pFrame->m_bBlame = !!parser.HasKey(_T("blame")); // diffing a blame means no editing! if (pFrame->m_bBlame) pFrame->m_bReadOnly = true; // try to find a suitable window title CString sYour = pFrame->m_Data.m_yourFile.GetDescriptiveName(); if (sYour.Find(_T(" - "))>=0) sYour = sYour.Left(sYour.Find(_T(" - "))); if (sYour.Find(_T(" : "))>=0) sYour = sYour.Left(sYour.Find(_T(" : "))); CString sTheir = pFrame->m_Data.m_theirFile.GetDescriptiveName(); if (sTheir.Find(_T(" - "))>=0) sTheir = sTheir.Left(sTheir.Find(_T(" - "))); if (sTheir.Find(_T(" : "))>=0) sTheir = sTheir.Left(sTheir.Find(_T(" : "))); if (!sYour.IsEmpty() && !sTheir.IsEmpty()) { if (sYour.CompareNoCase(sTheir)==0) pFrame->SetWindowText(sYour + _T(" - TortoiseMerge")); else if ((sYour.GetLength() < 10) && (sTheir.GetLength() < 10)) pFrame->SetWindowText(sYour + _T(" - ") + sTheir + _T(" - TortoiseMerge")); else { // we have two very long descriptive texts here, which // means we have to find a way to use them as a window // title in a shorter way. // for simplicity, we just use the one from "yourfile" pFrame->SetWindowText(sYour + _T(" - TortoiseMerge")); } } else if (!sYour.IsEmpty()) pFrame->SetWindowText(sYour + _T(" - TortoiseMerge")); else if (!sTheir.IsEmpty()) pFrame->SetWindowText(sTheir + _T(" - TortoiseMerge")); if (parser.HasKey(_T("createunifieddiff"))) { // user requested to create a unified diff file CString origFile = parser.GetVal(_T("origfile")); CString modifiedFile = parser.GetVal(_T("modifiedfile")); if (!origFile.IsEmpty() && !modifiedFile.IsEmpty()) { CString outfile = parser.GetVal(_T("outfile")); if (outfile.IsEmpty()) { OPENFILENAME ofn = {0}; // common dialog box structure TCHAR szFile[MAX_PATH] = {0}; // buffer for file name ofn.lStructSize = sizeof(OPENFILENAME); ofn.lpstrFile = szFile; ofn.nMaxFile = _countof(szFile); CString temp; temp.LoadString(IDS_SAVEASTITLE); if (!temp.IsEmpty()) ofn.lpstrTitle = temp; ofn.Flags = OFN_OVERWRITEPROMPT; CString sFilter; sFilter.LoadString(IDS_COMMONFILEFILTER); TCHAR * pszFilters = new TCHAR[sFilter.GetLength()+4]; _tcscpy_s (pszFilters, sFilter.GetLength()+4, sFilter); // Replace '|' delimiters with '\0's TCHAR *ptr = pszFilters + _tcslen(pszFilters); //set ptr at the NULL while (ptr != pszFilters) { if (*ptr == '|') *ptr = '\0'; ptr--; } ofn.lpstrFilter = pszFilters; ofn.nFilterIndex = 1; // Display the Save dialog box. CString sFile; if (GetSaveFileName(&ofn)==TRUE) { outfile = CString(ofn.lpstrFile); } delete [] pszFilters; } if (!outfile.IsEmpty()) { CAppUtils::CreateUnifiedDiff(origFile, modifiedFile, outfile, false); return FALSE; } } } // The one and only window has been initialized, so show and update it pFrame->ActivateFrame(); pFrame->ShowWindow(SW_SHOW); pFrame->UpdateWindow(); pFrame->ShowDiffBar(!pFrame->m_bOneWay); if (!pFrame->m_Data.IsBaseFileInUse() && pFrame->m_Data.m_sPatchPath.IsEmpty() && pFrame->m_Data.m_sDiffFile.IsEmpty()) { pFrame->OnFileOpen(); return TRUE; } return pFrame->LoadViews(); }
int _tmain (int argc, _TCHAR **argv) { for (int i = 0; i < argc; ++i) { out << argv[i] << std::endl; } if (argc < 2) { showHelp (); return (0); } params_t params; if (!parseCmdLine (argc - 1, argv + 1, ¶ms)) { if (otUnknown == params.opType) { out << _T (" : unknown operation") << std::endl; } else { out << _T ("bad command line") << std::endl; } return (-1); } if (FAILED (initLicensing (AppInfo, params.basesPaths, CLicensingPolicy::cmKeyOnly))) { return (-1); } // synchronizeKeys (AppInfo, KeyFile1, 0); #if defined (_WIN32) SetThreadLocale (MAKELCID (MAKELANGID (LANG_ENGLISH, SUBLANG_NEUTRAL), SORT_DEFAULT)); CComLib comLib; #endif switch(params.opType) { case otKeyReg : case otKeyRegAdd : regKey (params.keyFileName, params.keyAddMode); break; case otKeyRevoke : revokeKey (params.serialNumber); break; case otCheckActiveKey : checkActiveKey (); break; case otKeyFileInfo : keyFileInfo (params.keyFileName); break; case otViewInstalledKeys : viewInstalledKeys (); break; case otViewBlacklist : viewBlacklist (params.blacklistName); break; case otCheckAgainstBlacklist: checkAgainstBlackList (params.blacklistName.c_str ()); break; case otCheckKeyBlacklist : checKeyBlacklist (params.keyFileName, params.blacklistName); break; case otCheckKeyFile : case otCheckKeyFileAdd : checkKeyFile (params.keyFileName, params.keyAddMode); break; default : break; } // recreateTest (AppInfo, params.basesPaths, CLicensingPolicy::cmFullCheck); return (0); }
static void test_threadcp(void) { static const LCID ENGLISH = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); static const LCID HINDI = MAKELCID(MAKELANGID(LANG_HINDI, SUBLANG_HINDI_INDIA), SORT_DEFAULT); static const LCID GEORGIAN = MAKELCID(MAKELANGID(LANG_GEORGIAN, SUBLANG_GEORGIAN_GEORGIA), SORT_DEFAULT); static const LCID RUSSIAN = MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_RUSSIAN_RUSSIA), SORT_DEFAULT); static const LCID JAPANESE = MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN), SORT_DEFAULT); static const LCID CHINESE = MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT); BOOL islead, islead_acp; CPINFOEXA cpi; UINT cp, acp; int i, num; LCID last; BOOL ret; struct test { LCID lcid; UINT threadcp; } lcids[] = { { HINDI, 0 }, { GEORGIAN, 0 }, { ENGLISH, 1252 }, { RUSSIAN, 1251 }, { JAPANESE, 932 }, { CHINESE, 936 } }; struct test_islead_nocp { LCID lcid; BYTE testchar; } isleads_nocp[] = { { HINDI, 0x00 }, { HINDI, 0x81 }, { HINDI, 0xa0 }, { HINDI, 0xe0 }, { GEORGIAN, 0x00 }, { GEORGIAN, 0x81 }, { GEORGIAN, 0xa0 }, { GEORGIAN, 0xe0 }, }; struct test_islead { LCID lcid; BYTE testchar; BOOL islead; } isleads[] = { { ENGLISH, 0x00, FALSE }, { ENGLISH, 0x81, FALSE }, { ENGLISH, 0xa0, FALSE }, { ENGLISH, 0xe0, FALSE }, { RUSSIAN, 0x00, FALSE }, { RUSSIAN, 0x81, FALSE }, { RUSSIAN, 0xa0, FALSE }, { RUSSIAN, 0xe0, FALSE }, { JAPANESE, 0x00, FALSE }, { JAPANESE, 0x81, TRUE }, { JAPANESE, 0xa0, FALSE }, { JAPANESE, 0xe0, TRUE }, { CHINESE, 0x00, FALSE }, { CHINESE, 0x81, TRUE }, { CHINESE, 0xa0, TRUE }, { CHINESE, 0xe0, TRUE }, }; last = GetThreadLocale(); acp = GetACP(); for (i = 0; i < sizeof(lcids)/sizeof(lcids[0]); i++) { SetThreadLocale(lcids[i].lcid); cp = 0xdeadbeef; GetLocaleInfoA(lcids[i].lcid, LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER, (LPSTR)&cp, sizeof(cp)); ok(cp == lcids[i].threadcp, "wrong codepage %u for lcid %04x, should be %u\n", cp, lcids[i].threadcp, cp); /* GetCPInfoEx/GetCPInfo - CP_ACP */ SetLastError(0xdeadbeef); memset(&cpi, 0, sizeof(cpi)); ret = GetCPInfoExA(CP_ACP, 0, &cpi); ok(ret, "GetCPInfoExA failed for lcid %04x, error %d\n", lcids[i].lcid, GetLastError()); ok(cpi.CodePage == acp, "wrong codepage %u for lcid %04x, should be %u\n", cpi.CodePage, lcids[i].lcid, acp); /* WideCharToMultiByte - CP_ACP */ num = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, NULL, 0, NULL, NULL); ok(num == 7, "ret is %d (%04x)\n", num, lcids[i].lcid); /* MultiByteToWideChar - CP_ACP */ num = MultiByteToWideChar(CP_ACP, 0, "foobar", -1, NULL, 0); ok(num == 7, "ret is %d (%04x)\n", num, lcids[i].lcid); /* GetCPInfoEx/GetCPInfo - CP_THREAD_ACP */ SetLastError(0xdeadbeef); memset(&cpi, 0, sizeof(cpi)); ret = GetCPInfoExA(CP_THREAD_ACP, 0, &cpi); ok(ret, "GetCPInfoExA failed for lcid %04x, error %d\n", lcids[i].lcid, GetLastError()); if (lcids[i].threadcp) ok(cpi.CodePage == lcids[i].threadcp, "wrong codepage %u for lcid %04x, should be %u\n", cpi.CodePage, lcids[i].lcid, lcids[i].threadcp); else ok(cpi.CodePage == acp, "wrong codepage %u for lcid %04x, should be %u\n", cpi.CodePage, lcids[i].lcid, acp); /* WideCharToMultiByte - CP_THREAD_ACP */ num = WideCharToMultiByte(CP_THREAD_ACP, 0, foobarW, -1, NULL, 0, NULL, NULL); ok(num == 7, "ret is %d (%04x)\n", num, lcids[i].lcid); /* MultiByteToWideChar - CP_THREAD_ACP */ num = MultiByteToWideChar(CP_THREAD_ACP, 0, "foobar", -1, NULL, 0); ok(num == 7, "ret is %d (%04x)\n", num, lcids[i].lcid); } /* IsDBCSLeadByteEx - locales without codepage */ for (i = 0; i < sizeof(isleads_nocp)/sizeof(isleads_nocp[0]); i++) { SetThreadLocale(isleads_nocp[i].lcid); islead_acp = IsDBCSLeadByteEx(CP_ACP, isleads_nocp[i].testchar); islead = IsDBCSLeadByteEx(CP_THREAD_ACP, isleads_nocp[i].testchar); ok(islead == islead_acp, "wrong islead %i for test char %x in lcid %04x. should be %i\n", islead, isleads_nocp[i].testchar, isleads_nocp[i].lcid, islead_acp); } /* IsDBCSLeadByteEx - locales with codepage */ for (i = 0; i < sizeof(isleads)/sizeof(isleads[0]); i++) { SetThreadLocale(isleads[i].lcid); islead = IsDBCSLeadByteEx(CP_THREAD_ACP, isleads[i].testchar); ok(islead == isleads[i].islead, "wrong islead %i for test char %x in lcid %04x. should be %i\n", islead, isleads[i].testchar, isleads[i].lcid, isleads[i].islead); } SetThreadLocale(last); }