Beispiel #1
0
bool CTag::WriteTagToFile(CFileDataIO* file, EUtf8Str eStrEncode) const
{
	ASSERT_VALID(this);

	// don't write tags of unknown types, we wouldn't be able to read them in again 
	// and the met file would be corrupted
	if (IsStr() || IsInt() || IsFloat() || IsBlob() || IsInt64())
	{
		file->WriteUInt8(m_uType);
		
		if (m_pszName)
		{
			UINT taglen = strlen(m_pszName);
			file->WriteUInt16((uint16)taglen);
			file->Write(m_pszName, taglen);
		}
		else
		{
			file->WriteUInt16(1);
			file->WriteUInt8(m_uName);
		}

		if (IsStr())
		{
			file->WriteString(GetStr(), eStrEncode);
		}
		else if (IsInt())
		{
			file->WriteUInt32((uint32)m_uVal);
		}
		else if (IsInt64(false))
		{
			file->WriteUInt64(m_uVal);
		}
		else if (IsFloat())
		{
			file->Write(&m_fVal, 4);
		}
		else if (IsBlob())
		{
			// NOTE: This will break backward compatibility with met files for eMule versions prior to 0.44a
			file->WriteUInt32(m_nBlobSize);
			file->Write(m_pData, m_nBlobSize);
		}
		//TODO: Support more tag types
		else
		{
			TRACE("%s; Unknown tag: type=0x%02X\n", __FUNCTION__, m_uType);
			ASSERT(0);
			return false;
		}
		return true;
	}
	else
	{
		TRACE("%s; Ignored tag with unknown type=0x%02X\n", __FUNCTION__, m_uType);
		ASSERT(0);
		return false;
	}
}
Beispiel #2
0
PL_blob_data(atom_t a, size_t *len, struct PL_blob_t **type)
{
  Atom x = SWIAtomToAtom(a);

  if (!IsBlob(x)) {
    if (IsWideAtom(x)) {
      if ( len )
	*len = wcslen(x->WStrOfAE);
      if ( type )
	*type = &unregistered_blob_atom;
      return x->WStrOfAE;
    }
    if ( len )
      *len = strlen(x->StrOfAE);
      if ( type )
	*type = &unregistered_blob_atom;
      return x->StrOfAE;
  }
  if ( len )
    *len = x->rep.blob[0].length;
  if ( type )
    *type = RepBlobProp(x->PropsOfAE)->blob_t;

  return x->rep.blob[0].data;
}
Beispiel #3
0
int wxOdbcResultSet::GetFieldLength(int nField)
{
    // Some ODBC drivers (i.e. MS SQL SERVER) need the fields to be retrieved in order
    for (int ctr = 1; ctr <= nField; ctr++)
    {
        if (m_fieldValues[ctr-1].IsNull())
        {
            if (!IsBlob(ctr))
            {
                RetrieveFieldData(ctr);
            }
            else
            {
                wxMemoryBuffer buffer;
                GetResultBlob(ctr, buffer);
            }
        }
    }
    /*
    if (m_fieldValues[nField-1].IsNull())
        RetrieveFieldData(nField);
        */

    wxString strValue = m_fieldValues[nField-1].GetString();

    strValue = strValue.Trim();
    size_t real_size = strValue.Length();

    return real_size;
}
Beispiel #4
0
YAP_find_blob_type(YAP_Atom at)
{
  AtomEntry *a = RepAtom((Atom)at);
  if (!IsBlob(a)) {
    return &unregistered_blob_atom;
  }
  return RepBlobProp(a->PropsOfAE)->blob_t;
}
Beispiel #5
0
CTag::~CTag()
{
	if (IsStr()) {
		delete m_pstrVal;
	} else if (IsHash()) {
		delete m_hashVal;
	} else if (IsBlob() || IsBsob()) {
		delete[] m_pData;
	} 
}
Beispiel #6
0
CTag::~CTag()
{
	delete[] m_pszName;
	if (IsStr())
		delete m_pstrVal;
	else if (IsHash())
		delete[] m_pData;
	else if (IsBlob())
		delete[] m_pData;
}
Beispiel #7
0
static void
clean_atom_list(AtomHashEntry *HashPtr)
{
  Atom atm = HashPtr->Entry;
  Atom *patm = &(HashPtr->Entry);
  while (atm != NIL) {
    AtomEntry *at =  RepAtom(atm);
    if (AtomResetMark(at) ||
	( at->PropsOfAE != NIL && !IsBlob(at) ) ||
	(GLOBAL_AGCHook != NULL && !GLOBAL_AGCHook(atm))) {
      patm = &(at->NextOfAE);
      atm = at->NextOfAE;
    } else {
      NOfAtoms--;
      if (IsBlob(atm)) {
	BlobPropEntry *b = RepBlobProp(at->PropsOfAE);
	if (b->NextOfPE != NIL) {
	  patm = &(at->NextOfAE);
	  atm = at->NextOfAE;
	  continue;
	}
	NOfAtoms++;
	NOfBlobs--;
	Yap_FreeCodeSpace((char *)b);
	GLOBAL_agc_collected += sizeof(BlobPropEntry);
	GLOBAL_agc_collected += sizeof(AtomEntry)+sizeof(size_t)+at->rep.blob->length;
      } else if (IsWideAtom(atm)) {
#ifdef DEBUG_RESTORE3
	fprintf(stderr, "Purged %p:%S\n", at, at->WStrOfAE);
#endif
	GLOBAL_agc_collected += sizeof(AtomEntry)+wcslen(at->WStrOfAE);
      } else {
#ifdef DEBUG_RESTORE3
	fprintf(stderr, "Purged %p:%s patm=%p %p\n", at, at->StrOfAE, patm, at->NextOfAE);
#endif
	GLOBAL_agc_collected += sizeof(AtomEntry)+strlen(at->StrOfAE);
      }
      *patm = atm = at->NextOfAE;
      Yap_FreeCodeSpace((char *)at);
    }
  }
}
Beispiel #8
0
void CTag::AssertValid() const
{
	CObject::AssertValid();

	ASSERT( m_uType != 0 );
	ASSERT( m_uName != 0 && m_pszName == NULL || m_uName == 0 && m_pszName != NULL );
	ASSERT( m_pszName == NULL || AtlIsValidString(m_pszName) );
	if (IsStr())
		ASSERT( m_pstrVal != NULL && AtlIsValidString(*m_pstrVal) );
	else if (IsHash())
		ASSERT( m_pData != NULL && AtlIsValidAddress(m_pData, 16) );
	else if (IsBlob())
		ASSERT( m_pData != NULL && AtlIsValidAddress(m_pData, m_nBlobSize) );
}
Beispiel #9
0
// get field
bool wxOdbcResultSet::IsFieldNull(int nField)
{
  // Some ODBC drivers (i.e. MS SQL SERVER) need the fields to be retrieved in order
  for (int ctr = 1; ctr < nField; ctr++)
  {
    if (m_fieldValues[ctr-1].IsNull())
    {
      if (IsBlob(ctr))
      {
        wxMemoryBuffer buffer;
        GetResultBlob(ctr, buffer);
      }
      else
      {
        RetrieveFieldData(ctr);
      }
    }
  }

  if (!IsBlob(nField))
  {
    if (m_RetrievedValues.find(nField) == m_RetrievedValues.end())
    {
      RetrieveFieldData(nField);
    }
  }
  else
  {
    wxMemoryBuffer buffer;
    void* pBlob = GetResultBlob(nField, buffer);
    if (pBlob == NULL)
      m_NullValues.insert(nField);
  }

  return (m_NullValues.find(nField) != m_NullValues.end());
}
Beispiel #10
0
bool CTag::WriteTagToFile(CFileDataIO* file, EUtf8Str WXUNUSED(eStrEncode), bool restrictive) const
{
	
	// Don't write tags of unknown types, we wouldn't be able to read them in again 
	// and the met file would be corrupted
	if (!restrictive || (IsStr() || IsInt() || IsFloat() || IsBlob())) {
	
		// If this fails, it'll throw.
		file->WriteTag(*this);
		return true;

	} else {
		printf("%s; Ignored tag with unknown type=0x%02X\n", __FUNCTION__, m_uType);
		return false;
	}
}
Beispiel #11
0
bool YAP_is_blob(Term t, blob_type_t **type) {
  CACHE_REGS
  Term yt = Yap_GetFromSlot(t);
  Atom a;
  YAP_BlobPropEntry *b;

  if (IsVarTerm(yt))
    return FALSE;
  if (!IsAtomTerm(yt))
    return FALSE;
  a = AtomOfTerm(yt);
  if (!IsBlob(a))
    return FALSE;
  b = RepBlobProp(a->PropsOfAE);
  *type = b->blob_type;
  return TRUE;
}
Beispiel #12
0
PL_is_blob(term_t t, PL_blob_t **type)
{
  CACHE_REGS
  Term yt = Yap_GetFromSlot(t PASS_REGS);
  Atom a;
  BlobPropEntry *b;

  if (IsVarTerm(yt))
    return FALSE;
  if (!IsAtomTerm(yt))
    return FALSE;
  a = AtomOfTerm(yt);
  if (!IsBlob(a))
    return FALSE;
  b = RepBlobProp(a->PropsOfAE);
  *type = b->blob_t;
  return TRUE;
}
Beispiel #13
0
const byte* CTag::GetBlob() const
{
	CHECK_TAG_TYPE(IsBlob(), Blob);
	
	return m_pData;
}
Beispiel #14
0
uint32 CTag::GetBlobSize() const
{
	CHECK_TAG_TYPE(IsBlob(), Blob);
	
	return m_nSize;
}