示例#1
0
// Если nCtrlId==0 - hParent==hList
int CSetDlgLists::SelectStringExact(HWND hParent, WORD nCtrlId, LPCWSTR asText)
{
	if (!hParent)  // был ghOpWnd. теперь может быть вызван и для других диалогов!
		return -1;

	HWND hList = nCtrlId ? GetDlgItem(hParent, nCtrlId) : hParent;
	_ASSERTE(hList!=NULL);

	int nIdx = SendMessage(hList, CB_FINDSTRINGEXACT, -1, (LPARAM)asText);

	if (nIdx < 0)
	{
		int nCount = SendMessage(hList, CB_GETCOUNT, 0, 0);
		wchar_t* pszNumEnd = NULL;
		int nNewVal = wcstol(asText, &pszNumEnd, 10), nCurVal;
		bool bUseNumCmp = (pszNumEnd && *pszNumEnd) && ((nNewVal != 0) || (lstrcmp(pszNumEnd, L"0") == 0));

		// For `Font Sizes` generally
		if (bUseNumCmp)
		{
			wchar_t temp[MAX_PATH] = {};

			for (int i = 0; i < nCount; i++)
			{
				if (!SendMessage(hList, CB_GETLBTEXT, i, (LPARAM)temp))
					break;

				nCurVal = _wtol(temp);

				if (nCurVal == nNewVal)
				{
					nIdx = i;
					break;
				}
				else if (nCurVal > nNewVal)
				{
					nIdx = SendMessage(hList, CB_INSERTSTRING, i, (LPARAM)asText);
					break;
				}
			}
		}

		if (nIdx < 0)
		{
			nIdx = SendMessage(hList, CB_INSERTSTRING, 0, (LPARAM)asText);
		}
	}

	if (nIdx >= 0)
		SendMessage(hList, CB_SETCURSEL, nIdx, 0);
	else
		SetWindowText(hList, asText);

	return nIdx;
}
示例#2
0
BOOL COFSNcDlg2::LoadRectangle(IXMLDOMNode *pXmlRoot, LPCTSTR szRectangleName, CRect &r)
{
	ASSERT(pXmlRoot != NULL);
	ASSERT(szRectangleName != NULL);
	
	BOOL bResult = FALSE;
	CComPtr<IXMLDOMNode> pRectangle = NULL;
	CComBSTR bs;
	WCHAR *szNULL = L"\0x00";
	long x=0, y=0, cx=0, cy=0;
	
	bs.Empty();
	bs = L"Rectangle[@Name=\"";
	bs += szRectangleName;
	bs += L"\"]";
	
	pXmlRoot->selectSingleNode(bs, &pRectangle);
	if(pRectangle)
	{
		bs.Empty();
		SelectChildNode(pRectangle, CComBSTR(L"XPos"), NULL, &bs);
		if(bs.m_str != NULL)
			x = wcstol(bs.m_str, &szNULL, 10);
		bs.Empty();
		SelectChildNode(pRectangle, CComBSTR(L"YPos"), NULL, &bs);
		if(bs.m_str != NULL)
			y = wcstol(bs.m_str, &szNULL, 10);
		bs.Empty();
		SelectChildNode(pRectangle, CComBSTR(L"XLen"), NULL, &bs);
		if(bs.m_str != NULL)
			cx = wcstol(bs.m_str, &szNULL, 10);
		bs.Empty();
		SelectChildNode(pRectangle, CComBSTR(L"YLen"), NULL, &bs);
		if(bs.m_str != NULL)
			cy = wcstol(bs.m_str, &szNULL, 10);
		
		//pRectangle->Release();
		r = CRect(CPoint(x, y), CSize(cx, cy));
		bResult = TRUE;
	}
	return bResult;
}
示例#3
0
int fish_wcstoi(const wchar_t *str, wchar_t **endptr, int base) {
    long ret = wcstol(str, endptr, base);
    if (ret > INT_MAX) {
        ret = INT_MAX;
        errno = ERANGE;
    } else if (ret < INT_MIN) {
        ret = INT_MIN;
        errno = ERANGE;
    }
    return (int)ret;
}
 HRESULT SetTimeout(PCWSTR pszTimeout)
 {
     // Convert the specified timeout to an integer.
     PWSTR pszEnd;
     _dwTimeout = wcstol(pszTimeout, &pszEnd, 0);
     HRESULT hr = (*pszEnd ? E_INVALIDARG : S_OK);
     if (FAILED(hr))
     {
         ParseError(L"Invalid timeout: %s\n", pszTimeout);
     }
     return hr;
 }
示例#5
0
文件: utility.cpp 项目: bestustc/vld
// strtobool - Converts string values (e.g. "yes", "no", "on", "off") to boolean
//   values.
//
//  - s (IN): String value to convert.
//
//  Return Value:
//
//    Returns TRUE if the string is recognized as a "true" string. Otherwise
//    returns FALSE.
//
BOOL strtobool (LPCWSTR s) {
    WCHAR *end;

    if ((_wcsicmp(s, L"true") == 0) ||
        (_wcsicmp(s, L"yes") == 0) ||
        (_wcsicmp(s, L"on") == 0) ||
        (wcstol(s, &end, 10) == 1)) {
        return TRUE;
    }
    else {
        return FALSE;
    }
}
示例#6
0
bool ParseRectString(LPCWSTR lpszRect, CUIRect& rc)
{
    LPWSTR pstr = NULL;
    
    //
    // left
    //
    
    rc.left   = wcstol(lpszRect, &pstr, 10);
    if (pstr == NULL && *pstr != L','){
        return false;
    }
    
    //
    // top
    //
    
    rc.top    = wcstol(pstr + 1, &pstr, 10);
    if (pstr == NULL && *pstr != L','){
        return false;
    }
    
    //
    // right
    //
    
    rc.right  = wcstol(pstr + 1, &pstr, 10);
    if (pstr == NULL && *pstr != L','){
        return false;
    }

    rc.bottom = wcstol(pstr + 1, &pstr, 10);
    if (pstr == NULL){
        return false;
    }

    return true;
}
static bool XML_GetTupel(cgMSXML::IXMLElement* pElem, const wchar_t* pszAttrName, long* pa, long* pb)
{
    VARIANT     val;
    wchar_t*    pszEnd; 
    bool        bOk = true;
    long         a;
    long         b;

    VariantInit(&val);

    if(FAILED(pElem->getAttribute((wchar_t*)/*cast ok?*/pszAttrName, &val)) || val.vt!=VT_BSTR)
        return false;

    a = wcstol(val.bstrVal, &pszEnd, 10);
    if(pa)
        *pa = a;

    while(iswspace(*pszEnd))
        pszEnd++;

    if(*pszEnd == L';')
        pszEnd++;
    else
        bOk = false;

    b = wcstol(pszEnd, &pszEnd, 10);
    if(pb)
        *pb = b;

    while(iswspace(*pszEnd))
        pszEnd++;

    if(*pszEnd)
        bOk = false;

    VariantClear(&val);
    return bOk;
}
示例#8
0
static int
unify_uri_authority_components(term_t components,
			       size_t len, const pl_wchar_t *s)
{ const pl_wchar_t *end = &s[len];
  const pl_wchar_t *e;
  range user   = {0};
  range passwd = {0};
  range host   = {0};
  range port   = {0};
  term_t t = PL_new_term_refs(5);
  term_t av = t+1;

  if ( (e=skip_not(s, end, L"@")) && e<end )
  { user.start = s;
    user.end = e;
    s = e+1;
    if ( (e=skip_not(user.start, user.end, L":")) && e<user.end )
    { passwd.start = e+1;
      passwd.end   = user.end;
      user.end     = e;
    }
  }
  host.start = s;
  host.end = skip_not(s, end, L":");
  if ( host.end < end )
  { port.start = host.end+1;
    port.end = end;
  }

  if ( user.start )
    unify_decoded_atom(av+0, &user, ESC_USER);
  if ( passwd.start )
    unify_decoded_atom(av+1, &passwd, ESC_PASSWD);
  unify_decoded_atom(av+2, &host, ESC_HOST);
  if ( port.start )
  { wchar_t *ep;
    long pn = wcstol(port.start, &ep, 10);

    if ( ep == port.end )
    { if ( !PL_put_integer(av+3, pn) )
	return FALSE;
    } else
    { unify_decoded_atom(av+3, &port, ESC_PORT);
    }
  }

  return (PL_cons_functor_v(t, FUNCTOR_uri_authority4, av) &&
	  PL_unify(components, t));
}
示例#9
0
文件: CS_ansi.c 项目: asir6/Colt
long32_t EXP_LVL9 CS_strtol (Const char *ptr,char **endPtr,int base)
{
#ifdef __WINCE__
	wchar_t *wEndPtr;
	long32_t rtnValue;
	wchar_t wAscii [64];
	mbstowcs (wAscii,ptr,64);
	rtnValue = (long32_t)wcstol (wAscii,&wEndPtr,base);
	*endPtr = (char *)ptr + (wEndPtr - wAscii);
	return rtnValue;
#else
	/* time is ANSI standard, so this part is easy. */
	return (long32_t)strtol (ptr,endPtr,base);
#endif
}
示例#10
0
bool ParseSizeString(LPCWSTR lpszSize, CUISize& Size)
{
    LPWSTR pstr = NULL;
    
    //
    // parse x
    //

    Size.cx = wcstol(lpszSize, &pstr, 10);
    if (pstr == NULL && *pstr != L','){
        return false;
    }

    //
    // parse y
    //

    Size.cy = wcstol(pstr + 1, &pstr, 10);
    if (pstr == NULL){
        return false;
    }

    return true;
}
示例#11
0
TimeDelta SampleModePrefUI::GetSampleInterval() const {
  int time_value = wcstol(sample_interval_edit_->GetText(), NULL, 10);
  TimeScale scale = static_cast<TimeScale>(sample_interval_combo_->GetCurSel());
  switch (scale) {
  case SECOND:
    return TimeDelta::FromSeconds(time_value);
  case MINUTE:
    return TimeDelta::FromMinutes(time_value);
  case HOUR:
    return TimeDelta::FromHours(time_value);
  case DAY:
    return TimeDelta::FromDays(time_value);
  }
  return TimeDelta::Max();
}
示例#12
0
 //----------------------------------------------------------------------------
// Function: GetLimit
//
// Description:
//  Get the resource limit value in long type given the command line argument.
//
// Returns:
// TRUE: If successfully get the value
// FALSE: otherwise
static BOOL GetLimit(__in const wchar_t *str, __out long *value)
{
  wchar_t *end = NULL;
  if (str == NULL || value == NULL) return FALSE;
  *value = wcstol(str, &end, 10);
  if (end == NULL || *end != '\0')
  {
    *value = -1;
    return FALSE;
  }
  else
  {
    return TRUE;
  }
}
示例#13
0
INT cmdHelpMsg(INT argc, WCHAR **argv)
{
    LPWSTR endptr;
    LPWSTR lpBuffer;
    LONG errNum;
    INT i;

    if (argc < 3)
    {
        PrintResourceString(IDS_HELPMSG_SYNTAX);
        return 1;
    }

    for (i = 2; i < argc; i++)
    {
        if (_wcsicmp(argv[i], L"/help") == 0)
        {
            PrintResourceString(IDS_HELPMSG_HELP);
            return 1;
        }
    }

    errNum = wcstol(argv[2], &endptr, 10);
    if (*endptr != 0)
    {
        PrintResourceString(IDS_HELPMSG_SYNTAX);
        return 1;
    }

    /* Unicode printing is not supported in ReactOS yet */
    if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
                       NULL,
                       errNum,
                       LANG_USER_DEFAULT,
                       (LPWSTR)&lpBuffer,
                       0,
                       NULL))
    {
        printf("\n%S\n", lpBuffer);
        LocalFree(lpBuffer);
    }
    else
    {
        printf("Unrecognized error code: %ld\n", errNum);
    }

    return 0;
}
示例#14
0
	// SingleRegWatcher
	INT_PTR CALLBACK SingleRegWatcher::DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
		switch(uMsg){
		case WM_INITDIALOG:
		{
			// Create subclass of edit box function
			SetWindowSubclass(GetDlgItem(hWnd, IDC_REGVALUE), &EditSubclassProc, m_editSubclassID, NULL);
		}
			break;
		case WM_CLOSE:
		{
			RemoveWindowSubclass(GetDlgItem(hWnd, IDC_REGVALUE), &EditSubclassProc, m_editSubclassID);
			break;
		}
		case WM_ENABLE:
			EnableWindow(GetDlgItem(hWnd, IDC_REGVALUE), (BOOL)wParam);
			break;
		case H86_UPDATE_SYS_DATA:
		{
			Mutex sysMutex((void*)wParam);
			sys_state_ptr sysState=(sys_state_ptr)lParam;

			sysMutex.Lock();

			nsEmulator::Emulator* e=nsEmulator::Emulator::GetInstance();
			uint16 val=e->ReadReg(m_regNum);
			wchar_t data[5];
			_itow((uint32)val, data, 16);
			SetDlgItemText(hWnd, IDC_REGVALUE, data);

			sysMutex.Unlock();
		}
			break;
		case H86_USER_INPUT:
		{
			sys_state_ptr sysState=(sys_state_ptr)lParam;

			nsEmulator::Emulator* e=nsEmulator::Emulator::GetInstance();
			wchar_t data[5];
			GetDlgItemText(hWnd, IDC_REGVALUE, data, 5);
			uint16 val=wcstol(data, NULL, 16);
			e->WriteReg(m_regNum, val);
		}
			break;
		default:
			return 0;
		}
		return 0;
	}
示例#15
0
int OpenProcessAndInject(wchar_t *processId) {
	HANDLE hProcess = (HANDLE)wcstol(processId, nullptr, 0);
	if (hProcess == NULL)
	{
		printf("Failed to get process handle\n");
		return -1;
	}

	if (!InjectOpenVR(hProcess) ||
		!InjectLibRevive(hProcess)) {
		return -1;
	}

	printf("Injected dlls succesfully\n");
	return 0;
}
static DWORD GetConfigDWORD(LPCWSTR wzName, DWORD dwDefault)
{
    WRAPPER_CONTRACT;
    WCHAR wzValue[16];
    DWORD dwValue;

    if (PAL_FetchConfigurationString(TRUE, wzName, wzValue, sizeof(wzValue) / sizeof(WCHAR)))
    {
        LPWSTR pEnd;
        dwValue = wcstol(wzValue, &pEnd, 16);   // treat it has hex
        if (pEnd != wzValue)                    // success
            return dwValue;
    }

    return dwDefault;
}
示例#17
0
LONG UsbDeviceList::FindNextInterfaceFilterField(LPCWSTR str, DWORD offset, LPDWORD nextOffset, LPINTERFACE_FILTER_FIELD field)
{
	// Initialise field to match-all (*)
	field->match = TRUE;
	field->value = USB_NO_INFO;

	(*nextOffset) = offset;

	for (DWORD i = offset; i <= wcslen(str); i++) {
		// Field is terminated by ':', ';' or end of string
		if (str[i] == ':' || str[i] == ';' || str[i] == '\0') {
			// Represent ';' as reaching end of string (only flags occur after 
			// this seperator)
			if (str[i] == ';') {
				(*nextOffset) = wcslen(str) + 1;
			} else {
				(*nextOffset) = i + 1;
			}
			LONG result = ERROR_SUCCESS;

			// Empty fields are disallowed
			// Fields may contain '*' or a base 10 value (possibly prepended with '!'
			// to invert match).
			if (i == offset) {
				// Invalid (empty field)
				result = ERROR_INVALID_PARAMETER;
			} else if (!(i == offset + 1 && str[offset] == '*')) {
				// Field contains base 10 value
				wchar_t* endptr = NULL;
				if (str[offset] == '!') {
					field->match = FALSE;
					offset++;
				}
				field->value = wcstol(&str[offset], &endptr, 10);
				if (endptr == &str[offset] || 
					(endptr[0] != ':' && endptr[0] != ';' && endptr[0] != '\0')) {
					result = ERROR_INVALID_PARAMETER;
				}
			}
			return result;
		}
	}

	// Offset beyond end of string (this may occur if we're looking
	// for optional fields that are not present).
	return ERROR_INVALID_PARAMETER;
}
示例#18
0
文件: SOCKET.cpp 项目: tiku/test
bool Inet::StatusCodeAnalysis(wstring sctext,int* res){
	int i,n,pos;
	wchar_t *err;
	if(pos=sctext.find(' ')==wstring::npos){
		return false;
	}
	sctext.erase(0,pos+1);
	if(pos=sctext.find(' ')==wstring::npos){
		return false;
	}
	sctext.erase(pos);
	*res=wcstol(sctext.c_str(),&err,10);
	if(lstrlen(err)!=0){
		return false;
	}
	return true;
}
示例#19
0
int DIB_CreateWindow(_THIS)
{
	char *windowid = SDL_getenv("SDL_WINDOWID");

	SDL_RegisterApp(NULL, 0, 0);

	SDL_windowid = (windowid != NULL);
	if ( SDL_windowid ) {
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
		/* wince 2.1 does not have strtol */
		wchar_t *windowid_t = SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t));
		MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, SDL_strlen(windowid) + 1);
		SDL_Window = (HWND)wcstol(windowid_t, NULL, 0);
		SDL_free(windowid_t);
#else
		SDL_Window = (HWND)SDL_strtoull(windowid, NULL, 0);
#endif
		if ( SDL_Window == NULL ) {
			SDL_SetError("Couldn't get user specified window");
			return(-1);
		}

		/* DJM: we want all event's for the user specified
			window to be handled by SDL.
		 */
		userWindowProc = (WNDPROCTYPE)GetWindowLongPtr(SDL_Window, GWLP_WNDPROC);
		SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)WinMessage);
	} else {
		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
                        (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
                        CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL);
		if ( SDL_Window == NULL ) {
			SDL_SetError("Couldn't create window");
			return(-1);
		}
		ShowWindow(SDL_Window, SW_HIDE);
	}

	/* JC 14 Mar 2006
		Flush the message loop or this can cause big problems later
		Especially if the user decides to use dialog boxes or assert()!
	*/
	WIN_FlushMessageQueue();

	return(0);
}
示例#20
0
bool CFanmotorDlg::GetActiveDevice(BYTE& DeviceAddress)
{
	DeviceAddress = 255;
	CListBox* listBoxDevices = (CListBox*)GetDlgItem(IDC_DEVICE_LISTBOX);
	listBoxDevices->SetCurSel(0);
	if (listBoxDevices->GetCurSel() < 0) {
		DisplayInforMessageBox((LPCWSTR)L"Error", L"Select Active DEVICE!\r\nPress \"Device List\" button and Select Device");
		return false;
	}
	CString s;
	int n = listBoxDevices->GetTextLen(listBoxDevices->GetCurSel());
	WCHAR *ch, *buf = s.GetBuffer(n);
	listBoxDevices->GetText(listBoxDevices->GetCurSel(), buf);
	DeviceAddress = (BYTE)wcstol(buf,&ch,16);
	s.ReleaseBuffer();
	return true;
}
示例#21
0
BOOL TRegistry::GetLongW(const WCHAR *subKey, long *val)
{
	DWORD	type = REG_DWORD, dw_size = sizeof(long);

	if (::RegQueryValueExW(hKey[openCnt -1], subKey, 0, &type, (BYTE *)val, &dw_size)
			== ERROR_SUCCESS) {
		return	TRUE;
	}
// 昔の互換性用
	WCHAR	wbuf[100];
	long	size_byte = sizeof(wbuf);

	if (::RegQueryValueW(hKey[openCnt -1], subKey, wbuf, &size_byte) != ERROR_SUCCESS)
		return	FALSE;
	*val = wcstol(wbuf, 0, 10);
	return	TRUE;
}
示例#22
0
int StringToEnum(const STR16 value, const Str8EnumLookupType *table) 
{
	if (NULL == value || 0 == *value) 
		return 0;

	int result = 0;
	int len = wcslen(value)+1;
	STR8 mval = (STR8)malloc( len*sizeof(CHAR8) );
	wcstombs(mval, value, len);
	for (const Str8EnumLookupType *itr = table; itr->name != NULL; ++itr) {
		if (0 == _stricmp(mval, itr->name)) {
			result = itr->value;
		}
	}
	free(mval);
	return (result) ? result : (int)wcstol(value, NULL, 0);
}
示例#23
0
int CAPETag::CreateID3Tag(ID3_TAG * pID3Tag)
{
    // error check 
    if (pID3Tag == NULL) { return -1; }
    if (m_bAnalyzed == FALSE) { Analyze(); }
    if (m_nFields == 0) { return -1; }

    // empty
    ZeroMemory(pID3Tag, ID3_TAG_BYTES);

    // header
    pID3Tag->Header[0] = 'T'; pID3Tag->Header[1] = 'A'; pID3Tag->Header[2] = 'G';
    
    // standard fields
    GetFieldID3String(APE_TAG_FIELD_ARTIST, pID3Tag->Artist, 30);
    GetFieldID3String(APE_TAG_FIELD_ALBUM, pID3Tag->Album, 30);
    GetFieldID3String(APE_TAG_FIELD_TITLE, pID3Tag->Title, 30);
    GetFieldID3String(APE_TAG_FIELD_COMMENT, pID3Tag->Comment, 28);
    GetFieldID3String(APE_TAG_FIELD_YEAR, pID3Tag->Year, 4);

    // track number
    str_utf16 cBuffer[256] = { 0 }; int nBufferCharacters = 255;
    GetFieldString(APE_TAG_FIELD_TRACK, cBuffer, &nBufferCharacters);
    pID3Tag->Track = (unsigned char) wcstol(cBuffer,NULL,0);
    
    // genre
    cBuffer[0] = 0; nBufferCharacters = 255;
    GetFieldString(APE_TAG_FIELD_GENRE, cBuffer, &nBufferCharacters);
        
    // convert the genre string to an index
    pID3Tag->Genre = 255;
    int nGenreIndex = 0;
    BOOL bFound = FALSE;
    while ((nGenreIndex < GENRE_COUNT) && (bFound == FALSE))
    {
        if (wcscasecmp(cBuffer, g_ID3Genre[nGenreIndex]) == 0)
        {
            pID3Tag->Genre = nGenreIndex;
            bFound = TRUE;
        }
        
        nGenreIndex++;
    }

    return ERROR_SUCCESS;
}
示例#24
0
IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath,
                                   FX_WORD wDefaultLCID) {
  void* pPathHandle = FX_OpenFolder(pszLocalPath);
  if (!pPathHandle) {
    return NULL;
  }
  CFX_LocaleMgr* pLocaleMgr = new CFX_LocaleMgr(wDefaultLCID);
  CFX_WideString wsFileName;
  FX_BOOL bFolder = FALSE;
  while (FX_GetNextFile(pPathHandle, wsFileName, bFolder)) {
    if (!bFolder) {
      if (wsFileName.GetLength() < 4) {
        continue;
      }
      CFX_WideString wsExt = wsFileName.Right(4);
      wsExt.MakeLower();
      if (wsExt != L".xml") {
        continue;
      }
      CFX_WideString wsFullPath(pszLocalPath);
      wsFullPath += L"\\" + wsFileName;
      IFX_FileRead* pRead = FX_CreateFileRead(wsFullPath);
      if (!pRead) {
        continue;
      }
      CXML_Element* pXmlLocale = CXML_Element::Parse(pRead);
      pRead->Release();
      CFX_ByteString bssp = pXmlLocale->GetNamespace();
      if (bssp == "http://www.foxitsoftware.com/localization") {
        CFX_WideString wsLCID = pXmlLocale->GetAttrValue("", "lcid");
        wchar_t* pEnd = NULL;
        FX_DWORD dwLCID = wcstol(wsLCID, &pEnd, 16);
        if (pLocaleMgr->m_lcid2xml.GetValueAt((void*)(uintptr_t)dwLCID)) {
          delete pXmlLocale;
        } else {
          pLocaleMgr->m_lcid2xml.SetAt((void*)(uintptr_t)dwLCID, pXmlLocale);
        }
      } else {
        delete pXmlLocale;
      }
    }
  }
  FX_CloseFolder(pPathHandle);
  return pLocaleMgr;
}
示例#25
0
static PIMAGE_RESOURCE_DIRECTORY_ENTRY _MemorySearchResourceEntry(
    void *root,
    PIMAGE_RESOURCE_DIRECTORY resources,
    LPCTSTR key)
{
    PIMAGE_RESOURCE_DIRECTORY_ENTRY entries = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (resources + 1);
    PIMAGE_RESOURCE_DIRECTORY_ENTRY result = NULL;
    DWORD start;
    DWORD end;
    DWORD middle;

    if (!IS_INTRESOURCE(key) && key[0] == TEXT('#')) {
        // special case: resource id given as string
        TCHAR *endpos = NULL;
#if defined(UNICODE)
        long int tmpkey = (WORD) wcstol((TCHAR *) &key[1], &endpos, 10);
#else
        long int tmpkey = (WORD) strtol((TCHAR *) &key[1], &endpos, 10);
#endif
        if (tmpkey <= 0xffff && lstrlen(endpos) == 0) {
            key = MAKEINTRESOURCE(tmpkey);
        }
    }

    // entries are stored as ordered list of named entries,
    // followed by an ordered list of id entries - we can do
    // a binary search to find faster...
    if (IS_INTRESOURCE(key)) {
        WORD check = (WORD) (POINTER_TYPE) key;
        start = 0; //resources->NumberOfNamedEntries;
        end = resources->NumberOfIdEntries;
        while (end > start) {
            WORD entryName;
            middle = (start + end) >> 1;
            entryName = (WORD) entries[middle].Name;
            if (check < entryName) {
                end = (end != middle ? middle : middle-1);
            } else if (check > entryName) {
                start = (start != middle ? middle : middle+1);
            } else {
                result = &entries[middle];
                break;
            }
        }
    } else {
示例#26
0
文件: string.cpp 项目: themiwi/libcxx
long
stol(const wstring& str, size_t* idx, int base)
{
    wchar_t* ptr;
    const wchar_t* const p = str.c_str();
    long r = wcstol(p, &ptr, base);
    if (ptr == p)
    {
#ifndef _LIBCPP_NO_EXCEPTIONS
        if (r == 0)
            throw invalid_argument("stol: no conversion");
        throw out_of_range("stol: out of range");
#endif  // _LIBCPP_NO_EXCEPTIONS
    }
    if (idx)
        *idx = static_cast<size_t>(ptr - p);
    return r;
}
示例#27
0
//---------------------------------------------------------------------------
//  IFXString::ToValue
//
//  This method converts the string characters into a numerical value. 
//  Similar to atoi or other functions
//---------------------------------------------------------------------------
IFXRESULT IFXString::ToValue(U32* pValue, I8 iRadix)
{
	IFXRESULT result = IFX_OK;

	if (NULL == pValue)
		result = IFX_E_INVALID_POINTER;

	if (NULL == m_Buffer)
		result = IFX_E_NOT_INITIALIZED;

	if (IFXSUCCESS(result))
	{
		IFXCHAR* pEnd = NULL;
		*pValue=(U32)wcstol( m_Buffer, &pEnd, iRadix );
	}

	return result;
}
示例#28
0
HRESULT COFSNcDlg2::GetNodeAttributeAsLong(IXMLDOMNode *pNode, BSTR bsAttrName, long *pAttrValue, int nBase)
{
	HRESULT hr;
	IXMLDOMElement *pEle = NULL;
	WCHAR *szNULL = L"\0x00";
	CComBSTR bs;
	
	ASSERT(pAttrValue != NULL);
	
	if(pNode == NULL)
		return E_INVALIDARG;

	hr = GetNodeAttribute(pNode, bsAttrName, bs);
	if(bs.m_str != NULL)
		*pAttrValue = wcstol(bs.m_str, &szNULL, nBase);
	
	return hr;
}
示例#29
0
Text::Text(int x, int y, int width, int height,
        Gdiplus::Font *font, Gdiplus::StringAlignment align,
        std::wstring color, byte transparency,
        std::wstring formatString) :
Meter(x, y, 100),
_font(font->Clone()),
_formatString(formatString) {
    _rect.Width = width;
    _rect.Height = height;

    _strFormat.SetAlignment(align);

    unsigned long c = wcstol(color.c_str(), '\0', 16);
    unsigned long a = transparency << 24;
    _fontColor = new Gdiplus::SolidBrush(c | a);

    _replaceIndex = _formatString.find(L"[[PERC]]");
}
示例#30
0
文件: OAuthUtil.cpp 项目: ACUVE/EDCB
BOOL UrlDecodeUTF8(LPCWSTR src, DWORD srcSize, wstring& dest)
{
	if( src == NULL ){
		return FALSE;
	}

	string utf8;
	for( DWORD i=0; i<srcSize; i++ ){
		if( src[i] == '%' ){
			if( i+2 > srcSize ){
				break;
			}
			WCHAR tmp[3]=L"";
			tmp[0] = (char)src[i+1];
			tmp[1] = (char)src[i+2];

			WCHAR *endstr;
			char tmp2[2]="";
			tmp2[0] = (char)wcstol(tmp, &endstr, 16);
			utf8 += tmp2;

			i+=2;
		}else if( src[i] == '+' ){
			utf8 += " ";
		}else if( src[i] == '\0' ){
			break;
		}else{
			char tmp[2]="";
			tmp[0] = (char)src[i];
			utf8 += tmp;
		}
	}

	int iLen = MultiByteToWideChar( CP_UTF8, 0, utf8.c_str(), -1, NULL, 0 );
	WCHAR* pwszBuff = new WCHAR[iLen+1];
	ZeroMemory(pwszBuff, sizeof(WCHAR)*(iLen+1));
	MultiByteToWideChar( CP_UTF8, 0, utf8.c_str(), -1, pwszBuff, iLen );

	dest = pwszBuff;
	
	delete[] pwszBuff;

	return TRUE;
}