// MakeTorrent.cpp : ÀÀ¿ë ÇÁ·Î±×·¥¿¡ ´ëÇÑ Å¬·¡½º µ¿ÀÛÀ» Á¤ÀÇÇÕ´Ï´Ù. // #include "stdafx.h" #include "MakeTorrent.h" #include "MakeTorrentDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMakeTorrentApp BEGIN_MESSAGE_MAP(CMakeTorrentApp, CWinApp) ON_COMMAND(ID_HELP, &CWinApp::OnHelp) END_MESSAGE_MAP() // CMakeTorrentApp »ý¼º CMakeTorrentApp::CMakeTorrentApp() { // TODO: ¿©±â¿¡ »ý¼º Äڵ带 Ãß°¡ÇÕ´Ï´Ù. // InitInstance¿¡ ¸ðµç Áß¿äÇÑ ÃʱâÈ­ ÀÛ¾÷À» ¹èÄ¡ÇÕ´Ï´Ù. // _CrtSetBreakAlloc( 152 ); } // À¯ÀÏÇÑ CMakeTorrentApp °³Ã¼ÀÔ´Ï´Ù. CMakeTorrentApp theApp; // CMakeTorrentApp ÃʱâÈ­ BOOL CMakeTorrentApp::InitInstance() { // ÀÀ¿ë ÇÁ·Î±×·¥ ¸Å´ÏÆä½ºÆ®°¡ ComCtl32.dll ¹öÀü 6 ÀÌ»óÀ» »ç¿ëÇÏ¿© ºñÁÖ¾ó ½ºÅ¸ÀÏÀ» // »ç¿ëÇϵµ·Ï ÁöÁ¤ÇÏ´Â °æ¿ì, Windows XP »ó¿¡¼­ ¹Ýµå½Ã InitCommonControlsEx()°¡ ÇÊ¿äÇÕ´Ï´Ù. // InitCommonControlsEx()¸¦ »ç¿ëÇÏÁö ¾ÊÀ¸¸é âÀ» ¸¸µé ¼ö ¾ø½À´Ï´Ù. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // ÀÀ¿ë ÇÁ·Î±×·¥¿¡¼­ »ç¿ëÇÒ ¸ðµç °ø¿ë ÄÁÆ®·Ñ Ŭ·¡½º¸¦ Æ÷ÇÔÇϵµ·Ï // ÀÌ Ç׸ñÀ» ¼³Á¤ÇϽʽÿÀ. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); AfxEnableControlContainer(); // Ç¥ÁØ ÃʱâÈ­ // ÀÌµé ±â´ÉÀ» »ç¿ëÇÏÁö ¾Ê°í ÃÖÁ¾ ½ÇÇà ÆÄÀÏÀÇ Å©±â¸¦ ÁÙÀÌ·Á¸é // ¾Æ·¡¿¡¼­ ÇÊ¿ä ¾ø´Â ƯÁ¤ ÃʱâÈ­ // ·çƾÀ» Á¦°ÅÇØ¾ß ÇÕ´Ï´Ù. // ÇØ´ç ¼³Á¤ÀÌ ÀúÀåµÈ ·¹Áö½ºÆ®¸® ۸¦ º¯°æÇϽʽÿÀ. // TODO: ÀÌ ¹®ÀÚ¿­À» ȸ»ç ¶Ç´Â Á¶Á÷ÀÇ À̸§°ú °°Àº // ÀûÀýÇÑ ³»¿ëÀ¸·Î ¼öÁ¤ÇØ¾ß ÇÕ´Ï´Ù. SetRegistryKey(_T("·ÎÄà ÀÀ¿ë ÇÁ·Î±×·¥ ¸¶¹ý»ç¿¡¼­ »ý¼ºµÈ ÀÀ¿ë ÇÁ·Î±×·¥")); LPCWSTR cmdLine = GetCommandLine(); int nArgNum = 0; LPWSTR* argv = CommandLineToArgvW( cmdLine, &nArgNum ); bool bMake = false; if( argv && nArgNum > 1) { LoadConfig(); if( nArgNum == 2 ) { m_strMakeFileName = argv[1]; } else if( nArgNum == 3 ) { m_strWebSeeds = argv[2]; } else if( nArgNum == 4 ) { m_strTrackers = argv[3]; } LocalFree( argv ); return MakeTorrent( m_strMakeFileName.c_str(), m_strWebSeeds.c_str(), m_strTrackers.c_str() ); } CMakeTorrentDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: ¿©±â¿¡ [È®ÀÎ]À» Ŭ¸¯ÇÏ¿© ´ëÈ­ »óÀÚ°¡ ¾ø¾îÁú ¶§ ó¸®ÇÒ // Äڵ带 ¹èÄ¡ÇÕ´Ï´Ù. } else if (nResponse == IDCANCEL) { // TODO: ¿©±â¿¡ [Ãë¼Ò]¸¦ Ŭ¸¯ÇÏ¿© ´ëÈ­ »óÀÚ°¡ ¾ø¾îÁú ¶§ ó¸®ÇÒ // Äڵ带 ¹èÄ¡ÇÕ´Ï´Ù. } // ´ëÈ­ »óÀÚ°¡ ´ÝÇûÀ¸¹Ç·Î ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ¸Þ½ÃÁö ÆßÇÁ¸¦ ½ÃÀÛÇÏÁö ¾Ê°í ÀÀ¿ë ÇÁ·Î±×·¥À» ³¡³¾ ¼ö ÀÖµµ·Ï FALSE¸¦ // ¹ÝȯÇÕ´Ï´Ù. return FALSE; } void CMakeTorrentApp::LoadConfig() { FILE *fp; fopen_s( &fp, "MakeTorrent.cfg", "rt" ); if( fp == NULL ) return; char szTemp[1024]; TCHAR szWTemp[1024]; memset( szTemp, 0, sizeof(szTemp) ); memset( szWTemp, 0, sizeof(szWTemp) ); fread( szTemp, 1, 1024, fp ); MultiByteToWideChar( CP_ACP, 0, szTemp, -1, szWTemp, sizeof(TCHAR)*1024 ); std::wstring wstrTemp = szWTemp; std::vector tokens; TokenizeW( wstrTemp, tokens, std::wstring(L"\r\n") ); LPCTSTR strMakeFileName = L"makefilename:"; LPCTSTR strWebSeeds = L"webseeds:"; LPCTSTR strTrackers = L"trackers:"; for( int i=0; i<(int)tokens.size(); i++ ) { tokens[i].erase( remove_if( tokens[i].begin(), tokens[i].end(), iswspace ), tokens[i].end() ); if( NULL != StrStr(tokens[i].c_str(), strMakeFileName ) ) { tokens[i].erase( 0, tokens[i].find(L":") + 1 ); m_strMakeFileName = tokens[i]; } else if( NULL != StrStr(tokens[i].c_str(), strWebSeeds ) ) { tokens[i].erase( 0, tokens[i].find(L":") + 1 ); m_strWebSeeds = tokens[i]; } else if( NULL != StrStr(tokens[i].c_str(), strTrackers) ) { tokens[i].erase( 0, tokens[i].find(L":") + 1 ); m_strTrackers = tokens[i]; } } tokens.clear(); fclose( fp ); }