Ejemplo n.º 1
0
//+------------------------------------------------------------------------
//
//  Member:     BuildNamedArray
//
//  Synopsis:   Fills in an array based on names found in the array of the
//              given index.
//              If we are building a named array on the ELEMENT_COLLECTION
//              we check if we have already created a collection of all
//              named elements, if not, we build it, if yes, we use this
//              collection to access all named elements
//
//  Result:     S_OK
//              E_OUTOFMEMORY
//
//  Note: It is now the semantics of this function to always return a
//        named array (albeit with a size of 0) instead of returning
//        DISPID_MEMBERNOTFOUND.  This allows for Tags to return an empty
//        collection.
//-------------------------------------------------------------------------
HRESULT CCollectionCache::BuildNamedArray(
          long      lCollectionIndex,
          LPCTSTR   Name,
          BOOL      fTagName,
          CCollectionCacheItem* pIntoCacheItem,
          long      iStartFrom,
          BOOL      fCaseSensitive,
          BOOL      fUrn /*=FALSE*/)
{
    HRESULT                 hr = S_OK;
    CElement*               pElem;
    CCollectionCacheItem*   pFromCacheItem;
    BOOL                    fAddElement;

    Assert(lCollectionIndex>=0 && lCollectionIndex<_aryItems.Size());
    Assert(pIntoCacheItem);

    pFromCacheItem = _aryItems[lCollectionIndex]._pCacheItem;
    pIntoCacheItem->ResetContents(); 

    for(pFromCacheItem->MoveTo(iStartFrom); ;)
    {
        pElem = pFromCacheItem->GetNext();
        if(!pElem)
        {
            break;
        }

        if(fUrn)
        {
            // 'Name' is the Urn we are looking for.  Check if this element has the requested Urn
            /*fAddElement = pElem->HasPeerWithUrn(Name); wlw note*/
        }
        else if(CompareName(pElem, Name, fTagName, fCaseSensitive))
        {
            fAddElement = TRUE;
        }
        else
        {
            fAddElement = FALSE;
        }

        if(fAddElement)
        {
            hr = pIntoCacheItem->AppendElement(pElem);
            if(hr)
            {
                goto Cleanup;
            }
        }
    } 

Cleanup:
    RRETURN(hr);
}
Ejemplo n.º 2
0
bool DumpWrapper<T>::Compare(DumpBuffer& buffer, float threshold, OutputFormat output, size_t length , size_t stride ,size_t start)
{


  if(!CompareName(buffer)) return false;
  if(!CompareSize(buffer)){ 
    cout << "Buffer " << getName() << " differ in number of elements: " << getSize()/sizeof(T) << " / " << buffer.getSize()/sizeof(T) <<   endl;
    return false;
  }
 
  
  return CompareData((void*)buffer.getData(), threshold, output, length ,stride ,start);
  
}
Ejemplo n.º 3
0
bool DumpBuffer::Compare(DumpBuffer& buffer, float threshold, OutputFormat output, size_t length , size_t stride ,size_t start)
{


  if(!CompareName(buffer)) return false;
  if(!CompareSize(buffer)){ 
    cout << "Buffer " << getName() << " differ in size: " << getSize() << " / " << buffer.getSize() << " Bytes" <<  endl;
    return false;
  }
 
  
  return CompareData((void*)buffer.getData(), threshold, output, length ,stride ,start);
  
}
Ejemplo n.º 4
0
// Get the CA which signed the certificate
X *FindCaSignedX(LIST *o, X *x)
{
	X *ret;
	// Validate arguments
	if (o == NULL || x == NULL)
	{
		return NULL;
	}

	ret = NULL;

	LockList(o);
	{
		UINT i;
		for (i = 0;i < LIST_NUM(o);i++)
		{
			X *ca = LIST_DATA(o, i);
			if (CheckXDateNow(ca))
			{
				if (CompareName(ca->subject_name, x->issuer_name))
				{
					K *k = GetKFromX(ca);
					if (k != NULL)
					{
						if (CheckSignature(x, k))
						{
							ret = CloneX(ca);
						}
						FreeK(k);
					}
				}
				else if (CompareX(ca, x))
				{
					ret = CloneX(ca);
				}
			}

			if (ret != NULL)
			{
				break;
			}
		}
	}
	UnlockList(o);

	return ret;
}
Ejemplo n.º 5
0
//+------------------------------------------------------------------------
//
//  Member:     GetDisp
//
//  Synopsis:   Get a dispatch ptr on an element from the cache.
//      Return the nth element that mathces the name
//
//-------------------------------------------------------------------------
HRESULT CCollectionCache::GetDisp(
          long          lIndex,
          LPCTSTR       Name,
          long          lNthElement,
          IDispatch**   ppdisp,
          BOOL          fCaseSensitive)
{
    long                    lSize,l;
    HRESULT                 hr = DISP_E_MEMBERNOTFOUND;
    CCollectionCacheItem*   pItem;
    CElement*               pElem;

    Assert((lIndex>=0) && (lIndex<_aryItems.Size()));
    Assert(ppdisp);

    pItem = _aryItems[lIndex]._pCacheItem;

    *ppdisp = NULL;

    // if lIndexElement is too large, just pretend we
    //  didn't find it rather then erroring out
    if(lNthElement < 0)
    {
        hr = E_INVALIDARG;
        goto Cleanup;
    }

    lSize = pItem->Length();

    if(lNthElement >= lSize)
    {
        goto Cleanup;
    }

    for(l=0; l<lSize; ++l)
    {
        pElem = pItem->GetAt(l);
        Assert(pElem);
        if(CompareName(pElem, Name, FALSE, fCaseSensitive) && !lNthElement--)
        {
            RRETURN(pElem->QueryInterface(IID_IDispatch, (void**)ppdisp));
        }
    }

Cleanup:
    RRETURN(hr);
}
Ejemplo n.º 6
0
// Get the root certificate that signed the specified certificate from the list
X *GetIssuerFromList(LIST *cert_list, X *cert)
{
	UINT i;
	X *ret = NULL;
	// Validate arguments
	if (cert_list == NULL || cert == NULL)
	{
		return NULL;
	}

	for (i = 0;i < LIST_NUM(cert_list);i++)
	{
		X *x = LIST_DATA(cert_list, i);
		// Name comparison
		if (CheckXDateNow(x))
		{
			if (CompareName(x->subject_name, cert->issuer_name))
			{
				// Get the public key of the root certificate
				K *k = GetKFromX(x);

				if (k != NULL)
				{
					// Check the signature
					if (CheckSignature(cert, k))
					{
						ret = x;
					}
					FreeK(k);
				}
			}
		}
		if (CompareX(x, cert))
		{
			// Complete identical
			ret = x;
		}
	}

	return ret;
}
Ejemplo n.º 7
0
 void Visit(const Waypoint &waypoint) {
   if (CompareType(waypoint, type_index) &&
       (filter_data.distance_index == 0 || CompareName(waypoint, name)) &&
       CompareDirection(waypoint, direction_index, location, heading))
     waypoint_list.push_back(WaypointListItem(waypoint));
 }
Ejemplo n.º 8
0
/*
函数功能:	根据文件(夹)名在文件夹中寻找文件(夹),如果找到则获取文件(夹)参数
参数	:	CurDir		结构体指针,当前文件夹
			Target		结构体指针,目标文件(夹)
			Target_Name	目标文件(夹)名
			Object		FILE或DIR,用于区分目标是文件还是文件夹
返回值	:	FILE_EXIST或FILE_NOTEXIST
*/
FS_Status Search_inDir(FS_Object 	*CurDir,		
					   FS_Object 	*Target,		
					   u8 			*Target_Name,
					   u8			Object)		
{	
	DIR_tag	*DirTag;	 
	LongDir_Ent	*LongDirEnt;
	u32		CurClus;
	u16		CurEntAddr;
   	u8		CurSec,LngNmCnt,DirEntCnt;
	u16		Name_Buffer[53]; //最多容纳4个目录项 共52个Unicode字符
	u8		*Name;

	Name_Buffer[52]=0;
	CurClus=CurDir->FstClus;
	LngNmCnt=4;
	DirEntCnt=4;
	do
	{
		/***** Read and Scan FS_Object Data Aera by Sector ******/
		for(CurSec=0;CurSec<FS.Sec_PerClus;CurSec++)
		{
			ReadSec(CurClus,CurSec,FS_Buffer);
	
			/***** Scan Every DirEntry , 32 Bytes per DirEntry! *****/
			for(CurEntAddr=0;CurEntAddr<BYTES_PERSEC;CurEntAddr+=DIRENT_SIZE)
			{
				DirTag=(DIR_tag*)((u32)FS_Buffer+CurEntAddr);
	
				if(DirTag->FileName[0]==EMPTY)
				{
					return	FILE_NOTEXIST;
				}

				if(DirTag->FileName[0]!=DELETED)
				{
					if(DirTag->Attribute==LONG_NAME)
					{		   
						if(LngNmCnt!=0)
						{	
							LngNmCnt--;
							LongDirEnt=(LongDir_Ent*)DirTag;
							Name=(u8 *)Name_Buffer+LngNmCnt*26;
							CopyRam(LongDirEnt->Name1,Name,10);
							CopyRam(LongDirEnt->Name2,Name+10,12);
							CopyRam(LongDirEnt->Name3,Name+22,4);
						}
					}
					else if(DirTag->Attribute&Object)
					{
						if(LngNmCnt!=4)
						{
							LngNmCnt=4;
							Convert_LngNm(Name);
						}
						else
						{	
							Name=(u8 *)Name_Buffer;
							CopyRam(DirTag->FileName,Name,11);
							Convert_ShortNm(Name);
						}
						
						if(CompareName(Name,Target_Name)==SUCCESSED)
						{
							Target->Name	=Target_Name;
							Target->Attrib	=DirTag->Attribute;
							Target->Size	=DirTag->FileLength;
							Target->FstClus=DirTag->FstClusHI;
							Target->FstClus<<=16;
							Target->FstClus+=DirTag->FstClusLO;
							Target->DirEntryAddr=Get_ClusAddr(CurClus)
													 +CurSec*BYTES_PERSEC
													 +CurEntAddr;
							Target->CurClus=Target->FstClus;
							Target->CurSec=0;
							return FILE_EXIST;
						}
	
					}
					if(LngNmCnt!=4)
					{
						DirEntCnt--;
					}
					if(LngNmCnt!=DirEntCnt)
					{
						LngNmCnt=4;
						DirEntCnt=4;
					}
				}	
			}
		}
		CurClus=Read_NextClusNum(CurClus);
	}
	while(CurClus!=0x0fffffff);
	
	return	FILE_NOTEXIST;				
}
Ejemplo n.º 9
0
//+------------------------------------------------------------------------
//
//  Member:     GetIntoAry
//
//  Synopsis:   Return the element with a given name
//
//  Returns:    S_OK, if it found the element.  *ppNode is set
//              S_FALSE, if multiple elements w/ name were found.
//                  *ppNode is set to the first element in list.
//              Other errors.
//-------------------------------------------------------------------------
HRESULT CCollectionCache::GetIntoAry(
         long lCollectionIndex,
         LPCTSTR Name,
         BOOL fTagName,
         CElement** ppElem,
         long iStartFrom/*=0*/,
         BOOL fCaseSensitive/*=FALSE*/)
{
    HRESULT                 hr = S_OK;
    CElement*               pElemFirstMatched = NULL;
    CElement*               pElemLastMatched = NULL;
    CElement*               pElem;
    CCollectionCacheItem*   pCacheItem = _aryItems[lCollectionIndex]._pCacheItem;
    BOOL                    fLastOne = FALSE;

    Assert(ppElem);
    *ppElem = NULL;

    if(iStartFrom == -1)
    {
        iStartFrom = 0;
        fLastOne = TRUE;
    }

    for(pCacheItem->MoveTo(iStartFrom); ;)
    {
        pElem = pCacheItem->GetNext();
        if(!pElem)
        {
            break;
        }
        if(CompareName(pElem, Name, fTagName, fCaseSensitive))
        {
            if(!pElemFirstMatched)
            {
                pElemFirstMatched = pElem;
            }
            pElemLastMatched = pElem;
        }
    }

    if(!pElemLastMatched)
    {
        hr = DISP_E_MEMBERNOTFOUND;

        if(pCacheItem->IsRangeSyntaxSupported())
        {
            CCellRangeParser cellRangeParser(Name);
            if(!cellRangeParser.Failed())
            {
                hr = S_FALSE; // for allowing expando and properties/methods on the collection (TABLE_CELL_COLLECTION)
            }
        }

        goto Cleanup;
    }

    // A collection can be marked to always return the last matching name,
    // rather than the default first matching name.
    if(DoGetLastMatchedName(lCollectionIndex))
    {
        *ppElem = pElemLastMatched;
    }
    else
    {
        // The iStartFrom has higher precedence on which element we really
        // return first or last in the collection.
        *ppElem = fLastOne ? pElemLastMatched : pElemFirstMatched;
    }

    // return S_FALSE if we have more than one element that matced
    hr = (pElemFirstMatched==pElemLastMatched ) ? S_OK : S_FALSE;

Cleanup:
    RRETURN1(hr, S_FALSE);
}