Exemplo n.º 1
0
void CProjectDoc::Serialize(CArchive& ar)
{
   CProjectView* pview = GetProjectView();
   int i, l;

   if (ar.IsStoring())
   {  // Output
#ifdef _UNICODE
      _TCHAR uniflag = 0xfeff;  // written as fffe, which is right for PC unicode
      ar.Write(&uniflag, 2);
#endif
      pview->UpdateData(TRUE);
      ar.WriteString(_T("amzirel=4"));  // so we can check for valid ppj files
      ar.WriteString(CRLF);
      ar.WriteString(_T("xplfile="));
      ar.WriteString(pview->m_xplfile);
      ar.WriteString(CRLF);
      ar.WriteString(_T("directory="));
      ar.WriteString(pview->m_directory);
      ar.WriteString(CRLF);
      ar.WriteString(_T("opdefs="));
      ar.WriteString(pview->m_opdefs);
      ar.WriteString(CRLF);

      CListBox* pLB;
      CString s;

      pLB = (CListBox*)(pview->GetDlgItem(IDP_FILELIST));
      l = pLB->GetCount();
      for (i=0; i<l; i++)
      {
         pLB->GetText(i, s);
         ar.WriteString(_T("file="));
         ar.WriteString(s);
         ar.WriteString(CRLF);
      }

      pLB = (CListBox*)(pview->GetDlgItem(IDP_LIBLIST));
      l = pLB->GetCount();
      for (i=0; i<l; i++)
      {
         pLB->GetText(i, s);
         ar.WriteString(_T("library="));
         ar.WriteString(s);
         ar.WriteString(CRLF);
      }

      SaveOpenFiles(ar);
   }
   else
   {  // Input
      ReadArchive(ar);
   }
}
Exemplo n.º 2
0
void CHashDatabase::Serialize(CArchive& ar, CTigerTree* pTree)
{
	if ( ar.IsLoading() )
	{
		uint32 nHeight = 0;
		ar >> nHeight;
		pTree->SetHeight( nHeight );
		if ( uint32 nSize = pTree->GetSerialSize() )
		{
			auto_array< uchar > pBuf( new uchar[ nSize ] );
			ReadArchive( ar, pBuf.get(), nSize );
			pTree->Load( pBuf.get() );
		}
	}
Exemplo n.º 3
0
void CSecureRule::Serialize(CArchive& ar, int /*nVersion*/)
{
	if ( ar.IsStoring() )
	{
		ar << (int)m_nType;
		ar << m_nAction;
		ar << m_sComment;

		ar.Write( &m_pGUID, sizeof( GUID ) );

		ar << m_nExpire;
		ar << m_nEver;

		if ( m_nType == srAddress )
		{
			ar.Write( m_nIP, 4 );
			ar.Write( m_nMask, 4 );
		}
		else
		{
			ar << GetContentWords();
		}
	}
	else // Loading
	{
		int nType;
		ar >> nType;
		m_nType = (RuleType)nType;

		ar >> m_nAction;
		ar >> m_sComment;

		//if ( nVersion < 4 )
		//	CoCreateGuid( &m_pGUID );
		//else
			ReadArchive( ar, &m_pGUID, sizeof( GUID ) );

		ar >> m_nExpire;
		ar >> m_nEver;

		if ( m_nType == srAddress )
		{
			ReadArchive( ar, m_nIP, 4 );
			ReadArchive( ar, m_nMask, 4 );
			MaskFix();					// Make sure old rules are updated to new format (obsolete?)
		}
		else
		{
			//if ( nVersion < 5 )		// Map RuleType enum changes
			//{
			//	BYTE foo;
			//	ar >> foo;
			//	switch ( foo )
			//	{
			//	case 1:
			//		m_nType = srContentAll;
			//		break;
			//	case 2:
			//		m_nType = srContentRegExp;
			//		break;
			//	}
			//
			//	if ( nVersion < 3 )
			//	{
			//		for ( DWORD_PTR nCount = ar.ReadCount(); nCount > 0; nCount-- )
			//		{
			//			CString strWord;
			//			ar >> strWord;
			//			strTemp += L' ' + strWord;
			//		}
			//	}
			//}

			CString str;
			ar >> str;
			SetContentWords( str );
		}
	}
}
Exemplo n.º 4
0
int PluginClass::GetFindData(PluginPanelItem **pPanelItem,int *pItemsNumber,int OpMode)
{
  HANDLE ArcFindHandle;
  WIN32_FIND_DATA NewArcFindData;
  ArcFindHandle=FindFirstFile(ArcName,&NewArcFindData);
  FindClose(ArcFindHandle);

  if (ArcFindHandle==INVALID_HANDLE_VALUE)
    return FALSE;

  if (CompareFileTime(&NewArcFindData.ftLastWriteTime,&ArcFindData.ftLastWriteTime)!=0 ||
      NewArcFindData.nFileSizeLow!=ArcFindData.nFileSizeLow || ArcData==NULL)
  {
    BOOL ReadArcOK=FALSE;
    DWORD size = (DWORD)Info.AdvControl(Info.ModuleNumber,ACTL_GETPLUGINMAXREADDATA,(void *)0);
    HANDLE h=CreateFile(ArcName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
    if (h!=INVALID_HANDLE_VALUE)
    {
      unsigned char *Data=new unsigned char[size];
      DWORD read;
      int ret = ReadFile(h, Data, size, &read, 0);
      CloseHandle(h);
      if (Data && ret)
      {
        DWORD SFXSize;
        if (ArcPlugin->IsArchive(ArcPluginNumber, ArcName, Data, read, &SFXSize))
        {
          ReadArcOK=ReadArchive(ArcName);
        }
      }
      delete[] Data;
    }
    if (!ReadArcOK) return FALSE;
  }
  int CurDirLength=lstrlen(CurDir);
  *pPanelItem=NULL;
  *pItemsNumber=0;
  int AlocatedItemsNumber=0;
  for (int I=0;I<ArcDataCount;I++)
  {
    char Name[NM];
    PluginPanelItem CurItem=ArcData[I];
    BOOL Append=FALSE;
    lstrcpy(Name,CurItem.FindData.cFileName);

    if (Name[0]=='\\')
      Append=TRUE;

    if (Name[0]=='.' && (Name[1]=='\\' || (Name[1]=='.' && Name[2]=='\\')))
      Append=TRUE;

    if (!Append && lstrlen(Name)>CurDirLength && FSF.LStrnicmp(Name,CurDir,CurDirLength)==0 && (CurDirLength==0 || Name[CurDirLength]=='\\'))
    {
      char *StartName,*EndName;
      StartName=Name+CurDirLength+(CurDirLength!=0);

      if ((EndName=strchr(StartName,'\\'))!=NULL)
      {
        *EndName=0;
        CurItem.FindData.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY;
        CurItem.FindData.nFileSizeLow=CurItem.PackSize=0;
      }

      lstrcpy(CurItem.FindData.cFileName,StartName);
      Append=TRUE;

      if (CurItem.FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
      {
        for (int J=0; J < *pItemsNumber; J++)
          if ((*pPanelItem)[J].FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            if (FSF.LStricmp(CurItem.FindData.cFileName,(*pPanelItem)[J].FindData.cFileName)==0)
            {
              Append=FALSE;
              (*pPanelItem)[J].FindData.dwFileAttributes |= CurItem.FindData.dwFileAttributes;
            }
      }
    }

    if (Append)
    {
      PluginPanelItem *NewPanelItem=*pPanelItem;
      if (*pItemsNumber>=AlocatedItemsNumber)
      {
        AlocatedItemsNumber=AlocatedItemsNumber+256+AlocatedItemsNumber/4;
        NewPanelItem=(PluginPanelItem *)realloc(*pPanelItem,AlocatedItemsNumber*sizeof(PluginPanelItem));

        if (NewPanelItem==NULL)
          break;

        *pPanelItem=NewPanelItem;
      }
      NewPanelItem[*pItemsNumber]=CurItem;
      (*pItemsNumber)++;
    }
  }
  if (*pItemsNumber>0)
    *pPanelItem=(PluginPanelItem *)realloc(*pPanelItem,*pItemsNumber*sizeof(PluginPanelItem));
  return TRUE;
}
Exemplo n.º 5
0
void CDownloadSource::Serialize(CArchive& ar, int nVersion /* DOWNLOAD_SER_VERSION */)
{
	if ( ar.IsStoring() )
	{
		ar << m_sURL;
		ar << m_nProtocol;
		
		SerializeOut( ar, m_oGUID );
		
		ar << m_nPort;
		if ( m_nPort ) ar.Write( &m_pAddress, sizeof(m_pAddress) );
		ar << m_nServerPort;
		if ( m_nServerPort ) ar.Write( &m_pServerAddress, sizeof(m_pServerAddress) );
		
		ar << m_sName;
		ar << m_nIndex;
		ar << m_bHashAuth;
		ar << m_bSHA1;
		ar << m_bTiger;
		ar << m_bED2K;
		ar << m_bBTH;
		ar << m_bMD5;
		
		ar << m_sServer;
		ar << m_sNick;
		ar << m_sCountry;
		ar << m_sCountryName;
		ar << m_nSpeed;
		ar << m_bPushOnly;
		ar << m_bCloseConn;
		ar << m_bReadContent;
		ar.Write( &m_tLastSeen, sizeof(FILETIME) );
		
        SerializeOut2( ar, m_oPastFragments );

		ar << m_bClientExtended;
		ar << m_bMetaIgnore;
	}
	else if ( nVersion >= 21 )
	{
		ar >> m_sURL;
		ar >> m_nProtocol;
		
		SerializeIn( ar, m_oGUID, nVersion);
		
		ar >> m_nPort;
		if ( m_nPort ) ReadArchive( ar, &m_pAddress, sizeof(m_pAddress) );
		ar >> m_nServerPort;
		if ( m_nServerPort ) ReadArchive( ar, &m_pServerAddress, sizeof(m_pServerAddress) );
		
		ar >> m_sName;
		ar >> m_nIndex;
		ar >> m_bHashAuth;
		ar >> m_bSHA1;
		ar >> m_bTiger;
		ar >> m_bED2K;
		if ( nVersion >= 37 )
		{
			ar >> m_bBTH;
			ar >> m_bMD5;
		}