Ejemplo n.º 1
0
int CLocalSearch::ExecuteSharedFiles(int nMaximum)
{
	CQuickLock oLock( Library.m_pSection );
	CPtrList* pFiles = Library.Search( m_pSearch, nMaximum );
	if ( pFiles == NULL ) return 0;

	int nHits = pFiles->GetCount();

	while ( pFiles->GetCount() )
	{
		int nInThisPacket = min( pFiles->GetCount(), (int)Settings.Gnutella.HitsPerPacket );

		CreatePacket( nInThisPacket );

        int nHitB = 0;
		for ( int nHitA = 0 ; nHitA < nInThisPacket ; nHitA++ )
		{
			CLibraryFile* pFile = (CLibraryFile*)pFiles->RemoveHead();
			if ( AddHit( pFile, nHitB ) ) nHitB ++;
		}

		WriteTrailer();
		if ( nHitB > 0 ) DispatchPacket(); else DestroyPacket();
	}

	delete pFiles;

	return nHits;
}
Ejemplo n.º 2
0
void CDlgFreeTrainList::UpdateList()
{
  for(int no=0;no<m_ctlList.GetItemCount();no++)
	  g_SetCheck[no] = m_ctlList.GetCheck(no);
  while(m_ctlList.GetItemCount()<g_FreeTrainManageList.GetCount())
  {
    ::AddListItem(m_ctlList,0,0,"");
  }
  while(m_ctlList.GetItemCount()>g_FreeTrainManageList.GetCount())
  {
    m_ctlList.DeleteItem(0);
  }

  for(int item=0;item<g_FreeTrainManageList.GetCount();item++)
  {
    POSITION pos = g_FreeTrainManageList.FindIndex(item);
    struct TagFreeTrainStruct *pFreeTrain = (TagFreeTrainStruct *)g_FreeTrainManageList.GetAt(pos);

    ::SetItemText(m_ctlList,item,0,::GetFormatText("%d",item+1));
    ::SetItemText(m_ctlList,item,1,g_Unit[pFreeTrain->InFeederUnitID].UnitName);
    ::SetItemText(m_ctlList,item,2,g_Unit[pFreeTrain->OutFeederUnitID].UnitName);
    ::SetItemText(m_ctlList,item,3,::GetFormatText("%0.0f",pFreeTrain->AverCurrent));
    ::SetItemText(m_ctlList,item,4,::GetFormatText("%0.0f",pFreeTrain->AverAngle));
    ::SetItemText(m_ctlList,item,5,::GetFormatText("%d",pFreeTrain->InContinuedSeconds));
    ::SetItemText(m_ctlList,item,6,::GetFormatText("%d",pFreeTrain->ChangeContinuedSeconds));
    ::SetItemText(m_ctlList,item,7,::GetFormatText("%d",pFreeTrain->OutContinuedSeconds));
    ::SetItemText(m_ctlList,item,8,::GetFormatText("%0.1f",pFreeTrain->CurrentChangeRate*100));
    ::SetItemText(m_ctlList,item,9,::GetFormatText("%d",pFreeTrain->StartupDelaySecond));
    ::SetItemImage(m_ctlList,item,0);
	  m_ctlList.SetCheck(item,g_SetCheck[item]);
  }
}
Ejemplo n.º 3
0
BOOL CInfCreature::GetAffects(CPtrList &list)
{
	if (m_plAffects.GetCount() < 1)
		return(TRUE);

	INF_AFF *pAff, *pNew;
	POSITION pos = m_plAffects.GetHeadPosition();
	while(pos)
	{
		pAff = (INF_AFF*)m_plAffects.GetNext(pos);

		// Don't return the affects that are already handled in special cases.
		if (pAff->dwAffectType == AFF_TYPE_PROF ||	
			 (pAff->dwAffectType == AFF_TYPE_SPELL && !strnicmp(pAff->chResRef3,"SPCL812",7))
			)
			continue;

		pNew = new INF_AFF;
		if (!pNew)
			return(FALSE);

		memcpy(pNew,pAff,sizeof(INF_AFF));

		list.AddTail(pNew);
	}

	TRACE("CInfCreautre::GetAffects() - %d affects found.\n",list.GetCount());
	return(TRUE);
}
Ejemplo n.º 4
0
BOOL CUpdateUtil::CompareFileVersion(CItemList* pItemListSourceCmp, CItemList* pItemListDestCmp)
{
//	UPDATE_DATA* tmpClientSection = NULL;
//	UPDATE_DATA* tmpServerSection = NULL;

//	memset(tmpClientSection, 0, sizeof(UPDATE_DATA));
//	memset(tmpServerSection, 0, sizeof(UPDATE_DATA));
	
	CPtrList* pPLClient = pItemListDestCmp->GetPtrList();
	CPtrList* pPLServer = pItemListSourceCmp->GetPtrList();
	BOOL bExist = FALSE;
	UPDATE_DATA *psiServer = NULL;
	UPDATE_DATA *psiClient = NULL;
	CString strFilePath = "";

	UTIL_CANCEL();
	if(pPLClient->GetCount() == 0)
	{
		// Server xml File check
		POSITION posServer= pPLServer->GetHeadPosition();
		psiServer = NULL;
		strFilePath = "";
		while(posServer)
		{	
			bExist = FALSE;

			psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
			strFilePath.Format("%s\\%s", psiServer->DownPath, psiServer->Name);

			switch (VersionCheck(strFilePath, "0", psiServer->Version, psiServer->DownURL, psiServer->CheckSum, psiServer->Size))
			{
			case UPDATE_FLAG_NORMAL:
				TRACE("%s File : Do not anything  because %s == %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_NORMAL;
				break;
			case UPDATE_FLAG_NEW:
				TRACE("%s File : New  because not exsist\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_NEW;
				break;
			case UPDATE_FLAG_UPDATE:
				TRACE("%s File : Update  because %s < %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			case UPDATE_FLAG_DIFFERENT:
				TRACE("%s File : Update because different between xml version file and exist file\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			}
		}
	}
	else
	{
		return	CompareFileVersion2(pItemListSourceCmp, pItemListDestCmp);
	}

	return TRUE;
}
Ejemplo n.º 5
0
// 根据回调指针获取wke对象指针
CDuiWkeView* CDuiWkeView::GetWkeViewByClientHandler(const wkeClientHandler* pWkeClientHandler)
{
	int count = g_duiWkeViews.GetCount();
	for(int i = 0; i < count; i ++)
	{
		POSITION pos = g_duiWkeViews.FindIndex(i);
		CDuiWkeView* pDuiWkeView = (CDuiWkeView*)g_duiWkeViews.GetAt(pos);
		if(pWkeClientHandler == pDuiWkeView->GetWkeClientHandler())
		{
			return pDuiWkeView;
		}
	}
	return NULL;
}
Ejemplo n.º 6
0
BOOL CDlgFreeTrainList::LoadFreeTrainManageListFile()
{
  CString FileName = g_ProjectFilePath + "FeedTrain.lst";
  CFile file;
	if(!file.Open(FileName, CFile::modeRead))
  {
    ::AfxMessageBox(FileName + " 文件读取失败");
    return FALSE;
  }
  else
  {
    CArchive ar(&file,CArchive::load);

    g_FreeTrainManageList.RemoveAll();

    CString title = "FreeTrainList 1.0";
    ar>>title;

    WORD Count = g_FreeTrainManageList.GetCount();
    ar>>Count;
    
    for(int no=0;no<Count;no++)
    {
      struct TagFreeTrainStruct *pFreeTrain = new TagFreeTrainStruct;
      g_FreeTrainManageList.AddTail(pFreeTrain);
      ar>>pFreeTrain->InFeederUnitID;
      ar>>pFreeTrain->OutFeederUnitID;
      ar>>pFreeTrain->AverCurrent;
      ar>>pFreeTrain->AverAngle;
      ar>>pFreeTrain->CurrentChangeRate;
      ar>>pFreeTrain->InContinuedSeconds;
      ar>>pFreeTrain->ChangeContinuedSeconds;
      ar>>pFreeTrain->OutContinuedSeconds;
      ar>>pFreeTrain->StartupDelaySecond;
      CString InCurrentChangeRateList;
      CString OutCurrentChangeRateList;
      ar>>InCurrentChangeRateList;
      ar>>OutCurrentChangeRateList;
      strcpy(pFreeTrain->InCurrentChangeRateList,InCurrentChangeRateList.GetBuffer(0));
      strcpy(pFreeTrain->OutCurrentChangeRateList,OutCurrentChangeRateList.GetBuffer(0));
      ar>>g_SetCheck[no];
    }

    ar.Flush();
    ar.Close();
    file.Close();
  }	

  return TRUE;
}
Ejemplo n.º 7
0
void CDlgFreeTrainList::OnSave() 
{
  if(::AfxMessageBox("是否保存除自由行车管理文件?",MB_YESNO)==IDNO)
    return;

  CString FileName = g_ProjectFilePath + "FeedTrain.lst";
	CFile file;
	if(!file.Open(FileName, CFile::modeCreate | CFile::modeWrite))
  {
    AfxMessageBox(FileName+" 保存文件失败!",MB_SYSTEMMODAL);
    return;
  }

  char buffer[1024];
  CArchive ar(&file,CArchive::store,1024,buffer);

  CString title = "FreeTrainList 1.0";
  ar<<title;

  WORD Count = g_FreeTrainManageList.GetCount();
  ar<<Count;
    
  for(int no=0;no<Count;no++)
  {
    POSITION pos = g_FreeTrainManageList.FindIndex(no);
    struct TagFreeTrainStruct *pFreeTrain = (TagFreeTrainStruct *)g_FreeTrainManageList.GetAt(pos);
    ar<<pFreeTrain->InFeederUnitID;
    ar<<pFreeTrain->OutFeederUnitID;
    ar<<pFreeTrain->AverCurrent;
    ar<<pFreeTrain->AverAngle;
    ar<<pFreeTrain->CurrentChangeRate;
    ar<<pFreeTrain->InContinuedSeconds;
    ar<<pFreeTrain->ChangeContinuedSeconds;
    ar<<pFreeTrain->OutContinuedSeconds;
    ar<<pFreeTrain->StartupDelaySecond;
    CString InCurrentChangeRateList = pFreeTrain->InCurrentChangeRateList;
    CString OutCurrentChangeRateList = pFreeTrain->OutCurrentChangeRateList;
    ar<<InCurrentChangeRateList;
    ar<<OutCurrentChangeRateList;
	  g_SetCheck[no] = m_ctlList.GetCheck(no);
    ar<<g_SetCheck[no];
  }

  ar.Flush();
  ar.Close();
  file.Close();
}
Ejemplo n.º 8
0
CDuiWkeView::~CDuiWkeView()
{
	if(m_hwndHost != NULL)
	{
		::DestroyWindow(m_hwndHost);
	}

	// 删除wke对象列表中的项
	int count = g_duiWkeViews.GetCount();
	for(int i = 0; i < count; i ++)
	{
		POSITION pos = g_duiWkeViews.FindIndex(i);
		CDuiWkeView* pDuiWkeView = (CDuiWkeView*)g_duiWkeViews.GetAt(pos);
		if(pDuiWkeView == this) 
		{
			g_duiWkeViews.RemoveAt(pos);
			return;
		}
	}
}
Ejemplo n.º 9
0
bool CORDBList::ReadDBInfo()
{
CDBInfo			*db;
CStdioFile		listfile, infofile;
CFileStatus		fstatus;
CFileException	e;
CPtrList		plist;
char			data[1025];
char			*tmp;


	if (infofile.Open(m_ordbinfo, CFile::modeRead)) {
		while (1) {
			memset(data, 0x00, 1024);
			TRY {
				if (infofile.ReadString(data, 1024) == NULL) break;
				data[strlen(data)-1] = NULL;

				db = new CDBInfo();
				tmp = strtok(data, " ");	// db name
				if (tmp) {
					db->m_dbname.Format("%s", tmp);
				}
				tmp = strtok(NULL, " "); // permanent
				if (tmp) {
					if (!strcmp(tmp, "1")) db->m_permanent = true;
					else				  db->m_permanent = false;
				} 
				plist.AddTail(db);
			}
			CATCH_ALL(e)
			{
				break;
			}
			END_CATCH_ALL
		}
		infofile.Close();
	} 

	if (listfile.Open(m_ordblist, CFile::modeRead)) {
		listfile.GetStatus(fstatus);
		m_LastTime = fstatus.m_mtime;
	} else {
		return false;
	}

	while (1) {
		memset(data, 0x00, 1024);
		TRY {
			if (listfile.ReadString(data, 1024) == NULL) break;
			data[strlen(data)-1] = NULL;

			db = new CDBInfo();
			tmp = strtok(data, " ");	// db name
			if (tmp) {
				db->m_dbname.Format("%s", tmp);
			}
			tmp = strtok(NULL, " "); // db path
			if (tmp) {
				db->m_dbpath.Format("%s", tmp);
			}
			tmp = strtok(NULL, " "); // host
			if (tmp) {
				db->m_host.Format("%s", tmp);
			}
			tmp = strtok(NULL, " "); // log path
			if (tmp) {
				db->m_logpath.Format("%s", tmp);
			}
			int cnt = (int) plist.GetCount();
			if (cnt > 0) {
				for (int i = 0; i < cnt; i++) {
					CDBInfo *p = (CDBInfo *)plist.GetAt(plist.FindIndex(i));
					if (db->m_dbname == p->m_dbname) {
						db->m_permanent = p->m_permanent;
						break;
					}
				}
			}
			m_List.AddTail(db);
		}
		CATCH_ALL(e)
		{
			break;
		}
		END_CATCH_ALL
	}

	listfile.Close();

	while (!plist.IsEmpty()) {
		CDBInfo *p = (CDBInfo *)plist.RemoveHead();
		delete p;
	}

	return true;
}
Ejemplo n.º 10
0
void CDlgTimedMessageBox::GetWindowHandles(void)
{
	HWND		hWnd;
	CWnd		*pWnd;
	CString		title;
	CPtrList	allButtons;

	//
	// Handle of the messageBox
	//
	if( !m_hMsgBox )
	{
		hWnd = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
		while( (hWnd!=NULL) && (m_hMsgBox==NULL) )
		{
			pWnd = CWnd::FromHandle(hWnd);
			pWnd->GetWindowText(title);

			if( ::AfxIsDescendant(m_hParent, hWnd) && ::IsWindowVisible(hWnd) && (m_Title.CompareNoCase(title)==0) )
			{
				m_hMsgBox = hWnd;
				break;
			}
			
			hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
		}
	}

	//
	// Handle of the static text
	// TODO only if text-replace is needed
	//
	if( m_hMsgBox && !m_hStaticText )
	{
		// not sure if this will work always
		// under Win2000 it did
		//m_hStaticText = ::GetDlgItem(m_hMsgBox, 0xFFFF);

		// not sure, so lets find it dynamically!

		char		className[_MAX_PATH];
		CString		classNameOk("STATIC");
		LONG		id;

		hWnd = ::GetWindow(m_hMsgBox, GW_CHILD);
		while( (hWnd!=NULL) && (m_hStaticText==NULL) )
		{
			id = ::GetWindowLong(hWnd, GWL_ID);
			
			// small ids only for buttons
			if( id > IDHELP )
			{
				if( ::GetClassName(hWnd, className, _MAX_PATH) )
				{

					// looking only for a static 
					if( classNameOk.CompareNoCase(className) == 0 )
					{
						// not check the text
						pWnd = CWnd::FromHandle(hWnd);
						pWnd->GetWindowText(title);
						
						if( m_CurrentMessage.CompareNoCase(title) == 0 )
						{
							m_hStaticText = hWnd;
							break;
						}

					}
				}
			}
			else
			{
				allButtons.AddTail(hWnd);
			}

			hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
		}

	}

	//
	// Handle of the default button
	//
	if( m_hMsgBox && !m_hDefaultButton )
	{
		m_hDefaultButton = ::GetDlgItem(m_hMsgBox, m_DefaultReturn);
		
		// Problem: (reported from Keith Brown)
		// if generated with MB_OK the button has NOT IDOK, but IDCANCEL !!
		// then lets take the first button we find !
		// (with and IDCANCEL this works, because it is the only button
		// if this problem encounters also with 2 buttons, I have no chance 
		// to find out which one is the better one!)
		while( allButtons.GetCount()>0 && !m_hDefaultButton )
		{
			m_hDefaultButton = (HWND) allButtons.GetHead();
			allButtons.RemoveHead();
			
			if( m_hDefaultButton )
				m_DefaultReturn = ::GetWindowLong(m_hDefaultButton, GWL_ID);
		}
	}
}
Ejemplo n.º 11
0
/** \brief Indicates whether the list is empty
 *
 * \ingroup group__concept__shim__collection_logical__is_empty
 *
 */
inline int is_empty(CPtrList const& l)
{
    return 0 == l.GetCount();
}
Ejemplo n.º 12
0
BOOL 
CGenedocDoc::SetStructureAlignment(CDisplayVars *DisplayVars)
{

	int RowCount;
	ShadeSegStc *pSegArr;

	if ( pGSFiller == NULL ) {
		return 0;
	}
	
	if ( DisplayVars->GetStcGroup().GetResiduesSize() == 0 ) return 0;

	CPtrList *pGroupList;

	if ( DisplayVars->GetGroupName().GetLength() != 0 ) {
		pGroupList = DisplayVars->GetGroupList();
	} else {
		pGroupList = &pGSFiller->SegDataList;
	}

	RowCount = pGroupList->GetCount();	// Subtract 1 for comment row. here
	
	pSegArr = new ShadeSegStc[RowCount];	// Gonna need access to comment row here

	if ( pSegArr == 0 ) {
		AfxMessageBox("AutoShadeProperty:New Fail:1");
		return 0;
	}

	CGeneSegment *tCGSeg;
	int i = 0;
	HANDLE tSegHandle;
	int MasterRow = -1;

	CString MasterSeq = DisplayVars->GetStcGroup().GetMasterSeq();

	POSITION tPos = pGroupList->GetHeadPosition();
	while (tPos != NULL ) {
		tCGSeg = (CGeneSegment *)pGroupList->GetNext(tPos);

		// Check for master seq for later.
		if ( tCGSeg->GetTitle() == MasterSeq ) MasterRow = i;

		// Lock it down
		tSegHandle = tCGSeg->GetTextHandle();
		pSegArr[i].pGeneStor = (GeneStor *) GlobalLock( tSegHandle );
		pSegArr[i].pCGSeg = tCGSeg;
		if ( pSegArr[i].pGeneStor == NULL) {
			AfxMessageBox("AutoShadeProperty:GlobalLock:Fail:1");
			delete pSegArr;
			return 0;
		}
		i++;
	}

	// init locations
	DWORD StcResiduesPos = 1;
	HGLOBAL hStcResidues = DisplayVars->GetStcGroup().GetResidues();
	DWORD StcResiduesLength = DisplayVars->GetStcGroup().GetResiduesSize();


//	CDisplayVars *pDV;
//	CPtrList *pPL = &m_UserVars.m_DisplayVars;
	
	DWORD OuterCount = tCGSeg->GetTextLength();

	DWORD ScoreValue = 0;
	DWORD ScoreCount = 0;
	DWORD tCount;

	char *pStcResidues = (char *)GlobalLock( hStcResidues );
	if ( pStcResidues == NULL ) goto ErrorOut;

	if ( MasterRow == -1 ) {
		AfxMessageBox( "Master Sequence Not Found in Group" );
		goto ErrorOut;
	}

//	tPos = pPL->GetHeadPosition();
//	while ( tPos != NULL ) {
//		pDV = (CDisplayVars *)pPL->GetNext(tPos);
//		if ( pDV == DisplayVars ) {
//			break;
//		}
//	}

	for ( tCount = 0L; tCount < OuterCount; ++tCount ) {

		ScoreValue = 0L;

		if ( StcResiduesPos != 0L ) {
			char tChar = (pSegArr[MasterRow].pGeneStor)[tCount].CharGene;
			tChar = toupper (tChar);
			if ( (tChar >= 'A' && tChar <= 'Z') ) { 
				if ( tChar == toupper(pStcResidues[StcResiduesPos - 1L]) ) {
					ScoreValue = StcResiduesPos;
				}
			}
		}
		

		for ( i = 0; i < RowCount; ++i ) {
			
			// if its a comment row .. go on .. after shading.
			if ( pSegArr[i].pCGSeg->GetStyle() != LINESEQUENCE ) {
		 		continue;
			}
		
			// Save New Residue Location Value
			(pSegArr[i].pGeneStor)[tCount].CharScore = ScoreValue;
		}


		if ( ScoreValue > 0L ) {
			if ( StcResiduesPos++ >= StcResiduesLength ) {
				StcResiduesPos = 0L;
			}
			ScoreCount++;
		}
	}


	if ( ! ((ScoreCount > (OuterCount/2))||(ScoreCount > (StcResiduesLength/2))) ) {

		StcResiduesPos = 1;
		
		for ( tCount = 0L; tCount < OuterCount; ++tCount ) {

			ScoreValue = 0L;

			if ( StcResiduesPos != 0L ) {
				char tChar = (pSegArr[MasterRow].pGeneStor)[tCount].CharGene;
				tChar = toupper (tChar);
				if ( (tChar >= 'A' && tChar <= 'Z') ) { 

					if ( tChar == toupper(pStcResidues[StcResiduesPos - 1L]) ) {
						ScoreValue = StcResiduesPos;
					} else {
						for ( ;StcResiduesPos < StcResiduesLength; StcResiduesPos++ ) {
							if ( tChar == toupper(pStcResidues[StcResiduesPos - 1L]) ) {
								if ( (StcResiduesPos+1 < StcResiduesLength ) && (tCount+1 < OuterCount) ) {
									char tChar2 = toupper((pSegArr[MasterRow].pGeneStor)[tCount+1].CharGene);
									if ( tChar2 >= 'A' && tChar2 <= 'Z' ) {
										if ( toupper(pStcResidues[StcResiduesPos]) == tChar2 ) {
											ScoreValue = StcResiduesPos;
											break;
										}
									} else {
										ScoreValue = StcResiduesPos;
										break;
									}
								} else {
									ScoreValue = StcResiduesPos;
									break;
								}
							}
						}
					}
				}
			}
			

			for ( i = 0; i < RowCount; ++i ) {
				
				// if its a comment row .. go on .. after shading.
				if ( pSegArr[i].pCGSeg->GetStyle() != LINESEQUENCE ) {
		 			continue;
				}
			
				// Save New Residue Location Value
				(pSegArr[i].pGeneStor)[tCount].CharScore = ScoreValue;
			}


			if ( ScoreValue > 0L ) {
				if ( StcResiduesPos++ >= StcResiduesLength ) {
					StcResiduesPos = 0L;
				}
			}
		}
	}	
	
	GlobalUnlock( hStcResidues );

ErrorOut:

	tPos = pGroupList->GetHeadPosition();
	while (tPos != NULL ) {
		tCGSeg = (CGeneSegment *)pGroupList->GetNext(tPos);
		tSegHandle = tCGSeg->GetTextHandle();
		GlobalUnlock( tSegHandle );
	}
	delete pSegArr;

	return 1;
}