コード例 #1
0
ファイル: PWPListEntries.cpp プロジェクト: soundsrc/pwsafe
int CALLBACK CPWPListEntries::CompareFunc(LPARAM lParam1, LPARAM lParam2,
                                          LPARAM closure)
{
  CPWPListEntries *self = (CPWPListEntries *)closure;
  int nSortColumn = self->m_iSortedColumn;
  const st_GroupTitleUser pLHS = self->m_pventries->at(lParam1);
  const st_GroupTitleUser pRHS = self->m_pventries->at(lParam2);

  int iResult(0);
  switch (nSortColumn) {
  case 0:
    iResult = CompareNoCase(pLHS.group, pRHS.group);
    break;
  case 1:
    iResult = CompareNoCase(pLHS.title, pRHS.title);
    break;
  case 2:
    iResult = CompareNoCase(pLHS.user, pRHS.user);
    break;
  default:
    ASSERT(FALSE);
  }

  if (!self->m_bSortAscending && iResult != 0)
    iResult *= -1;

  return iResult;
}
コード例 #2
0
// GetBool
// Returns the key value as a bool type. Returns false if the key is
// not found.
bool CDataFile::GetBool(t_Str szKey, t_Str szSection)
{
   bool bValue = false;
   t_Str szValue = GetValue(szKey, szSection);

   if ( szValue.find("1") == 0
        || CompareNoCase(szValue, "true")
        || CompareNoCase(szValue, "yes") )
      {
         bValue = true;
      }

   return bValue;
}
コード例 #3
0
ファイル: DLNADmsContentDB.cpp プロジェクト: ACUVE/EDCB
int CDLNADmsContentDB::GetContainerItem(wstring containerObjectID, DLNA_DMS_CONTAINER_INFO* info)
{
	if( lock.Lock(L"CDLNADmsContentDB::GetContainerItem") == FALSE ){
		return ERR_FALSE;
	}

	int ret = NO_ERR;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itr1;

	DLNA_DMS_CONTAINER_ITEM* item = NULL;

	if( CompareNoCase(containerObjectID, L"0") == 0 ){
		item = root;
	}else{
		itr1 = containerList.find(containerObjectID);
		if( itr1 == containerList.end() ){
			ret = ERR_FALSE;
			goto Err_End;
		}
		item = itr1->second;
	}

	info->objectID = item->objectID;
	info->parentObjectID = item->parentObjectID;
	info->uri = rootUri;
	if( item->info != NULL ){
		info->info = *(item->info);
	}

Err_End:
	lock.UnLock();

	return ret;
}
コード例 #4
0
void CParser::parsingWordBlank()
{
    if( token.type == TT_LineFeed ) {
        token.Swap( savedToken1 );
        CRuleParser::BeginFunction(); // action
        state = &CParser::parsingInitial;
        return;
    }
    if( token.type == TT_Word ) {
        if( CDirectiveParser::StartParseIfStartDirective( savedToken1 ) ) {
            state = &CParser::parsingDirective;
            return;
        }
        if( CompareNoCase( token.word, QualifierTag ) ) {
            token.Move( savedToken2 );
            state = &CParser::parsingWordBlankS;
            return;
        }
    }
    token.Swap( savedToken1 );
    if( !CRuleParser::BeginFunction() ) { // action
        state = &CParser::parsingIgnoreLine;
        return;
    }
    token.Swap( savedToken1 );
    state = &CParser::parsingRule;
    AddToken();
}
コード例 #5
0
ファイル: SetDlgBasic.cpp プロジェクト: Z774M/EDEN
void CSetDlgBasic::OnBnClickedButtonRecAdd()
{
	// TODO: ここにコントロール通知ハンドラー コードを追加します。
	UpdateData(TRUE);
	if( recFolderPath.IsEmpty() == true ){
		return ;
	}
	wstring addPath = recFolderPath.GetBuffer(0);
	ChkFolderPath( addPath );

	//同一フォルダがすでにあるかチェック
	int iNum = recFolderList.GetCount();
	BOOL findFlag = FALSE;
	for( int i = 0; i < iNum; i++ ){
		CString folder = L"";
		recFolderList.GetText( i, folder );
		wstring strPath = folder.GetBuffer(0);
		ChkFolderPath( strPath );

		if( CompareNoCase( addPath, strPath ) == 0 ){
			findFlag = TRUE;
			break;
		}
	}
	if( findFlag == FALSE ){
		recFolderList.AddString( addPath.c_str() );
	}

	UpdateData(FALSE);
}
コード例 #6
0
ファイル: ExcelDnaLoader.cpp プロジェクト: DPorras/ExcelDna
HRESULT GetClrOptions(std::wstring& clrVersion, bool& shadowCopyFiles, bool& createSandboxedAppDomain)
{
	HRESULT hr;
	std::wstring header;
	std::wstring addInName;
	std::wstring createSandboxedAppDomainValue;

	hr = GetDnaHeader(true, header);	// Errors will be shown in there.
	if (!FAILED(hr))
	{
		hr = ParseDnaHeader(header, addInName, clrVersion, shadowCopyFiles, createSandboxedAppDomainValue); // No errors yet.
		if (FAILED(hr))
		{
			// XML Parse error
			ShowMessage(IDS_MSG_HEADER_DNAPROBLEM, 
			IDS_MSG_BODY_DNAPARSEFAILED, 
			IDS_MSG_FOOTER_ENSUREDNAFILE,
			hr);

			return E_FAIL;
		}
		
		// Default version expansions
		if (clrVersion == L"v2.0") clrVersion = L"v2.0.50727";
		if (clrVersion == L"v4.0") clrVersion = L"v4.0.30319";

		// Default sandboxedAppDomain options
		if (CompareNoCase(createSandboxedAppDomainValue, L"true") == 0)
		{
			createSandboxedAppDomain = true;
		}
		else if (CompareNoCase(createSandboxedAppDomainValue, L"false") == 0)
		{
			createSandboxedAppDomain = false;
		}
		else
		{
			// Default => true under .NET >= 4.0, else false
			if (CompareNoCase(clrVersion, L"v4.0") >= 0)
				createSandboxedAppDomain = true;
			else
				createSandboxedAppDomain = false;
		}
	}
	return hr;
}
コード例 #7
0
sint_t AFileNode::CompareByExt(const AListNode *pNode1, const AListNode *pNode2, void *context)
{
	const AFileNode *fNode1 = AFileNode::Cast(pNode1);
	const AFileNode *fNode2 = AFileNode::Cast(pNode2);
	uint_t flags = context ? *(uint_t *)context : 0;
	sint_t ret = 0, mul = (flags & SORT_FLAG_REVERSE) ? -1 : 1;
	bool mixed = ((flags & SORT_FLAG_MIXED) != 0);

	if (fNode1 && fNode2) {
		if (mixed || (fNode1->IsDir() == fNode2->IsDir())) {
			ret = mul * CompareNoCase(fNode1->GetShortName().Suffix(), fNode2->GetShortName().Suffix());
			if (ret == 0) ret = mul * CompareNoCase(fNode1->GetShortName(), fNode2->GetShortName());
		}
		else if (fNode1->IsDir()) ret = -1;
		else					  ret =  1;
	}

	return ret;
}
コード例 #8
0
ファイル: DLNAManager.cpp プロジェクト: PyYoshi/EDCB
int CDLNAManager::AddFolderItem(wstring folderPath, wstring parentObjectID)
{
	wstring searchKey = folderPath;
	searchKey += L"\\*";

	WIN32_FIND_DATA findData;
	HANDLE find;

	//指定フォルダのファイル一覧取得
	find = FindFirstFile( searchKey.c_str(), &findData);
	if ( find == INVALID_HANDLE_VALUE ) {
		return FALSE;
	}
	do{
		if( (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ){
			wstring filePath;
			Format(filePath, L"%s\\%s", folderPath.c_str(), findData.cFileName);

			wstring objectID;
			AddFileItem(parentObjectID, filePath, objectID);
		}else{
			if(CompareNoCase(findData.cFileName, L".") != 0 && CompareNoCase(findData.cFileName, L"..") != 0 ){
				wstring subFolderPath;
				Format(subFolderPath, L"%s\\%s", folderPath.c_str(), findData.cFileName);

				DLNA_DMS_CONTAINER_META_INFO info;
				info.title = findData.cFileName;
				info.uploadFolderPath = subFolderPath;
				info.uploadSupportFlag = 0;

				wstring objectID;
				if( this->dms.CreateContainer(parentObjectID, &info, objectID) == NO_ERR){
					AddFolderItem(subFolderPath, objectID);
				}
			}
		}
	}while(FindNextFile(find, &findData));

	FindClose(find);

	return NO_ERR;
}
コード例 #9
0
ファイル: DesignerWin.cpp プロジェクト: dreamsxin/ultimatepp
void DesignLayout(String open_file) {
	Array<LayoutDesigner>& list = GetDesigners();
	for(int i = 0; i < list.GetCount(); i++)
		if(!CompareNoCase(list[i].GetFileName(), open_file))
		{
			list[i].SetWantFocus();
			return;
		}
	LayoutDesigner& ld = list.Add();
	ld.OpenWindow();
	ld.LoadLayoutFile(open_file);
}
コード例 #10
0
// GetSection
// Given a section name, locates that section in the list and returns a pointer
// to it. If the section was not found, returns NULL
t_Section* CDataFile::GetSection(t_Str szSection)
{
   SectionItor s_pos;

   for (s_pos = m_Sections.begin(); s_pos != m_Sections.end(); s_pos++)
      {
         if ( CompareNoCase( (*s_pos).szName, szSection ) == 0 )
            return (t_Section*)&(*s_pos);
      }

   return NULL;
}
コード例 #11
0
// SetFileName
// Set's the m_szFileName member variable. For use when creating the CDataFile
// object by hand (-vs- loading it from a file
void CDataFile::SetFileName(t_Str szFileName)
{
   if (m_szFileName.size() != 0 && CompareNoCase(szFileName, m_szFileName) != 0)
      {
         m_bDirty = true;

         Report(E_WARN, "[CDataFile::SetFileName] The filename has changed from <%s> to <%s>.",
                m_szFileName.c_str(), szFileName.c_str());
      }

   m_szFileName = szFileName;
}
コード例 #12
0
// DeleteSection
// Delete a specific section. Returns false if the section cannot be
// found or true when sucessfully deleted.
bool CDataFile::DeleteSection(t_Str szSection)
{
   SectionItor s_pos;

   for (s_pos = m_Sections.begin(); s_pos != m_Sections.end(); s_pos++)
      {
         if ( CompareNoCase( (*s_pos).szName, szSection ) == 0 )
            {
               m_Sections.erase(s_pos);
               return true;
            }
      }

   return false;
}
コード例 #13
0
// SetSectionComment
// Set the comment for a given section. Returns false if the section
// was not found.
bool CDataFile::SetSectionComment(t_Str szSection, t_Str szComment)
{
   SectionItor s_pos;

   for (s_pos = m_Sections.begin(); s_pos != m_Sections.end(); s_pos++)
      {
         if ( CompareNoCase( (*s_pos).szName, szSection ) == 0 )
            {
               (*s_pos).szComment = szComment;
               m_bDirty = true;
               return true;
            }
      }

   return false;
}
コード例 #14
0
ファイル: DLNADmsContentDB.cpp プロジェクト: ACUVE/EDCB
int CDLNADmsContentDB::CreateContainer(wstring parentObjectID, DLNA_DMS_CONTAINER_META_INFO* info, wstring& objectID)
{
	if( lock.Lock(L"CDLNADmsContentDB::CreateContainer") == FALSE ){
		return ERR_FALSE;
	}

	int ret = NO_ERR;
	map<wstring, DLNA_DMS_CONTENT_ITEM*>::iterator itr1;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itr2;
	wstring id = L"";
	DLNA_DMS_CONTAINER_ITEM* containerInfo = NULL;

	do{
		Format(id, L"%I64d", this->nextObjectID);

		itr1 = contentList.find(id);
		itr2 = containerList.find(id);

		this->nextObjectID++;
	}while(itr1 != contentList.end() || itr2 != containerList.end());

	containerInfo = new DLNA_DMS_CONTAINER_ITEM;
	containerInfo->objectID = id;
	containerInfo->parentObjectID = parentObjectID;
	containerInfo->info = new DLNA_DMS_CONTAINER_META_INFO;
	*containerInfo->info = *info;

	if( CompareNoCase(parentObjectID, L"0") == 0 ){
		containerList.insert(pair<wstring, DLNA_DMS_CONTAINER_ITEM*>(containerInfo->objectID, containerInfo));
		root->childContainer.insert(pair<wstring, DLNA_DMS_CONTAINER_ITEM*>(containerInfo->objectID, containerInfo));
	}else{
		itr2 = containerList.find(parentObjectID);
		if( itr2 == containerList.end() ){
			SAFE_DELETE(containerInfo);
			ret = ERR_FALSE;
			goto Err_End;
		}
		itr2->second->childContainer.insert(pair<wstring, DLNA_DMS_CONTAINER_ITEM*>(containerInfo->objectID, containerInfo));
		containerList.insert(pair<wstring, DLNA_DMS_CONTAINER_ITEM*>(containerInfo->objectID, containerInfo));
	}
	objectID = id;

Err_End:
	lock.UnLock();

	return ret;
}
コード例 #15
0
ファイル: PathUtil.cpp プロジェクト: ACUVE/EDCB
BOOL IsExt(wstring filePath, wstring ext)
{
	if( filePath.empty() == true ){
		return FALSE;
	}
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	WCHAR szFname[_MAX_FNAME];
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( filePath.c_str(), szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFname, _MAX_FNAME, szExt, _MAX_EXT );

	if( CompareNoCase( szExt, ext ) != 0 ){
		return FALSE;
	}

	return TRUE;
}
コード例 #16
0
ファイル: ExcelDnaLoader.cpp プロジェクト: DPorras/ExcelDna
BOOL IsRunningOnCluster()
{
	// Our check is to see if the current process is called Excel.exe.
	// Hopefully this doen't change soon.
	
	TCHAR hostPathName[MAX_PATH];
	DWORD count = GetModuleFileName(NULL, hostPathName, MAX_PATH);

	std::wstring hostPath = hostPathName;
	StripPath(hostPath);

	if (CompareNoCase(hostPath, L"EXCEL.EXE") == 0)
	{
		return false;
	}
	
	return true;
}
コード例 #17
0
ファイル: DLNADmsContentDB.cpp プロジェクト: ACUVE/EDCB
int CDLNADmsContentDB::SearchContainer(wstring virtualPath, wstring& objectID)
{
	if( lock.Lock(L"CDLNADmsContentDB::SearchContainer") == FALSE ){
		return ERR_FALSE;
	}

	int ret = NO_ERR;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itr1;
	DLNA_DMS_CONTAINER_ITEM* parentContainer = root;
	wstring findName;
	wstring buff1 = virtualPath;
	wstring buff2;

	BOOL find = FALSE;
	while( buff1.size() > 0 ){
		Separate(buff1, L"/", findName, buff1);
		if( findName.size() == 0 ){
			continue;
		}
		find = FALSE;
		for( itr1 = parentContainer->childContainer.begin(); itr1 != parentContainer->childContainer.end(); itr1++){
			if( CompareNoCase(itr1->second->info->title, findName ) == 0 ){
				find = TRUE;
				break;
			}
		}
		if( find == TRUE ){
			parentContainer = itr1->second;
			objectID = itr1->first;
		}else{
			ret = ERR_FALSE;
			break;
		}
	}

	if( find == FALSE ){
		objectID = L"";
		ret = ERR_FALSE;
	}

	lock.UnLock();

	return ret;
}
コード例 #18
0
ファイル: ExcelDnaLoader.cpp プロジェクト: DPorras/ExcelDna
// Load the desired Clr version using .Net 4+ the MetaHost interfaces.
HRESULT LoadClrMeta(std::wstring clrVersion, ICLRMetaHost* pMetaHost, ICorRuntimeHost **ppHost)
{
	// Even if we want to load .Net 2.0, we might need to multi-host since .Net 4.0 runtime
	// might also be loaded.

	HRESULT hr = E_FAIL;
	ICLRRuntimeInfoPtr pRuntimeInfo;
	bool needNet40 = (CompareNoCase(clrVersion, L"v4.0") >= 0);

	hr = pMetaHost->GetRuntime(clrVersion.c_str(), IID_ICLRRuntimeInfo, (LPVOID*)&pRuntimeInfo);
	if (FAILED(hr))
	{
		// The version we ask for is not installed.
		// I.e. we want 2.0 but only 4.0 is installed.
		ShowMessage(IDS_MSG_HEADER_VERSIONLOADFAILED, 
					IDS_MSG_BODY_METAHOSTGETRUNTIMEFAILED, 
					IDS_MSG_FOOTER_ENSUREVERSION, 
					hr);
		hr = E_FAIL;
	}
	else
	{
		// Test for mixed file binding issue - try before or after the GetInterface call?
		// Discussed here: http://exceldna.codeplex.com/discussions/253974
		//		HRESULT hrbind = pRuntimeInfo->BindAsLegacyV2Runtime();
		hr = pRuntimeInfo->GetInterface(CLSID_CorRuntimeHost, IID_ICorRuntimeHost, (LPVOID*)ppHost); 
		if (FAILED(hr))
		{
			// Not sure why this would happen???
			ShowMessage( needNet40 ? IDS_MSG_HEADER_NEEDCLR40 : IDS_MSG_HEADER_NEEDCLR20, 
						IDS_MSG_BODY_RUNTIMEGETINTERFACEFAILED, 
						IDS_MSG_FOOTER_UNEXPECTED,
						hr);

			hr = E_FAIL;
		}
		else
		{
			hr = S_OK;
		
		}
	}
	return hr;
}
コード例 #19
0
// DeleteKey
// Delete a specific key in a specific section. Returns false if the key
// cannot be found or true when sucessfully deleted.
bool CDataFile::DeleteKey(t_Str szKey, t_Str szFromSection)
{
   KeyItor k_pos;
   t_Section* pSection;

   if ( (pSection = GetSection(szFromSection)) == NULL )
      return false;

   for (k_pos = pSection->Keys.begin(); k_pos != pSection->Keys.end(); k_pos++)
      {
         if ( CompareNoCase( (*k_pos).szKey, szKey ) == 0 )
            {
               pSection->Keys.erase(k_pos);
               return true;
            }
      }

   return false;
}
コード例 #20
0
// GetKey
// Given a key and section name, looks up the key and if found, returns a
// pointer to that key, otherwise returns NULL.
t_Key*   CDataFile::GetKey(t_Str szKey, t_Str szSection)
{
   KeyItor k_pos;
   t_Section* pSection;

   // Since our default section has a name value of t_Str("") this should
   // always return a valid section, wether or not it has any keys in it is
   // another matter.
   if ( (pSection = GetSection(szSection)) == NULL )
      return NULL;

   for (k_pos = pSection->Keys.begin(); k_pos != pSection->Keys.end(); k_pos++)
      {
         if ( CompareNoCase( (*k_pos).szKey, szKey ) == 0 )
            return (t_Key*)&(*k_pos);
      }

   return NULL;
}
コード例 #21
0
ファイル: DLNADmsContentDB.cpp プロジェクト: ACUVE/EDCB
int CDLNADmsContentDB::DeleteContainer(wstring objectID)
{
	if( lock.Lock(L"CDLNADmsContentDB::DeleteContainer") == FALSE ){
		return ERR_FALSE;
	}

	int ret = NO_ERR;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itr1;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itr2;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itr3;

	if( CompareNoCase(objectID, L"0") == 0 ){
		ret = ERR_FALSE;
		goto Err_End;
	}

	itr1 = containerList.find(objectID);
	if( itr1 == containerList.end() ){
		ret = ERR_FALSE;
		goto Err_End;
	}

	itr2 = containerList.find(itr1->second->parentObjectID);
	if( itr2 == containerList.end() ){
		ret = ERR_FALSE;
		goto Err_End;
	}

	itr3 = itr2->second->childContainer.find(objectID);
	if( itr3 == itr2->second->childContainer.end() ){
		ret = ERR_FALSE;
		goto Err_End;
	}
	itr2->second->childContainer.erase(itr3);

	SAFE_DELETE(itr1->second);
	containerList.erase(itr1);

Err_End:
	lock.UnLock();

	return ret;
}
コード例 #22
0
// SetKeyComment
// Set the comment of a given key. Returns true if the key is not found.
bool CDataFile::SetKeyComment(t_Str szKey, t_Str szComment, t_Str szSection)
{
   KeyItor k_pos;
   t_Section* pSection;

   if ( (pSection = GetSection(szSection)) == NULL )
      return false;

   for (k_pos = pSection->Keys.begin(); k_pos != pSection->Keys.end(); k_pos++)
      {
         if ( CompareNoCase( (*k_pos).szKey, szKey ) == 0 )
            {
               (*k_pos).szComment = szComment;
               m_bDirty = true;
               return true;
            }
      }

   return false;

}
コード例 #23
0
bool CTreeBuilder::GetAsBool(string sSectionPath, bool bDefaultValue)
{
	string sNodeValue;
	bool fNodeValue = bDefaultValue; 
	CTreeNode* pCurrentNode = NodeFind(sSectionPath); 
	if ( pCurrentNode!= NULL)
	{
		sNodeValue = pCurrentNode->GetNodeValue(); 
	}

	if ( CompareNoCase ( sNodeValue, "yes" ) || CompareNoCase ( sNodeValue, "true" ) ||
		CompareNoCase ( sNodeValue, "1" ))
	{
		fNodeValue = true; 
	}
	else if ( CompareNoCase ( sNodeValue, "no" ) || CompareNoCase ( sNodeValue, "false" ) ||
		CompareNoCase ( sNodeValue, "0" ))
	{
		fNodeValue = false; 
	}

	return fNodeValue ;
}
コード例 #24
0
ファイル: HttpPublicFileSend.cpp プロジェクト: HK323232/EDCB
int CHttpPublicFileSend::HttpRequest(string method, string uri, nocase::map<string, string>* headerList, SOCKET clientSock, HANDLE stopEvent)
{
	int ret = 200;
	string buff = "";
	string path = "";
	string rootA = "";
	wstring filePath = L"";
	wstring wbuff = L"";
	map<string, wstring>::iterator itrVPath;
	nocase::map<string, string>::iterator itrHead;
	nocase::map<string, string> httpResHeader;
	__int64 fileSize = 0;
	string contentType = "";
	__int64 offset = 0;
	__int64 endPos = 0;
	map<__int64, __int64> rangeList;

	if( this->folderPath.size() == 0 || this->rootUri.size() == 0){
		ret = 404;
		goto Err_End;
	}
	if( CompareNoCase(method, "GET") != 0 ){
		ret = 404;
		goto Err_End;
	}

	WtoA(this->rootUri, rootA);

	UrlDecode(uri.c_str(), (DWORD)uri.size(), buff);


	//仮想パスから検索
	for(itrVPath = this->virtualPathList.begin(); itrVPath != this->virtualPathList.end(); itrVPath++){
		string key;
		Format(key, "%s/%s/", rootA.c_str(), itrVPath->first.c_str());

		if( buff.find(key) == 0 ){
			Separate(buff, key, buff, path);
			Replace(path, "/", "\\");

			UTF8toW(path, wbuff);

			filePath = itrVPath->second;
			ChkFolderPath(filePath);
			filePath += L"\\";
			filePath += wbuff;
			break;
		}
	}

	if(filePath.size() == 0 ){
		//通常のルート
		Separate(buff, rootA, buff, path);
		Replace(path, "/", "\\");

		UTF8toW(path, wbuff);

		filePath = this->folderPath;
		ChkFolderPath(filePath);
		filePath += L"\\";
		filePath += wbuff;
	}

	if( PathFileExists(filePath.c_str()) == FALSE ){
		ret = 404;
		goto Err_End;
	}

	httpSend.GetContentType(filePath, contentType);
	fileSize = httpSend.GetContentLength(filePath);

	endPos = fileSize;

	itrHead = headerList->find("Range");
	if( itrHead == headerList->end() ){
		//Rangeなし
		Format(buff, "%I64d", fileSize);
		httpResHeader.insert(pair<string, string>("Content-Length", buff));
		httpResHeader.insert(pair<string, string>("Content-Type", contentType));

		httpSend.SendResponseHeader(200, &httpResHeader, clientSock, stopEvent);
		httpSend.SendFile(filePath, offset, endPos, clientSock, stopEvent);
	}else{
		if( httpSend.ParseRangeHeader(fileSize, itrHead->second, &rangeList) == FALSE ){
			//Range指定が何かおかしい
			Format(buff, "%I64d", fileSize);
			httpResHeader.insert(pair<string, string>("Content-Length", buff));
			httpResHeader.insert(pair<string, string>("Content-Type", contentType));

			httpSend.SendResponseHeader(200, &httpResHeader, clientSock, stopEvent);
			httpSend.SendFile(filePath, offset, endPos, clientSock, stopEvent);
		}else{
			httpResHeader.insert(pair<string, string>("Accept-Ranges", "bytes"));
			if( rangeList.size() > 1 ){
				//複数の場所指定
				Format(buff, "multipart/byteranges; boundary=%s", MULTI_PART_BOUNDARY);
				httpResHeader.insert(pair<string, string>("Content-Type", buff));

				httpSend.SendResponseHeader(206, &httpResHeader, clientSock, stopEvent);


				map<__int64, __int64>::iterator itr;
				string boundary = "";
				for( itr = rangeList.begin(); itr != rangeList.end(); itr++ ){
					boundary = "--";
					boundary += MULTI_PART_BOUNDARY;
					boundary += "\r\n";
					Format(buff, "Content-Type: %s\r\n", contentType);
					boundary += buff;
					Format(buff, "Content-Range: bytes %I64d-%I64d/%I64d\r\n", itr->first, itr->second, fileSize);
					boundary += buff;
					boundary += "\r\n";

					if( httpSend.SendData((BYTE*)boundary.c_str(), (DWORD)boundary.size(), clientSock, stopEvent) != NO_ERR ){
						goto End;
					}
					if( httpSend.SendFile(filePath, itr->first, itr->second+1, clientSock, stopEvent) != NO_ERR ){
						goto End;
					}

					boundary = "\r\n";
					httpSend.SendData((BYTE*)boundary.c_str(), (DWORD)boundary.size(), clientSock, stopEvent);
				}
				boundary = "--";
				boundary += MULTI_PART_BOUNDARY;
				boundary += "--\r\n";
				httpSend.SendData((BYTE*)boundary.c_str(), (DWORD)boundary.size(), clientSock, stopEvent);
			}else{
				//一カ所のみ
				map<__int64, __int64>::iterator itr;
				itr = rangeList.begin();

				httpResHeader.insert(pair<string, string>("Content-Type", contentType));
				Format(buff, "bytes %I64d-%I64d/%I64d", itr->first, itr->second, fileSize);
				httpResHeader.insert(pair<string, string>("Content-Range", buff));
				Format(buff, "%I64d", itr->second-itr->first+1);
				httpResHeader.insert(pair<string, string>("Content-Length", buff));

				httpSend.SendResponseHeader(206, &httpResHeader, clientSock, stopEvent);
				httpSend.SendFile(filePath, itr->first, itr->second+1, clientSock, stopEvent);

			}
		}
	}



	return ret;

Err_End:
	httpSend.SendResponseHeader(ret, &httpResHeader, clientSock, stopEvent);
End:
	return ret;
}
コード例 #25
0
ファイル: StringUtils.cpp プロジェクト: KeTao/kodi-cmake
int StringUtils::CompareNoCase(const std::string &str1, const std::string &str2)
{
  return CompareNoCase(str1.c_str(), str2.c_str());
}
コード例 #26
0
ファイル: ExcelDnaLoader.cpp プロジェクト: DPorras/ExcelDna
HRESULT ParseDnaHeader(std::wstring header, std::wstring& addInName, std::wstring& runtimeVersion, bool& shadowCopyFiles, std::wstring& createSandboxedAppDomain)
{
	HRESULT hr;

	size_t rootTagStart = header.find(L"<DnaLibrary");
	if (rootTagStart == -1)
	{
		// Parse error
		return E_FAIL;
	}

	size_t rootTagEnd = header.find(L">", rootTagStart);
	if (rootTagEnd == -1)
	{
		// Parse error
		return E_FAIL;
	}

	std::wstring rootTag = header.substr(rootTagStart, rootTagEnd - rootTagStart + 1);

	// CONSIDER: Some checks, e.g. "v.X..."
	hr = GetAttributeValue(rootTag, L"RuntimeVersion", runtimeVersion);
	if (FAILED(hr))
	{
		// Parse error
		return E_FAIL;
	}
	if (hr == S_FALSE)
	{
		runtimeVersion = CLR_VERSION_20;
		hr = S_OK;
	}

	std::wstring shadowCopyFilesValue;
	hr = GetAttributeValue(rootTag, L"ShadowCopyFiles", shadowCopyFilesValue);
	if (FAILED(hr))
	{
		// Parse error
		return E_FAIL;
	}
	if (hr == S_FALSE)
	{
		shadowCopyFiles = false;
		hr = S_OK;
	}
	else // attribute read OK
	{
		if (CompareNoCase(shadowCopyFilesValue, L"true") == 0)
			shadowCopyFiles = true;
		else
			shadowCopyFiles = false;
	}

	hr = GetAttributeValue(rootTag, L"CreateSandboxedAppDomain", createSandboxedAppDomain);
	if (FAILED(hr))
	{
		// Parse error
		return E_FAIL;
	}
	if (hr == S_FALSE)
	{
		createSandboxedAppDomain = L"";
		hr = S_OK;
	}

	hr = GetAttributeValue(rootTag, L"Name", addInName);
	if (FAILED(hr))
	{
		// Parse error
		return E_FAIL;
	}
	if (hr == S_FALSE)
	{
		addInName = L"";
		hr = S_OK;
	}
	return hr;
}
コード例 #27
0
ファイル: DLNADmsContentDB.cpp プロジェクト: ACUVE/EDCB
int CDLNADmsContentDB::GetChildItem(wstring containerObjectID, vector<DLNA_DMS_CONTAINER_INFO>* childContainerList, vector<DLNA_DMS_CONTENT_INFO>* childContentList)
{
	if( lock.Lock(L"CDLNADmsContentDB::GetChildItem") == FALSE ){
		return ERR_FALSE;
	}

	int ret = NO_ERR;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itr1;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itr2;
	map<wstring, DLNA_DMS_CONTENT_ITEM*>::iterator itr3;

	map<wstring, DLNA_DMS_CONTAINER_ITEM*> sortContainer;
	map<wstring, DLNA_DMS_CONTENT_ITEM*> sortContetn;


	DLNA_DMS_CONTAINER_ITEM* parent = NULL;

	if( CompareNoCase(containerObjectID, L"0") == 0 ){
		parent = root;
	}else{
		itr1 = containerList.find(containerObjectID);
		if( itr1 == containerList.end() ){
			ret = ERR_FALSE;
			goto Err_End;
		}
		parent = itr1->second;
	}

	for( itr2 = parent->childContainer.begin(); itr2 != parent->childContainer.end(); itr2++ ){
		sortContainer.insert(pair<wstring, DLNA_DMS_CONTAINER_ITEM*>(itr2->second->info->title, itr2->second));
	}
	for( itr2 = sortContainer.begin(); itr2 != sortContainer.end(); itr2++ ){
		DLNA_DMS_CONTAINER_INFO item;
		item.objectID = itr2->second->objectID;
		item.parentObjectID = itr2->second->parentObjectID;
		item.uri = rootUri;
		item.info = *(itr2->second->info);

		childContainerList->push_back(item);
	}

	for( itr3 = parent->childContent.begin(); itr3 != parent->childContent.end(); itr3++ ){
		sortContetn.insert(pair<wstring, DLNA_DMS_CONTENT_ITEM*>(itr3->second->info->title, itr3->second));
	}
	for( itr3 = sortContetn.begin(); itr3 != sortContetn.end(); itr3++ ){
		wstring uri = L"";
		Format(uri, L"%s/%s", rootUri.c_str(), itr3->second->objectID.c_str());
		DLNA_DMS_CONTENT_INFO item;
		item.objectID = itr3->second->objectID;
		item.parentObjectID = itr3->second->parentObjectID;
		item.uri = uri;
		item.info = *(itr3->second->info);

		childContentList->push_back(item);
	}

Err_End:
	lock.UnLock();

	return ret;
}
コード例 #28
0
ファイル: ExcelDnaLoader.cpp プロジェクト: DPorras/ExcelDna
// Ensure the CLR is loaded, create a new AppDomain, get the manager loader running,
// and do the ExportInfo hook-up.
bool XlLibraryInitialize(XlAddInExportInfo* pExportInfo)
{
	HRESULT hr;
	ICorRuntimeHostPtr pHost;
	std::wstring clrVersion;
	bool shadowCopyFiles;
	bool createSandboxedAppDomain;
	
	hr = GetClrOptions(clrVersion, shadowCopyFiles, createSandboxedAppDomain);
	if (FAILED(hr))
	{
		// SelectClrVersion shows diagnostic MessageBoxes if needed.
		// Perhaps remember that we are not loaded?
		return 0;
	}
#ifdef _M_X64
	bool allowedVersion = CompareNoCase(clrVersion, L"v4.0") >= 0;
	if (!allowedVersion)
	{
		ShowMessage(IDS_MSG_HEADER_64NET4, 
					IDS_MSG_BODY_64NET4,
					IDS_MSG_FOOTER_ENSUREVERSION,
					hr);
		return 0;
	}
#endif
	hr = LoadClr(clrVersion, &pHost);
	if (FAILED(hr) || pHost == NULL)
	{
		// LoadClr shows diagnostic MessageBoxes if needed.
		// Perhaps remember that we are not loaded?
		return 0;
	}

	// If all is fine now, also start the CLR (always safe to do again).
	hr = pHost->Start();
	if (FAILED(hr))
	{
		ShowMessage(IDS_MSG_HEADER_NEEDCLR20, 
					IDS_MSG_BODY_HOSTSTART,
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}

	// Load (or find) the AppDomain that will contain the add-in
	std::wstring addInFullPath = GetAddInFullPath();
	_AppDomainPtr pAppDomain;
	_AssemblyPtr pLoaderAssembly;
	bool unloadAppDomain;

	hr = LoadAppDomain(pHost, addInFullPath, createSandboxedAppDomain, shadowCopyFiles, pLoaderAssembly, pAppDomain, unloadAppDomain);
	if (FAILED(hr))
	{
		// Message already shown by LoadAppDomain
		return 0;
	}

	_TypePtr pXlAddInType;
	hr = pLoaderAssembly->GetType_2(_bstr_t(L"ExcelDna.Loader.XlAddIn"), &pXlAddInType);
	if (FAILED(hr) || pXlAddInType == NULL)
	{
		ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
					IDS_MSG_BODY_XLADDIN, 
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}

	SafeVariantArray initArgs(3);
	initArgs.lock();
#ifndef _M_X64
	initArgs.setElement(0, (INT32)pExportInfo);
	initArgs.setElement(1, (INT32)hModuleCurrent);
#else
	initArgs.setElement(0, (INT64)pExportInfo);
	initArgs.setElement(1, (INT64)hModuleCurrent);
#endif
	initArgs.setElement(2, SysAllocStringLen(addInFullPath.c_str(), static_cast<UINT>(addInFullPath.length())));
	initArgs.unlock();
	_variant_t initRetVal;
	_variant_t target;
#ifndef _M_X64
	hr = pXlAddInType->InvokeMember_3(_bstr_t("Initialize32"), (BindingFlags)(BindingFlags_Static | BindingFlags_Public | BindingFlags_InvokeMethod), NULL, target, initArgs, &initRetVal);
#else
	hr = pXlAddInType->InvokeMember_3(_bstr_t("Initialize64"), (BindingFlags)(BindingFlags_Static | BindingFlags_Public | BindingFlags_InvokeMethod), NULL, target, initArgs, &initRetVal);
#endif
	if (FAILED(hr) || initRetVal.boolVal == 0)
	{
		ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
					IDS_MSG_BODY_XLADDININIT, 
					IDS_MSG_FOOTER_CHECKINTEGRATION,
					hr);
		return 0;
	}

	// Keep references needed for later host reference unload.
	if (unloadAppDomain)
	{
		pAppDomain_ForUnload = (IUnknown*)pAppDomain.Detach();
	}
	pHost_ForUnload = pHost.Detach();

	return initRetVal.boolVal == 0 ? false : true;
}
コード例 #29
0
ファイル: ExcelDnaLoader.cpp プロジェクト: DPorras/ExcelDna
// Try to get the right version of the CLR running.
HRESULT LoadClr(std::wstring clrVersion, ICorRuntimeHost **ppHost)
{
	// Check whether the .Net 4+ MetaHost interfaces are present.
	// The checks here are according to this blog post: 
	// http://bradwilson.typepad.com/blog/2010/04/selecting-clr-version-from-unmanaged-host.html
	/*
	1. LoadLibrary mscoree
	2. GetProcAddress for CLRCreateInstance. If you get NULL, fall back to legacy path (CorBindToRuntimeEx)
	3. Call CLRCreateInstance to get ICLRMetaHost. If you get E_NOTIMPL, fall back to legacy path (same as above)
	4. Otherwise, party on the ICLRMetaHost you just got
	*/
	// If present, load the desired version using the new interfaces.
	// If not, check if we want .Net 4+, if so fail, else load old-style.

	HRESULT hr = E_FAIL;
	HMODULE hMscoree = NULL;
	ICLRMetaHostPtr pMetaHost;

	bool needNet40 = (CompareNoCase(clrVersion, L"v4.0") >= 0);
	bool needMetaHost = needNet40;

	hMscoree = LoadLibrary(L"mscoree.dll");
	if (hMscoree == 0)
	{
		// No .Net installed
		// CONSIDER: Doing explicit checking according to http://support.microsoft.com/kb/318785
		if (needNet40)
		{
				ShowMessage(IDS_MSG_HEADER_NEEDCLR40, 
					IDS_MSG_BODY_LOADMSCOREE, 
					IDS_MSG_FOOTER_ENSURECLR40 );
		}
		else
		{
				ShowMessage(IDS_MSG_HEADER_NEEDCLR20, 
					IDS_MSG_BODY_LOADMSCOREE, 
					IDS_MSG_FOOTER_ENSURECLR20 );
		}
		hr = E_FAIL;
	}
	else
	{
		pfnCLRCreateInstance CLRCreateInstance = (pfnCLRCreateInstance)GetProcAddress(hMscoree, "CLRCreateInstance");
		if (CLRCreateInstance == 0)
		{
			// Certainly no .Net 4 installed
			if (needMetaHost)
			{
				// We need .Net 4.0 but it is not installed
				ShowMessage(IDS_MSG_HEADER_NEEDCLR40, 
							IDS_MSG_BODY_NOCLRCREATEINSTANCE, 
							IDS_MSG_FOOTER_ENSURECLR40 );
				hr = E_FAIL;
			}
			else
			{
				// We need only .Net 2.0 runtime and cannot MetaHost.
				// Load .Net 2.0 with old code path
				hr = LoadClr20(ppHost);
			}
		}
		else
		{
			hr = CLRCreateInstance(CLSID_CLRMetaHost, IID_ICLRMetaHost, (LPVOID*)&pMetaHost);
			if (FAILED(hr))
			{
				// MetaHost is not available, even though we have a new version of MSCorEE.dll
				// Certainly no .Net 4 installed
				if (needMetaHost)
				{
					// We need .Net 4.0 but it is not installed
					ShowMessage(IDS_MSG_HEADER_NEEDCLR40, 
								IDS_MSG_BODY_CLRCREATEINSTANCEFAILED, 
								IDS_MSG_FOOTER_ENSURECLR40, 
								hr );
					hr = E_FAIL;
				}
				else
				{
					// We need only .Net 2.0 runtime and cannot MetaHost.
					// Load .Net 2.0 with old code path
					hr = LoadClr20(ppHost);
				}
			}
			else
			{
				// Yay! We have a metahost
				hr = LoadClrMeta(clrVersion, pMetaHost, ppHost);
			}
		}
		FreeLibrary(hMscoree);
	}
	return hr;
}
コード例 #30
0
ファイル: DLNADmsContentDB.cpp プロジェクト: ACUVE/EDCB
int CDLNADmsContentDB::CreateContainer2(wstring virtualPath, DLNA_DMS_CONTAINER_META_INFO* info, wstring& objectID)
{
	if( lock.Lock(L"CDLNADmsContentDB::CreateContainer2") == FALSE ){
		return ERR_FALSE;
	}

	int ret = NO_ERR;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itr1;
	DLNA_DMS_CONTAINER_ITEM* parentContainer = root;
	wstring findName;
	wstring buff1 = virtualPath;
	wstring buff2;
	wstring id = L"";
	DLNA_DMS_CONTAINER_ITEM* containerInfo = NULL;

	map<wstring, DLNA_DMS_CONTENT_ITEM*>::iterator itrID1;
	map<wstring, DLNA_DMS_CONTAINER_ITEM*>::iterator itrID2;

	BOOL find = FALSE;
	while( buff1.size() > 0 ){
		Separate(buff1, L"/", findName, buff1);
		if( findName.size() == 0 ){
			continue;
		}
		find = FALSE;
		for( itr1 = parentContainer->childContainer.begin(); itr1 != parentContainer->childContainer.end(); itr1++){
			if( CompareNoCase(itr1->second->info->title, findName ) == 0 ){
				find = TRUE;
				break;
			}
		}
		if( find == FALSE ){
			do{
				Format(id, L"%I64d", this->nextObjectID);

				itrID1 = contentList.find(id);
				itrID2 = containerList.find(id);

				this->nextObjectID++;
			}while(itrID1 != contentList.end() || itrID2 != containerList.end());

			containerInfo = new DLNA_DMS_CONTAINER_ITEM;
			containerInfo->parentObjectID = parentContainer->objectID;
			containerInfo->objectID = id;
			containerInfo->info = new DLNA_DMS_CONTAINER_META_INFO;
			if( buff1.size() == 0){
				*containerInfo->info = *info;
			}else{
				containerInfo->info->title = findName;
				containerInfo->info->uploadSupportFlag = 0;
				containerInfo->info->uploadFolderPath = L"";
			}

			parentContainer->childContainer.insert(pair<wstring, DLNA_DMS_CONTAINER_ITEM*>(containerInfo->objectID, containerInfo));
			containerList.insert(pair<wstring, DLNA_DMS_CONTAINER_ITEM*>(containerInfo->objectID, containerInfo));

			objectID = containerInfo->objectID;
		}else{
			objectID = itr1->first;
			parentContainer = itr1->second;
		}
	}

	lock.UnLock();

	return ret;
}