int WINAPI DetourMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) { USES_CONVERSION; wstring msg(A2CT(lpText)); if(msg.find(L"当前安全设置禁止") != wstring::npos) return IDOK; if(msg.find(L"功能失败") != wstring::npos) return IDOK; return mhMessageBox(hWnd, A2CT(lpText), A2CT(lpCaption), uType); }
int GetData(const char* szKey, void*& pData, size_t& nData) { USES_CONVERSION; int nResult = 0; void* pProtectedData = NULL; DWORD dwProtectedData = 0; void* pUnprotectedData = NULL; size_t nUnprotectedData = 0; { CRegKey key; nResult = key.Open( HKEY_LOCAL_MACHINE, c_szRegKeyName, KEY_READ); if(nResult) goto onCleanup; nResult = RegQueryValueEx( key, A2CT(szKey), NULL, NULL, NULL, &dwProtectedData); if(dwProtectedData) nResult = 0; if(nResult) goto onCleanup; pProtectedData = malloc(dwProtectedData); nResult = RegQueryValueEx( key, A2CT(szKey), NULL, NULL, (BYTE*)pProtectedData, &dwProtectedData); if(nResult) goto onCleanup; nResult = UnprotectDataCAPI( szKey, pProtectedData, dwProtectedData, &pUnprotectedData, &nUnprotectedData); if(nResult) goto onCleanup; pData = pUnprotectedData; nData = nUnprotectedData; pUnprotectedData = NULL; nUnprotectedData = 0; }; onCleanup: Free(pProtectedData, dwProtectedData); Free(pUnprotectedData, nUnprotectedData); return nResult; };
CProcessTemplate* GetProcessTemplate() #endif // hab270 { USES_CONVERSION; return new CProcessTemplate( RUNTIME_CLASS(CJoinCompProcess), A2CT(JOINCOMPDISPLAYNAME), CJoinCompProcess::INPUT_TYPE_DISPLAY(), CJoinCompProcess::OUTPUT_TYPE_DISPLAY(), A2CT(CJoinCompProcess::ID()), CProcess::kAnalysis, 0); // to do: figure out what the version number really should mean }
BOOL CShellMgr::GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, LPTSTR lpFriendlyName) { BOOL bSuccess = TRUE; STRRET str = { STRRET_CSTR }; if (lpsf->GetDisplayNameOf(lpi, dwFlags, &str) == NOERROR) { USES_CONVERSION; switch (str.uType) { case STRRET_WSTR: lstrcpy(lpFriendlyName, W2CT(str.pOleStr)); ::CoTaskMemFree(str.pOleStr); break; case STRRET_OFFSET: lstrcpy(lpFriendlyName, (LPTSTR)lpi + str.uOffset); break; case STRRET_CSTR: lstrcpy(lpFriendlyName, A2CT(str.cStr)); break; default: bSuccess = FALSE; break; } } else { bSuccess = FALSE; } return bSuccess; }
void CLibraryDetailView::OnFindItemA(NMLVFINDITEM* pNotify, LRESULT* pResult) { USES_CONVERSION; LPCTSTR pszFind = A2CT( (LPCSTR)pNotify->lvfi.psz ); GET_LIST(); CQuickLock oLock( Library.m_pSection ); for ( int nLoop = 0 ; nLoop < 2 ; nLoop++ ) { for ( int nItem = pNotify->iStart ; nItem < pList->GetItemCount() ; nItem++ ) { if ( CLibraryFile* pFile = Library.LookupFile( m_pList[ nItem ].nIndex ) ) { if ( pNotify->lvfi.flags & LVFI_STRING ) { if ( _tcsnicmp( pszFind, pFile->m_sName, _tcslen( pszFind ) ) == 0 ) { *pResult = nItem; return; } } } } pNotify->iStart = 0; } *pResult = -1; }
int CALLBACK CSSLContext::InternalServerNameCallback(SSL* ssl, int* ad, void* arg) { USES_CONVERSION; CSSLContext* pThis = (CSSLContext*)arg; ASSERT(pThis->m_fnServerNameCallback != nullptr); const char* lpszServerName = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name); if(lpszServerName == nullptr) return SSL_TLSEXT_ERR_NOACK; int iIndex = pThis->m_fnServerNameCallback(A2CT(lpszServerName)); if(iIndex == 0) return SSL_TLSEXT_ERR_OK; if(iIndex < 0) { ::SetLastError(ERROR_INVALID_NAME); return SSL_TLSEXT_ERR_ALERT_FATAL; } SSL_CTX* sslCtx = pThis->GetContext(iIndex); if(sslCtx == nullptr) { ::SetLastError(ERROR_INVALID_INDEX); return SSL_TLSEXT_ERR_ALERT_FATAL; } SSL_set_SSL_CTX(ssl, sslCtx); return SSL_TLSEXT_ERR_OK; }
CSSLSession* CSSLSession::Renew(const CSSLContext& sslCtx, LPCSTR lpszHostName) { ASSERT(!IsValid()); m_ssl = SSL_new(sslCtx.GetDefaultContext()); m_bioSend = BIO_new(BIO_s_mem()); m_bioRecv = BIO_new(BIO_s_mem()); SSL_set_bio(m_ssl, m_bioRecv, m_bioSend); if(sslCtx.GetSessionMode() == SSL_SM_SERVER) SSL_accept(m_ssl); else { USES_CONVERSION; if(lpszHostName && lpszHostName[0] != 0 && !::IsIPAddress(A2CT(lpszHostName))) SSL_set_tlsext_host_name(m_ssl, lpszHostName); SSL_connect(m_ssl); } m_pitSend = m_itPool.PickFreeItem(); m_pitRecv = m_itPool.PickFreeItem(); m_bufSend.buf = (char*)m_pitSend->Ptr(); m_bufRecv.buf = (char*)m_pitRecv->Ptr(); m_enStatus = SSL_HSS_PROC; return this; }
BOOL CSqlite3Recordset::GetField(short iIndex, LPTSTR pData, UINT cchMax) { _ASSERTE(IsOpen()); _ASSERTE(iIndex>=0 && iIndex<m_nCols); if( IsEOF() ) return FALSE; if( iIndex < 0 || iIndex >= m_nCols ) return FALSE; if( m_lType == DB_OPEN_TYPE_FORWARD_ONLY ) { #if !defined(UNICODE) USES_CONVERSION; _tcsncpy(pData, A2T( (char*)::sqlite3_column_text(m_pVm, iIndex) ), cchMax); #else // UNICODE _tcsncpy(pData, (WCHAR*) ::sqlite3_column_text16(m_pVm, iIndex), cchMax); #endif // UNICODE } else { LPSTR pstr = m_ppSnapshot[ ((m_iPos + 1) * m_nCols) + iIndex ]; if( pstr == NULL ) { _tcscpy(pData, _T("")); } else { USES_CONVERSION; LPCSTR pstr = m_ppSnapshot[ ((m_iPos + 1) * m_nCols) + iIndex ]; _tcsncpy(pData, A2CT(pstr), cchMax); } } return TRUE; }
BOOL WINAPI DDEnumDevCallback(GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm) { LPDIRECTDRAW ddp; LPDIRECTDRAW4 dd4p; DDDEVICEIDENTIFIER ddDev; BOOL ret = FALSE; if (DirectDrawCreate(lpGUID,&ddp,0) == DD_OK) { if(ddp->QueryInterface(IID_IDirectDraw4,(void **)&dd4p) == S_OK) { ZeroMemory(&ddDev,sizeof(ddDev)); if(GetDeviceIdentifierEx(dd4p,&ddDev, DDGDI_GETHOSTIDENTIFIER) == DD_OK) { // add to table USES_CONVERSION; CUtilGPU::AddDisplayDevice(A2CT(lpDriverName), ddDev.dwVendorId, ddDev.dwDeviceId, ddDev.szDescription, ddDev.szDriver); ret = TRUE; } dd4p->Release(); } ddp->Release(); } return ret; }
CHttpDownloader::CHttpDownloader() { USES_CONVERSION; m_strHWID = A2CT(GenHWID2().c_str()); m_wcsOriginalFileName = L"error"; }
void CSocketManager::DisplayData(const LPBYTE lpData, DWORD dwCount, const SockAddrIn& sfrom) { CString strData; #ifndef UNICODE USES_CONVERSION; memcpy(strData.GetBuffer(dwCount), A2CT((LPSTR)lpData), dwCount); strData.ReleaseBuffer(dwCount); #else MultiByteToWideChar(CP_ACP, 0, reinterpret_cast<LPCSTR>(lpData), dwCount, strData.GetBuffer(dwCount+1), dwCount+1 ); strData.ReleaseBuffer(dwCount); #endif if (!sfrom.IsNull()) { LONG uAddr = sfrom.GetIPAddr(); BYTE* sAddr = (BYTE*) &uAddr; int nPort = ntohs( sfrom.GetPort() ); // show port in host format... CString strAddr; // Address is stored in network format... strAddr.Format(_T("%u.%u.%u.%u (%d)>"), (UINT)(sAddr[0]), (UINT)(sAddr[1]), (UINT)(sAddr[2]), (UINT)(sAddr[3]), nPort); strData = strAddr + strData; } AppendMessage( strData ); }
BOOL CCsvDatabase::_BindColumns() { USES_CONVERSION; // Count number of columns LPCSTR p = m_pstrText; if( *p == ';' ) p++; // Sometimes column-definition line starts with a ';'-char if( *p == '\r' || *p == '\n' || *p == ' ' ) return _Error(1, _T("Junk at start of file")); m_nCols = 1; m_cSep = ','; m_bFixedWidth = false; bool bInsideQuote = false; bool bWasSpace = false; while( *p != '\n' ) { // Look for a possible new separator if( *p == ';' && m_nCols == 1 ) m_cSep = *p; if( *p == '\0' ) return _Error(2, _T("EOF before columns were defined")); // So is this a column, then? if( !bInsideQuote && *p == m_cSep ) m_nCols++; // Skip skip skip if( *p == '\"' ) bInsideQuote = !bInsideQuote; p++; if( *p == '\n' && bInsideQuote ) return _Error(2, _T("Unclosed quotes in field definition")); } // Create columns array m_pColumns = new CCsvColumn[m_nCols]; // Ready for new run where we populate the columns p = m_pstrText; if( *p == ';' ) p++; bInsideQuote = false; bWasSpace = false; int iField = 0; int iWidth = 0; LPCSTR pstrName = p; while( *p != '\n' ) { if( !bInsideQuote && *p == m_cSep ) { // Populate column information m_pColumns[iField].iSize = iWidth; m_pColumns[iField].lOffset = p - pstrName; // A space before the field-separator indicates fixed-width. // The "fixed width"-flag is global so we only need to see it once. if( bWasSpace ) { m_bFixedWidth = true; // Trim name as well while( iWidth > 0 && pstrName[iWidth - 1] == ' ' ) iWidth--; } _tcsncpy(m_pColumns[iField].szName, A2CT(pstrName), iWidth); // Prepare for next column pstrName = ++p; iWidth = 0; iField++; } if( *p == '\"' ) bInsideQuote = !bInsideQuote; if( bInsideQuote ) m_pColumns[iField].iType = VT_BSTR; bWasSpace = (*p == ' '); iWidth++; p++; } return TRUE; }
void CProcessStatus::startingProcessor(CProcess * pProc) { m_iProcNumber++; ASSERTX(m_iTotalProcessCount); int iPercentage = (int) (100.0* (float(m_iProcNumber-1) / float(m_iTotalProcessCount))); USES_CONVERSION; progress(A2CT(pProc->getDisplayName()), iPercentage); }
/** * ログ追加 * @param[in] lpFormat フォーマット * @param[in] argptr 引数 */ void CTraceWnd::AddFormat(LPCSTR lpFormat, va_list argptr) { USES_CONVERSION; TCHAR szBuf[4096]; _vstprintf(szBuf, A2CT(lpFormat), argptr); AddString(szBuf); }
void EnumDir(CStringA resToken, int nEnumSubdir, std::vector<CString>& vecFiles) { int nEndSlash = resToken.ReverseFind('\\'); if (nEndSlash == -1) return; USES_CONVERSION; CStringA path = resToken.Mid(0, nEndSlash); CStringA findname = resToken.Mid(nEndSlash + 1); // file WIN32_FIND_DATAA fd; memset(&fd, 0, sizeof(WIN32_FIND_DATAA)); HANDLE hFind = FindFirstFileA(resToken, &fd); if (hFind != INVALID_HANDLE_VALUE) { do { CStringA subname = fd.cFileName; if (subname != "." && subname != "..") { CStringA fname = path + "\\" + subname; if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { } else vecFiles.push_back(A2CT(fname)); } } while (FindNextFileA(hFind, &fd) != 0); FindClose(hFind); } // directory if (nEnumSubdir > 0) { hFind = FindFirstFileA(path + "\\*.*", &fd); if (hFind != INVALID_HANDLE_VALUE) { do { CStringA subname = fd.cFileName; if (subname != "." && subname != "..") { CStringA fname = path + "\\" + subname; if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) EnumDir(fname + "\\" + findname, nEnumSubdir, vecFiles); } } while (FindNextFileA(hFind, &fd) != 0); FindClose(hFind); } } }
void CSocketManager::DisplayData(const LPBYTE lpData, DWORD dwCount, const SockAddrIn& sfrom,__int64 startTime, BYTE type) { CString strData; #ifndef UNICODE USES_CONVERSION; memcpy(strData.GetBuffer(dwCount), A2CT((LPSTR)lpData), dwCount); strData.ReleaseBuffer(dwCount); #else MultiByteToWideChar(CP_ACP, 0, reinterpret_cast<LPCSTR>(lpData), dwCount, strData.GetBuffer(dwCount+1), dwCount+1 ); strData.ReleaseBuffer(dwCount); #endif // variables char temp[512]; if (type == 3) { static int laserCommandMessageCount = 0; static CLaserCommand command((BYTE*)A2CT((LPSTR)lpData)); command.BytesToStatus(((BYTE*)A2CT((LPSTR)lpData))); // debug string for display sprintf(temp, "+LASER COMMAND MESSAGE(%d)\r\n", ++laserCommandMessageCount); sprintf(temp, "%s|->isLaserOn = %d\r\n", temp,command.LaserCommand.IsLaserOn); sprintf(temp, "%s|->AZ = %d\r\n", temp,command.LaserCommand.PWM_AZ); sprintf(temp, "%s|->EL = %d\r\n", temp,command.LaserCommand.PWM_EL); sprintf(temp, "%s\r\n\r\n", temp); } else { static int laserConfigMessageCount = 0; static CLaserConfiguration config; config.BytesToStatus(((BYTE*)A2CT((LPSTR)lpData))); // debug string for display sprintf(temp, "+LASER Configuration MESSAGE(%d)\r\n", ++laserConfigMessageCount); sprintf(temp, "%s|->Frequency = %d\r\n", temp,config.LaserConfiguration.Frequency); sprintf(temp, "%s|->AZ(min) = %d\r\n", temp,config.LaserConfiguration.PWM_AZ.MIN); sprintf(temp, "%s|->AZ(max) = %d\r\n", temp,config.LaserConfiguration.PWM_AZ.MAX); sprintf(temp, "%s|->EL(min) = %d\r\n", temp,config.LaserConfiguration.PWM_EL.MIN); sprintf(temp, "%s|->EL(max) = %d\r\n", temp,config.LaserConfiguration.PWM_EL.MAX); sprintf(temp, "%s\r\n\r\n", temp); } AppendMessage( temp ); }
//***************************************************************************** //* Function Name: DecodeProperty //* Description: Decode a single property value. We support a small number //* of simple data types. Having converted the string value //* to a particular data type, hand it off to one of two //* property descriptors - either p_pPropertyDescriptor which //* holds a single value or p_pPropertyArrayDescriptor which //* holds a vector of values (of the same type). //***************************************************************************** void CEntityDecoder::DecodeProperty ( const _bstr_t& p_sbstrValue, bool p_bPropertyArray, const CPropertyDescriptor* p_pPropertyDescriptor, const CPropertyArrayDescriptor* p_pPropertyArrayDescriptor) { _variant_t l_svarValue (p_sbstrValue); _ASSERTE ( (p_bPropertyArray == true && p_pPropertyDescriptor == NULL && p_pPropertyArrayDescriptor != NULL) || (p_bPropertyArray == false && p_pPropertyDescriptor != NULL && p_pPropertyArrayDescriptor == NULL)); const type_info& l_tiPropertyType = (p_bPropertyArray) ? p_pPropertyArrayDescriptor->GetPropertyType () : p_pPropertyDescriptor->GetPropertyType (); if (l_tiPropertyType == typeid (_bstr_t)) { _bstr_t l_sbstrValue = l_svarValue; if (p_bPropertyArray) p_pPropertyArrayDescriptor->AddPropertyValue (l_sbstrValue); else p_pPropertyDescriptor->SetPropertyValue (l_sbstrValue); } else if (l_tiPropertyType == typeid (double)) { double l_dblValue = l_svarValue; if (p_bPropertyArray) p_pPropertyArrayDescriptor->AddPropertyValue (l_dblValue); else p_pPropertyDescriptor->SetPropertyValue (l_dblValue); } else if (l_tiPropertyType == typeid (long)) { long l_lValue = l_svarValue; if (p_bPropertyArray) p_pPropertyArrayDescriptor->AddPropertyValue (l_lValue); else p_pPropertyDescriptor->SetPropertyValue (l_lValue); } else if (l_tiPropertyType == typeid (bool)) { bool l_bValue = l_svarValue; if (p_bPropertyArray) p_pPropertyArrayDescriptor->AddPropertyValue (l_bValue); else p_pPropertyDescriptor->SetPropertyValue (l_bValue); } else { USES_CONVERSION; LPCTSTR l_lpszPropertyTypeName = A2CT (l_tiPropertyType.name ()); ThrowComErrorException ( __FILE__, __LINE__, E_UNEXPECTED, IDS_UNSUPPORTED_PROPERTY_DATA_TYPE, l_lpszPropertyTypeName); } }
SFMFile::SFMFile(LPCSTR lpszPathName, char cCommentChar, BOOL bForWriting) : m_forWriting(bForWriting), m_stream(lpszPathName, ios::in | ios::nocreate), m_bNothingLogged(TRUE), m_cCommentChar(cCommentChar), m_bDidOutputSkippedCommentNotice(FALSE) { USES_CONVERSION; m_pathName = A2CT(lpszPathName); // used when reporting errors }
BOOL CSqlite3Recordset::GetColumnName(short iIndex, LPTSTR pstrName, UINT cchMax) { _ASSERTE(IsOpen()); _ASSERTE(iIndex>=0 && iIndex<m_nCols); if( iIndex < 0 || iIndex >= m_nCols ) return FALSE; USES_CONVERSION; LPCSTR pstrSrc = m_lType == DB_OPEN_TYPE_FORWARD_ONLY ? ::sqlite3_column_name(m_pVm, iIndex) : m_ppSnapshot[iIndex]; _tcsncpy(pstrName, A2CT(pstrSrc), cchMax); return TRUE; }
int WINAPI DetourMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) { USES_CONVERSION; wstring msg(A2CT(lpText)); if(msg.find(L"当前安全设置禁止") != wstring::npos) return IDOK; if(msg.find(L"功能失败") != wstring::npos) return IDOK; if(msg.find(L"Adobe Flash Player") != wstring::npos) { if(FlashAlertTime > 0) return IDCANCEL; else { lpText = "您没有安装Adobe Flash Player,点击确定将访问Adobe.com,请您下载安装"; FlashAlertTime = 2; } } return mhMessageBox(hWnd, A2CT(lpText), A2CT(lpCaption), uType); }
void AppLauncherDlg::OnInitDialog() { USES_CONVERSION; nsCOMPtr<nsIMIMEInfo> mimeInfo; nsCAutoString url; if (mHelperAppLauncher) { mHelperAppLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo)); nsCOMPtr<nsIURI> uri; mHelperAppLauncher->GetSource(getter_AddRefs(uri)); uri->GetSpec(url); } nsMIMEInfoHandleAction prefAction = nsIMIMEInfo::saveToDisk; nsAutoString appName; nsCAutoString contentType; if (mimeInfo) { mimeInfo->GetPreferredAction(&prefAction); mimeInfo->GetApplicationDescription(appName); mimeInfo->GetMIMEType(contentType); } if (prefAction == nsIMIMEInfo::saveToDisk) { CheckRadioButton(mHwndDlg, IDC_OPENWITHAPP, IDC_SAVETOFILE, IDC_SAVETOFILE); } else { CheckRadioButton(mHwndDlg, IDC_OPENWITHAPP, IDC_SAVETOFILE, IDC_OPENWITHAPP); } SetDlgItemText(mHwndDlg, IDC_URL, url.IsEmpty() ? _T("") : A2CT(url.get())); SetDlgItemText(mHwndDlg, IDC_APPLICATION, appName.IsEmpty() ? _T("<No Application>") : W2CT(appName.get())); SetDlgItemText(mHwndDlg, IDC_CONTENTTYPE, contentType.IsEmpty() ? _T("") : A2CT(contentType.get())); }
/** * ログ追加 * @param[in] c 文字 */ void CTraceWnd::AddChar(char c) { if ((c == 0x0a) || (c == 0x0d)) { if (!m_lineBuffer.empty()) { USES_CONVERSION; AddString(A2CT(m_lineBuffer.c_str())); m_lineBuffer.erase(); } } else { m_lineBuffer += c; } }
int PutData(const char* szKey, const void* pData, size_t nData) { USES_CONVERSION; int nResult = 0; void* pProtectedData = NULL; size_t nProtectedData = 0; { nResult = ProtectDataCAPI( szKey, pData, nData, &pProtectedData, &nProtectedData); if(nResult) goto onCleanup; CRegKey key; if(pData) { nResult = key.Create( HKEY_LOCAL_MACHINE, c_szRegKeyName, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL, NULL); if(nResult) goto onCleanup; nResult = RegSetValueEx( key, A2CT(szKey), NULL, REG_BINARY, (CONST BYTE*)pProtectedData, nProtectedData); if(nResult) goto onCleanup; } else { RegDeleteKey(HKEY_LOCAL_MACHINE, c_szRegKeyName); }; }; onCleanup: Free(pProtectedData, nProtectedData); return nResult; };
CProcessTemplate* GetProcessTemplate() #endif // hab270 { USES_CONVERSION; return new CProcessTemplate( RUNTIME_CLASS(CPCPATRDllProcess), _T("PC-PATR DLL"), CPCPATRDllProcess::INPUT_TYPE_DISPLAY(), CPCPATRDllProcess::OUTPUT_TYPE_DISPLAY(), A2CT(CPCPATRDllProcess::ID()), #ifndef hab245 CProcess::kAnalysis | CProcess::kInterlinear | CProcess::kTransfer | CProcess::kSynthesis, #else // hab245 CProcess::kAnalysis, #endif // hab245 0); // to do: figure out what the version number really should mean }
// exceptions: CString for parsing errors CProcessingPrefs::CProcessingPrefs(SFMFile* f) : m_pInputLang(NULL), m_pTargetLang(NULL), m_iGoal(kTargetText), m_iVerbosity(0) { USES_CONVERSION; CString sMarker, sField; while(f->getField(sMarker, sField)) { if(sMarker==A2CT(ksrcEndMarker)) break; else if (sMarker == _T("Verbosity")) { m_iVerbosity = _ttoi(sField); } else checkAndReadInt(_T("Goal"), m_iGoal) else if(sMarker == _T("Flags")) m_dwFlags=_ttoi(sField); else if (sMarker == _T("InputLangID")) { m_pInputLang = NULL; // can't look this up yet m_sTempInputLangID = sField; // save for the "finish create" cycle, when all language docs have been loaded // and we can look up this id and get the pointer } else if (sMarker == _T("TargetLangID")) { m_pTargetLang = NULL; // can't look this up yet m_sTempTargetLangID = sField; // save for the "finish create" cycle, when all language docs have been loaded // and we can look up this id and get the pointer } else f->throwParseFailure(_T("ProcessingPrefs"), sMarker, sField); } if(theApp.getProject()->getHaveLanguages()) { if(!m_pInputLang) m_pInputLang = theApp.getProject()->getLangFromIndex(0); if(!m_pTargetLang) m_pTargetLang = theApp.getProject()->getLangFromIndex(0); } }
BOOL COledbRecordset::GetField(short iIndex, CString& pData) { _ASSERTE(IsOpen()); iIndex += m_iAdjustIndex; _ASSERTE(iIndex>=0 && iIndex<m_nCols); // NOTE: We should never be forced to convert between MBCS/UNICODE because // the column binding sets up the desired TCHAR type. USES_CONVERSION; switch( m_rgBindings[iIndex].wType ) { case DBTYPE_STR: pData = A2CT( (char*) ((LPBYTE) m_pData + m_rgBindings[iIndex].obValue) ); return TRUE; case DBTYPE_WSTR: pData = W2CT( (WCHAR*) ((LPBYTE) m_pData + m_rgBindings[iIndex].obValue) ); return TRUE; default: _ASSERTE(false); return FALSE; } }
void PostOnHeadersComplete(CONNID dwConnID, LPCSTR lpszSummary, LPCTSTR lpszName) { USES_CONVERSION; static LPCTSTR PREFIX = _T("* * * * * * * * * Summary * * * * * * * * *\r\n"); static int PREFIX_LEN = lstrlen(PREFIX); LPCTSTR lpszSummaryT = A2CT(lpszSummary); int content_len = lstrlen(lpszSummaryT) + PREFIX_LEN + 1; LPTSTR lpszContent = new TCHAR[content_len]; memcpy(lpszContent, PREFIX, PREFIX_LEN * sizeof(TCHAR)); memcpy(lpszContent + PREFIX_LEN, lpszSummaryT, (content_len - PREFIX_LEN) * sizeof(TCHAR)); info_msg* msg = info_msg::Construct(dwConnID, EVT_ON_HEADERS_COMPLETE, content_len, lpszContent, lpszName); PostInfoMsg(msg); }
void CSocketManager::DisplayData(const LPBYTE lpData, DWORD dwCount, const SockAddrIn& sfrom) { CString strData; memcpy(strData.GetBuffer(dwCount), A2CT((LPSTR)lpData), dwCount); strData.ReleaseBuffer(); if (!sfrom.IsNull()) { LONG uAddr = sfrom.GetIPAddr(); BYTE* sAddr = (BYTE*) &uAddr; short nPort = ntohs( sfrom.GetPort() ); // show port in host format... CString strAddr; // Address is stored in network format... strAddr.Format(_T("%u.%u.%u.%u (%d)>"), (UINT)(sAddr[0]), (UINT)(sAddr[1]), (UINT)(sAddr[2]), (UINT)(sAddr[3]), nPort); strData = strAddr + strData; } AppendMessage(strData); }
HRESULT CMainFrameDropTarget::PasteHDROP(COleDataObject &data) { HRESULT hrPasteResult = E_FAIL; HANDLE hMem; if ((hMem = data.GetGlobalData(CF_HDROP)) != NULL) { LPDROPFILES lpDrop; if ((lpDrop = (LPDROPFILES)GlobalLock(hMem)) != NULL) { if (lpDrop->fWide) { LPCWSTR pszFileNameW = (LPCWSTR)((LPBYTE)lpDrop + lpDrop->pFiles); while (*pszFileNameW != L'\0') { USES_CONVERSION; if (FAILED(AddUrlFileContents(W2CT(pszFileNameW)))) break; hrPasteResult = S_OK; pszFileNameW += wcslen(pszFileNameW) + 1; } } else { LPCSTR pszFileNameA = (LPCSTR)((LPBYTE)lpDrop + lpDrop->pFiles); while (*pszFileNameA != '\0') { USES_CONVERSION; if (FAILED(AddUrlFileContents(A2CT(pszFileNameA)))) break; hrPasteResult = S_OK; pszFileNameA += strlen(pszFileNameA) + 1; } } GlobalUnlock(hMem); } GlobalFree(hMem); } return hrPasteResult; }
void vmsHttpFlvTrafficAnalyzer::ExtractTitleFromXml(const vmsHttpTrafficCollector::HttpDialog *pDlg, wstring &wstrTitle, const vmsHttpTrafficCollector::HttpDialog* pFlvDlg) { extern LPCSTR strstrni (LPCSTR pszSrc, LPCSTR pszSrch, int lenSrc); extern LPCSTR strstrn (LPCSTR pszSrc, LPCSTR pszSrch, int lenSrc); wstrTitle = L""; assert (pDlg != NULL); if (!pDlg) return; assert (pDlg->enCT == vmsHttpTrafficCollector::HttpDialog::XML); if (pDlg->vbResponseBody.empty ()) return; LPCSTR pszXml = (LPCSTR)&pDlg->vbResponseBody [0]; int iXmlLen = pDlg->vbResponseBody.size (); LPCSTR pszXml2 = strstrni (pszXml, "encoding=\"", iXmlLen); if (!pszXml2) return; pszXml2 += 10; iXmlLen -= pszXml2 - pszXml; pszXml = pszXml2; if (iXmlLen < 5) return; if (strnicmp (pszXml, "utf-8", 5)) return; USES_CONVERSION; tstring tstrRequestUrl = A2CT (pFlvDlg->strRequestUrl.c_str ()); string strUrl = vmsXmlHelper::toUtf8noEncode (tstrRequestUrl); pszXml2 = strstrn (pszXml, strUrl.c_str (), iXmlLen); if (!pszXml2) { strUrl = vmsXmlHelper::toUtf8 (tstrRequestUrl); pszXml2 = strstrn (pszXml, strUrl.c_str (), iXmlLen); if (!pszXml2) { strUrl = pFlvDlg->strRequestUrl; pszXml2 = strstrn (pszXml, strUrl.c_str (), iXmlLen); } } LPCSTR pszVideoSectionTag = pszXml; if (pszXml2) { bool bAsAttr = pszXml2 [-1] != '>'; if (bAsAttr) { while (pszXml2 > pszXml && *pszXml2 != '"') pszXml2--; pszXml2--; if (pszXml2 > pszXml) { bool bInQ = false; while (pszXml2 > pszXml) { if (*pszXml2 == '"') bInQ = !bInQ; else if (*pszXml2 == '<' && bInQ == false) break; pszXml2--; } if (pszXml2 > pszXml) pszVideoSectionTag = pszXml2; } } else { while (pszXml2 > pszXml && *pszXml2 != '<') pszXml2--; pszXml2--; if (pszXml2 > pszXml) { bool bInT = false; while (pszXml2 > pszXml) { if (*pszXml2 == '<') { if (bInT) { bInT = false; } else { if (pszXml2 [1] == '/') { bInT = true; } else { break; } } } pszXml2--; } if (pszXml2 > pszXml) pszVideoSectionTag = pszXml2; } } } int iXmlLen2 = iXmlLen - (pszVideoSectionTag - pszXml); LPCSTR apszTags [] = {"title=\"", "<title>", "name=\"", "<name>"}; int iTag; LPCSTR pszTitle = NULL; do { for (iTag = 0; iTag < sizeof (apszTags)/sizeof (LPCSTR) && pszTitle == NULL; iTag++) pszTitle = strstrni (pszVideoSectionTag, apszTags [iTag], iXmlLen2); if (!pszTitle) { if (pszVideoSectionTag != pszXml) { pszVideoSectionTag = pszXml; iXmlLen2 = iXmlLen; } else { return; } } } while (pszTitle == NULL); pszTitle += strlen (apszTags [iTag]); LPCSTR pszTitleE = pszTitle; int iXmlLen3 = iXmlLen - (pszTitle - pszXml); char chEnd = pszTitle [-1] == '>' ? '<' : '"'; while (*pszTitleE != chEnd && iXmlLen3) { pszTitleE++; iXmlLen3--; } if (!iXmlLen3) return; string strTitle; strTitle.assign (pszTitle, pszTitleE-pszTitle); int n = MultiByteToWideChar (CP_UTF8, 0, strTitle.c_str (), -1, NULL, 0); assert (n != 0); LPWSTR pwsz = new WCHAR [n+1]; *pwsz = 0; MultiByteToWideChar (CP_UTF8, 0, strTitle.c_str (), -1, pwsz, n); wstrTitle = pwsz; delete [] pwsz; }