示例#1
0
static LPITEMIDLIST _ILReadFromSharedMemory(PCWSTR strField)
{
    LPITEMIDLIST ret = NULL;

    // Ensure it really is an IDLIST-formatted parameter
    // Format for IDLIST params: ":pid:shared"
    if (*strField != L':')
        return NULL;

    HANDLE hData = (HANDLE) StrToIntW(strField + 1);
    PWSTR strSecond = StrChrW(strField + 1, L':');

    if (strSecond)
    {
        int pid = StrToIntW(strSecond + 1);
        void* pvShared = SHLockShared(hData, pid);
        if (pvShared)
        {
            ret = ILClone((LPCITEMIDLIST) pvShared);
            SHUnlockShared(pvShared);
            SHFreeShared(hData, pid);
        }
    }
    return ret;
}
示例#2
0
HRESULT VersionFromString(LPCWSTR wzVersionIn, WORD *pwVerMajor, WORD *pwVerMinor,
                          WORD *pwVerBld, WORD *pwVerRev)
{
    HRESULT                                  hr = S_OK;
    LPWSTR                                   wzVersion = NULL;
    WCHAR                                   *pchStart = NULL;
    WCHAR                                   *pch = NULL;
    WORD                                    *pawVersions[4] = {pwVerMajor, pwVerMinor, pwVerBld, pwVerRev};
    int                                      i;

    if (!wzVersionIn || !pwVerMajor || !pwVerMinor || !pwVerRev || !pwVerBld) {
        hr = E_INVALIDARG;
        goto Exit;
    }                          

    wzVersion = WSTRDupDynamic(wzVersionIn);
    if (!wzVersion) {
        hr = E_OUTOFMEMORY;
        goto Exit;
    }

    pchStart = wzVersion;
    pch = wzVersion;

    *pwVerMajor = 0;
    *pwVerMinor = 0;
    *pwVerRev = 0;
    *pwVerBld = 0;

    for (i = 0; i < 4; i++) {

        while (*pch && *pch != L'.') {
            pch++;
        }
    
        if (i < 3) {
            if (!*pch) {
                // Badly formatted string
                hr = E_UNEXPECTED;
                goto Exit;
            }

            *pch++ = L'\0';
        }
    
        *(pawVersions[i]) = (WORD)StrToIntW(pchStart);
        pchStart = pch;
    }

Exit:
    SAFEDELETEARRAY(wzVersion);

    return hr;
}
示例#3
0
文件: string.c 项目: Sunmonds/wine
static void test_StrToIntW(void)
{
  WCHAR szBuff[256];
  const StrToIntResult *result = StrToInt_results;
  int return_val;

  while (result->string)
  {
    MultiByteToWideChar(0,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
    return_val = StrToIntW(szBuff);
    ok(return_val == result->str_to_int, "converted '%s' wrong (%d)\n",
       result->string, return_val);
    result++;
  }
}
示例#4
0
void set_hotkey(LPWNDINFO pInfo)
{
	WCHAR	lpstr[VALUE_LEN+1];
	const	WCHAR delim[] = L"+";
	WCHAR   tmp_stor[3][16] = { {0,0} };
	pInfo->key_mod = 0x06;          /* CONTROL+SHIFT 键 */
	pInfo->key_vk = 0xc0;           /* ~键  */
	if ( read_appkey(L"attach",L"Hotkey",lpstr,sizeof(lpstr)) )
	{
		int		i = 0;
		LPWSTR	p = lpstr;
		int		tmp[3] = {0};
		int		num;
		LPWSTR strtmp = StrStrW(lpstr, delim);
		while( strtmp != NULL && i < 3 )
		{
			strtmp[0]=L'\0';
			wcsncpy(tmp_stor[i++],p,15);
			p = strtmp + wcslen(delim);
			strtmp = StrStrW( p, delim);
			if (!strtmp)
			{
				wcsncpy(tmp_stor[i],p,15);
			}
		}
		for ( num = 0 ; num <= i ; num++ )
		{
			tmp[num] = StrToIntW(tmp_stor[num]);
		}
		if ( is_modkey(tmp[0]) )
		{
			if ( (i==2) && is_modkey(tmp[1]) && !is_modkey(tmp[2]) )
			{
				pInfo->key_mod = tmp[0]|tmp[1];
				pInfo->key_vk = tmp[2];
			}
			else if ( i==1 && tmp[1]>0x2f )
			{
				pInfo->key_mod = tmp[0];
				pInfo->key_vk = tmp[1];
			}
		}
	}
}
示例#5
0
UINT	WStrToIP4(LPCWSTR strIP)
{
	if (!strIP)
		return 0;
	BYTE pIP[4] = { 0 };
	std::wstring strTempIP(strIP);
	SIZE_T nb = 0;
	SIZE_T ne = 0;
	for (size_t i = 0; i < 4; i++)
	{
		ne = strTempIP.find('.', nb);
		if (ne != strTempIP.npos)
		{
			pIP[i] = StrToIntW(strTempIP.substr(nb, ne).c_str());
			nb = ne + 1;
		}
		else
			break;
	}
	pIP[3] = StrToInt(strTempIP.substr(nb, strTempIP.length()).c_str());
	return *(UINT*)pIP;
}
示例#6
0
文件: cookie.cpp 项目: seledka/syslib
    static void Cookie_Parse(HTTP_SESSION_HANDLE *lpSession,WCHAR *lpCookieDomain,WCHAR *lpCookiePath,WCHAR *lpCookieName,WCHAR *lpData)
    {
        WCHAR *lpPtr=lpData,
              *lpPorts=NULL;

        DWORD dwCookieFlags=0,
              dwFlags=0,
              dwPortsCount=0;

        FILETIME ftExpiry={0};
        while (true)
        {
            if (!(lpPtr=StrChrW(lpPtr,L';')))
                break;

            *lpPtr++=0;

            while ((*lpPtr) && (*lpPtr == L' '))
                lpPtr++;

            if (IsKnownParam(dcrW_c7ed8bb1("domain"),6))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                lpCookieDomain=lpPtr;
            }
            else if (IsKnownParam(dcrW_1ab74e01("path"),4))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                lpCookiePath=lpPtr;
            }
            else if (IsKnownParam(dcrW_a3df71ef("expires"),7))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                if ((!(dwCookieFlags & COOKIE_FLAG_EXPIRES_SET)) && (!(dwFlags & COOKIE_HANDLER_MAXAGE_SET)))
                {
                    SYSTEMTIME st;
                    if (InternetTimeToSystemTimeW(lpPtr,&st,0))
                    {
                        dwCookieFlags|=COOKIE_FLAG_EXPIRES_SET;
                        SystemTimeToFileTime(&st,&ftExpiry);
                        FILETIME tm;
                        GetSystemTimeAsFileTime(&tm);

                        if (CompareFileTime(&tm,&ftExpiry) > 0)
                            dwFlags|=COOKIE_HANDLER_EXPIRED;
                    }
                }
            }
            else if (IsKnownParam(dcrW_77b02e79("secure"),6))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                dwCookieFlags|=COOKIE_FLAG_SECURE;
            }
            else if (IsKnownParam(dcrW_60249e06("discard"),7))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                dwCookieFlags|=COOKIE_FLAG_DISCARD;
            }
            else if (IsKnownParam(dcrW_53e691c9("max-age"),7))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                GetSystemTimeAsFileTime(&ftExpiry);

                /**
                    MSDN:
                    It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times.
                    Instead, you should copy the low- and high-order parts of the file time to a LARGE_INTEGER structure, perform
                    64-bit arithmetic on the QuadPart member, and copy the LowPart and HighPart members into the FILETIME structure.

                    Do not cast a pointer to a FILETIME structure to either a LARGE_INTEGER* or __int64* value because it can cause
                    alignment faults on 64-bit Windows.
                **/

                LARGE_INTEGER liTime={ftExpiry.dwLowDateTime,ftExpiry.dwHighDateTime};
                liTime.QuadPart+=StrToIntW(lpPtr)*_100NS_IN_SEC;
                ftExpiry.dwLowDateTime=liTime.LowPart;
                ftExpiry.dwHighDateTime=liTime.HighPart;

                dwFlags|=COOKIE_HANDLER_MAXAGE_SET;
                dwCookieFlags|=COOKIE_FLAG_EXPIRES_SET;
            }
            else if (IsKnownParam(dcrW_f98fd7e9("port"),4))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                do
                {
                    if (dwCookieFlags & COOKIE_FLAG_PORT_SET)
                        break;

                    if (*lpPtr != L'"')
                        break;

                    WCHAR *lpPortsStart=lpPtr+1,
                          *lpPortsEnd=StrChrW(lpPortsStart,L'"');

                    if (!lpPortsEnd)
                        break;

                    dwPortsCount=1;
                    WCHAR *lpCurPort=lpPortsStart;
                    while (true)
                    {
                        lpCurPort=StrChrW(lpCurPort,L',');
                        if (!lpCurPort)
                            break;

                        if (lpCurPort > lpPortsEnd)
                            break;

                        dwPortsCount++;
                        lpCurPort++;
                    }

                    lpPorts=lpPortsStart;
                    dwCookieFlags|=COOKIE_FLAG_PORT_SET;
                }
                while (false);
            }
        }

        do
        {
            COOKIE_DOMAIN *lpDomain=Cookie_FindDomain(lpSession,lpCookieDomain,lpCookiePath,false,NULL);
            if ((!lpDomain) && (!(dwFlags & COOKIE_HANDLER_EXPIRED)))
                lpDomain=Cookie_AddDomain(lpSession,lpCookieDomain,lpCookiePath);

            if (!lpDomain)
                break;

            COOKIE *lpCookie=Cookie_Find(lpDomain,lpCookieName);
            if (lpCookie)
                Cookie_Delete(lpCookie,(!(dwFlags & COOKIE_HANDLER_EXPIRED)));

            if (!(dwFlags & COOKIE_HANDLER_EXPIRED))
            {
                COOKIE *lpCookie=Cookie_Add(lpDomain,lpCookieName,lpData);
                if (!lpCookie)
                    break;

                lpCookie->ftExpiry=ftExpiry;
                lpCookie->dwCookieFlags=dwCookieFlags;

                if (dwCookieFlags & COOKIE_FLAG_PORT_SET)
                {
                    lpCookie->lpPortsList=(WORD*)MemQuickAlloc(dwPortsCount*sizeof(WORD));
                    if (lpCookie->lpPortsList)
                    {
                        lpCookie->dwPortsCount&=~COOKIE_FLAG_PORT_SET;
                        break;
                    }

                    lpCookie->dwPortsCount=dwPortsCount;

                    WCHAR *lpCurPort=lpPorts;
                    for (DWORD i=0; i < dwPortsCount; i++)
                    {
                        lpCookie->lpPortsList[i]=StrToIntW(lpCurPort);

                        lpCurPort=StrChrW(lpCurPort,L',');
                        lpCurPort++;
                    }
                }
            }
        }
        while (false);
        return;
    }
示例#7
0
/*************************************************************************
 *              Options_RunDLLW (SHELL32.@)
 */
EXTERN_C VOID WINAPI Options_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow)
{
    Options_RunDLLCommon(hWnd, hInst, StrToIntW(cmd), nCmdShow);
}
示例#8
0
/*******************************************************************
 * GAMEUX_loadGameStatisticsFromFile
 * Helper function, loads game statistics from file and stores them
 * in the structure.
 *
 * Parameters:
 *  data                [I/O]   structure containing file name to
 *                              load and data fields to store data in
 */
static HRESULT GAMEUX_loadStatisticsFromFile(struct GAMEUX_STATS *data)
{
    static const WCHAR sStatistics[] = {'S','t','a','t','i','s','t','i','c','s',0};
    static const WCHAR sCategory[] = {'C','a','t','e','g','o','r','y',0};
    static const WCHAR sIndex[] = {'I','n','d','e','x',0};
    static const WCHAR sStatistic[] = {'S','t','a','t','i','s','t','i','c',0};
    static const WCHAR sName[] = {'N','a','m','e',0};
    static const WCHAR sValue[] = {'V','a','l','u','e',0};

    HRESULT hr = S_OK;
    IXMLDOMDocument *document = NULL;
    IXMLDOMElement *root = NULL, *categoryElement, *statisticElement;
    IXMLDOMNode *categoryNode, *statisticNode;
    IXMLDOMNodeList *rootChildren = NULL, *categoryChildren;
    VARIANT vStatsFilePath, vValue;
    BSTR bstrStatistics = NULL, bstrCategory = NULL, bstrIndex = NULL,
        bstrStatistic = NULL, bstrName = NULL, bstrValue = NULL;
    VARIANT_BOOL isSuccessful =  VARIANT_FALSE;
    int i, j;

    TRACE("(%p)\n", data);

    V_VT(&vStatsFilePath) = VT_BSTR;
    V_BSTR(&vStatsFilePath) = SysAllocString(data->sStatsFile);
    if(!V_BSTR(&vStatsFilePath))
        hr = E_OUTOFMEMORY;

    if(SUCCEEDED(hr))
        hr = CoCreateInstance(&CLSID_DOMDocument30, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void**)&document);

    if(SUCCEEDED(hr))
    {
        bstrStatistics = SysAllocString(sStatistics);
        if(!bstrStatistics)
            hr = E_OUTOFMEMORY;
    }

    if(SUCCEEDED(hr))
    {
        bstrCategory = SysAllocString(sCategory);
        if(!bstrCategory)
            hr = E_OUTOFMEMORY;
    }

    if(SUCCEEDED(hr))
    {
        bstrIndex = SysAllocString(sIndex);
        if(!bstrIndex)
            hr = E_OUTOFMEMORY;
    }

    if(SUCCEEDED(hr))
    {
        bstrStatistic = SysAllocString(sStatistic);
        if(!bstrStatistic)
            hr = E_OUTOFMEMORY;
    }

    if(SUCCEEDED(hr))
    {
        bstrName = SysAllocString(sName);
        if(!bstrName)
            hr = E_OUTOFMEMORY;
    }

    if(SUCCEEDED(hr))
    {
        bstrValue = SysAllocString(sValue);
        if(!bstrValue)
            hr = E_OUTOFMEMORY;
    }

    if(SUCCEEDED(hr))
        hr = IXMLDOMDocument_load(document, vStatsFilePath, &isSuccessful);

    if(hr == S_OK && isSuccessful != VARIANT_TRUE)
        hr = S_FALSE;

    if( hr == S_OK )
        hr = IXMLDOMDocument_get_documentElement(document, &root);

    if(hr == S_OK)
        hr = IXMLDOMElement_get_childNodes(root, &rootChildren);

    if(hr == S_OK)
    {
        hr = S_OK;
        while(hr == S_OK)
        {
            hr = IXMLDOMNodeList_nextNode(rootChildren, &categoryNode);

            if(hr == S_OK)
            {
                hr = IXMLDOMNode_QueryInterface(categoryNode, &IID_IXMLDOMElement, (LPVOID*)&categoryElement);

                if(SUCCEEDED(hr))
                {
                    hr = IXMLDOMElement_getAttribute(categoryElement, bstrIndex, &vValue);
                    if( hr == S_OK && V_VT(&vValue) != VT_BSTR)
                        hr = E_FAIL;

                    if(SUCCEEDED(hr))
                    {
                        i = StrToIntW(V_BSTR(&vValue));
                        hr = IXMLDOMElement_getAttribute(categoryElement, bstrName, &vValue);
                        if( hr == S_OK && V_VT(&vValue) != VT_BSTR)
                            hr = E_FAIL;
                    }

                    if(SUCCEEDED(hr))
                    {
                        lstrcpynW(data->categories[i].sName, V_BSTR(&vValue), MAX_CATEGORY_LENGTH);
                        TRACE("category %d name %s\n", i, debugstr_w(data->categories[i].sName));
                        hr = IXMLDOMElement_get_childNodes(categoryElement, &categoryChildren);
                    }

                    if(SUCCEEDED(hr))
                    {
                        hr = S_OK;
                        while(hr == S_OK)
                        {
                            hr = IXMLDOMNodeList_nextNode(categoryChildren, &statisticNode);

                            if(hr == S_OK)
                            {
                                hr = IXMLDOMNode_QueryInterface(statisticNode, &IID_IXMLDOMElement, (LPVOID*)&statisticElement);

                                if(SUCCEEDED(hr))
                                {
                                    hr = IXMLDOMElement_getAttribute(statisticElement, bstrIndex, &vValue);
                                    if( hr == S_OK && V_VT(&vValue) != VT_BSTR)
                                        hr = E_FAIL;

                                    if(SUCCEEDED(hr))
                                    {
                                        j = StrToIntW(V_BSTR(&vValue));
                                        hr = IXMLDOMElement_getAttribute(statisticElement, bstrName, &vValue);
                                        if( hr == S_OK && V_VT(&vValue) != VT_BSTR)
                                            hr = E_FAIL;
                                    }

                                    if(SUCCEEDED(hr))
                                    {
                                        lstrcpynW(data->categories[i].stats[j].sName, V_BSTR(&vValue), MAX_NAME_LENGTH);
                                        hr = IXMLDOMElement_getAttribute(statisticElement, bstrValue, &vValue);
                                        if( hr == S_OK && V_VT(&vValue) != VT_BSTR)
                                            hr = E_FAIL;
                                    }

                                    if(SUCCEEDED(hr))
                                    {
                                        lstrcpynW(data->categories[i].stats[j].sValue, V_BSTR(&vValue), MAX_VALUE_LENGTH);
                                        TRACE("statistic %d name %s value %s\n", j,
                                              debugstr_w(data->categories[i].stats[j].sName),
                                              debugstr_w(data->categories[i].stats[j].sValue));
                                    }
                                    IXMLDOMElement_Release(statisticElement);
                                }

                                IXMLDOMNode_Release(statisticNode);
                            }
                        }

                        if(SUCCEEDED(hr))
                            hr = S_OK;
                    }
                    IXMLDOMElement_Release(categoryElement);
                }

                IXMLDOMNode_Release(categoryNode);
            }
        }
        if(SUCCEEDED(hr))
            hr = S_OK;
    }

    if(rootChildren) IXMLDOMNodeList_Release(rootChildren);
    if(root) IXMLDOMElement_Release(root);
    if(document) IXMLDOMDocument_Release(document);

    SysFreeString(bstrValue);
    SysFreeString(bstrName);
    SysFreeString(bstrStatistic);
    SysFreeString(bstrIndex);
    SysFreeString(bstrCategory);
    SysFreeString(bstrStatistics);
    SysFreeString(V_BSTR(&vStatsFilePath));
    return hr;
}
示例#9
0
static DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
{
    WCHAR szTopic[MAX_PATH];
    WCHAR szCommand[MAX_PATH];
    WCHAR *pszCommand;

    DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);

    pszCommand = (WCHAR*) DdeAccessData(hdata, NULL);
    if (!pszCommand)
        return DDE_FNOTPROCESSED;

    StringCchCopyW(szCommand, _countof(szCommand), pszCommand);

    DdeUnaccessData(hdata);

    TRACE("Dde_OnExecute: hconv=%p, topic=%S, command=%S\n", hconv, szTopic, pszCommand);

    /*
    [ViewFolder("%l", %I, %S)]    -- Open a folder in standard mode
    [ExploreFolder("%l", %I, %S)] -- Open a folder in "explore" mode (file tree is shown to the left by default)
    [FindFolder("%l", %I)]        -- Open a folder in "find" mode (search panel is shown to the left by default)
    [ShellFile("%1","%1",%S)]     -- Execute the contents of the specified .SCF file

    Approximate grammar (Upper names define rules, <lower> names define terminals, single-quotes are literals):

        Rules
            Command = ('[' Function ']') | Function
            Function = <identifier> '(' Parameters ')'
            Parameters = (<quoted-string> (',' <idlist> (',' <number>)?)?)?

        Terminals
            <identifier> =  [a-zA-Z]+
            <quoted-string> = \"([^\"]|\\.)\"
            <idlist> = \:[0-9]+\:[0-9]+
            <number> = [0-9]+
    */

    WCHAR Command[MAX_PATH] = L"";
    WCHAR Path[MAX_PATH] = L"";
    LPITEMIDLIST IdList = NULL;
    INT UnknownParameter = 0;

    // Simplified parsing (assumes the command will not be TOO broken):

    PWSTR cmd = szCommand;
    //    1. if starts with [, skip first char
    if (*cmd == L'[')
        cmd++;

    if (*cmd == L']')
    {
        ERR("Empty command. Nothing to run.\n");
        return DDE_FNOTPROCESSED;
    }

    // Read until first (, and take text before ( as command name
    {
        PWSTR cmdEnd = StrChrW(cmd, L'(');

        if (!cmdEnd)
        {
            ERR("Could not find '('. Invalid command.\n");
            return DDE_FNOTPROCESSED;
        }

        *cmdEnd = 0;

        StringCchCopy(Command, _countof(Command), cmd);

        cmd = cmdEnd + 1;
    }

    // Read first param after (, expecting quoted string
    if (*cmd != L')')
    {
        // Copy unescaped string
        PWSTR dst = Path;
        BOOL isQuote = FALSE;

        PWSTR arg = cmd;

        while (*arg && (isQuote || *arg != L','))
        {
            if (*arg == L'"')
            {
                isQuote = !isQuote;
                if (isQuote && arg != cmd) // do not copy the " at the beginning of the string
                {
                    *(dst++) = L'"';
                }
            }
            else
            {
                *(dst++) = *arg;
            }

            arg++;
        }

        cmd = arg + 1;

        while (*cmd == L' ')
            cmd++;
    }

    // Read second param, expecting an idlist in shared memory
    if (*cmd != L')')
    {
        if (*cmd != ':')
        {
            ERR("Expected ':'. Invalid command.\n");
            return DDE_FNOTPROCESSED;
        }

        PWSTR idlistEnd = StrChrW(cmd, L',');

        if (!idlistEnd)
            idlistEnd = StrChrW(cmd, L')');

        if (!idlistEnd)
        {
            ERR("Expected ',' or ')'. Invalid command.\n");
            return DDE_FNOTPROCESSED;
        }

        IdList = _ILReadFromSharedMemory(cmd);

        cmd = idlistEnd + 1;
    }

    // Read third param, expecting an integer
    if (*cmd != L')')
    {
        UnknownParameter = StrToIntW(cmd);
    }

    TRACE("Parse end: cmd=%S, S=%d, pidl=%p, path=%S\n", Command, UnknownParameter, IdList, Path);

    // Find handler in list
    for (int i = 0; i < HandlerListLength; i++)
    {
        DDECommandHandler & handler = HandlerList[i];
        if (StrCmpW(handler.Command, Command) == 0)
        {
            return handler.Handler(Command, Path, IdList, UnknownParameter);
        }
    }

    // No handler found
    ERR("Unknown command %S\n", Command);
    return DDE_FNOTPROCESSED;
}
示例#10
0
void FileListDialog::OnFileListDoubleClicked(){
	
	if (IsSymbolSearch){
		gtagSearchResult.GetCurrentSelection(fileName,FALSE);
		linenum_list.clear();
		gtagFunctionList.ClearAll();
		int FileSel=gtagSearchResult.GetCurrentSelectionIndex();
		int first,last;
		std::vector<int>::iterator it1=symbol_blocks.begin();
		std::vector<int>::iterator it2=symbol_linenum_list.begin();
		std::vector<std::wstring>::iterator it3 = symbol_list.begin();
		if(FileSel==0){
			first = 0;
			last = *(it1);
		}
		else{
			first=it1[FileSel-1];
			last=it1[FileSel];
		}
		for (first;first<last;first++){
			linenum_list.push_back(it2[first]);
			gtagFunctionList.AddItem(it3[first]);
		}
	}
	else if(IsDefSearch){
		int start=0;
		int end=0;

		gtagSearchResult.GetCurrentSelection(fileName,FALSE);
		file_name_length = fileName.size();

		if((start=fileName.find(L":",2))==std::wstring::npos)
			return;
		else
			if((end=fileName.find(L":",start+1))==std::wstring::npos)
				return;
			else{
				std::wstring num_char = fileName.substr(start+1,end-start);
				std::wstring file_name_part = fileName.substr(0,start);
				int num=StrToIntW(num_char.c_str());
				OpenFileAndGotoLine(file_name_part.c_str(),num);
			}
			return;
	}
	else{
		TCHAR str[20];
		std::wstring list_item;
		linenum_list.clear();
		gtagSearchResult.GetCurrentSelection(fileName,FALSE);
		file_name_length = fileName.size();
		ctag_func_list.clear();
		ctag_linenum_list.clear();
		FullPathToExe=L".\\plugins\\gtagfornplus\\global.exe";
		Parameters = L" -arf ";
		Parameters.append(SearchString);
		Parameters.append(L" \"");
		Parameters.append(fileName);
		Parameters.append(L"\"");		
		Search(GTAG_FUNCTION);
		FullPathToExe=L".\\plugins\\gtagfornplus\\ctags.exe";
		Parameters = L" -x --sort=no ";
		Parameters.append(L" \"");
		Parameters.append(fileName);
		Parameters.append(L"\"");
		Search(CTAG_FUNCTION);
		if((ctag_func_list.size()==ctag_linenum_list.size())&& ctag_func_list.size()!=0){
			int list_size=ctag_linenum_list.size();
			int looper=0;
			
			std::vector<int>::iterator it1;
			std::vector<int>::iterator it2 = ctag_linenum_list.begin();
			std::vector<std::wstring>::iterator it3 = ctag_func_list.begin();

			if(list_size==1){
				for ( it1=linenum_list.begin() ; it1 != linenum_list.end(); it1++ ){
					if(*it2>=*it1){
						list_item.clear();
						list_item.append(*it3);
						list_item.append(L" : ");
					}
					else
						list_item.append(L"Global Declaration : ");

					::_itot_s(*it1,str,20,10);
					list_item.append(str);
					gtagFunctionList.AddItem(list_item);
					list_item.clear();
				}
			}
			else {
				looper=0;
				for ( it1=linenum_list.begin() ; it1 != linenum_list.end(); it1++ ){
					if(looper==0 && *it1<it2[looper]){
							list_item.clear();
							list_item.append(L"Global Declaration : ");
							list_item.append(L" : ");
							::_itot_s(*it1,str,20,10);
							list_item.append(str);
							gtagFunctionList.AddItem(list_item);
							continue;
					}
					for(;looper<(list_size-2);looper++){
						if(*it1>it2[looper] && *it1<it2[looper+1]){
							list_item.clear();
							list_item.append(it3[looper]);
							list_item.append(L" : ");
							::_itot_s(*it1,str,20,10);
							list_item.append(str);
							gtagFunctionList.AddItem(list_item);
							break;
						}
					}
					if(looper==(list_size-2)){
						//The items may fall between last and 'last but one' functions.
						if(*it1>it2[looper] && *it1<it2[looper+1]){
							list_item.clear();
							list_item.append(it3[looper]);
							list_item.append(L" : ");
							::_itot_s(*it1,str,20,10);
							list_item.append(str);
							gtagFunctionList.AddItem(list_item);
							continue;
						}else 
							looper++;
					}
					if(looper==(list_size-1)){
						list_item.clear();
						list_item.append(it3[looper]);
						list_item.append(L" : ");
						::_itot_s(*it1,str,20,10);
						list_item.append(str);
						gtagFunctionList.AddItem(list_item);
						continue;
					}
				}
			}
		}							
		else return; //something wrong... lets find out later
	}
}
示例#11
0
void FileListDialog::ReadFromPipe(HANDLE g_hChildStd_OUT_Rd,int SearchType) 
{ 
   DWORD dwRead, dwWritten=0,len; 
   char charBuf[CHAR_SIZE]; 
   char *context,*buf,*chBuf=charBuf;
   TCHAR tchBuf[UCHAR_SIZE];
   BOOL bSuccess = FALSE;
   SearchStringSize = SearchString.size();
   std::wstring LastFile,NewFile;
   int Blocks=0;

   if(SearchType == GTAG_FILES)
	   	gtagSearchResult.ClearAll();
   gtagFunctionList.ClearAll();
   
    for (;;) 
   { 
	  if(dwWritten){
		strncpy_s(chBuf,CHAR_SIZE,buf,dwWritten);
		chBuf+=(dwWritten);
	  }
      bSuccess = ReadFile( g_hChildStd_OUT_Rd, chBuf, CHAR_SIZE-dwWritten, &dwRead, NULL);
      if( ! bSuccess || dwRead == 0 ) break; 
	  chBuf=charBuf;	  
	  dwWritten += dwRead;
	  buf=strtok_s(chBuf,"\r\n",&context);
	  while( buf != NULL ) {
		len = strlen(buf)+2;
		if(len<=dwWritten){
			mbstowcs(tchBuf,buf,len);
			dwWritten-=len;
			if(SearchType==GTAG_FUNCTION &&(StrCmpNW(tchBuf,SearchString.c_str(),SearchStringSize))==0){
				if(StrCmpNW(&tchBuf[SearchStringSize],L" ",1) == 0){
					int looper;
					int numstart=0;
					std::wstring line_num;
					for(looper=SearchStringSize+1;looper<99;looper++) {
						if(StrCmpNW(tchBuf+looper,L" ",1)==0)
							if(numstart)
								break;
							else
								continue;
						else{
							line_num.append(tchBuf+looper,1);
							numstart=1;
						}
					}
					linenum_list.push_back(StrToIntW(line_num.c_str()));
				}
			}
			else if(SearchType==GTAG_FILES)	{
				fileName=tchBuf;
				int colonPos=0,numberPos=0;
				if(IsSymbolSearch){
					if((colonPos=fileName.find(L":",2))==std::wstring::npos)continue;
					NewFile = fileName.substr(0,colonPos);
					if(LastFile.size()==0)LastFile=NewFile;
					if(LastFile!=NewFile){
						gtagSearchResult.AddItem(LastFile);	
						symbol_blocks.push_back(Blocks);
						LastFile=NewFile;
					}
					colonPos++;
					if((numberPos=fileName.find(L":",colonPos))==std::wstring::npos)continue;
					NewFile=fileName.substr(colonPos,numberPos-colonPos);
					symbol_linenum_list.push_back(StrToIntW(NewFile.c_str()));
					NewFile = fileName.substr(numberPos+1);
					NewFile.erase (0, NewFile.find_first_not_of (L" \t\r\n")) ; 
					symbol_list.push_back(NewFile);
					Blocks++;
				}
				else{
				//for now dont add h files
				if(fileName.find(L".h",fileName.size()-5)==std::wstring::npos)
					gtagSearchResult.AddItem(tchBuf);
				}
			}
			else if(SearchType==CTAG_FUNCTION){
				std::wstring buffer = tchBuf;
				size_t sz = buffer.find(L"function");
				if(sz!=std::wstring::npos && sz!=0){
					unsigned int looper=sz;
					int numstart=0;
					std::wstring line_num;
					for(looper=sz+11;looper<sz+21;looper++) {
						if(StrCmpNW(tchBuf+looper,L" ",1)==0)
							if(numstart)
								break;
							else
								continue;
						else{
							line_num.append(tchBuf+looper,1);
							numstart=1;
						}
					}
					ctag_linenum_list.push_back(StrToIntW(line_num.c_str()));
					ctag_func_list.push_back(tchBuf+looper+1+file_name_length);
				}
			}
			buf = strtok_s( NULL, "\r\n",&context );
		}
		else
			break;
	  }

	}
	if(IsSymbolSearch){
		gtagSearchResult.AddItem(LastFile);	
		symbol_blocks.push_back(Blocks);
	}
	CloseHandle(g_hChildStd_OUT_Rd);
} 
示例#12
0
void nsPluginInstance::performAction(const nsAString &args, PRInt32 *_retval)
{
	std::map<std::wstring, std::wstring> argMap;
	argMap.clear();

	const PRUnichar* data = new PRUnichar[args.Length() * sizeof(PRUnichar)];
	NS_StringGetData(args, &data); 
	std::wstring localArgs(data);

	BSTR bArgs = ::SysAllocString(localArgs.c_str());

	CTranslator::browserArgsToMapW(bArgs, argMap);
	std::map<std::wstring, std::wstring>::iterator it = argMap.find(L"operation");
	std::map<std::wstring, std::wstring>::iterator regit = argMap.find(L"reg");

	if (it != argMap.end())
	{
		if (0 == it->second.compare(L"screencast"))
		{
			if (1 == m_property->remoteDesktop())
			{
				*_retval = 1;
				return;
			}
			CTranslator::executePublisherRunW();

			if (regit != argMap.end())
			{
				m_property->setRegistration(regit->second);
				if (false == CPublisherIO::getInstance()->validateRegistration(m_property))
				{
					*_retval = -1;
					return;
				}
			}
			else
			{
				*_retval = -1;
				return;
			}

			it = argMap.find(L"action");
			if (it != argMap.end())
			{
				if (0 == it->second.compare(L"share"))
				{
					CTranslator::executeScreencasterRunW();
					CTranslator::executeScreencasterRunTrackW();
					setupDriver();
					//if (1 != m_property->driverInstalled())
					//	CTranslator::invokeDriverInstall();

					it = argMap.find(L"handle");
					if (it != argMap.end())
					{
						LONG handle = StrToIntW(it->second.c_str());
						if (false == m_property->isValidHandle(handle))
						{
							m_property->setScreencastResult(L"{screencastResult:\"4\"}");
							*_retval = 1;
							return;
						}

						if (0 != wcscmp(m_property->getScreencastResult(false), L"{screencastResult:\"1\"}"))
						{
							m_property->setScreencastResult(L"{screencastResult:\"0\"}");
							CTranslator::executeScreencasterShareAndConnectW(it->second, m_property->getScreencastURL());
						}
						else
						{
							CTranslator::executeScreencasterShareW(it->second);
						}

						*_retval = 1;
						return;
					}
				}
				else
				{
					CTranslator::executeScreencasterStopW();
					*_retval = 1;
					return;
				}
			}
		}
		else if (0 == it->second.compare(L"mint"))
		{
			it = argMap.find(L"action");
			if (it != argMap.end())
			{
				if (0 == it->second.compare(L"run"))
				{
					CTranslator::executePublisherRunW();
				}
				else if (0 == it->second.compare(L"installDriver"))
				{
					CTranslator::invokeDriverInstall();
				}
				else if (0 == it->second.compare(L"checkDriver"))
				{
					//*_retval = m_property->driverInstalled();
					*_retval = 1;
					return;
				}
				else
				{
					CTranslator::executePublisherKillW();
				}
			}
			*_retval = 1;
		}
	}

	*_retval = 0;
}
示例#13
0
/*********************************************************************
 * add_zone_to_listview [internal]
 *
 */
static void add_zone_to_listview(secdlg_data *sd, DWORD *pindex, DWORD zone)
{
    DWORD lv_index = *pindex;
    ZONEATTRIBUTES *za = &sd->zone_attr[lv_index];
    LVITEMW lvitem;
    HRESULT hr;
    INT iconid = 0;
    HMODULE hdll = NULL;
    WCHAR * ptr;
    HICON icon;

    TRACE("item %d (zone %d)\n", lv_index, zone);

    sd->zones[lv_index] = zone;

    memset(&lvitem, 0, sizeof(LVITEMW));
    memset(za, 0, sizeof(ZONEATTRIBUTES));
    za->cbSize = sizeof(ZONEATTRIBUTES);
    hr = IInternetZoneManager_GetZoneAttributes(sd->zone_mgr, zone, za);
    if (SUCCEEDED(hr)) {
        TRACE("displayname: %s\n", debugstr_w(za->szDisplayName));
        TRACE("description: %s\n", debugstr_w(za->szDescription));
        TRACE("minlevel: 0x%x, recommended: 0x%x, current: 0x%x (flags: 0x%x)\n", za->dwTemplateMinLevel,
             za->dwTemplateRecommended, za->dwTemplateCurrentLevel, za->dwFlags);

        if (za->dwFlags & ZAFLAGS_NO_UI ) {
            TRACE("item %d (zone %d): UI disabled for %s\n", lv_index, zone, debugstr_w(za->szDisplayName));
            return;
        }

        sd->levels[lv_index] = za->dwTemplateCurrentLevel;

        lvitem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
        lvitem.iItem = lv_index;
        lvitem.iSubItem = 0;
        lvitem.pszText = za->szDisplayName;
        lvitem.lParam = (LPARAM) zone;

        /* format is "filename.ext#iconid" */
        ptr = StrChrW(za->szIconPath, '#');
        if (ptr) {
            *ptr = 0;
            ptr++;
            iconid = StrToIntW(ptr);
            hdll = LoadLibraryExW(za->szIconPath, NULL, LOAD_LIBRARY_AS_DATAFILE);
            TRACE("%p: icon #%d from %s\n", hdll, iconid, debugstr_w(za->szIconPath));

            icon = LoadImageW(hdll, MAKEINTRESOURCEW(iconid), IMAGE_ICON, GetSystemMetrics(SM_CXICON),
                              GetSystemMetrics(SM_CYICON), LR_SHARED);

            if (!icon) {
                FIXME("item %d (zone %d): missing icon #%d in %s\n", lv_index, zone, iconid, debugstr_w(za->szIconPath));
            }

            /* the failure result (NULL) from LoadImageW let ImageList_AddIcon fail
               with -1, which is reused in ListView_InsertItemW to disable the image */
            lvitem.iImage = ImageList_AddIcon(sd->himages, icon);
        }
        else
            FIXME("item %d (zone %d): malformed szIconPath %s\n", lv_index, zone, debugstr_w(za->szIconPath));

        if (ListView_InsertItemW(sd->hlv, &lvitem) >= 0) {
            /* activate first item in the listview */
            if (! lv_index) {
                lvitem.state = LVIS_FOCUSED | LVIS_SELECTED;
                lvitem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
                SendMessageW(sd->hlv, LVM_SETITEMSTATE, 0, (LPARAM) &lvitem);
                sd->last_level = ~0;
                update_zone_info(sd, lv_index);
            }
            (*pindex)++;
        }
        FreeLibrary(hdll);
    }
    else
        FIXME("item %d (zone %d): GetZoneAttributes failed with 0x%x\n", lv_index, zone, hr);
}