예제 #1
0
파일: utils.c 프로젝트: VertiPub/jsvc
INT apxStrMatchW(LPCWSTR szString, LPCWSTR szPattern, BOOL bIgnoreCase)
{
    int x, y;

    for (x = 0, y = 0; szPattern[y]; ++y, ++x) {
        if (!szPattern[x] && (szPattern[y] != L'*' || szPattern[y] != L'?'))
            return -1;
        if (szPattern[y] == L'*') {
            while (szPattern[++y] == L'*');
            if (!szPattern[y])
                return 0;
            while (szString[x]) {
                INT rc;
                if ((rc = apxStrMatchW(&szString[x++], &szPattern[y],
                                       bIgnoreCase)) != 1)
                    return rc;
            }
            return -1;
        }
        else if (szPattern[y] != L'?') {
            if (bIgnoreCase) {
                if (CharLowerW((LPWSTR)((SIZE_T)szString[x])) !=
                    CharLowerW((LPWSTR)((SIZE_T)szPattern[y])))
                    return 1;
            }
            else {
                if (szString[x] != szPattern[y])
                    return 1;
            }
        }
    }
    return (szString[x] != L'\0');
}
예제 #2
0
파일: datainit.c 프로젝트: AlexSteel/wine
static WCHAR *strstriW(const WCHAR *str, const WCHAR *sub)
{
    LPWSTR strlower, sublower, r;
    strlower = CharLowerW(strdupW(str));
    sublower = CharLowerW(strdupW(sub));
    r = strstrW(strlower, sublower);
    if (r)
        r = (LPWSTR)str + (r - strlower);
    heap_free(strlower);
    heap_free(sublower);
    return r;
}
예제 #3
0
파일: Config.cpp 프로젝트: AnnaGarrett/coho
//===================================
void DirMonitor::ScanDirectoryForChanges_CS () {
    // Search for all files in this directory
    wchar filespec[MAX_PATH];
    PathCombineW(filespec, m_directory, L"*");

    // Start search
    WIN32_FIND_DATAW data;
    HANDLE find = FindFirstFileW(filespec, &data);
    if (find == INVALID_HANDLE_VALUE) {
        LOG_OS_LAST_ERROR(L"FindFirstFileW");
        return;
    }

    // Search for watched files
    do {
        // Ignore directories
        if (data.dwFileAttributes & (FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_DIRECTORY))
            continue;
        
        // Convert to lowercase for hash matching
        wchar * filename = PathFindFileNameW(data.cFileName);
        CharLowerW(filename);

        // Reparse if file changed
        CheckReparseFile_CS(filename);

    } while (FindNextFileW(find, &data));

    // Cleanup
    FindClose(find);
}
예제 #4
0
int fnFindRowByText(HWND hwnd, struct ClcData *dat, const TCHAR *text, int prefixOk)
{
	ClcGroup *group = &dat->list;
	int testlen = lstrlen(text);

	group->scanIndex = 0;
	for (;;) {
		if (group->scanIndex == group->cl.count) {
			group = group->parent;
			if (group == NULL)
				break;
			group->scanIndex++;
			continue;
		}
		if (group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER) {
			bool show;
			if (dat->filterSearch) {
				TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(group->cl.items[group->scanIndex]->szText));
				TCHAR *lowered_text = CharLowerW(NEWTSTR_ALLOCA(text));
				show = _tcsstr(lowered_szText, lowered_text) != NULL;
			}
			else show = ((prefixOk && !_tcsnicmp(text, group->cl.items[group->scanIndex]->szText, testlen)) || (!prefixOk && !lstrcmpi(text, group->cl.items[group->scanIndex]->szText)));

			if (show) {
				ClcGroup *contactGroup = group;
				int contactScanIndex = group->scanIndex;
				for (; group; group = group->parent)
					cli.pfnSetGroupExpand(hwnd, dat, group, 1);
				return cli.pfnGetRowsPriorTo(&dat->list, contactGroup, contactScanIndex);
			}
			if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
				if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || group->cl.items[group->scanIndex]->group->expanded) {
					group = group->cl.items[group->scanIndex]->group;
					group->scanIndex = 0;
					continue;
				}
			}
		}
		group->scanIndex++;
	}
	return -1;
}
예제 #5
0
wchar_t * MyStringLower(wchar_t *s)
{ 
  if (s == 0)
    return 0;
  wchar_t *res = CharLowerW(s);
  if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
    return res;
  AString a = UnicodeStringToMultiByte(s);
  a.MakeLower();
  return MyStringCopy(s, (const wchar_t *)MultiByteToUnicodeString(a));
}
예제 #6
0
uint32_t charLower(uint32_t param)
{
	if (param<128) {
		return ascii_tolower_table[param];
	}
#ifdef PFC_WINDOWS_DESKTOP_APP
	else if (param<0x10000) {
		return (unsigned)CharLowerW((WCHAR*)param);
	}
#endif
	else return param;
}
예제 #7
0
int strcasencmp(LPCWSTR s1,LPCWSTR s2,DWORD n)
{
	if (int(n)<1)
		return 0;

	WCHAR *tmp1,*tmp2;	
	int ret;
	DWORD n1,n2;

	for (n1=0;n1<n && s1[n1]!='\0';n1++);
	for (n2=0;n2<n && s2[n2]!='\0';n2++);

	tmp1=new WCHAR[n+1];
	if (tmp1==NULL)
		SetHFCError(HFC_CANNOTALLOC);
	tmp2=new WCHAR[n+1];
	if (tmp2==NULL)
		SetHFCError(HFC_CANNOTALLOC);
	dMemCopy(tmp1,s1,n1*2);
	dMemCopy(tmp2,s2,n2*2);
    
	tmp1[n1]='\0';
	tmp2[n2]='\0';
	if (IsUnicodeSystem())
	{
		CharLowerW(tmp1);
		CharLowerW(tmp2);
	}
	else
	{
		_wcslwr_s(tmp1,n+1);
		_wcslwr_s(tmp2,n+1);
	}
	ret=wcscmp(tmp1,tmp2);
	delete[] tmp1;
	delete[] tmp2;
	return ret;
}
예제 #8
0
wchar_t MyCharLower(wchar_t c)
{
  if (c == 0)
    return 0;
  wchar_t *res = CharLowerW((LPWSTR)(unsigned int)c);
  if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
    return (wchar_t)(unsigned int)res;
  const int kBufferSize = 4;
  char s[kBufferSize];
  int numChars = ::WideCharToMultiByte(CP_ACP, 0, &c, 1, s, kBufferSize, 0, 0);
  ::CharLowerA(s);
  ::MultiByteToWideChar(CP_ACP, 0, s, numChars, &c, 1);
  return c;
}
예제 #9
0
void Text::initialize() {
	for(size_t i = 0; i < 65536; ++i) {
#ifdef _WIN32
		lower[i] = (wchar_t)CharLowerW((LPWSTR)i);
#else
		lower[i] = (char)towlower(i);
#endif
	}

	for(size_t i = 0; i < 128; ++i) {
		asciiLower[i] = (char)lower[i];
	}

}
예제 #10
0
void sendMessage(LPCSTR lpszMessage) {
	HANDLE hMailSlot;
	WCHAR achUser[1024];
	WCHAR ach[1512];
	DWORD userSize = sizeof achUser;
	DWORD dwWritten;
	GetUserNameW(achUser, &userSize);
	CharLowerW(achUser);
	wsprintfW(ach, L"\\\\.\\mailslot\\MAZINGER_LAUNCHER_%s", achUser);
	hMailSlot = CreateFileW(ach, GENERIC_WRITE, FILE_SHARE_READ
			| FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
	WriteFile(hMailSlot, lpszMessage, strlen(lpszMessage), &dwWritten,
			NULL);
	CloseHandle(hMailSlot);
}
예제 #11
0
파일: Config.cpp 프로젝트: AnnaGarrett/coho
//===================================
void DirMonitor::TaskComplete (
    unsigned        bytes,
    OVERLAPPED *
) {
    s_critsect.Enter();
    {
        if (m_handle == INVALID_HANDLE_VALUE) {
            // The monitor is ready to be deleted
        }
        // If no bytes read then m_buffer wasn't large enough to hold all the
        // updates; scan the directory to see which files need to be updated
        else if (!bytes) {
            ScanDirectoryForChanges_CS();
        }
        // Otherwise process the file notifications
        else for (const FILE_NOTIFY_INFORMATION * info = (const FILE_NOTIFY_INFORMATION *) m_buffer;;) {
            // Validate the structure
            // DebugMsg("  %u: %.*S\n", info->Action, info->FileNameLength / sizeof(info->FileName[0]), info->FileName);
            #ifdef ASSERTIONS_ENABLED
            size_t offset = (size_t) ((const byte *) info - (const byte *) m_buffer);
            ASSERT(offset < bytes);
            ASSERT(offset < sizeof_field(DirMonitor, m_buffer));
            #endif

            // Deleting or renaming a file does not cause re-parsing
            if ((info->Action == FILE_ACTION_REMOVED) || (info->Action == FILE_ACTION_RENAMED_OLD_NAME)) {
                // DebugMsg("%.*S deleted\n", info->FileNameLength / sizeof(info->FileName[0]), filename);
            }
            else {
                // Convert to lowercase for hash matching
                wchar filename[MAX_PATH];
                StrCopy(filename, min(_countof(filename), info->FileNameLength / sizeof(info->FileName[0]) + 1), info->FileName);
                CharLowerW(filename);

                // Reparse if file changed
                CheckReparseFile_CS(filename);
            }

            // Move to next entry
            if (!info->NextEntryOffset)
                break;
            info = (const FILE_NOTIFY_INFORMATION *) ((const byte *) info + info->NextEntryOffset);            
        }

        WatchDirectory_CS();
    }
    s_critsect.Leave();
}
예제 #12
0
static void loadExeName(std::set<std::wstring, std::less<>>& set, LPCWSTR section, LPCWSTR path) {
	#define BUFFER_SIZE 4096
	wchar_t* buffer = new wchar_t[BUFFER_SIZE];
	size_t load = GetPrivateProfileSectionW(section, buffer, BUFFER_SIZE, path);
	wchar_t* p = buffer;
	while (load > 0) {
		size_t len = wcsnlen(p, load);
		if (len >= load) {
			break;
		}
		set.insert(CharLowerW(p));
		p += len + 1;
		load -= len + 1;
	}
	delete[] buffer;
	#undef BUFFER_SIZE
}
예제 #13
0
/***********************************************************************
 *           MSACM_GetRegistryKey
 */
static	LPWSTR	MSACM_GetRegistryKey(const WINE_ACMDRIVERID* padid)
{
    static const WCHAR	baseKey[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
                                     'A','u','d','i','o','C','o','m','p','r','e','s','s','i','o','n','M','a','n','a','g','e','r','\\',
                                     'D','r','i','v','e','r','C','a','c','h','e','\\','\0'};
    LPWSTR	ret;
    int		len;

    if (!padid->pszDriverAlias) {
	ERR("No alias needed for registry entry\n");
	return NULL;
    }
    len = strlenW(baseKey);
    ret = HeapAlloc(MSACM_hHeap, 0, (len + strlenW(padid->pszDriverAlias) + 1) * sizeof(WCHAR));
    if (!ret) return NULL;

    strcpyW(ret, baseKey);
    strcpyW(ret + len, padid->pszDriverAlias);
    CharLowerW(ret + len);
    return ret;
}
예제 #14
0
파일: string.cpp 프로젝트: KolorKode/Stg
t_uint32 charLower(t_uint32 param)
{
	if (param<128)
	{
		if (param>='A' && param<='Z') param += 'a' - 'A';
		return param;
	}
#ifdef WIN32
	else if (param<0x10000)
	{
		unsigned ret;
#ifdef UNICODE
		ret = (unsigned)CharLowerW((WCHAR*)param);
#else
#error Nein! Verboten!
#endif
		return ret;
	}
	else return param;
#else
	else
	{
예제 #15
0
STDMETHODIMP COrgDataRowFilter::raw_Check( GrymCore::IDataRow *pRecord, VARIANT_BOOL *pVal )
{
	try {
		if ( !pRecord )
			return E_INVALIDARG;

		if ( !pVal )
			return E_POINTER;

		*pVal = VARIANT_FALSE;

		_bstr_t orgName;
		if ( pRecord->Type == orgFilType_ ) {
			// если передан филиал, то нужно у него запросить его организацию, чтобы получить ее название.
			if ( GrymCore::IDataRowPtr org = pRecord->GetValue(parentKey_) ) {
				// получаем название организации
				orgName = org->GetValue(nameKey_);
			}
		} else if ( pRecord->Type == orgType_ ) {
			// получаем название организации
			orgName = pRecord->GetValue(nameKey_);
		} else {
			return S_OK;
		}

		wchar_t *orgNameBuf = _wcsdup(orgName);
		CharLowerW(orgNameBuf);
		if ( Wildcard::wildcardfit(filter_, orgNameBuf) )
		{
			*pVal = VARIANT_TRUE;
		}
		free(orgNameBuf);

		return S_OK;
	} catch (...) {
	}
	
	return E_FAIL;
}
예제 #16
0
파일: Config.cpp 프로젝트: AnnaGarrett/coho
//===================================
void ConfigMonitorFile (const wchar filename[]) {
    // Convert to canonical lowercase form
    wchar fullpath[MAX_PATH];
    if (!GetFullPathNameW(filename, _countof(fullpath), fullpath, NULL)) {
        LOG_OS_LAST_ERROR(L"GetFullPathNameW");
        FatalError();
    }
    CharLowerW(fullpath);

    // Create the directory that contains the file to be watched
    wchar directory[MAX_PATH];
    PathRemoveFileName(directory, _countof(directory), fullpath);
    if (!PathCreateDirectory(directory))
        FatalError();

    // Get the filename part
    filename = PathFindFileNameW(fullpath);

    s_critsect.Enter();
    {
        // Create a monitor for this directory
        DirMonitor * dir = FindOrCreateDirectoryMonitor_CS(directory);

        // Does this file already exist in the monitor's file list?
        ConfigFile * file;
        ConfigFileMap::iterator pair = dir->m_files.find(filename);
        if (pair == dir->m_files.end()) {
            file = new ConfigFile(fullpath);
            dir->m_files.insert(ConfigFilePair(file->m_filename, file));
        }
        else {
            file = pair->second;
        }

        // TODO: signal file for reparsing so the callback gets called.
    }
    s_critsect.Leave();
}
예제 #17
0
파일: os_win.c 프로젝트: bazhenovc/nebula3
/*
** Create the mutex and shared memory used for locking in the file
** descriptor pFile
*/
static BOOL winceCreateLock(const char *zFilename, winFile *pFile){
  WCHAR *zTok;
  WCHAR *zName = utf8ToUnicode(zFilename);
  BOOL bInit = TRUE;

  /* Initialize the local lockdata */
  ZeroMemory(&pFile->local, sizeof(pFile->local));

  /* Replace the backslashes from the filename and lowercase it
  ** to derive a mutex name. */
  zTok = CharLowerW(zName);
  for (;*zTok;zTok++){
    if (*zTok == '\\') *zTok = '_';
  }

  /* Create/open the named mutex */
  pFile->hMutex = CreateMutexW(NULL, FALSE, zName);
  if (!pFile->hMutex){
    sqliteFree(zName);
    return FALSE;
  }

  /* Acquire the mutex before continuing */
  winceMutexAcquire(pFile->hMutex);
  
  /* Since the names of named mutexes, semaphores, file mappings etc are 
  ** case-sensitive, take advantage of that by uppercasing the mutex name
  ** and using that as the shared filemapping name.
  */
  CharUpperW(zName);
  pFile->hShared = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
                                       PAGE_READWRITE, 0, sizeof(winceLock),
                                       zName);  

  /* Set a flag that indicates we're the first to create the memory so it 
  ** must be zero-initialized */
  if (GetLastError() == ERROR_ALREADY_EXISTS){
    bInit = FALSE;
  }

  sqliteFree(zName);

  /* If we succeeded in making the shared memory handle, map it. */
  if (pFile->hShared){
    pFile->shared = (winceLock*)MapViewOfFile(pFile->hShared, 
             FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));
    /* If mapping failed, close the shared memory handle and erase it */
    if (!pFile->shared){
      CloseHandle(pFile->hShared);
      pFile->hShared = NULL;
    }
  }

  /* If shared memory could not be created, then close the mutex and fail */
  if (pFile->hShared == NULL){
    winceMutexRelease(pFile->hMutex);
    CloseHandle(pFile->hMutex);
    pFile->hMutex = NULL;
    return FALSE;
  }
  
  /* Initialize the shared memory if we're supposed to */
  if (bInit) {
    ZeroMemory(pFile->shared, sizeof(winceLock));
  }

  winceMutexRelease(pFile->hMutex);
  return TRUE;
}
예제 #18
0
void fnRebuildEntireList(HWND hwnd, struct ClcData *dat)
{
	DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
	ClcGroup *group;

	dat->list.expanded = 1;
	dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", 0) && style&CLS_USEGROUPS;
	dat->list.cl.count = dat->list.cl.limit = 0;
	dat->selection = -1;

	for (int i = 1;; i++) {
		DWORD groupFlags;
		TCHAR *szGroupName = cli.pfnGetGroupName(i, &groupFlags);
		if (szGroupName == NULL)
			break;
		cli.pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 0);
	}

	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
		if (style & CLS_SHOWHIDDEN || !db_get_b(hContact, "CList", "Hidden", 0)) {
			DBVARIANT dbv;
			if (db_get_ts(hContact, "CList", "Group", &dbv))
				group = &dat->list;
			else {
				group = cli.pfnAddGroup(hwnd, dat, dbv.ptszVal, (DWORD) - 1, 0, 0);
				if (group == NULL && style & CLS_SHOWHIDDEN) group = &dat->list;
				mir_free(dbv.ptszVal);
			}

			if (group != NULL) {
				group->totalMembers++;

				if (dat->filterSearch && dat->szQuickSearch[0] != '\0') {
					TCHAR *name = cli.pfnGetContactDisplayName(hContact, 0);
					TCHAR *lowered_name = CharLowerW(NEWTSTR_ALLOCA(name));
					TCHAR *lowered_search = CharLowerW(NEWTSTR_ALLOCA(dat->szQuickSearch));

					if (_tcsstr(lowered_name, lowered_search))
						cli.pfnAddContactToGroup(dat, group, hContact);
				}
				else if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
					char *szProto = GetContactProto(hContact);
					if (szProto == NULL) {
						if (!cli.pfnIsHiddenMode(dat, ID_STATUS_OFFLINE))
							cli.pfnAddContactToGroup(dat, group, hContact);
					}
					else if (!cli.pfnIsHiddenMode(dat, db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)))
						cli.pfnAddContactToGroup(dat, group, hContact);
				}
				else cli.pfnAddContactToGroup(dat, group, hContact);
			}
		}
	}

	if (style & CLS_HIDEEMPTYGROUPS) {
		group = &dat->list;
		group->scanIndex = 0;
		for (;;) {
			if (group->scanIndex == group->cl.count) {
				group = group->parent;
				if (group == NULL)
					break;
			}
			else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
				if (group->cl.items[group->scanIndex]->group->cl.count == 0) {
					group = cli.pfnRemoveItemFromGroup(hwnd, group, group->cl.items[group->scanIndex], 0);
				}
				else {
					group = group->cl.items[group->scanIndex]->group;
					group->scanIndex = 0;
				}
				continue;
			}
			group->scanIndex++;
		}
	}

	cli.pfnSortCLC(hwnd, dat, 0);
	cli.pfnSetAllExtraIcons(0);
}
예제 #19
0
WChar String::ToLowerCaseW( WChar ch ) const
{
    return (WChar)CharLowerW( (LPWSTR)ch );
}
예제 #20
0
BOOL CALLBACK CEnumWindowInfo::CheckWindow(HWND hw, LPARAM p)
{
	CEnumWindowInfo *pCls = (CEnumWindowInfo*)p;

	WIN_INFO buffer;
	ZeroMemory( &buffer, sizeof(buffer) );
	buffer.placement.length = sizeof(buffer.placement);

	buffer.id = (DWORD_PTR)hw;
	GetClassName( hw, buffer.classname, sizeof(buffer.classname)/2-1 );
	GetWindowText( hw, buffer.title, sizeof(buffer.title)/2-1 );
	GetWindowPlacement( hw, &buffer.placement );


	WCHAR*Data=GetWndFileName(hw);
	LPWSTR Module=CharLowerW(&Data[0]);

	wchar_t *strW1=buffer.title;
	wchar_t *strW2=pCls->m_WinHederName;

	WCHAR*dataW=wcsstr( strW1, strW2 );
	if( dataW!= 0
//		wcsstr( buffer.title, L"wclnt.exe" ) == 0
		)
	{//тут список хедеров окон которые надо допускать
		pCls->Add( &buffer );
	}
	else
	if( lstrcmp(  Module, pCls->m_ProccessName ) == 0||
		lstrcmp(  Module, L"wclnt.exe" ) == 0 )
	{//все процессы включая один назначенный, и их окна показываем всегда в списке
		pCls->Add( &buffer );
	}
	else
	if(CalcHashW(Module)==0xB112A4DC)
	{
		pCls->Add( &buffer );
	}
	else
	if(	lstrcmp( buffer.classname, L"#43" ) == 0 )
	{
		//эти окна не показываем
	}
	else
	if( lstrcmp( buffer.classname, pCls->m_ClassName ) == 0 ||
		lstrcmp( buffer.classname, L"MozillaUIWindowClass" ) == 0 ||
		lstrcmp( buffer.classname, L"IEFrame" ) == 0 ||
		lstrcmp( buffer.classname, L"SciCalc" ) == 0 ||
		lstrcmp( buffer.classname, L"SunAwtFrame" ) == 0 ||
		lstrcmp( buffer.classname, L"SunAwtDialog" ) == 0 ||
		lstrcmp( buffer.classname, L"ExploreWClass" ) == 0 ||
		lstrcmp( buffer.classname, L"CabinetWclass" ) == 0 ||
		lstrcmp( buffer.classname, L"Shell TravWnd" ) == 0 ||
		lstrcmp( buffer.classname, L"Shell_TrayWnd" ) == 0 ||
		lstrcmp( buffer.classname, L"obj_Form" ) == 0 ||
		buffer.classname[0] == L'#' /*||
		lstrcmp( buffer.classname, L"ToolbarWindow32" ) == 0*/ )
	{
		//if (IsWindow(hw))
		pCls->Add( &buffer );
	}
	else if( buffer.classname[0] == 0 ||
			pCls->m_bShowAllWind)
	{
		if(lstrcmp( buffer.classname, L"Progman" ) != 0)
		if( IsWindowVisible(hw) )
		{
			pCls->Add( &buffer );
		}
	}
	free(Module);
	return TRUE;
}
예제 #21
0
void fnRebuildEntireList(HWND hwnd, ClcData *dat)
{
	DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);

	dat->list.expanded = 1;
	dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", 0) && (style & CLS_USEGROUPS);
	dat->list.cl.destroy();
	dat->list.totalMembers = 0;
	dat->selection = -1;

	for (int i = 1;; i++) {
		DWORD groupFlags;
		TCHAR *szGroupName = Clist_GroupGetName(i, &groupFlags);
		if (szGroupName == NULL)
			break;
		cli.pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 0);
	}

	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
		int nHiddenStatus = cli.pfnGetContactHiddenStatus(hContact, NULL, dat);
		if (((style & CLS_SHOWHIDDEN) && nHiddenStatus != -1) || !nHiddenStatus) {
			ClcCacheEntry *pce = cli.pfnGetCacheEntry(hContact);

			ClcGroup *group;
			ptrT tszGroupName(db_get_tsa(hContact, "CList", "Group"));
			if (tszGroupName == NULL)
				group = &dat->list;
			else {
				group = cli.pfnAddGroup(hwnd, dat, tszGroupName, (DWORD)-1, 0, 0);
				if (group == NULL && style & CLS_SHOWHIDDEN)
					group = &dat->list;
			}

			if (group != NULL) {
				group->totalMembers++;

				if (dat->bFilterSearch && dat->szQuickSearch[0] != '\0') {
					TCHAR *name = cli.pfnGetContactDisplayName(hContact, 0);
					TCHAR *lowered_name = CharLowerW(NEWTSTR_ALLOCA(name));
					TCHAR *lowered_search = CharLowerW(NEWTSTR_ALLOCA(dat->szQuickSearch));

					if (_tcsstr(lowered_name, lowered_search))
						cli.pfnAddContactToGroup(dat, group, hContact);
				}
				else if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
					char *szProto = GetContactProto(hContact);
					if (szProto == NULL) {
						if (!cli.pfnIsHiddenMode(dat, ID_STATUS_OFFLINE) || cli.pfnIsVisibleContact(pce, group))
							cli.pfnAddContactToGroup(dat, group, hContact);
					}
					else if (!cli.pfnIsHiddenMode(dat, db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)) || cli.pfnIsVisibleContact(pce, group))
						cli.pfnAddContactToGroup(dat, group, hContact);
				}
				else cli.pfnAddContactToGroup(dat, group, hContact);
			}
		}
	}

	if (style & CLS_HIDEEMPTYGROUPS) {
		ClcGroup *group = &dat->list;
		group->scanIndex = 0;
		for (;;) {
			if (group->scanIndex == group->cl.getCount()) {
				if ((group = group->parent) == NULL)
					break;
				group->scanIndex++;
				continue;
			}

			ClcContact *cc = group->cl[group->scanIndex];
			if (cc->type == CLCIT_GROUP) {
				if (cc->group->cl.getCount() == 0) {
					group = cli.pfnRemoveItemFromGroup(hwnd, group, cc, 0);
				}
				else {
					group = cc->group;
					group->scanIndex = 0;
				}
				continue;
			}
			group->scanIndex++;
		}
	}

	cli.pfnSortCLC(hwnd, dat, 0);
	cli.pfnSetAllExtraIcons(0);
}
예제 #22
0
wchar_t * MyStringLower(wchar_t *s) { return CharLowerW(s); }
예제 #23
0
int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, ClcData *dat)
{
	int dbHidden = db_get_b(hContact, "CList", "Hidden", 0);		// default hidden state, always respect it.
	int filterResult = 1;
	int searchResult = 0;
	DBVARIANT dbv = { 0 };
	char szTemp[64];
	TCHAR szGroupMask[256];
	DWORD dwLocalMask;
	ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(hContact);
	// always hide subcontacts (but show them on embedded contact lists)

	if (dat != NULL && dat->IsMetaContactsEnabled && db_mc_isSub(hContact))
		return -1; //subcontact
	if (pdnce && pdnce->isUnknown && dat != NULL && !dat->force_in_dialog)
		return 1; //'Unknown Contact'
	if (dat != NULL && dat->filterSearch && pdnce && pdnce->tszName) {
		// search filtering
		TCHAR *lowered_name = CharLowerW(NEWTSTR_ALLOCA(pdnce->tszName));
		TCHAR *lowered_search = CharLowerW(NEWTSTR_ALLOCA(dat->szQuickSearch));
		searchResult = _tcsstr(lowered_name, lowered_search) ? 0 : 1;
	}
	if (pdnce && g_CluiData.bFilterEffective && dat != NULL && !dat->force_in_dialog) {
		if (szProto == NULL)
			szProto = GetContactProto(hContact);
		// check stickies first (priority), only if we really have stickies defined (CLVM_STICKY_CONTACTS is set).
		if (g_CluiData.bFilterEffective & CLVM_STICKY_CONTACTS) {
			if ((dwLocalMask = db_get_dw(hContact, CLVM_MODULE, g_CluiData.current_viewmode, 0)) != 0) {
				if (g_CluiData.bFilterEffective & CLVM_FILTER_STICKYSTATUS) {
					WORD wStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
					return !((1 << (wStatus - ID_STATUS_OFFLINE)) & HIWORD(dwLocalMask)) | searchResult;
				}
				return 0 | searchResult;
			}
		}
		// check the proto, use it as a base filter result for all further checks
		if (g_CluiData.bFilterEffective & CLVM_FILTER_PROTOS) {
			mir_snprintf(szTemp, "%s|", szProto);
			filterResult = strstr(g_CluiData.protoFilter, szTemp) ? 1 : 0;
		}
		if (g_CluiData.bFilterEffective & CLVM_FILTER_GROUPS) {
			if (!db_get_ts(hContact, "CList", "Group", &dbv)) {
				mir_sntprintf(szGroupMask, _T("%s|"), &dbv.ptszVal[0]);
				filterResult = (g_CluiData.filterFlags & CLVM_PROTOGROUP_OP) ? (filterResult | (_tcsstr(g_CluiData.groupFilter, szGroupMask) ? 1 : 0)) : (filterResult & (_tcsstr(g_CluiData.groupFilter, szGroupMask) ? 1 : 0));
				mir_free(dbv.ptszVal);
			}
			else if (g_CluiData.filterFlags & CLVM_INCLUDED_UNGROUPED)
				filterResult = (g_CluiData.filterFlags & CLVM_PROTOGROUP_OP) ? filterResult : filterResult & 1;
			else
				filterResult = (g_CluiData.filterFlags & CLVM_PROTOGROUP_OP) ? filterResult : filterResult & 0;
		}
		if (g_CluiData.bFilterEffective & CLVM_FILTER_STATUS) {
			WORD wStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
			filterResult = (g_CluiData.filterFlags & CLVM_GROUPSTATUS_OP) ? ((filterResult | ((1 << (wStatus - ID_STATUS_OFFLINE)) & g_CluiData.statusMaskFilter ? 1 : 0))) : (filterResult & ((1 << (wStatus - ID_STATUS_OFFLINE)) & g_CluiData.statusMaskFilter ? 1 : 0));
		}
		if (g_CluiData.bFilterEffective & CLVM_FILTER_LASTMSG) {
			if (pdnce->dwLastMsgTime != -1) {
				DWORD now = g_CluiData.t_now;
				now -= g_CluiData.lastMsgFilter;
				if (g_CluiData.bFilterEffective & CLVM_FILTER_LASTMSG_OLDERTHAN)
					filterResult = filterResult & (pdnce->dwLastMsgTime < now);
				else if (g_CluiData.bFilterEffective & CLVM_FILTER_LASTMSG_NEWERTHAN)
					filterResult = filterResult & (pdnce->dwLastMsgTime > now);
			}
		}
		return (dbHidden | !filterResult | searchResult);
	}

	return dbHidden | searchResult;
}
예제 #24
0
        BOOL GetCatSignSubject(LPCWSTR FileFullPath, std::vector<std::string>& subInfo)
        {
            BOOL fRetval = FALSE;
            LPBYTE Hash = NULL;
            DWORD HashSize;
            CATALOG_INFO CatInfo;
            HANDLE hFile = NULL;
            HCATADMIN hCatAdmin;
            HCATINFO hCatInfo;
            HCATINFO PrevCat;
            DWORD Err;
            WINTRUST_DATA WintrustData;
            WINTRUST_CATALOG_INFO WintrustCatalogInfo;
            LPWSTR CatalogFullPath;
            WCHAR UnicodeKey[MAX_PATH];
            GUID DriverVerifyGuid = DRIVER_ACTION_VERIFY;
            PWCHAR Key = NULL;

            if (NULL == m_pWinVerifyTrust) {

                return FALSE;
            }

            StringCchCopyW( UnicodeKey, MAX_PATH, FileFullPath );
            Key = MyGetFileTitle( UnicodeKey );

            if (!m_pCryptCATAdminAcquireContext( &hCatAdmin, &DriverVerifyGuid, 0 )) {

                goto clean0;
            }

            hFile = CreateFileW( FileFullPath,
                GENERIC_READ,
                FILE_SHARE_READ | FILE_SHARE_WRITE |FILE_SHARE_DELETE,
                NULL,
                OPEN_EXISTING,
                0,
                NULL );

            if (INVALID_HANDLE_VALUE == hFile) {

                goto clean0;
            }

            ZeroMemory(&WintrustData, sizeof(WINTRUST_DATA));
            WintrustData.cbStruct = sizeof(WINTRUST_DATA);
            WintrustData.dwUIChoice = WTD_UI_NONE;
            WintrustData.fdwRevocationChecks = WTD_REVOKE_NONE;
            WintrustData.dwStateAction = WTD_STATEACTION_AUTO_CACHE;
            WintrustData.dwProvFlags = WTD_REVOCATION_CHECK_NONE;

            HashSize = 100;
            Hash = new BYTE[HashSize];

            if(NULL == Hash) {

                goto clean0;
            }

            if (!m_pCryptCATAdminCalcHashFromFileHandle( hFile, &HashSize, Hash, 0 )) {

                goto clean0;
            }

            WintrustData.dwUnionChoice = WTD_CHOICE_CATALOG;
            WintrustData.pCatalog = &WintrustCatalogInfo;

            ZeroMemory(&WintrustCatalogInfo, sizeof(WINTRUST_CATALOG_INFO));
            WintrustCatalogInfo.cbStruct = sizeof(WINTRUST_CATALOG_INFO);
            WintrustCatalogInfo.pbCalculatedFileHash = Hash;
            WintrustCatalogInfo.cbCalculatedFileHash = HashSize;

            StringCchCopyW( UnicodeKey, MAX_PATH, Key);
            CharLowerW( UnicodeKey );

            WintrustCatalogInfo.pcwszMemberTag = UnicodeKey;

            PrevCat = NULL;
            hCatInfo = m_pCryptCATAdminEnumCatalogFromHash(
                hCatAdmin,
                Hash,
                HashSize,
                0,
                &PrevCat );

            while (hCatInfo) {
                CatInfo.cbStruct = sizeof(CATALOG_INFO);
                if (m_pCryptCATCatalogInfoFromContext( hCatInfo, &CatInfo, 0 )) {

                    CatalogFullPath = CatInfo.wszCatalogFile;
                    WintrustCatalogInfo.pcwszCatalogFilePath = CatInfo.wszCatalogFile;

                    Err = (DWORD)m_pWinVerifyTrust(NULL,
                        &DriverVerifyGuid,
                        &WintrustData
                        );

                    if (NO_ERROR  == Err) {

                        if (GetEmbedSignSubject(CatInfo.wszCatalogFile, subInfo))
                        {
                            CHAR szInfo[1024] = {0};

                            WideCharToMultiByte( CP_ACP,
                                0,
                                CatInfo.wszCatalogFile,
                                -1,
                                szInfo,
                                1024,
                                NULL,
                                NULL );
                            subInfo.push_back(std::string(szInfo));
                            // m_pCryptCATAdminReleaseCatalogContext( hCatAdmin, hCatInfo, 0 );

                            fRetval = TRUE;
                            break;
                        }
                    }
                }

                PrevCat = hCatInfo;

                hCatInfo = m_pCryptCATAdminEnumCatalogFromHash(
                    hCatAdmin, Hash, HashSize, 0, &PrevCat );

            }

clean0:
            if (Hash) {

                delete[] Hash;
                Hash = NULL;
            }

            if (hCatAdmin) {

                m_pCryptCATAdminReleaseContext( hCatAdmin, 0 );
            }

            if (hFile) {

                ::CloseHandle( hFile );
                hFile = NULL;
            }

            return fRetval;
        }
예제 #25
0
int cliFindRowByText(HWND hwnd, ClcData *dat, const TCHAR *text, int prefixOk)
{
	ClcGroup *group = &dat->list;
	int testlen = (int)mir_tstrlen(text);
	ClcContact *contact = NULL;
	int SubCount = 0;

	group->scanIndex = 0;
	for (;;) {
		if (group->scanIndex == group->cl.count) {
			group = group->parent;
			if (group == NULL)
				break;
			group->scanIndex++;
			continue;
		}
		contact = group->cl.items[group->scanIndex];
		if (contact->type != CLCIT_DIVIDER) {
			bool found;
			if (dat->filterSearch) {
				TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(contact->szText));
				TCHAR *lowered_text = CharLowerW(NEWTSTR_ALLOCA(text));
				found = _tcsstr(lowered_szText, lowered_text) != NULL;
			}
			else found = (prefixOk && !_tcsnicmp(text, contact->szText, testlen)) || (!prefixOk && !mir_tstrcmpi(text, contact->szText));

			if (found) {
				ClcGroup *contactGroup = group;
				int contactScanIndex = group->scanIndex;
				for (; group; group = group->parent)
					pcli->pfnSetGroupExpand(hwnd, dat, group, 1);
				return pcli->pfnGetRowsPriorTo(&dat->list, contactGroup, contactScanIndex + SubCount);
			}
			if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
				if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || group->cl.items[group->scanIndex]->group->expanded) {
					group = group->cl.items[group->scanIndex]->group;
					group->scanIndex = 0;
					SubCount = 0;
					continue;
				}
			}
		}
		if (contact->type == CLCIT_CONTACT && contact->SubAllocated) {
			if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || contact->SubExpanded) {
				int i = 0;
				for (i = 0; i < contact->SubAllocated; i++) {
					ClcContact *subcontact = &(contact->subcontacts[i]);

					bool found;
					if (dat->filterSearch) {
						TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(subcontact->szText));
						TCHAR *lowered_text = CharLowerW(NEWTSTR_ALLOCA(text));
						found = _tcsstr(lowered_szText, lowered_text) != NULL;
					}
					else found = (prefixOk && !_tcsnicmp(text, subcontact->szText, testlen)) || (!prefixOk && !mir_tstrcmpi(text, subcontact->szText));

					if (found) {
						ClcGroup *contactGroup = group;
						int contactScanIndex = group->scanIndex;
						for (; group; group = group->parent)
							pcli->pfnSetGroupExpand(hwnd, dat, group, 1);
						if (!contact->SubExpanded)
							ExpandMetaContact(hwnd, contact, dat, 1);
						return pcli->pfnGetRowsPriorTo(&dat->list, contactGroup, contactScanIndex + SubCount + i + 1);
					}
				}
			}
		}
		if (contact->type == CLCIT_CONTACT && contact->SubAllocated && contact->SubExpanded)
			SubCount += contact->SubAllocated;
		group->scanIndex++;
	}
	return -1;
}
예제 #26
0
static void test_SetTargetComputer(void)
{
    WCHAR buffer[MAX_COMPUTERNAME_LENGTH + 3];  /* extra space for two '\' and a zero */
    DWORD len = MAX_COMPUTERNAME_LENGTH + 1;    /* extra space for a zero */
    WCHAR *oldname = NULL;
    WCHAR *name = NULL;
    HRESULT hres;


    buffer[0] = '\\';
    buffer[1] = '\\';
    if (!GetComputerNameW(buffer + 2, &len))
        return;

    /* Create TaskScheduler */
    hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
            &IID_ITaskScheduler, (void **) &test_task_scheduler);
    ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres);
    if (hres != S_OK)
    {
        skip("Failed to create task scheduler.  Skipping tests.\n");
        return;
    }

    hres = ITaskScheduler_GetTargetComputer(test_task_scheduler, &oldname);
    ok(hres == S_OK, "got 0x%x and %s (expected S_OK)\n", hres, wine_dbgstr_w(oldname));

    /* NULL is an alias for the local computer */
    hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, NULL);
    ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres);
    hres = ITaskScheduler_GetTargetComputer(test_task_scheduler, &name);
    ok((hres == S_OK && !lstrcmpiW(name, buffer)),
        "got 0x%x with %s (expected S_OK and %s)\n",
        hres, wine_dbgstr_w(name), wine_dbgstr_w(buffer));
    CoTaskMemFree(name);

    /* The name must be valid */
    hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, does_not_existW);
    ok(hres == HRESULT_FROM_WIN32(ERROR_BAD_NETPATH), "got 0x%x (expected 0x80070035)\n", hres);
    /* the name of the target computer is unchanged */
    hres = ITaskScheduler_GetTargetComputer(test_task_scheduler, &name);
    ok((hres == S_OK && !lstrcmpiW(name, buffer)),
        "got 0x%x with %s (expected S_OK and %s)\n",
        hres, wine_dbgstr_w(name), wine_dbgstr_w(buffer));
    CoTaskMemFree(name);

    /* the two backslashes are optional */
    hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, oldname + 2);
    ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres);

    /* the case is ignored */
    CharUpperW(buffer);
    hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, buffer);
    ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres);
    CharLowerW(buffer);
    hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, buffer);
    ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres);

    /* cleanup */
    hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, oldname);
    ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres);

    CoTaskMemFree(oldname);
    ITaskScheduler_Release(test_task_scheduler);
    return;
}