HANDLE apiCreateThread(LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, LPDWORD lpThreadId, LPCSTR asThreadNameFormat /*= NULL*/, int anFormatArg /*= 0*/) { HANDLE hThread = NULL; ConEmuThreadStartArg* args = new ConEmuThreadStartArg(lpStartAddress, lpParameter, GetCurrentThreadId()); if (!args) { // Not enough memory return NULL; } // Set user-friendly thread name for VisualStudio debugger if (asThreadNameFormat && *asThreadNameFormat) { if (strchr(asThreadNameFormat, '%') != NULL) { INT_PTR cchMax = strlen(asThreadNameFormat) + 64; char* pszNewName = new char[cchMax]; if (pszNewName) { _wsprintfA(pszNewName, SKIPLEN(cchMax) asThreadNameFormat, anFormatArg); _ASSERTE(strlen(pszNewName) < THREAD_MAX_NAME_LEN); lstrcpynA(args->sName, pszNewName, countof(args->sName)); delete[] pszNewName; } } if (args->sName[0] == 0) { _ASSERTE(strlen(asThreadNameFormat) < THREAD_MAX_NAME_LEN); lstrcpynA(args->sName, asThreadNameFormat, countof(args->sName)); } } // Start the thread hThread = ::CreateThread(NULL, 0, apiThreadHelper, args, CREATE_SUSPENDED, lpThreadId); DWORD nLastError = GetLastError(); if (hThread) { args->hThread = hThread; ResumeThread(hThread); } else { delete args; } // Done SetLastError(nLastError); return hThread; }
inline STDMETHODIMP get_command_string(void *p, UINT id, UINT flags, UINT *reserved, LPSTR name, UINT size) { const char *text; if (!(flags & GCS_HELPTEXT)) return E_INVALIDARG; text = get_menu_item_text(id); if (!text) return E_INVALIDARG; if (flags & GCS_UNICODE) { size_t len = strlen(text) + 1; LPWSTR tw = xmalloc(len * sizeof(wchar_t)); /* need to convert terminating NULL as well */ mbstowcs(tw, text, len); lstrcpynW((LPWSTR)name, tw, size); free(tw); } else lstrcpynA(name, text, size); return S_OK; }
void PSDRV_AFM2C(const AFM *afm) { char buffer[256]; FILE *of; int i; lstrcpynA(buffer, afm->FontName, sizeof(buffer) - 2); for (i = 0; i < strlen(buffer); ++i) if (buffer[i] == '-') buffer[i] = '_'; buffer[i] = '.'; buffer[i + 1] = 'c'; buffer[i + 2] = '\0'; MESSAGE("writing '%s'\n", buffer); of = fopen(buffer, "w"); if (of == NULL) { ERR("error opening '%s' for writing\n", buffer); return; } buffer[i] = '\0'; writeHeader(of, afm, buffer); writeMetrics(of, afm, buffer); writeAFM(of, afm, buffer); fclose(of); }
static DWORD getInterfaceStatusByName(const char *name, PDWORD status) { DWORD ret; int fd; if (!name) return ERROR_INVALID_PARAMETER; if (!status) return ERROR_INVALID_PARAMETER; fd = socket(PF_INET, SOCK_DGRAM, 0); if (fd != -1) { struct ifreq ifr; lstrcpynA(ifr.ifr_name, name, IFNAMSIZ); if ((ioctl(fd, SIOCGIFFLAGS, &ifr))) ret = ERROR_INVALID_DATA; else { if (ifr.ifr_flags & IFF_UP) *status = MIB_IF_OPER_STATUS_OPERATIONAL; else *status = MIB_IF_OPER_STATUS_NON_OPERATIONAL; ret = NO_ERROR; } close(fd); } else ret = ERROR_NO_MORE_FILES; return ret; }
void RegisterFontServiceFonts() { if (ServiceExists(MS_FONT_REGISTER)) { int i; char szTemp[100]; LOGFONTA lf; FontID fid = {0}; fid.cbSize = sizeof(fid); strncpy(fid.group, "Scriver", sizeof(fid.group)); strncpy(fid.dbSettingsGroup, SRMMMOD, sizeof(fid.dbSettingsGroup)); fid.flags = FIDF_DEFAULTVALID; for (i = 0; i < sizeof(fontOptionsList) / sizeof(fontOptionsList[0]); i++) { LoadMsgDlgFont(i, &lf, &fontOptionsList[i].colour); fontOptionsList[i].size = _snprintf(szTemp, sizeof(szTemp), "SRMFont%d", i); strncpy(fid.prefix, szTemp, sizeof(fid.prefix)); fid.order = i; strncpy(fid.name, fontOptionsList[i].szDescr, sizeof(fid.name)); fid.deffontsettings.colour = fontOptionsList[i].colour; fid.deffontsettings.size = (char) lf.lfHeight; //(BYTE)DBGetContactSettingByte(NULL, FONTMODULE, szTemp, fontOptionsList[0].defSize); //fid.deffontsettings.size = -MulDiv(fid.deffontsettings.size, GetDeviceCaps(hdc, LOGPIXELSY), 72); fid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? FONTF_BOLD : 0) | (lf.lfItalic ? FONTF_ITALIC : 0); fid.deffontsettings.charset = lf.lfCharSet; lstrcpynA(fid.deffontsettings.szFace, lf.lfFaceName, LF_FACESIZE); CallService(MS_FONT_REGISTER, (WPARAM)&fid, 0); } } HookEvent(ME_FONT_RELOAD, FontServiceFontsChanged); }
STDMETHODIMP CShellExtension::GetCommandString( UINT_PTR idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax) { // Check idCmd, it must be 0 since we have only one menu item. if (0 != idCmd) return E_INVALIDARG; // If Explorer is asking for a help string, copy our string into the // supplied buffer. if (uFlags & GCS_HELPTEXT) { LPCTSTR szText = _T("This is the simple shell extension's help"); if (uFlags & GCS_UNICODE) { _tcscpy_s((_TCHAR *)pszName, cchMax, szText); } else { // Use the ANSI string copy API to return the help string. lstrcpynA(pszName, (LPSTR)szText, cchMax); } return S_OK; } return E_INVALIDARG; }
HRESULT CSimpleShlExt::GetCommandString( UINT idCmd, UINT uFlags,UINT* pwReserved, LPSTR pszName, UINT cchMax ) { USES_CONVERSION; //检查 idCmd, 它必须是0,因为我们仅有一个添加的菜单项. if ( 0 != idCmd ) return E_INVALIDARG; // 如果 Explorer 要求帮助字符串,就将它拷贝到提供的缓冲区中. if ( uFlags & GCS_HELPTEXT ) { LPCTSTR szText = _T("This is the simple shell extension's help"); if ( uFlags & GCS_UNICODE ) { // 我们需要将 pszName 转化为一个 Unicode 字符串, 接着使用Unicode字符串拷贝 API. lstrcpynW ( (LPWSTR) pszName, T2CW(szText), cchMax ); } else { // 使用 ANSI 字符串拷贝API 来返回帮助字符串. lstrcpynA ( pszName, T2CA(szText), cchMax ); } return S_OK; } return E_INVALIDARG; }
HRESULT STDMETHODCALLTYPE CRenameExtImpl::GetCommandString(UINT idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax) { HRESULT hr = E_INVALIDARG; int uMaxNameLen = 100; if(idCmd != IDM_DISPLAY) { return hr; } switch(uFlags) { case GCS_HELPTEXTA: case GCS_VERBA: lstrcpynA(pszName, "Change File Extention", uMaxNameLen); hr = S_OK; break; case GCS_HELPTEXTW: case GCS_VERBW: lstrcpynW((LPWSTR)pszName, L"Change File Extention", uMaxNameLen); hr = S_OK; break; default: hr = S_OK; break; } return hr; }
Protocol::Protocol(const char *aName, const TCHAR* descr) { lstrcpynA(name, aName, SIZEOF(name)); lstrcpyn(description, descr, SIZEOF(description)); data_changed = true; // Load services int caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_1, 0); if (caps & PF1_IM) valid = true; else return; can_have_listening_to = (ProtoServiceExists(name, PS_SET_LISTENINGTO) != 0); PF3 = CallProtoService(name, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0); caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_4, 0); can_have_avatar = (caps & PF4_AVATARS) != 0; can_set_nick = ProtoServiceExists(name, PS_SETMYNICKNAME) != FALSE; // Initial value GetStatus(); GetStatusMsg(); GetNick(); GetAvatar(); }
/************************************************************************* * DragQueryFile [SHELL.11] */ UINT16 WINAPI DragQueryFile16( HDROP16 hDrop, WORD wFile, LPSTR lpszFile, WORD wLength) { LPSTR lpDrop; UINT i = 0; LPDROPFILESTRUCT16 lpDropFileStruct = (LPDROPFILESTRUCT16) GlobalLock16(hDrop); TRACE("(%04x, %x, %p, %u)\n", hDrop,wFile,lpszFile,wLength); if(!lpDropFileStruct) goto end; lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->wSize; while (i++ < wFile) { while (*lpDrop++); /* skip filename */ if (!*lpDrop) { i = (wFile == 0xFFFF) ? i : 0; goto end; } } i = strlen(lpDrop); if (!lpszFile ) goto end; /* needed buffer size */ lstrcpynA (lpszFile, lpDrop, wLength); end: GlobalUnlock16(hDrop); return i; }
unsigned dbgsymengine::fileline (char * buf, unsigned len, unsigned * pline, unsigned * pdisplacement) { if (!len || !buf || IsBadWritePtr(buf, len) || (pline && IsBadWritePtr(pline, sizeof(unsigned))) || (pdisplacement && IsBadWritePtr(pdisplacement, sizeof(unsigned)))) return 0; if (!check()) return 0; IMAGEHLP_LINE img_line; memset(&img_line, 0, sizeof(IMAGEHLP_LINE)); img_line.SizeOfStruct = sizeof(IMAGEHLP_LINE); HANDLE hProc = SymGetProcessHandle(); unsigned displacement = 0; if (!get_line_from_addr(hProc, m_address, &displacement, &img_line)) return 0; if (pdisplacement) *pdisplacement = displacement; if (pline) *pline = img_line.LineNumber; lstrcpynA(buf, img_line.FileName, len); return lstrlenA(buf); }
BOOL SM_ChangeNick(char *pszID, char * pszModule, GCEVENT * gce) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; if(!pszModule) return FALSE; while (pTemp != NULL) { if ((!pszID || !lstrcmpiA(pTemp->pszID,pszID)) && !lstrcmpiA(pTemp->pszModule,pszModule)) { USERINFO * ui = UM_FindUser(pTemp->pUsers, (char *)gce->pszUID); if(ui) { ui->pszNick = (char *)realloc(ui->pszNick, lstrlenA(gce->pszText) + 1); lstrcpynA(ui->pszNick, gce->pszText, lstrlenA(gce->pszText) + 1); SM_MoveUser(pTemp->pszID, pTemp->pszModule, ui->pszUID); if(pTemp->hWnd) SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, (WPARAM)0, (LPARAM)0); } if(pszID) return TRUE; } pLast = pTemp; pTemp = pTemp->next; } return TRUE; }
BOOL SM_ChangeUID(char *pszID, char * pszModule, char * pszUID, char * pszNewUID) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; if(!pszModule) return FALSE; while (pTemp != NULL) { if ((!pszID || !lstrcmpiA(pTemp->pszID,pszID)) && !lstrcmpiA(pTemp->pszModule,pszModule)) { USERINFO * ui = UM_FindUser(pTemp->pUsers, pszUID); if(ui) { ui->pszUID = (char *)realloc(ui->pszUID, lstrlenA(pszNewUID) + 1); lstrcpynA(ui->pszUID, pszNewUID, lstrlenA(pszNewUID) + 1); } if(pszID) return TRUE; } pLast = pTemp; pTemp = pTemp->next; } return TRUE; }
char *TemplateHTMLBuilder::timestampToString(DWORD dwFlags, time_t check, int mode) { static char szResult[512]; TCHAR str[300]; DBTIMETOSTRINGT dbtts; dbtts.cbDest = 70; dbtts.szDest = str; szResult[0] = '\0'; if (mode) { //time dbtts.szFormat = (dwFlags & Options::LOG_SHOW_SECONDS) ? _T("s") : _T("t"); CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, check, (LPARAM)&dbtts); } else {//date struct tm tm_now, tm_today; time_t now = time(NULL); time_t today; tm_now = *localtime(&now); tm_today = tm_now; tm_today.tm_hour = tm_today.tm_min = tm_today.tm_sec = 0; today = mktime(&tm_today); if (dwFlags & Options::LOG_RELATIVE_DATE && check >= today) _tcsncpy(str, TranslateT("Today"), SIZEOF(str)); else if(dwFlags & Options::LOG_RELATIVE_DATE && check > (today - 86400)) _tcsncpy(str, TranslateT("Yesterday"), SIZEOF(str)); else { dbtts.szFormat = (dwFlags & Options::LOG_LONG_DATE) ? _T("D") : _T("d"); CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, check, (LPARAM) & dbtts); } } lstrcpynA(szResult, ptrA(mir_utf8encodeT(str)), 500); return szResult; }
BOOL memory_get_string(struct dbg_process* pcs, void* addr, BOOL in_debuggee, BOOL unicode, char* buffer, int size) { SIZE_T sz; WCHAR* buffW; buffer[0] = 0; if (!addr) return FALSE; if (in_debuggee) { BOOL ret; if (!unicode) ret = pcs->process_io->read(pcs->handle, addr, buffer, size, &sz); else { buffW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); ret = pcs->process_io->read(pcs->handle, addr, buffW, size * sizeof(WCHAR), &sz); WideCharToMultiByte(CP_ACP, 0, buffW, sz / sizeof(WCHAR), buffer, size, NULL, NULL); HeapFree(GetProcessHeap(), 0, buffW); } if (size) buffer[size-1] = 0; return ret; } else { lstrcpynA(buffer, addr, size); } return TRUE; }
/*********************************************************************** * TaskNext (TOOLHELP.64) */ BOOL16 WINAPI TaskNext16( TASKENTRY *lpte ) { TDB *pTask; INSTANCEDATA *pInstData; TRACE_(toolhelp)("(%p): task=%04x\n", lpte, lpte->hNext ); if (!lpte->hNext) return FALSE; /* make sure that task and hInstance are valid (skip initial Wine task !) */ while (1) { pTask = TASK_GetPtr( lpte->hNext ); if (!pTask || pTask->magic != TDB_MAGIC) return FALSE; if (pTask->hInstance) break; lpte->hNext = pTask->hNext; } pInstData = MapSL( MAKESEGPTR( GlobalHandleToSel16(pTask->hInstance), 0 ) ); lpte->hTask = lpte->hNext; lpte->hTaskParent = pTask->hParent; lpte->hInst = pTask->hInstance; lpte->hModule = pTask->hModule; lpte->wSS = SELECTOROF( pTask->teb->WOW32Reserved ); lpte->wSP = OFFSETOF( pTask->teb->WOW32Reserved ); lpte->wStackTop = pInstData->stacktop; lpte->wStackMinimum = pInstData->stackmin; lpte->wStackBottom = pInstData->stackbottom; lpte->wcEvents = pTask->nEvents; lpte->hQueue = pTask->hQueue; lstrcpynA( lpte->szModule, pTask->module_name, sizeof(lpte->szModule) ); lpte->wPSPOffset = 0x100; /*??*/ lpte->hNext = pTask->hNext; return TRUE; }
void CActionsSampleView::OnInitialUpdate() { CRichEditView::OnInitialUpdate(); USES_CONVERSION; // Set the printing margins (720 twips = 1/2 inch). SetMargins(CRect(720, 720, 720, 720)); CHARFORMAT cf; ZeroMemory(&cf, sizeof(CHARFORMAT)); CString strDefFont = _T("Tahoma"); cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_BOLD |CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_SIZE | CFM_COLOR | CFM_OFFSET | CFM_PROTECTED | CFM_FACE; cf.dwEffects = CFE_AUTOCOLOR; cf.yHeight = 200; //10pt cf.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; #if (_RICHEDIT_VER >= 0x0200) lstrcpyn(cf.szFaceName, strDefFont, LF_FACESIZE); #else lstrcpynA(cf.szFaceName, T2A((LPTSTR) (LPCTSTR) strDefFont), LF_FACESIZE); #endif GetRichEditCtrl().SetDefaultCharFormat(cf); }
HRESULT __stdcall moeShell::GetCommandString( UINT_PTR idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax ) { if ( uFlags & GCS_HELPTEXT ) { if (uFlags & GCS_UNICODE) { if ( idCmd < cmd_indexes_.size() ) { UINT cmd = cmd_indexes_[idCmd]; std::wstring s = mol::towstring(menu_cmds_[cmd]->description); lstrcpynW((LPWSTR)pszName, s.c_str(), cchMax); } } else { if ( idCmd < cmd_indexes_.size() ) { UINT cmd = cmd_indexes_[idCmd]; std::string s = mol::tostring(menu_cmds_[cmd]->description); lstrcpynA((LPSTR)pszName, s.c_str(), cchMax); } } } return S_OK; }
STDMETHODIMP ExifShellExtension::GetCommandString( UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax) { // If Explorer is asking for a help string, copy our string into the // supplied buffer. if (uFlags & GCS_HELPTEXT) { CString cszText; if (idCmd == m_uidMenuCopyExif) cszText = _T("Copies Exif data to clipboard"); else if (idCmd == m_uidMenuPasteExif) cszText = _T("Pastes Exif data from clipboard"); else return E_INVALIDARG; USES_CONVERSION; if (uFlags & GCS_UNICODE) { // We need to cast pszName to a Unicode string, and then use the // Unicode string copy API. lstrcpynW(reinterpret_cast<LPWSTR>(pszName), T2CW(cszText), cchMax); } else { // Use the ANSI string copy API to return the help string. lstrcpynA(pszName, T2CA(cszText), cchMax); } return S_OK; } return E_INVALIDARG; }
BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot) { HKEY hkey; char szTemp[MAX_EXTENSION_LENGTH + 2]; TRACE("%s %p\n", szExtension, szFileType); /* added because we do not want to have double dots */ if (szExtension[0] == '.') bPrependDot = 0; if (bPrependDot) szTemp[0] = '.'; lstrcpynA(szTemp + (bPrependDot?1:0), szExtension, MAX_EXTENSION_LENGTH); if (RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hkey)) { return FALSE; } if (RegQueryValueA(hkey, NULL, szFileType, &len)) { RegCloseKey(hkey); return FALSE; } RegCloseKey(hkey); TRACE("--UE;\n} %s\n", szFileType); return TRUE; }
/****************************************************************** * add_module * * Add a module to a dump context */ static BOOL add_module(struct dump_context* dc, const char* name, DWORD base, DWORD size, DWORD timestamp, DWORD checksum, BOOL is_elf) { if (!dc->module) dc->module = HeapAlloc(GetProcessHeap(), 0, ++dc->num_module * sizeof(*dc->module)); else dc->module = HeapReAlloc(GetProcessHeap(), 0, dc->module, ++dc->num_module * sizeof(*dc->module)); if (!dc->module) return FALSE; if (is_elf || !GetModuleFileNameExA(dc->hProcess, (HMODULE)base, dc->module[dc->num_module - 1].name, sizeof(dc->module[dc->num_module - 1].name))) lstrcpynA(dc->module[dc->num_module - 1].name, name, sizeof(dc->module[dc->num_module - 1].name)); dc->module[dc->num_module - 1].base = base; dc->module[dc->num_module - 1].size = size; dc->module[dc->num_module - 1].timestamp = timestamp; dc->module[dc->num_module - 1].checksum = checksum; dc->module[dc->num_module - 1].is_elf = is_elf; return TRUE; }
BOOL CreateD3D9DeviceData(IN LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapter, IN LPD3D9_DEVICEDATA pDeviceData) { HDC hDC; /* Test DC creation for the display device */ if (NULL == (hDC = CreateDCA(NULL, pDisplayAdapter->szDeviceName, NULL, NULL))) { DPRINT1("Could not create dc for display adapter: %s", pDisplayAdapter->szDeviceName); return FALSE; } pDeviceData->hDC = hDC; pDeviceData->DisplayGuid = pDisplayAdapter->DisplayGuid; pDeviceData->DeviceType = D3DDEVTYPE_HAL; lstrcpynA(pDeviceData->szDeviceName, pDisplayAdapter->szDeviceName, CCHDEVICENAME); pDeviceData->szDeviceName[CCHDEVICENAME-1] = '\0'; if (pDisplayAdapter->bInUseFlag) { pDeviceData->D3D9Callbacks.DeviceType = D3DDEVTYPE_HAL; } else if (IsGDIDriver(hDC)) { pDeviceData->D3D9Callbacks.DeviceType = D3DDEVTYPE_REF; } if (FALSE == GetDeviceData(pDeviceData)) { DPRINT1("Could not get device data for display adapter: %s", pDisplayAdapter->szDeviceName); return FALSE; } return TRUE; }
STDMETHODIMP CSimpleShlExt::GetCommandString ( UINT_PTR idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax ) { USES_CONVERSION; // Check idCmd, it must be 0 since we have only one menu item. if ( 0 != idCmd ) return E_INVALIDARG; // If Explorer is asking for a help string, copy our string into the // supplied buffer. if ( uFlags & GCS_HELPTEXT ) { LPCTSTR szText = _T("Git shell extensions"); if ( uFlags & GCS_UNICODE ) { // We need to cast pszName to a Unicode string, and then use the // Unicode string copy API. lstrcpynW ( (LPWSTR) pszName, T2CW(szText), cchMax ); } else { // Use the ANSI string copy API to return the help string. lstrcpynA ( pszName, T2CA(szText), cchMax ); } return S_OK; } return E_INVALIDARG; }
static HICON ExtractIconFromPath(const char *path) { char *comma; char file[MAX_PATH],fileFull[MAX_PATH]; int n; HICON hIcon; { // char buf[512]; // sprintf(buf,"LoadIcon %s\r\n",path); // OutputDebugStringA(buf); } lstrcpynA(file,path,SIZEOF(file)); comma=strrchr(file,','); if(comma==NULL) n=0; else {n=atoi(comma+1); *comma=0;} CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)file, (LPARAM)fileFull); #ifdef _DEBUG { // char buf[512]; // sprintf(buf,"LoadIconFull %d %s\r\n",n,fileFull); // OutputDebugStringA(buf); } #endif hIcon=NULL; ExtractIconExA(fileFull,n,NULL,&hIcon,1); return hIcon; }
static DWORD getInterfaceMtuByName(const char *name, PDWORD mtu) { DWORD ret; int fd; if (!name) return ERROR_INVALID_PARAMETER; if (!mtu) return ERROR_INVALID_PARAMETER; fd = socket(PF_INET, SOCK_DGRAM, 0); if (fd != -1) { struct ifreq ifr; lstrcpynA(ifr.ifr_name, name, IFNAMSIZ); if ((ioctl(fd, SIOCGIFMTU, &ifr))) ret = ERROR_INVALID_DATA; else { #ifndef __sun *mtu = ifr.ifr_mtu; #else *mtu = ifr.ifr_metric; #endif ret = NO_ERROR; } close(fd); } else ret = ERROR_NO_MORE_FILES; return ret; }
void __cdecl CYahooProto::get_status_thread(HANDLE hContact) { int l; DBVARIANT dbv; char *gm = NULL, *sm = NULL, *fm; Sleep( 150 ); /* Check Yahoo Games Message */ if (!getString(hContact, "YGMsg", &dbv)) { gm = strdup(dbv.pszVal); db_free(&dbv); } if (! db_get_s(hContact, "CList", "StatusMsg", &dbv)) { if (lstrlenA(dbv.pszVal) >= 1) sm = strdup(dbv.pszVal); db_free(&dbv); } else { int status = getWord(hContact, "YStatus", (WORD)YAHOO_STATUS_OFFLINE); sm = yahoo_status_code( yahoo_status(status)); if (sm) sm = strdup(sm); /* we need this to go global FREE later */ } l = 0; if (gm) l += lstrlenA(gm) + 3; l += lstrlenA(sm) + 1; fm = (char *) malloc(l); fm[0] ='\0'; if (gm && lstrlenA(gm) > 0) { /* BAH YAHOO SUCKS! WHAT A PAIN! find first carriage return add status message then add the rest */ char *c = strchr(gm, '\r'); if (c != NULL) { lstrcpynA(fm,gm, c - gm + 1); fm[c - gm + 1] = '\0'; } else lstrcpyA(fm, gm); if (sm) { lstrcatA(fm, ": "); lstrcatA(fm, sm); } if (c != NULL) lstrcatA(fm, c); } else if (sm) { lstrcatA(fm, sm); } FREE(sm); ProtoBroadcastAck( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE )1, (LPARAM)( TCHAR* )_A2T(fm)); }
int CALLBACK CContextMenuHelper::EnhMetaFileProc( HDC hDC, // handle to DC HANDLETABLE *lpHTable, // metafile handle table CONST ENHMETARECORD *lpEMFR, // metafile record int nObj, // count of objects LPARAM lpData // optional data ) { EMREXTTEXTOUTA& emrTOA = *(EMREXTTEXTOUTA*)lpEMFR; EMREXTTEXTOUTW& emrTOW = *(EMREXTTEXTOUTW*)lpEMFR; CContextMenuHelper* pThis = (CContextMenuHelper*)lpData; switch (lpEMFR->iType) { case EMR_EXTTEXTOUTA: if (emrTOA.emrtext.nChars > 0) { pThis->m_iLeftOfText = emrTOA.rclBounds.left; lstrcpynA(pThis->m_pBuffer, (LPSTR)((LPBYTE)lpEMFR + emrTOA.emrtext.offString), __min(emrTOA.emrtext.nChars, MAX_PATH)); return FALSE; // stop enum } break; case EMR_EXTTEXTOUTW: if (emrTOW.emrtext.nChars > 0) { pThis->m_iLeftOfText = emrTOW.rclBounds.left; WideCharToMultiByte(CP_ACP, 0, (LPWSTR)((LPBYTE)lpEMFR + emrTOW.emrtext.offString), emrTOW.emrtext.nChars, pThis->m_pBuffer, MAX_PATH, NULL, NULL); return FALSE; // stop enum } break; } return TRUE; // go on }
/* * Returns the number of folders in a folder. */ static int get_number_of_folders(LPCSTR path) { int number_of_folders = 0; char path_search_string[MAX_PATH]; WIN32_FIND_DATAA find_data; HANDLE find_handle; lstrcpynA(path_search_string, path, MAX_PATH); strncat(path_search_string, "*", 1); find_handle = FindFirstFileA(path_search_string, &find_data); if (find_handle == INVALID_HANDLE_VALUE) return -1; do { if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && strcmp(find_data.cFileName, ".") != 0 && strcmp(find_data.cFileName, "..") != 0) { number_of_folders++; } } while (FindNextFileA(find_handle, &find_data) != 0); FindClose(find_handle); return number_of_folders; }
void CPluginAnsi::GetPluginInfoPtr(void *piv) { PluginInfo *pi = (PluginInfo*)piv; _ASSERTE(pi->StructSize==0); pi->StructSize = sizeof(struct PluginInfo); //_ASSERTE(pi->StructSize>0 && (pi->StructSize >= sizeof(*pi))); static char *szMenu[1], szMenu1[255]; szMenu[0]=szMenu1; // Устарело. активация через [Read/Peek]ConsoleInput //// Проверить, не изменилась ли горячая клавиша плагина, и если да - пересоздать макросы //IsKeyChanged(TRUE); //if (gcPlugKey) szMenu1[0]=0; else lstrcpyA(szMenu1, "[&\xDC] "); // а тут действительно OEM lstrcpynA(szMenu1/*+lstrlenA(szMenu1)*/, InfoA->GetMsg(InfoA->ModuleNumber,CEPluginName), 240); _ASSERTE(pi->StructSize == sizeof(struct PluginInfo)); pi->Flags = PF_EDITOR | PF_VIEWER | PF_DIALOG | PF_PRELOAD; pi->DiskMenuStrings = NULL; pi->DiskMenuNumbers = 0; pi->PluginMenuStrings = szMenu; pi->PluginMenuStringsNumber = 1; pi->PluginConfigStrings = NULL; pi->PluginConfigStringsNumber = 0; pi->CommandPrefix = "ConEmu"; pi->Reserved = 0; }
static void module_fill_module(const char* in, char* out, size_t size) { const char *ptr,*endptr; size_t len, l; endptr = in + strlen(in); for (ptr = endptr - 1; ptr >= in && *ptr != '/' && *ptr != '\\'; ptr--); ptr++; len = min(endptr-ptr,size-1); memcpy(out, ptr, len); out[len] = '\0'; if (len > 4 && (l = match_ext(out, len))) out[len - l] = '\0'; else if (len > 12 && (!strcasecmp(out + len - 12, "wine-pthread") || !strcasecmp(out + len - 12, "wine-kthread"))) lstrcpynA(out, "<wine-loader>", size); else { if (len > 3 && !strcasecmp(&out[len - 3], ".so") && (l = match_ext(out, len - 3))) strcpy(&out[len - l - 3], "<elf>"); } while ((*out = tolower(*out))) out++; }