/// /// @brief 패킷을 분석하여 메일 내용을 가져온다. /// void MakeLogContents(const char * buf, int len) { CString strBuf = (CString)buf; static CString strFileName; CStdioFile file; /// 서버로 보내는 패킷이라면 if(0 == strBuf.Find(L"POST")) { /// 호스트 이름으로 INI에 저장되어 있는 키 값을 얻어온다. CString strHost = GetHostName(buf, len); wchar_t szTemp[1024] = {0}; if(0 != GetPrivateProfileString(L"CONTENTS", strHost, L"", szTemp, 1024, HOOK_WEB_INI)) { /// 메일 내용을 보내는 패킷을 찾기 위해서 /// 호스트 이름에 해당되는 키 값과 POST 이후에 오는 문자열이 같은 지 확인한다. if(5 == strBuf.Find(szTemp)) { /// 메일 내용을 보내는 패킷이라면 html 파일을 생성한다. _TRACE(L"Mail Contents!"); strFileName = (CString)LOG_WEB_CONTENTS + L"\\" + MakeLogFileName(L"PostPacket.html"); if(FALSE == file.Open(strFileName, CFile::modeCreate | CFile::modeWrite)) { //_TRACE(L"Post Packet file open fail! Error Code : %d", GetLastError()); } else file.Close(); } } } else if(0 == strBuf.Find(L"GET")) { /// GET 패킷은 제어하지 않는다. strFileName = L""; } else { /// 메일 내용을 보내는 POST 패킷 이후에 이어서 오는 패킷을 저장한다. if(FALSE == file.Open(strFileName, CFile::modeWrite)) { //_TRACE(L"None Packet file open fail! Error Code : %d", GetLastError()); } else { /// 패킷에서 주로 쓰이는 구분자 '&'를 html 문법에서 줄바꿈에 해당하는 <br>문자로 바꾼다. strBuf.Replace(L"&", L"<br>"); /// URL 인코딩된 패킷을 디코딩한다. CString strDecode = Unicode_URLDecode(strBuf); /// UTF-8 형식으로 패킷 내용을 html 파일에 저장한다. WriteFileUTF8(file, strDecode); file.Close(); } } }
wxString CodeBeautifier::ExecuteUncrustify(const wxString &input, const wxString &ext) { wxString pathToBuffer = m_mgr->GetStartupDirectory() + wxT("/uncrustify.buffer"); WriteFileUTF8(pathToBuffer, input); wxCharBuffer configFile = (m_mgr->GetStartupDirectory() + wxT("/uncrustify.cfg")).mb_str(); const int argumentsCount = 8; char ** arguments = new char *[argumentsCount]; arguments[0] = new char[4]; strcpy(arguments[0], "-c"); arguments[1] = new char[configFile.length()]; strcpy(arguments[1], configFile.data()); arguments[2] = new char[4]; strcpy(arguments[2], "-f"); arguments[3] = new char[pathToBuffer.mb_str().length()]; strcpy(arguments[3], pathToBuffer.mb_str()); arguments[4] = new char[4]; strcpy(arguments[4], "-o"); arguments[5] = new char[pathToBuffer.mb_str().length()]; strcpy(arguments[5], pathToBuffer.mb_str()); arguments[6] = new char[4]; strcpy(arguments[6], "-l"); arguments[7] = new char[ext.mb_str().length()]; strcpy(arguments[7], ext.mb_str()); UncrustifyExecute(argumentsCount, arguments, UncrustifyErrorHandler); wxString output; ReadFileWithConversion(pathToBuffer, output); for (int i = 0; i < argumentsCount; i++) { delete [] arguments[i]; } delete [] arguments; return output; }
/// /// @brief 네이버 메일 ssl 통신 시에 본문 로그를 남김 /// BOOL WINAPI InternetWriteFileCallback( _In_ HINTERNET hFile, _In_ LPCVOID lpBuffer, _In_ DWORD dwNumberOfBytesToWrite, _Out_ LPDWORD lpdwNumberOfBytesWritten ) { _TRACE(L""); CString strURL = GetURL(); if(strURL.GetLength() > 0) strURL.MakeUpper(); if(0 == strURL.Find(L"HTTPS://MAIL.NAVER.COM")) { CStringA strBuf = (LPCSTR)lpBuffer; if(0 == strBuf.Find("senderName=")) { CString strFileName; CStdioFile file; /// 메일 내용을 보내는 패킷이라면 html 파일을 생성한다. _TRACE(L"Mail Contents!"); strFileName = (CString)LOG_WEB_CONTENTS + L"\\" + MakeLogFileName(L"PostPacket.html"); if(FALSE == file.Open(strFileName, CFile::modeCreate | CFile::modeWrite)) _TRACE(L"file open fail! Error Code : %d", GetLastError()); else { /// 패킷에서 주로 쓰이는 구분자 '&'를 html 문법에서 줄바꿈에 해당하는 <br>문자로 바꾼다. strBuf.Replace("&", "<br>"); /// URL 인코딩된 패킷을 디코딩한다. CString strDecode = Unicode_URLDecode((CString)strBuf); /// UTF-8 형식으로 패킷 내용을 html 파일에 저장한다. WriteFileUTF8(file, strDecode); file.Close(); } } } return InternetWriteFileNext( hFile, lpBuffer, dwNumberOfBytesToWrite, lpdwNumberOfBytesWritten ); }
bool CodeLiteApp::IsSingleInstance(const wxCmdLineParser &parser, const wxString &curdir) { // check for single instance if ( clConfig::Get().Read("SingleInstance", false) ) { const wxString name = wxString::Format(wxT("CodeLite-%s"), wxGetUserId().c_str()); m_singleInstance = new wxSingleInstanceChecker(name); if (m_singleInstance->IsAnotherRunning()) { // prepare commands file for the running instance wxString files; for (size_t i=0; i< parser.GetParamCount(); i++) { wxString argument = parser.GetParam(i); //convert to full path and open it wxFileName fn(argument); fn.MakeAbsolute(curdir); files << fn.GetFullPath() << wxT("\n"); } if (files.IsEmpty() == false) { Mkdir(ManagerST::Get()->GetStarupDirectory() + wxT("/ipc")); wxString file_name, tmp_file; tmp_file << ManagerST::Get()->GetStarupDirectory() << wxT("/ipc/command.msg.tmp"); file_name << ManagerST::Get()->GetStarupDirectory() << wxT("/ipc/command.msg"); // write the content to a temporary file, once completed, // rename the file to the actual file name WriteFileUTF8(tmp_file, files); wxRenameFile(tmp_file, file_name); } return false; } } return true; }