Ejemplo n.º 1
0
//Delete word item which 
//(1)frequency is 0 
//(2)word is same as following but the POS value is parent set of the following
//for example "江泽民/n/0" will deleted, because "江泽民/nr/0" is more detail and correct
bool CDictionary::Optimum()
{
   int nPrevPOS,i,j,nPrevFreq;
   char sPrevWord[WORD_MAXLENGTH],sCurWord[WORD_MAXLENGTH];
   for(i=0;i<CC_NUM;i++)
   {
       j=0;  
	   sPrevWord[0]=0;
	   nPrevPOS=0;
	   nPrevFreq=-1;
	   while(j<m_IndexTable[i].nCount)
	   {
		 sprintf(sCurWord,"%c%c%s",CC_CHAR1(i),CC_CHAR2(i),m_IndexTable[i].pWordItemHead[j].sWord);
         if(nPrevPOS==30720||nPrevPOS==26368||nPrevPOS==29031||(strcmp(sPrevWord,sCurWord)==0&&nPrevFreq==0&&m_IndexTable[i].pWordItemHead[j].nHandle/256*256==nPrevPOS))
		 {//Delete Previous word item
		  //Delete word with POS 'x','g' 'qg'
			DelItem(sPrevWord,nPrevPOS);
		 }
		 strcpy(sPrevWord,sCurWord);
		 nPrevPOS=m_IndexTable[i].pWordItemHead[j].nHandle;
		 nPrevFreq=m_IndexTable[i].pWordItemHead[j].nFrequency;
 		 j+=1;//Get next item in the original table.
	   }
   }
   return true;
}
Ejemplo n.º 2
0
int     CZiMainFrame::OnClickRightMenu(TNotifyUI & msg)
{
	CNodeList * pNode  = 0;
	CNodeList * pNodeP = 0;
	CListUI   * pList  = static_cast<CListUI*>(msg.pSender);
	int         nSel   = pList->GetCurSel();

	if(nSel < 0 || !pList->GetItemAt(nSel))
	{
		return 0;
	}

	// 右键操作
	pNode = (CNodeList *)pList->GetItemAt(nSel)->GetTag();
	Assert(pNode);

    //TODO 
    //发送命令道服务器端,等服务端验证成功后再做操作
    //发送网络命令
	switch(msg.wParam)
	{
	case Event_OpenItem:   { CreateChatDailog(pNode);  break; }
	case Event_ModifyItem: { OnModifyGroupName(pNode); break; }
	case Event_DeleteItem: 
        { 
			DelItem(pNode);
        }
        break;
	default:               
		{ Assert(0); break; }
	}

	return 0;
}
Ejemplo n.º 3
0
void BiSortTree::DeleteCom()//删除命令
{
	int temp=0;
	cout<<"Please input Id:";
	cin>>temp;
	DelItem(temp);
}
Ejemplo n.º 4
0
/**
* @date     2013/07/28
*
*  Removes all items from the list. The caller is responsible for deleting the
*  objects removed from the list.
*
******************************************************************************/
void DlList::MakeEmpty(void)
{
   while(Head != NULL)
   {
      DelItem(Head);
   }
}
Ejemplo n.º 5
0
int PSItems::RemoveOld(PSTree *tree, char *FileName)
{
  int count = 0;
  if (!base)
    return count;
  //struct EditorSetPosition esp;
  char FN[_MAX_PATH];
  char type[20];
  PSInfo info = {type, FN, NULL};
  bool del = false;
  LoadFile(FileName,tree);
  PSgmlExt Item = base->next();
  while (Item)
  {
    if (Item->getname() && !FSF.LStricmp(Item->getname(),"item") && Item->GetChrParam("path") && Item->GetChrParam("type"))
    {
      lstrcpy(info.Type,Item->GetChrParam("type"));
      lstrcpy(info.FileName,Item->GetChrParam("path"));
      WIN32_FIND_DATA fd;
      HANDLE h = FindFirstFile(info.FileName,&fd);
      if (h == INVALID_HANDLE_VALUE)
      {
        if (tree)
        {
          PSTrackInfo ti;
          lstrcpy(ti.FileName,info.FileName);
          ti.Type = TI_UNKNOWN;
          if (!FSF.LStricmp(info.Type,"editor"))
            ti.Type = TI_EDITOR;
          #ifdef ALLOW_VIEWER_API
          else
            if (!FSF.LStricmp(info.Type,"viewer"))
              ti.Type = TI_VIEWER;
          #endif
          if (ti.Type!=TI_UNKNOWN && !tree->FindFN(&ti))
            del = true;
        }
        else
        {
          del = true;
        }
      }
      else
       FindClose(h);
    }
    Item = Item->next();
    if (del)
    {
      DelItem(info);
      del = false;
      count++;
    }
  }
  SaveFile(FileName,tree,false);
  return count;
}
Ejemplo n.º 6
0
/// 개수만 감소하는 경우에는 별도로 처리할필요가 없다.
void	CItemSlot::SubItem( int iInvenIdx, tagITEM& Item )
{
	assert( iInvenIdx >= 0 && iInvenIdx < INVENTORY_TOTAL_SIZE );
	CItem* pItem = GetItem( iInvenIdx );
	assert( pItem );
	if( pItem )
	{
		if( !Item.IsEnableDupCNT() )///개수 없는 아이템일경우 삭제한다.
		{
			DelItem( iInvenIdx );
			assert( 0 && "개수 없는 아이템을 빼려고 한다@ CItemSlot::SubItem" );
		}

		if( pItem->IsEmpty() )
		{
			DelItem( iInvenIdx );
			return;
		}
	}
	ChangeItemStatus( iInvenIdx );
}
Ejemplo n.º 7
0
int	CItemSlot::SetItem( int iInvenIdx, tagITEM& Item )
{
	assert( iInvenIdx >= 0 && iInvenIdx < INVENTORY_TOTAL_SIZE );
	CItem* pItem = GetItem( iInvenIdx );

	if( pItem )
		DelItem( iInvenIdx );

	if( !Item.IsEmpty() )
		AddItem( iInvenIdx, Item );
	return 0;
}
Ejemplo n.º 8
0
void CComBox::DelItem(std::string text)
{
    int cnt = TotalCounts();
    fprintf(stderr,"cbx cnt =%d\n",cnt);
    for(int i = 0; i < cnt; i++)
    {
        std::string text1 = GetItemText(i);
        if(text1 == text)
        {
            DelItem(i);
            return;
        }
    }
}
Ejemplo n.º 9
0
void droppet(Tree *pt){
	Item temp;
	if(TreeIsEmpty(pt)){
		puts("No Entries!");
		return ;
	}
	puts("Please enter name of pet you wish to delete :");
	fgets(temp.petname,MAXN,stdin);
	puts("Please enter pet kind:");
	fgets(temp.petkind,MAXN,stdin);
	printf("%s the %s ",temp.petname,temp.petkind);
	if(DelItem(&temp,pt)){
		printf("is drop form the club.\n");
	}else{
		printf("is not a member.\n");
	}
}
Ejemplo n.º 10
0
int     CZiMainFrame::MoveItem(CNodeList * pNodeInfo, CNodeList * pNodeInfoSrcParent, CNodeList * pNodeInfoDesParent)
{
	// parent 必须存在, 也就是根节点不能移动. 
	// 增加群成员, 不能调用 MoveItem, 必须调用 AddItem. 
	Assert(pNodeInfo);
	Assert(pNodeInfoSrcParent && pNodeInfoDesParent);
	Assert(pNodeInfo->GetNodeData().chType == Type_ImcFriend);
	Assert(pNodeInfoSrcParent->GetNodeData().chType == Type_ImcTeam);
	Assert(pNodeInfoSrcParent->GetNodeData().chType == pNodeInfoDesParent->GetNodeData().chType);

	CBaseItemListUI * pItemListUi = GetNodeListUi(pNodeInfoSrcParent->GetNodeData().chType);
	ItemNodeInfo_t    itemInfo    = pNodeInfo->GetNodeData();

	DelItem(pNodeInfo, pNodeInfoSrcParent);
	AddItem(&itemInfo, pNodeInfoDesParent);

	// 网络发送 ... ???
	return 0;
}
Ejemplo n.º 11
0
BOOL VirtualFAT::DelItem(SVFIP &Item)
{    
    if (Item->IsDirectory){
        for (int i = 0; i < Item->Items.size(); i++)
            DelItem(Item->Items[i]);        
    
        Item->Items.empty();
    }

    my_free(Item->Description);
    my_free(Item->FileName);
    my_free(Item->Plugin);
    if (Item->UserData.Data)
        my_free(Item->UserData.Data);
    my_free(Item);
    Item = NULL;    
        
    return TRUE;
}
Ejemplo n.º 12
0
void VirtualFAT::ReInitFAT()
{
    if (Root) {
        DelItem(Root);
    }

    Root = (SVFIP)my_malloc(sizeof SVFI);
    Root->FileName      = my_strdup("\\");
    Root->Description   = my_strdup("<dir>");
    Root->Plugin        = my_strdup("");
    Root->IsDirectory   = TRUE;
    Root->Fmt           = -1;
    Root->IsExtension   = FALSE;
    Root->Offset        = 0;
    Root->LevelUp       = NULL;
    Root->PackedSize    = 0;
    Root->UnpackedSize  = 0;
    Root->UserData.Size = 0;
    Root->UserData.Data = NULL;
}
Ejemplo n.º 13
0
LRESULT CZiMainFrame::HandleCustomMessage(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	BOOL bFree = FALSE;

	switch(nMsg)
	{
	case WM_TIMER:
		if(wParam == 1) OnTimer();
		break;

	case Msg_InTray:
		{
			Assert(wParam == IDR_MAINFRAME);

			switch(lParam)
			{
			case WM_RBUTTONUP:
				{
					// 右键单击 -> 弹出右键菜单. 
					// ... 
				}
				break;

			case WM_LBUTTONDBLCLK:
				{
					// 左键双击 -> 1 消息, 2 显示. 
					BOOL bNoMsg  = true;
					BOOL bHide   = ::IsWindowVisible(m_hWnd);

					bNoMsg = HandleNetCmd();
					if(bNoMsg)
					{
						break;
					}
					{
						::ShowWindow(m_hWnd, SW_SHOW);
						::SetForegroundWindow(m_hWnd);
					}
				}
				break;
			}
		}
		break;

	case Msg_InQueryVerify:
		// 发送验证回复消息给对方. 
		Assert(lParam);
		OnClickVerifyResponse(wParam, lParam);
		break;

	case Msg_ScResponseUsers:
		{
			SearchScResponse_t * pResponse = (SearchScResponse_t*)lParam;
			if(wParam != 0)
			{
				CZimcHelper::ErrorMessageBox(m_hWnd, Msg_CsQueryUsers, wParam);
			}
			else if(m_pSearchWindow)
			{
				m_pSearchWindow->HandleResponseResult(pResponse);
			}

			bFree = TRUE;
		}
		break;
	case Msg_ScResponseGroup:
		{
			SearchGroup_t *pSearchGroup = (SearchGroup_t *)lParam;
			if (wParam != 0) {
				CZimcHelper::ErrorMessageBox(m_hWnd, nMsg, wParam);
			}
			else if (m_pSearchWindow) {
				m_pSearchWindow->HandleResponseResultForGroup(pSearchGroup);
			}
			bFree = TRUE;
		}
		break;
	case Msg_ScQueryVerify:
	case Msg_ScResponseVerify:
	case Msg_ScAddGroupVerify: 
		{
			Assert(lParam != 0);
			AddGroupInfo_t *pAddgroupinfo = (AddGroupInfo_t *)lParam;
			DelayDispatchNetCmd(nMsg, pAddgroupinfo->nSenderId, (void*)lParam);
		}
		break;
	case Msg_ScTextChat:
		{
			Assert(lParam != 0);
			CChatDialog * pChatDialog = 0;
            ChatCcTextData_t *pChatText = (ChatCcTextData_t *)lParam;
            if (pChatText->nRecvType == Type_ImcFriend) { //好友消息
                ImcSubWindowTable_t::iterator it = m_mapSubWindows.find(pChatText->nSenderId);
                if(it != m_mapSubWindows.end()) pChatDialog = static_cast<CChatDialog*>(it->second);
            }
            else { //群消息
                ImcSubWindowTable_t::iterator it = m_mapSubWindows.find(pChatText->nRecverId);
                if(it != m_mapSubWindows.end()) pChatDialog = static_cast<CChatDialog*>(it->second);
            }
			if(pChatDialog)
			{
				pChatDialog->OnTextMsgShow(pChatText);
				bFree = TRUE;
			}
			else
			{
				DelayDispatchNetCmd(nMsg, pChatText->nSenderId, (void*)lParam);
			}
		}
		break;
    case Msg_ScDelFriend:
        {
            Assert(lParam != 0);
			
			DelFriendItem *pDelFriend = (DelFriendItem *)lParam;
			int nDelId = IdNetToLocal(pDelFriend->type, pDelFriend->nDelId);
			int nSendId = IdNetToLocal(Type_ImcFriend, pDelFriend->nSendId);
			if (pDelFriend->succ == 0) {				
				//TODO
				if (pDelFriend->type == Type_ImcTeam) {
				}
				else if (pDelFriend->type == Type_ImcFriend) {
					CNodeList *pNodeinfo = NULL;
					if (nDelId == m_itemSelfInfo.nId) {
						pNodeinfo = GetNodeInfo(nSendId);
					}
					else {
						pNodeinfo = GetNodeInfo(nDelId);
					}
					if (pNodeinfo) {
						DelItem(pNodeinfo, pNodeinfo->GetParent());
					}
				}
				else if (pDelFriend->type == Type_ImcFriendX) {

				}
				else if (pDelFriend->type == Type_ImcGroup) {
					if (nDelId != m_itemSelfInfo.nId) {
						CNodeList *pNodeInfo = GetNodeInfo(nDelId);
						m_mapGroupTable.erase(pNodeInfo);
						Assert(pNodeInfo);
						ItemNodeInfo_t  & itemInfo    = pNodeInfo->GetNodeData();
						CBaseItemListUI * pItemListUi = GetNodeListUi(itemInfo.chType);
						Assert(pItemListUi);
						pItemListUi->RemoveNode(pNodeInfo);
						DeleteGroupNode(nDelId);
					}
				}
				else {
				}	
			}
			if (nDelId == m_itemSelfInfo.nId) {
				DelayDispatchNetCmd(nMsg, nSendId, (void*)lParam);
			}
			else {
				DelayDispatchNetCmd(nMsg, nDelId, (void*)lParam);
			}
        }
        break;
	case  Msg_ScEvilReport:
		{
			// 显示验证请求框, 交给用户操作. 
			// 还需要显示请求者的信息, 未实现 ... ???
			ReportCsEvilData_t * pReport = (ReportCsEvilData_t*)lParam;
			char              szText[1024] = {0};
			sprintf_s(szText, sizeof(szText)/sizeof(szText[0]), 
				"举报 %s", pReport->succ == 0 ? "成功" : "失败");

			CNotifyWindow::MessageBoxX(m_hWnd, _T("通知"), CA2T(szText));
			bFree = TRUE;
		}
		break;
	case Msg_ScCreateGroup:
		handleGreateGroup((GroupInfoData_t *)lParam);
		bFree = TRUE;
		break;
	case Msg_InAddGroupVerify:
		Assert(lParam);
		OnClickAddGroupResponse(wParam, lParam);
		break;
	case Msg_ScModifyGroup:
		Assert(lParam);
		handlerModifyGroup((GroupInfoData_t *)lParam);
		break;
	}

	if(bFree) m_pMainMsger->FreeDataEx(nMsg, (void*)lParam);
	return 0;
}
Ejemplo n.º 14
0
bool PSItems::LoadFile(char *FileName, PSTree *tree)
{
  HANDLE fp = CreateFile(FileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
  char *buf;
  DWORD sz;
  if (fp!=INVALID_HANDLE_VALUE)
  {
    FILETIME ft;
    BOOL gottime = GetFileTime(fp,NULL,NULL,&ft);
    if (!gottime || FSF.LStricmp(LastFileName,FileName) || CompareFileTime(&ft,&LastFileTime)>0)
    {
      lstrcpy(LastFileName,FileName);
      if (gottime)
        LastFileTime = ft;
      else
        memset(&LastFileTime,0,sizeof(LastFileTime));
      if (!base)
      {
        sz = GetFileSize(fp,NULL);
        if (sz == INVALID_FILE_SIZE)
          sz = 0;
        buf = (char *)malloc(sz+1);
        if (buf)
        {
          DWORD transfered;
          if (sz)
          {
            ReadFile(fp,buf,sz,&transfered,NULL);
            sz = transfered;
          }
          buf[sz]=0;
        }
      }
      CloseHandle(fp);
    }
    else
    {
      CloseHandle(fp);
      return true;
    }
  }
  else
  {
    *LastFileName = 0;
    memset(&LastFileTime,0,sizeof(LastFileTime));
    if (!base)
    {
      sz = 0;
      buf = (char *)malloc(1);
      buf[0] = 0;
    }
  }

  #if 0
  {
    HANDLE fp = CreateFile("e:\\download\\temp\\alex.alex",GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,0,NULL);
    SetFilePointer(fp,0,NULL,FILE_END);
    DWORD t;
    WriteFile(fp,"read\r\n",6,&t,NULL);
    CloseHandle(fp);
  }
  #endif

  if (!buf && !base)
  {
    return false;
  }
  if (!base)
  {
    base = new CSgmlExt;
    if (!base)
    {
      free(buf);
      return false;
    }
    if (!base->parse(buf,sz))
    {
      delete base;
      free(buf);
      return false;
    }
    free(buf);
  }
  else
  {
    {
      PSItems temp;
      if (!temp.LoadFile(FileName,NULL))
      {
        delete base;
        return false;
      }
      struct EditorSetPosition esp;
      #ifdef ALLOW_VIEWER_API
      struct ViewerSetPosition vsp;
      #endif
      char str[_MAX_PATH];
      PSInfo info = {"editor",str,&esp};
      int type = TI_EDITOR;
      #ifdef ALLOW_VIEWER_API
      for (int i=0; i<2; i++)
      #endif
      {
        PSgmlExt Item = base->next();
        while (Item)
        {
          if (Item->getname() && !FSF.LStricmp(Item->getname(),"item") && Item->GetChrParam("type") && !FSF.LStricmp(Item->GetChrParam("type"),info.Type) && Item->GetChrParam("path"))
          {
            //GetItem(Item,info);
            lstrcpy(info.FileName,Item->GetChrParam("path"));
            if (!temp.FindItem(info))
            {
              if (tree)
              {
                PSTrackInfo ti;
                lstrcpy(ti.FileName,info.FileName);
                ti.Type = type;
                while (tree->GetFN(&ti))
                  tree->Delete(&ti);
              }
              Item = Item->prev();
              DelItem(info);
              #if 0
              {
                HANDLE fp = CreateFile("e:\\download\\temp\\alex.alex",GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,0,NULL);
                SetFilePointer(fp,0,NULL,FILE_END);
                DWORD t;
                WriteFile(fp,"del\r\n",5,&t,NULL);
                CloseHandle(fp);
              }
              #endif
            }
            else
            {
              PSTrackInfo ti;
              lstrcpy(ti.FileName,info.FileName);
              ti.Type = type;
              if (!tree || !tree->FindFN(&ti))
              {
                PSgmlExt tmp = temp.PFindItem(info);
                temp.GetItem(tmp,info);
                lstrcpy(info.FileName,tmp->GetChrParam("path"));
                SetItem(info);
              }
            }
          }
          Item = Item->next();
        }
        #ifdef ALLOW_VIEWER_API
        type = TI_VIEWER;
        info.Type = "viewer";
        info.vsp = &vsp;
        #endif
      }
      #ifdef ALLOW_VIEWER_API
      info.Type = "editor";
      for (int i=0; i<2; i++)
      #endif
      {
        PSgmlExt Item = temp.Base()->next();
        while (Item)
        {
          if (Item->getname() && !FSF.LStricmp(Item->getname(),"item") && Item->GetChrParam("type") && !FSF.LStricmp(Item->GetChrParam("type"),info.Type) && Item->GetChrParam("path"))
          {
            GetItem(Item,info);
            lstrcpy(info.FileName,Item->GetChrParam("path"));
            if (!FindItem(info))
            {
              NewItem(info);
            }
          }
          Item = Item->next();
        }
        #ifdef ALLOW_VIEWER_API
        info.Type = "viewer";
        info.vsp = &vsp;
        #endif
      }
    }
  }
  return true;
}
Ejemplo n.º 15
0
VirtualFAT::~VirtualFAT()
{
    if (Root) {
        DelItem(Root);
    }
}
Ejemplo n.º 16
0
void cStructLoader::Load(bool reload)
{
  if(SL_TSTFLAG(SL_DISABLED) || (reload && !SL_TSTFLAG(SL_WATCH))) return;
  FILE *f=fopen(path,"r");
  if(f) {
    PreLoad();
    int curr_mtime=MTime(true);
    ListLock(true);
    bool doload=false;
    if(!reload) {
      Clear(); Modified(false);
      mtime=curr_mtime;
      doload=true;
      }
    else if(mtime<curr_mtime) {
      PRINTF(L_CORE_LOAD,"detected change of %s",path);
      if(IsModified())
        PRINTF(L_CORE_LOAD,"discarding in-memory changes");
      for(cStructItem *a=First(); a; a=Next(a)) DelItem(a);
      Modified(false);
      mtime=curr_mtime;
      doload=true;
      }
    if(doload) {
      SL_SETFLAG(SL_LOADED);
      PRINTF(L_GEN_INFO,"loading %s from %s",type,path);
      CheckAccess();
      int lineNum=0, num=0;
      char buff[4096];
      while(fgets(buff,sizeof(buff),f)) {
        lineNum++;
        if(!index(buff,'\n') && !feof(f)) {
          PRINTF(L_GEN_ERROR,"file %s readbuffer overflow line#%d",path,lineNum);
          SL_CLRFLAG(SL_LOADED);
          break;
          }
        strreplace(buff,'\n',0); strreplace(buff,'\r',0); // chomp
        bool hasContent=false;
        char *ls;
        for(ls=buff; *ls; ls++) {
          if(*ls==';' || *ls=='#') {		  // comment
            if(hasContent)
              while(ls>buff && ls[-1]<=' ') ls--; // search back to non-whitespace
            break;
            }
          if(*ls>' ') hasContent=true;		  // line contains something usefull
          }
        cStructItem *it=0;
        if(hasContent) {
          char save=*ls;
          *ls=0; it=ParseLine(skipspace(buff)); *ls=save;
          if(!it) {
            PRINTF(L_GEN_ERROR,"file %s has error in line #%d",path,lineNum);
            ls=buff;
            }
          else num++;
          }
        else ls=buff;
        if(!it) it=new cCommentItem;
        if(it) {
          it->SetComment(ls);
          Add(it);
          }
        else {
          PRINTF(L_GEN_ERROR,"out of memory loading file %s",path);
          SL_CLRFLAG(SL_LOADED);
          break;
          }
        }
      ListUnlock();
      PRINTF(L_CORE_LOAD,"loaded %d %s from %s",num,type,path);
      PostLoad();
      }
    else ListUnlock();

    fclose(f);
    LoadFinished();
    }
  else
    OpenFailed();
}