Example #1
0
void CHomeLibraryBox::OnSkinChange()
{
	if ( m_pDocument ) delete m_pDocument;
	m_pDocument = NULL;
	m_pdLibraryFiles = m_pdLibraryVolume = m_pdLibraryHashRemaining = NULL;

	SetCaptionmark( _T("CHomeLibraryBox.Caption") );

	CXMLElement* pXML = Skin.GetDocument( _T("CHomeLibraryBox") );
	if ( pXML == NULL ) return;

	SetCaption( pXML->GetAttributeValue( _T("title"), _T("Library") ) );
	HICON hIcon = CoolInterface.ExtractIcon( IDR_LIBRARYFRAME, Settings.General.LanguageRTL );
	if ( hIcon ) SetIcon( hIcon );

	m_pDocument = new CRichDocument();

	CMap< CString, const CString&, CRichElement*, CRichElement* > pMap;
	if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return;

	pMap.Lookup( _T("LibraryFiles"), m_pdLibraryFiles );
	pMap.Lookup( _T("LibraryVolume"), m_pdLibraryVolume );
	pMap.Lookup( _T("LibraryHashRemaining"), m_pdLibraryHashRemaining );

	SetDocument( m_pDocument );

	Update();

	// Update Dropshadow	(Note: Caused app freeze when allowing hovered item during skin change)
	m_wndTip.DestroyWindow();
	m_wndTip.Create( this, &Settings.Interface.TipLibrary );
}
Example #2
0
void CHomeConnectionBox::OnSkinChange()
{
	if ( m_pDocument ) delete m_pDocument;
	m_pDocument = NULL;
	m_pdConnectedHours = m_pdConnectedMinutes = NULL;

	for ( PROTOCOLID nP = PROTOCOL_NULL ; nP < PROTOCOL_LAST ; ++nP )
	{
		for ( int nT = ntNode ; nT <= ntLeaf ; nT++ )
		{
			m_pdCount[ nP ][ nT ] = NULL;
			m_sCount[ nP ][ nT ].Empty();
		}
	}

	SetCaptionmark( _T("CHomeConnectionBox.Caption") );

	CXMLElement* pXML = Skin.GetDocument( _T("CHomeConnectionBox") );
	if ( pXML == NULL ) return;

	SetCaption( pXML->GetAttributeValue( _T("title"), _T("Connection") ) );
	HICON hIcon = CoolInterface.ExtractIcon( IDR_NEIGHBOURSFRAME, Settings.General.LanguageRTL );
	if ( hIcon ) SetIcon( hIcon );

	m_pDocument = new CRichDocument();

	CMap< CString, const CString&, CRichElement*, CRichElement* > pMap;
	if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return;

	pMap.Lookup( _T("ConnectedHours"), m_pdConnectedHours );
	pMap.Lookup( _T("ConnectedMinutes"), m_pdConnectedMinutes );

	pMap.Lookup( _T("G1Peers"), m_pdCount[PROTOCOL_G1][ntNode] );
	pMap.Lookup( _T("G1Hubs"), m_pdCount[PROTOCOL_G1][ntHub] );
	pMap.Lookup( _T("G1Leaves"), m_pdCount[PROTOCOL_G1][ntLeaf] );

	pMap.Lookup( _T("G2Peers"), m_pdCount[PROTOCOL_G2][ntNode] );
	pMap.Lookup( _T("G2Hubs"), m_pdCount[PROTOCOL_G2][ntHub] );
	pMap.Lookup( _T("G2Leaves"), m_pdCount[PROTOCOL_G2][ntLeaf] );

	pMap.Lookup( _T("EDServers"), m_pdCount[PROTOCOL_ED2K][ntHub] );

	pMap.Lookup( _T("DCHubs"), m_pdCount[PROTOCOL_DC][ntHub] );

	for ( PROTOCOLID nP = PROTOCOL_NULL ; nP < PROTOCOL_LAST ; ++nP )
	{
		for ( int nT = ntNode ; nT < ntLast ; nT++ )
		{
			if ( m_pdCount[ nP ][ nT ] != NULL )
				m_sCount[ nP ][ nT ] = m_pdCount[ nP ][ nT ]->m_sText;
		}
	}

	SetDocument( m_pDocument );

	Update();
}
Example #3
0
void CRefReport::NBTPage(BTPAGE * pBTPage, PAGETRAILER * pPT, IB ib)
{
	UINT icon = (m_pNDBViewer->FValidPage(ib, ptypeNBT) ? (pBTPage->cLevel == 0 ? iconLeafPage : iconPage ) : iconCorrupt);
	WCHAR buffer[255];
	const WCHAR * pNidName;
	BOOL fGreatSuccess;

	// add a ref for the data block and subnodes block of all entries
	NBTENTRY *pnbtEntry = (NBTENTRY*)(pBTPage->rgbte);
	for(UINT i = 0; i < NBTEnt(*pBTPage); i++, pnbtEntry++)
	{
		if(BIDStrip(pnbtEntry->bidData) == m_bid)
		{
			NodeData * pNodeData = new NodeData;
			pNodeData->bref.bid = pPT->bid;
			pNodeData->bref.ib = ib;
			pNodeData->cb = 512;
			pNodeData->btkey = 0;
			pNodeData->ulFlags = aOpenBTPage;

			m_lc.InsertItem(m_cCalculatedCount, L"Page", icon);

			wsprintf(buffer, L"0x%I64X", pPT->bid);
			m_lc.SetItemText(m_cCalculatedCount, 1, buffer);

			fGreatSuccess = s_nidToString.Lookup((NID)pnbtEntry->nid, pNidName);
			wsprintf(buffer, L"Data BID for NID 0x%I64X (%s)", pnbtEntry->nid, fGreatSuccess ? pNidName : TYPESTRINGFROMNID(pnbtEntry->nid));
			m_lc.SetItemText(m_cCalculatedCount, 2, buffer);

			m_lc.SetItemData(m_cCalculatedCount, (DWORD_PTR)pNodeData);
			m_cCalculatedCount++;
		}

		if(BIDStrip(pnbtEntry->bidSub) == m_bid)
		{
			NodeData * pNodeData = new NodeData;
			pNodeData->bref.bid = pPT->bid;
			pNodeData->bref.ib = ib;
			pNodeData->cb = 512;
			pNodeData->btkey = 0;
			pNodeData->ulFlags = aOpenBTPage;

			m_lc.InsertItem(m_cCalculatedCount, L"Page", icon);

			wsprintf(buffer, L"0x%I64X", pPT->bid);
			m_lc.SetItemText(m_cCalculatedCount, 1, buffer);

			fGreatSuccess = s_nidToString.Lookup((NID)pnbtEntry->nid, pNidName);
			wsprintf(buffer, L"Subnode BID for NID 0x%I64X (%s)", pnbtEntry->nid, fGreatSuccess ? pNidName : TYPESTRINGFROMNID(pnbtEntry->nid));
			m_lc.SetItemText(m_cCalculatedCount, 2, buffer);

			m_lc.SetItemData(m_cCalculatedCount, (DWORD_PTR)pNodeData);
			m_cCalculatedCount++;
		}
	}
}
static int Script_DebugSetLocation( LuaState* state )
{
	LuaStackObject stateObj( state, 1 );
	LuaStackObject filenameObj( state, 2 );
	LuaStackObject lineNumberObj( state, 3 );

	const char* stateStr = stateObj.GetString();

	CString fileName = filenameObj.GetString();
	fileName.MakeLower();
	int lineNumber = lineNumberObj.GetInteger();

	CString fileNameNoPath = fileName;
	int slashPos = fileNameNoPath.ReverseFind('/');
	fileNameNoPath = fileNameNoPath.Mid(slashPos + 1);

	int temp;
	if (!m_receivedFileMap.Lookup(fileNameNoPath, temp))
	{
		// Go to the next line.
		CString command;
		command.Format(_T("DebugStepOut()"));
		theApp.GetNetworkClient().SendCommand(command);
	}
	else
	{
		theApp.GetDebuggerView()->DebugSetLocation(stateStr, fileNameNoPath, lineNumber);
	}

	return 0;
}
Example #5
0
TPUT_API CBdd PCM_Eval_tput_0(int& maxSize, int limit, CDynElement * p_this)
{
  CDynProperty *prop;
  int propVal = 0;
  POSITION pos;
  CBdd ret;


  CBdd encoding = p_this->GetEncoding();
  CBdd baseEnc = p_this->GetBaseEncoding();

  const CDynElementList& children = p_this->GetChildren();  
  const CDynElement * parent = p_this->GetParent();

  if (tputBdd_cache.Lookup(p_this, ret)) return ret;
	
/*
  if (tputDone)
    return tputBdd;
*/
  switch((CDecomposition)*p_this)
  {
  case decompAnd:
    ret = DoPathTput(maxSize, limit, p_this);
    break;

  case decompOr:
    ret = CBdd::Zero();
    pos = children.GetHeadPosition();
    while(pos)
      //ret = ret || children.GetNext(pos)->Tput_0(maxSize, limit);
	  ret = ret || PCM_Eval_tput_0(maxSize, limit,  children.GetNext(pos));

    break;

  case decompLeaf:
    prop = ((CDynElement*)p_this)->FindProperty(_T("tput"));
   // ret = prop ? prop->MaptoBdd( encoding ) : CBdd::One();
	 ret = prop ? prop->MapValuetoBdd( encoding ) : CBdd::One();
    break;
  }

  /*
   * if parent is OR decomposed, then
   * append the orthogonality factor to the child
   */
  if (parent && (decompOr == (CDecomposition)(*parent)))
    ret = CBdd::Mtbdd_Ite(baseEnc, ret);
/*
  tputBdd = ret;
  tputDone = true;
  */
  
  tputBdd_cache[p_this] = ret;

  int sz = ret.size();
  if (sz > maxSize) maxSize = sz;
  return ret;
}
void KeepRxPacket(void *buffer, ULONG serial)
{
    void *p;
    if (QueueOfRxPackets.Lookup(serial, p))
    {
        FailCase("[%s] - packet %d already exists!", __FUNCTION__, serial);
        QueueOfRxPackets.RemoveKey(serial);
    }
    QueueOfRxPackets.SetAt(serial, buffer);
}
void *GetRxPacket(ULONG serial)
{
    void *p = NULL;
    if (QueueOfRxPackets.Lookup(serial, p))
    {
        QueueOfRxPackets.RemoveKey(serial);
        return p;
    }
    else
    {
        FailCase("[%s] - packet %d does not exist!", __FUNCTION__, serial);
        return NULL;
    }
}
Example #8
0
BOOL ShellIcons::DrawIcon(CDC* pDC, SHELLICON nIndex, const CPoint& ptTopLeft, bool bLarge)
{
	// maintain a static list of large and small icons
	static CMap<SHELLICON, SHELLICON, HICON, HICON> mapLarge, mapSmall;

	// try lookup first
	HICON hIcon = NULL;

	if (bLarge)
		mapLarge.Lookup(nIndex, hIcon);
	else
		mapSmall.Lookup(nIndex, hIcon);

	// else extract
	if (hIcon == NULL)
		hIcon = ExtractIcon(nIndex, bLarge);

	ASSERT(hIcon);

	if (hIcon)
	{
		int nSize = bLarge ? 32 : 16;

		if (DrawIconEx(*pDC, ptTopLeft.x, ptTopLeft.y, hIcon, nSize, nSize, 0, NULL, DI_NORMAL))
		{
			if (bLarge)
				mapLarge[nIndex] = hIcon;
			else
				mapSmall[nIndex] = hIcon;

			return TRUE;
		}
	}

	// else
	return FALSE;
}
int CALLBACK CRemoteFileDialog::SortProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
	CMap<int, int, FILEITEM, FILEITEM&>* pMapItems = (CMap<int, int, FILEITEM, FILEITEM&>*)lParamSort;

	FILEITEM fi1, fi2;

	VERIFY(pMapItems->Lookup(lParam1, fi1));
	VERIFY(pMapItems->Lookup(lParam2, fi2));

	if (fi1.nType != fi2.nType)
	{
		return fi1.nType - fi2.nType;
	}

	return fi1.sFilename.CompareNoCase(fi2.sFilename);
}
Example #10
0
// This is the command 'NOTIFY'
void asdkBubble()
{
	// Create the bubble notification message, and callbacks.
	int result;
	AcApDocument *pDoc=acDocManager->curDocument();
	CString strMsg((CString)_T("Document ")+pDoc->docTitle()+_T(" Notification"));
	AcTrayItemBubbleWindowControl bwControl(_T("Attention!"), strMsg, _T("HyperText Here"), _T("www.autodesk.com"));
	bwControl.SetIconType(AcTrayItemBubbleWindowControl::BUBBLE_WINDOW_ICON_INFORMATION);
	bwControl.SetCallback(BubbleWindowCallback, pDoc);
	
	// Display the notification at the first of our icons - kept as a pointer in the map.
	CTrayItem *pFirstTrayItem=NULL;
	documentTrayMap.Lookup(acDocManager->curDocument(),pFirstTrayItem);
	if(pFirstTrayItem)
		result=pFirstTrayItem->ShowBubbleWindow(&bwControl);
}
Example #11
0
void CHomeUploadsBox::OnSkinChange()
{
	if ( m_pDocument ) delete m_pDocument;
	m_pDocument = NULL;
	m_pdUploadsNone = m_pdUploadsOne = m_pdUploadsMany = NULL;
	m_pdUploadedNone = m_pdUploadedOne = m_pdUploadedMany = NULL;
	m_pdTorrentsOne = m_pdTorrentsMany = NULL;

	SetCaptionmark( _T("CHomeUploadsBox.Caption") );

	CXMLElement* pXML = Skin.GetDocument( _T("CHomeUploadsBox") );
	if ( pXML == NULL ) return;

	SetCaption( pXML->GetAttributeValue( _T("title"), _T("Uploads") ) );
	HICON hIcon = CoolInterface.ExtractIcon( IDR_UPLOADSFRAME, Settings.General.LanguageRTL );
	if ( hIcon ) SetIcon( hIcon );

	m_pDocument = new CRichDocument();

	CMap< CString, const CString&, CRichElement*, CRichElement* > pMap;
	if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return;

	pMap.Lookup( _T("UploadsNone"), m_pdUploadsNone );
	pMap.Lookup( _T("UploadsOne"), m_pdUploadsOne );
	pMap.Lookup( _T("UploadsMany"), m_pdUploadsMany );
	pMap.Lookup( _T("UploadedNone"), m_pdUploadedNone );
	pMap.Lookup( _T("UploadedOne"), m_pdUploadedOne );
	pMap.Lookup( _T("UploadedMany"), m_pdUploadedMany );
	pMap.Lookup( _T("TorrentsOne"), m_pdTorrentsOne );
	pMap.Lookup( _T("TorrentsMany"), m_pdTorrentsMany );

	if ( m_pdUploadedOne ) m_sUploadedOne = m_pdUploadedOne->m_sText;
	if ( m_pdUploadedMany ) m_sUploadedMany = m_pdUploadedMany->m_sText;

	if ( m_pdUploadsMany ) m_sUploadsMany = m_pdUploadsMany->m_sText;
	if ( m_pdTorrentsMany ) m_sTorrentsMany = m_pdTorrentsMany->m_sText;

	SetDocument( m_pDocument );

	Update();
}
Example #12
0
void CSizeableDlg::OnSizeControl(CWnd &stWnd, int cx, int cy, UINT nLocks)
{
	static CMap <CWnd*, CWnd*, WND_SIZE_DATA, WND_SIZE_DATA&> mapWnds;

	if (!IsWindow(stWnd))
		return;

	// check if this window was already measured by us
	WND_SIZE_DATA stSD;
	if (mapWnds.Lookup(&stWnd, stSD))
	{
		CRect stRect = stSD.stFirst;

		if (nLocks & 2)
		{
			stRect.right += cx - stSD.cx_now;
			if (nLocks & 1)
				stRect.left += cx - stSD.cx_now;
		}

		if (nLocks & 8)
		{
			stRect.bottom += cy - stSD.cy_now;
			if (nLocks & 4)
				stRect.top += cy - stSD.cy_now;
		}

		stWnd.MoveWindow(&stRect);
	} else
	{
		// this is a new window
		WND_SIZE_DATA stSD;
		stSD.cx_now = cx;
		stSD.cy_now = cy;

		stWnd.GetWindowRect(&stSD.stFirst);
		ScreenToClient(&stSD.stFirst);

		mapWnds.SetAt(&stWnd, stSD);
	}
}
Example #13
0
void CHomeDownloadsBox::OnSkinChange()
{
	if ( m_pDocument ) delete m_pDocument;
	m_pDocument = NULL;
	m_pdDownloadsNone = m_pdDownloadsOne = m_pdDownloadsMany = NULL;
	m_pdDownloadedNone = m_pdDownloadedOne = m_pdDownloadedMany = m_pdDownloadedVolume = NULL;

	SetCaptionmark( _T("CHomeDownloadsBox.Caption") );

	CXMLElement* pXML = Skin.GetDocument( _T("CHomeDownloadsBox") );
	if ( pXML == NULL ) return;

	SetCaption( pXML->GetAttributeValue( _T("title"), _T("Downloads") ) );
	HICON hIcon = CoolInterface.ExtractIcon( IDR_DOWNLOADSFRAME, Settings.General.LanguageRTL );
	if ( hIcon ) SetIcon( hIcon );

	m_pDocument = new CRichDocument();

	CMap< CString, const CString&, CRichElement*, CRichElement* > pMap;
	if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return;

	pMap.Lookup( _T("DownloadsNone"), m_pdDownloadsNone );
	pMap.Lookup( _T("DownloadsOne"), m_pdDownloadsOne );
	pMap.Lookup( _T("DownloadsMany"), m_pdDownloadsMany );
	pMap.Lookup( _T("DownloadedNone"), m_pdDownloadedNone );
	pMap.Lookup( _T("DownloadedOne"), m_pdDownloadedOne );
	pMap.Lookup( _T("DownloadedMany"), m_pdDownloadedMany );
	pMap.Lookup( _T("DownloadedVolume"), m_pdDownloadedVolume );

	if ( m_pdDownloadsMany ) m_sDownloadsMany = m_pdDownloadsMany->m_sText;
	if ( m_pdDownloadedMany ) m_sDownloadedMany = m_pdDownloadedMany->m_sText;

	SetDocument( m_pDocument );		// Was GetView().SetDocument( m_pDocument );

	Update();

	// Update Dropshadow
	m_wndTip.DestroyWindow();
	m_wndTip.Create( this, &Settings.Interface.TipDownloads );
}
void CXTPMarkupInputElement::FireTriggers(CXTPMarkupDependencyProperty* pProperty, CXTPMarkupObject* pNewValue)
{
	BOOL bChanged = FALSE;
	int i;

	CMap<CXTPMarkupDependencyProperty*, CXTPMarkupDependencyProperty*, CXTPMarkupObject*, CXTPMarkupObject*> mapOldValues;

	if (m_pActiveTriggers)
	{
		for (i = m_pActiveTriggers->GetCount() - 1; i >= 0; i--)
		{
			CXTPMarkupTrigger* pTrigger = m_pActiveTriggers->GetItem(i);

			if (pTrigger->GetTriggerProperty() == pProperty)
			{
				if (!pTrigger->GetTriggerValue()->IsEqual(pNewValue))
				{
					CXTPMarkupSetterColection* pSetters = pTrigger->GetSetters();

					for (int j = 0; j < pSetters->GetCount(); j++)
					{
						CXTPMarkupSetter* pSetter = pSetters->GetItem(j);
						CXTPMarkupDependencyProperty* pSetterProperty = pSetter->GetSetterProperty();

						CXTPMarkupObject* pOldValue = m_pTriggerProperties->Lookup(pSetterProperty);

						CXTPMarkupObject* pTempValue;
						if (!mapOldValues.Lookup(pSetterProperty, pTempValue))
						{
							MARKUP_ADDREF(pOldValue);
							mapOldValues.SetAt(pSetterProperty, pOldValue);
						}

						m_pTriggerProperties->Set(pSetterProperty, NULL);
					}

					m_pActiveTriggers->Remove(i);
					bChanged = TRUE;
				}
			}
		}
	}

	if (m_pStyleCache)
	{
		bChanged = AddStyleTriggers(m_pStyleCache, pProperty, pNewValue) || bChanged;
	}
	else if (GetType()->GetTypeStyle())
	{
		bChanged = AddStyleTriggers(GetType()->GetTypeStyle(), pProperty, pNewValue) || bChanged;
	}


	if (bChanged)
	{
		if (!m_pTriggerProperties)
			m_pTriggerProperties = new CXTPMarkupProperties(NULL);

		for (i = 0; i < m_pActiveTriggers->GetCount(); i++)
		{
			CXTPMarkupTrigger* pTrigger = m_pActiveTriggers->GetItem(i);

			CXTPMarkupSetterColection* pSetters = pTrigger->GetSetters();

			for (int j = 0; j < pSetters->GetCount(); j++)
			{
				CXTPMarkupSetter* pSetter = pSetters->GetItem(j);

				CXTPMarkupObject* pValue = pSetter->GetSetterValue();

				CXTPMarkupDependencyProperty* pSetterProperty = pSetter->GetSetterProperty();

				CXTPMarkupObject* pOldValue = m_pTriggerProperties->Lookup(pSetterProperty);

				if (!pValue->IsEqual(pOldValue))
				{
					CXTPMarkupObject* pTempValue;
					if (!mapOldValues.Lookup(pSetterProperty, pTempValue))
					{
						MARKUP_ADDREF(pOldValue);
						mapOldValues.SetAt(pSetterProperty, pOldValue);
					}

					pValue->AddRef();
					m_pTriggerProperties->Set(pSetterProperty, pValue);
				}
			}
		}
	}

	POSITION pos = mapOldValues.GetStartPosition();
	while (pos)
	{
		CXTPMarkupDependencyProperty* pProperty;
		CXTPMarkupObject* pOldValue;
		mapOldValues.GetNextAssoc(pos, pProperty, pOldValue);

		CXTPMarkupObject* pNewValue = m_pTriggerProperties->Lookup(pProperty);

		if (!::IsEqual(pNewValue, pOldValue))
		{
			OnPropertyChanged(pProperty, pOldValue, pNewValue);

			if (pProperty->GetFlags() & CXTPMarkupPropertyMetadata::flagInherited)
			{
				RecursePropertyChanged(pProperty, pOldValue, pNewValue);
			}
		}

		MARKUP_RELEASE(pOldValue);
	}
}
Example #15
0
bool CTobCompiler::CompilePass2(F_ErrorHandler ErrorHandler)
{
	bool haserr = false;
	int i, j, m, n = m_exp.GetSize();
	int pos, val, temp, factor;
	int len = m_bin.GetSize();
	CString err;
	m_line = 0;
	for(i = 0; i < n; ++i)
	{
		val = 0;
		factor = 1;
		const SExpInfo* ti = m_exp.ElementAt(i);
		m = ti->m_item.GetSize();
		pos = ti->m_pos;
		for(j = 0; j < m; ++j)
		{
			CString& str = ti->m_item[j];
			if(str == "+")
				factor = 1;
			else if(str == "-")
				factor = -1;
			else if(str == "@")
			{
				val += (pos + m_bit_i/8) * factor;
				factor = 1;
			}
			else
			{
				char c = str[0];
				if(c == '$')
				{
					str.Delete(0);
					c = str[0];
				}
				if(c >= '0' && c <= '9')
					val += atoi(str) * factor;
				else
				{
					if(m_label.Lookup(str, temp))
						val += temp * factor;
					else
					{
						m_err.Format("not found token '%s' at line %d", (LPCTSTR)str, ti->m_line);
						haserr = true;
						if(!ErrorHandler(GetErrorString(err))) return false;
					}
				}
				factor = 1;
			}
		}
		if(pos + m_bit_i/8 > len)
		{
			m_err.Format("internal compiler error %d > %d", pos + m_bit_i/8, len);
			haserr = true;
			ErrorHandler(GetErrorString(err));
			return false;
		}
		if(m_bit_i < 32 && val >= (1<<m_bit_i))
		{
			m_err.Format("overflow address (%p) when setting '.bit %u'", val, m_bit_i);
			haserr = true;
			if(!ErrorHandler(GetErrorString(err))) return false;
		}
						  m_bin[pos    ] =	val 	   & 255;
		if(m_bit_i >= 16) m_bin[pos + 1] = (val >>	8) & 255;
		if(m_bit_i >= 24) m_bin[pos + 2] = (val >> 16) & 255;
		if(m_bit_i >= 32) m_bin[pos + 3] =	val >> 24;
	}
	return !haserr;
}
Example #16
0
CTobCompiler::EToken CTobCompiler::CompilePass1()
{
	EToken r;
	CString str, buf;
	CByteArray* bin = 0;

	for(;;)
	{
		if((r = GetToken(str)) <= 0) return r;
		if(r == SYM_KEY)
		{
			if((r = GetToken(str)) < 0) return r;
			if(r != SYM_TOKEN)
			{
				m_err = "not found keyword after '.'";
				return ERR_NORMAL;
			}
			if(str == "def")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found token after '.def'";
					return ERR_NORMAL;
				}
				if((r = GetToken(buf)) < 0) return r;
				if(r == SYM_BIN)
				{
					bin = new CByteArray;
					if((r = GetBinary(*bin)) < 0) { delete bin; return r; }
				}
				else if(r == SYM_STR)
				{
					if((r = GetString(buf, false)) < 0) return r;
					bin = new CByteArray;
					for(LPCTSTR p = buf; *p; ++p) bin->Add(*(U8*)p);
					if(r == SYM_STRING) bin->Add(0);
				}
				else if(r == SYM_STRING)
				{
					if((r = GetString(buf, true)) < 0) return r;
					bin = new CByteArray;
					for(LPCTSTR p = buf; *p; ++p) bin->Add(*(U8*)p);
					if(r == SYM_STRING) bin->Add(0);
				}
				else
				{
					m_err = "not found '[' or ''' or '\"' after '.def <token>''";
					return ERR_NORMAL;
				}
				m_defbin.SetAt(str, bin);
				bin = 0;
			}
			else if(str == "change")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_STR)
				{
					m_err = "not found ''' after '.change'";
					return ERR_NORMAL;
				}
				if((r = GetString(str, false)) < 0) return r;
				if( str.IsEmpty() || str.GetLength()>2 || str.GetLength() == 2 && (U8)str[0]<0x80)
				{
					m_err = "only one character is allowed after '.change'";
					return ERR_NORMAL;
				}
				U16 c = (U8)str[0];
				if(str.GetLength() == 2) c = (c<<8) + (U8)str[1];
				if((r = GetToken(str)) < 0) return r;
				if(r == SYM_BIN)
				{
					CByteArray tmp;
					if((r = GetBinary(tmp)) < 0) return r;
					buf.Empty();
					int i, n = tmp.GetSize();
					for(i = 0; i < n; ++i)
					{
						U8 b = tmp.GetAt(i);
						if(!b) break;
						buf += (TCHAR)b;
					}
				}
				else if(r == SYM_STR)
				{
					if((r = GetString(buf, false)) < 0) return r;
				}
				else if(r == SYM_STRING)
				{
					if((r = GetString(buf, true)) < 0) return r;
				}
				else
				{
					m_err = "not found ''' or '\"' after '.change <char>'";
					return ERR_NORMAL;
				}
				m_change.SetAt(c, buf);
			}
			else if(str == "bit")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.bit'";
					return ERR_NORMAL;
				}
				int bit = atoi(str);
				if(bit!=8 && bit!=16 && bit!=24 && bit!=32)
				{
					m_err = "only '.bit 8/16/24/32' is available";
					return ERR_NORMAL;
				}
				m_bit_i = bit;
			}
			else if(str == "maxc")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxc'";
					return ERR_NORMAL;
				}
				m_maxc = atoi(str);
			}
			else if(str == "maxw")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxw'";
					return ERR_NORMAL;
				}
				m_maxw = atoi(str);
			}
			else if(str == "maxs")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxs'";
					return ERR_NORMAL;
				}
				m_maxs = atoi(str);
			}
			else
			{
				m_err.Format("unknwon keyword '%s' after '.'", (LPCTSTR)str);
				return ERR_NORMAL;
			}
		}
		else if(r == SYM_BIN)
		{
			if((r = GetBinary(m_bin)) < 0) return r;
		}
		else if(r == SYM_STR)
		{
			if((r = GetString(buf, false)) < 0) return r;
			for(LPCTSTR p=buf;* p; ++p) m_bin.Add(*(U8*)p);
			if(r == SYM_STRING) m_bin.Add(0);
		}
		else if(r == SYM_STRING)
		{
			if((r = GetString(buf, true)) < 0) return r;
			for(LPCTSTR p=buf;* p; ++p) m_bin.Add(*(U8*)p);
			if(r == SYM_STRING) m_bin.Add(0);
		}
		else if(r == SYM_TOKEN)
		{
			if(!m_defbin.Lookup(str, bin))
			{
				m_err.Format("not defined token '%s'", (LPCTSTR)str);
				return ERR_NORMAL;
			}
			m_bin.Append(*bin);
			bin = 0;
		}
		else if(r == SYM_ADDR)
		{
			if((r = GetToken(str)) < 0)
				return r;
			SExpInfo* ti = new SExpInfo(m_bin.GetSize(), m_line);
			if(r == SYM_EXP_BEGIN)
			{
				for(;;)
				{
					if((r = GetToken(buf)) < 0)
					{
						delete ti;
						return r;
					}
					if(r == SYM_TOKEN || r == SYM_NUM)
						ti->m_item.Add(buf);
					else if(r == SYM_ADD)
						ti->m_item.Add("+");
					else if(r == SYM_SUB)
						ti->m_item.Add("-");
					else if(r == SYM_ADDR)
						ti->m_item.Add("@");
					else if(r == SYM_EXP_END)
						break;
					else
					{
						delete ti;
						m_err.Format("found unknown token '%s' in expression", (LPCTSTR)buf);
						return ERR_NORMAL;
					}
				}
			}
			else if(r == SYM_TOKEN)
				ti->m_item.Add(str);
			else
			{
				delete ti;
				m_err = "not found token or expression after '@'";
				return ERR_NORMAL;
			}
			m_exp.Add(ti);
			for(int i = m_bit_i/8; i--;)
				m_bin.Add(0);
		}
		else if(r == SYM_LABEL)
		{
			if((r = GetToken(str)) < 0) return r;
			if(r != SYM_TOKEN)
			{
				m_err = "not found label after '#'";
				return ERR_NORMAL;
			}
			m_label.SetAt(str, m_bin.GetSize());
		}
		else
		{
			m_err = "unknown or bad symbol";
			return ERR_NORMAL;
		}
	}
}
//! Gets the created HTML elements as HTML text
void CRTF_HTMLConverter::R2H_GetHTMLElements(CString& strHTML)
{
	strHTML = _T("");

	// remove invalid trailing elements
	int iElemCount = m_arrHTMLElements.GetSize();

	while (iElemCount--)
	{
		CHTMLElement* pElem = m_arrHTMLElements[iElemCount];

		if (pElem->m_enNodeType == CHTMLElement::c_nodHTMLEnd)
		{
			iElemCount++; // we want this element
			break;
		}
		else if (pElem->m_enNodeType == CHTMLElement::c_nodText)
		{
			CString sText = pElem->m_strNodeText;
			sText.TrimLeft();
			sText.TrimRight();

			if (!sText.IsEmpty() && sText != _T("br") && sText != _T("\n") && sText != _T("\r\n"))
			{
				iElemCount++; // we want this element
				break;
			}
		}
	}

	// Loop thru what's remaining of the HTML elements
	CMap<CString, LPCTSTR, int, int> mapOpenTags;

	for (int iElem = 0; iElem < iElemCount; iElem++)
	{
		CHTMLElement* pElem = m_arrHTMLElements[iElem];
		CString sElem;

		if (pElem->m_enNodeType == CHTMLElement::c_nodHTMLBegin)
		{
			// look ahead so that we can strip out empty tag pairs (typically 'font')
			bool bEmpty = false;

			if (iElem + 1 < m_arrHTMLElements.GetSize())
			{
				CHTMLElement* pElemNext = m_arrHTMLElements[iElem + 1];

				if (pElemNext->m_enNodeType == CHTMLElement::c_nodHTMLEnd &&
					pElemNext->m_strNodeText == pElem->m_strNodeText)
				{
					//TRACE ("CRTF_HTMLConverter::R2H_GetHTMLElements(removing '%s')\n", pElemNext->m_strNodeText);
					bEmpty = true;
				}
			}

			if (bEmpty)
			{
				iElem++;   // remove end tag too
			}
			else
			{
				// keep track of opentags
				int nCount = 0;

				mapOpenTags.Lookup(pElem->m_strNodeText, nCount);
				mapOpenTags[pElem->m_strNodeText] = ++nCount;

				// HTML element open tag
				sElem = _T("<");
				sElem += pElem->m_strNodeText;

				// HTML element parameters (<font param1="test" param2="hugo">
				POSITION pos = pElem->m_mapParams.GetStartPosition();

				while (pos)
				{
					CString strKey, strValue;
					pElem->m_mapParams.GetNextAssoc(pos, strKey, strValue);

					sElem += _T(" ") + strKey + _T(" = ") + strValue;
				}
				sElem += _T(">");
			}
		}
		else if (pElem->m_enNodeType == CHTMLElement::c_nodHTMLEnd)
		{
			sElem.Format(_T("</%s>"), pElem->m_strNodeText);

			// decrement open tag count
			int nCount = 0;

			mapOpenTags.Lookup(pElem->m_strNodeText, nCount);

			if (nCount > 0)
			{
				mapOpenTags[pElem->m_strNodeText] = --nCount;
			}
		}
		else if (pElem->m_enNodeType == CHTMLElement::c_nodText)
		{
			sElem = pElem->m_strNodeText;
		}
		else
		{
			ASSERT(FALSE); //internal error (wrong html tag)
		}

		if (!sElem.IsEmpty())
		{
			strHTML += sElem;
		}
	}

	// any open tags remaining?
	POSITION pos = mapOpenTags.GetStartPosition();

	while (pos)
	{
		CString sTag, sClose;
		int nCount = 0;
		mapOpenTags.GetNextAssoc(pos, sTag, nCount);

		if (nCount && sTag != _T("br"))
		{
			sClose.Format(_T("</%s>"), sTag);

			while (nCount--)
			{
				strHTML += sClose;
			}
		}
	}
}
Example #18
0
void CRefReport::BBTPage(BTPAGE * pBTPage, PAGETRAILER * pPT, IB ib)
{
	UINT icon = (m_pNDBViewer->FValidPage(ib, ptypeBBT) ? (pBTPage->cLevel == 0 ? iconLeafPage : iconPage ) : iconCorrupt);
	BBTENTRY *pbbtEntry = (BBTENTRY*)(pBTPage->rgbte);
	WCHAR buffer[255];
	BOOL fGreatSuccess;
	const WCHAR * pNidName;

	for(int i = 0; i < pBTPage->cEnt; i++, pbbtEntry++)
	{
		if(BIDStrip(pbbtEntry->bref.bid) == m_bid)
		{
			NodeData * pNodeData = new NodeData;
			pNodeData->bref.bid = pPT->bid;
			pNodeData->bref.ib = ib;
			pNodeData->cb = 512;
			pNodeData->btkey = 0;
			pNodeData->ulFlags = aOpenBTPage;
			m_lc.InsertItem(m_cCalculatedCount, L"Page", icon);

			wsprintf(buffer, L"0x%I64X", pPT->bid);
			m_lc.SetItemText(m_cCalculatedCount, 1, buffer);

			m_lc.SetItemText(m_cCalculatedCount, 2, L"BBT Leaf Page Ref");

			m_lc.SetItemData(m_cCalculatedCount, (DWORD_PTR)pNodeData);
			m_cCalculatedCount++;
		}

		// if the bid is an internal bid, we have to open the block and add all of it's refs
		if(BIDIsInternal(pbbtEntry->bref.bid))
		{
			BYTE * blockData = new BYTE[BBufferSize(pbbtEntry->cb)];
			UINT iconBlock = (m_pNDBViewer->FValidBlock(pbbtEntry->bref.ib, pbbtEntry->cb, pbbtEntry->bref.bid) ? iconInternalBlock : iconCorrupt);
			BLOCKTRAILER bt;

			m_pNDBViewer->ReadBlock(blockData, BBufferSize(pbbtEntry->cb), &bt, pbbtEntry->bref.ib, CbAlignDisk(pbbtEntry->cb));

			// add all of the refs
			if(blockData[0] == btypeSB)
			{
				SBLOCK * psb = (SBLOCK*)blockData;
				if(psb->cLevel > 0)
				{
					SIENTRY * siEntry = psb->rgsi;
					for(UINT i = 0; i < SBIEnt(*psb, BBufferSize(pbbtEntry->cb)); i++, siEntry++)
					{
						if(BIDStrip(siEntry->bid) == m_bid)
						{
							NodeData * pNodeData = new NodeData;
							pNodeData->bref = pbbtEntry->bref;
							pNodeData->cb = pbbtEntry->cb;
							pNodeData->btkey = 0;
							pNodeData->ulFlags = aOpenBlock | aBrowseBBT;
							m_lc.InsertItem(m_cCalculatedCount, L"Block", iconBlock);

							wsprintf(buffer, L"0x%I64X", pbbtEntry->bref.bid);
							m_lc.SetItemText(m_cCalculatedCount, 1, buffer);

							wsprintf(buffer, L"SIENTRY %u", i);
							m_lc.SetItemText(m_cCalculatedCount, 2, buffer);

							m_lc.SetItemData(m_cCalculatedCount, (DWORD_PTR)pNodeData);
							m_cCalculatedCount++;
						}
					}
				}
				else
				{
					SLENTRY * slEntry = psb->rgsl;
					for(UINT i = 0; i < SBLEnt(*psb, BBufferSize(pbbtEntry->cb)); i++, slEntry++)
					{
						if(BIDStrip(slEntry->bidData) == m_bid)
						{
							NodeData * pNodeData = new NodeData;
							pNodeData->bref = pbbtEntry->bref;
							pNodeData->cb = pbbtEntry->cb;
							pNodeData->btkey = 0;
							pNodeData->ulFlags = aOpenBlock | aBrowseBBT;
							m_lc.InsertItem(m_cCalculatedCount, L"Block", iconBlock);

							wsprintf(buffer, L"0x%I64X", pbbtEntry->bref.bid);
							m_lc.SetItemText(m_cCalculatedCount, 1, buffer);

							fGreatSuccess = s_nidToString.Lookup((NID)slEntry->nid, pNidName);
							wsprintf(buffer, L"Data BID for Subnode NID 0x%X (%s)", slEntry->nid, fGreatSuccess ? pNidName : TYPESTRINGFROMNID(slEntry->nid));
							m_lc.SetItemText(m_cCalculatedCount, 2, buffer);
							
							m_lc.SetItemData(m_cCalculatedCount, (DWORD_PTR)pNodeData);
							m_cCalculatedCount++;
						}
						if(BIDStrip(slEntry->bidSub) == m_bid)
						{
							NodeData * pNodeData = new NodeData;
							pNodeData->bref = pbbtEntry->bref;
							pNodeData->cb = pbbtEntry->cb;
							pNodeData->btkey = 0;
							pNodeData->ulFlags = aOpenBlock | aBrowseBBT;
							m_lc.InsertItem(m_cCalculatedCount, L"Block", iconBlock);

							wsprintf(buffer, L"0x%I64X", pbbtEntry->bref.bid);
							m_lc.SetItemText(m_cCalculatedCount, 1, buffer);

							fGreatSuccess = s_nidToString.Lookup((NID)slEntry->nid, pNidName);
							wsprintf(buffer, L"Subnode BID for Subnode NID 0x%X (%s)", slEntry->nid, fGreatSuccess ? pNidName : TYPESTRINGFROMNID(slEntry->nid));
							m_lc.SetItemText(m_cCalculatedCount, 2, buffer);

							m_lc.SetItemData(m_cCalculatedCount, (DWORD_PTR)pNodeData);
							m_cCalculatedCount++;
						}
					}
				}
			}
			else if(blockData[0] == btypeXB)
			{
				XBLOCK *pxb = (XBLOCK*)blockData;
				// here we don't care about level, every level XBLOCK is just a list of BIDs
				for(UINT i = 0; i < XBEnt(*pxb, BBufferSize(pbbtEntry->cb)); i++)
				{
					if(BIDStrip(pxb->rgbid[i]) == m_bid)
					{
						NodeData * pNodeData = new NodeData;
						pNodeData->bref = pbbtEntry->bref;
						pNodeData->cb = pbbtEntry->cb;
						pNodeData->btkey = 0;
						pNodeData->ulFlags = aOpenBlock | aBrowseBBT;

						m_lc.InsertItem(m_cCalculatedCount, L"Block", iconBlock);

						wsprintf(buffer, L"0x%I64X", pbbtEntry->bref.bid);
						m_lc.SetItemText(m_cCalculatedCount, 1, buffer);

						wsprintf(buffer, L"XBLOCK entry %u", i);
						m_lc.SetItemText(m_cCalculatedCount, 2, buffer);

						m_lc.SetItemData(m_cCalculatedCount, (DWORD_PTR)pNodeData);
						m_cCalculatedCount++;
					}
				}
			}
			delete [] blockData;
		}
	}
}
bool tScriptState::GetVariable(LPCSTR s, ULONG& value) const
{
    bool b = !!Variables.Lookup(s, value);
    return b;
}
Example #20
0
void HandleListCommand(const CStringArray& saArgs)
{
	// get the active Compression Manager interface
	CComPtr<IUnknown> pCompressionRuleManagerUnk;
	HRESULT hr = ::GetActiveObject(CLSID_CompressionRuleManager, NULL, (IUnknown**) &pCompressionRuleManagerUnk);
	if (hr != S_OK)
	{
		throw ProcessingException(hr, IDS_ERROR_NORUNNINGIISXPRESS);				
	}	

	// get the rule manager
	CComQIPtr<ICompressionRuleManager> pCompressionRuleManager = pCompressionRuleManagerUnk;
	if (pCompressionRuleManager == NULL)
	{
		throw ProcessingException(E_NOINTERFACE, IDS_INTERNALERROR);
	}

	// get the never compress rules
	CComQIPtr<INeverCompressRules> pNeverCompressRules = pCompressionRuleManager;
	if (pNeverCompressRules == NULL)
	{
		throw ProcessingException(E_NOINTERFACE, IDS_INTERNALERROR);
	}

	if (saArgs.GetCount() == 1 && saArgs[0].CompareNoCase(_T("extn")) == 0)
	{
		CComPtr<IEnumExclusionRule> pExtnRules;
		hr = pNeverCompressRules->EnumExtensions(&pExtnRules);
		if (hr != S_OK || pExtnRules == NULL)
		{
			throw ProcessingException(hr, IDS_ERROR_UNABLETOENUMEXTNS);
		}

		int nExtns = 0;
		ULONG nFetched = 0;
		ExclusionRuleInfo RuleInfo;
		while (pExtnRules->Next(1, &RuleInfo, &nFetched) == S_OK)
		{
			if (nExtns == 0)
			{
				_tprintf(_T("Extensions:\n"));
			}

			_tprintf(_T(" %ls\n"), RuleInfo.bsRule);
			nExtns++;
		}

		_tprintf(_T("%sFound %d excluded extension(s)\n"), 
			nExtns > 0 ? _T("\n") : _T(""),
			nExtns);
	}
	else if (saArgs.GetCount() == 1 && saArgs[0].CompareNoCase(_T("ct")) == 0)
	{
		CComPtr<IEnumExclusionRule> pCTRules;
		hr = pNeverCompressRules->EnumContentTypes(&pCTRules);
		if (hr != S_OK || pCTRules == NULL)
		{
			throw ProcessingException(hr, IDS_ERROR_UNABLETOENUMCTS);
		}

		int nCTs = 0;
		ULONG nFetched = 0;
		ExclusionRuleInfo RuleInfo;
		while (pCTRules->Next(1, &RuleInfo, &nFetched) == S_OK)
		{
			if (nCTs == 0)
			{
				_tprintf(_T("Content Types:\n"));
			}

			_tprintf(_T(" %ls\n"), RuleInfo.bsRule);
			nCTs++;
		}

		_tprintf(_T("%sFound %d excluded content type(s)\n"), 
			nCTs > 0 ? _T("\n") : _T(""),
			nCTs);
	}
	else if (saArgs.GetCount() == 1 && saArgs[0].CompareNoCase(_T("uri")) == 0)
	{
		CMap<CStringW, LPCWSTR, CString, LPCTSTR> Servers;		

		CComPtr<IEnumExclusionRule> pURIRules;
		hr = pNeverCompressRules->EnumFolders(&pURIRules);
		if (hr != S_OK || pURIRules == NULL)
		{
			throw ProcessingException(hr, IDS_ERROR_UNABLETOENUMURIS);
		}

		// for Vista we need to get the config document
		CComPtr<IXMLDOMDocument> pDoc;
		if (g_VerInfo.dwMajorVersion >= 6 && CIIS7XMLConfigHelper::GetApplicationHostConfigDocument(&pDoc) != S_OK)
		{
			// TODO: throw better error message
			throw ProcessingException(hr, IDS_ERROR_UNABLETOENUMURIS);
		}

		int nURIs = 0;
		ULONG nFetched = 0;
		ExclusionRuleInfo RuleInfo;
		while (pURIRules->Next(1, &RuleInfo, &nFetched) == S_OK)
		{						
			if (nURIs == 0)
			{
				_tprintf(_T("Web site/URI:\n"));
			}

			CString sInstance;

			// try to map the server name to an instance
			if (Servers.Lookup(RuleInfo.bsInstance, sInstance) == TRUE)
			{
				// we got a hit, do nothing
			}
			else if (g_VerInfo.dwMajorVersion < 6 && MapInstanceToServerName(RuleInfo.bsInstance, sInstance) == true)
			{
				// the mapping was a success, so store it
				Servers[sInstance] = RuleInfo.bsInstance;
			}
			else if (g_VerInfo.dwMajorVersion >= 6)
			{
				// for Vista we get the site node from the XML config file
				CComPtr<IXMLDOMNode> pSite;				
				if (CIIS7XMLConfigHelper::GetSiteNode(pDoc, RuleInfo.bsInstance, &pSite) == S_OK)
				{
					CAtlString sId;
					CAtlString sDesc;
					CAtlString sPhysicalPath;
					CAtlArray<CAtlString> Ports;
					CAtlArray<CAtlString> SecurePorts;

					if (CIIS7XMLConfigHelper::GetSiteInfo(pSite, sId, sDesc, sPhysicalPath, Ports, SecurePorts) == S_OK)
					{
						sInstance = sDesc;

						// the mapping was a success, so store it
						Servers[sInstance] = RuleInfo.bsInstance;
					}
				}
			}
			else
			{
				// use the raw instance number
				sInstance = RuleInfo.bsInstance;
			}

			_tprintf(_T(" %-24ls %ls%s\n"), 
				sInstance, 
				RuleInfo.bsRule,
				RuleInfo.dwFlags == RULEFLAGS_FOLDER_WILDCARDMATCH ? _T("/*") : _T(""));

			nURIs++;			
		}

		_tprintf(_T("%sFound %d excluded URIs(s)\n"), 
			nURIs > 0 ? _T("\n") : _T(""),
			nURIs);
	}
	else if (saArgs.GetCount() == 2 && saArgs[0].CompareNoCase(_T("uri")) == 0)
	{								
		CComPtr<IEnumExclusionRule> pURIRules;
		hr = pNeverCompressRules->EnumFolders(&pURIRules);
		if (hr != S_OK || pURIRules == NULL)
		{
			throw ProcessingException(hr, IDS_ERROR_UNABLETOENUMURIS);
		}

		// assume the arg is an instance number
		CString sInstance = saArgs[1];

		if (g_VerInfo.dwMajorVersion < 6)
		{
			// attempt to map the arg to an instance id
			MapServerNameToInstance(saArgs[1], sInstance);
		}
		else
		{
			CComPtr<IXMLDOMDocument> pDoc;
			if (CIIS7XMLConfigHelper::GetApplicationHostConfigDocument(&pDoc) == S_OK)
			{
				// attempt to map the arg to an instance id
				MapServerNameToInstance(pDoc, saArgs[1], sInstance);
			}
		}

		int nURIs = 0;
		ULONG nFetched = 0;
		ExclusionRuleInfo RuleInfo;
		while (pURIRules->Next(1, &RuleInfo, &nFetched) == S_OK)
		{	
			if (sInstance.CompareNoCase(RuleInfo.bsInstance) != 0)
				continue;

			if (nURIs == 0)
			{
				_tprintf(_T("URI:\n"));
			}

			_tprintf(_T(" %ls%s\n"), 				
				RuleInfo.bsRule,
				RuleInfo.dwFlags == RULEFLAGS_FOLDER_WILDCARDMATCH ? _T("/*") : _T(""));

			nURIs++;			
		}

		_tprintf(_T("%sFound %d excluded URIs(s)\n"), 
			nURIs > 0 ? _T("\n") : _T(""),
			nURIs);
	}
	else if (saArgs.GetCount() == 1 && saArgs[0].CompareNoCase(_T("ip")) == 0)
	{		
		CComPtr<IEnumExclusionRule> pIPRules;
		hr = pNeverCompressRules->EnumIPAddresses(&pIPRules);
		if (hr != S_OK || pIPRules == NULL)
		{
			throw ProcessingException(hr, IDS_ERROR_UNABLETOENUMIPS);
		}

		int nIPs = 0;
		ULONG nFetched = 0;
		ExclusionRuleInfo RuleInfo;
		while (pIPRules->Next(1, &RuleInfo, &nFetched) == S_OK)
		{
			if (nIPs == 0)
			{
				_tprintf(_T("IP Addresses:\n"));
			}

			_tprintf(_T(" %ls\n"), RuleInfo.bsRule);
			nIPs++;
		}

		_tprintf(_T("%sFound %d excluded IP(s)\n"), 
			nIPs > 0 ? _T("\n") : _T(""),
			nIPs);
	}
	else if (saArgs.GetCount() >= 1 && saArgs[0].CompareNoCase(_T("file")) == 0)
	{
		CComQIPtr<IStaticFileRules> pStaticFileRules = pNeverCompressRules;
		if (pStaticFileRules != NULL)
		{
			// loop round the supplied filepaths
			for (int i = 1; i < saArgs.GetCount(); i++)
			{
				const TCHAR* pszFilepath = saArgs[i];

				CComPtr<IEnumStaticFileInfo> pEnumFileInfo;
				HRESULT hr = pStaticFileRules->EnumByPath(CStringA(pszFilepath), &pEnumFileInfo);
				if (hr != S_OK)
					continue;

				if (i != 1)
				{
					_tprintf(_T("\n"));
				}

				_tprintf(_T("Path: %s\n"), pszFilepath);

				int nFiles = 0;

				while (1)
				{
					ULONG nFetched = 0;
					StaticFileInfo fileInfo;
					hr = pEnumFileInfo->Next(1, &fileInfo, &nFetched);
					if (hr != S_OK || nFetched != 1)
					{
						break;
					}

					// only show user excluded files
					if (fileInfo.nUserCompression == 0)
					{						
						wprintf(L" %s\n", fileInfo.bsFilename);						

						nFiles++;
					}

					::SysFreeString(fileInfo.bsPath);
					::SysFreeString(fileInfo.bsFilename);															
				}

				_tprintf(_T("Found %d excluded file(s)\n"), nFiles);
			}
		}
	}
	else
	{
		CString sMsg;
		sMsg.LoadString(IDS_ERROR_COMMANDLINEINCORRECT);		
		throw sMsg;
	}	
}
Example #21
0
int CGrfDoc::DeleteTags(bool WithPrompts)
  {
  Strng_List MyTags;
  GetTagList(MyTags);
  int nTags=MyTags.Length();
  int nTagsMultPgs=0;
  if (nTags>0)
    {
    CMap<LPTSTR, LPTSTR, Strng*, Strng*> MyTagMap;
    MyTagMap.InitHashTable(FindNextPrimeNumber(MyTags.Length()));
    for (Strng *pTag=MyTags.First(); pTag; pTag=MyTags.Next())
      {
      pTag->SetIndex(0);
      MyTagMap.SetAt(pTag->Str(), pTag);
      }

    for (int iTmpl=iGraphTemplate; iTmpl<=iVisioTemplate; iTmpl++)
      {
      if (ScdApp()->TemplateExists(iTmpl))
        {
        POSITION Pos = ScdApp()->Template(iTmpl).GetFirstDocPosition();
        while (Pos)
          {
          CGrfDoc* pOtherDoc = (CGrfDoc*)(ScdApp()->Template(iTmpl).GetNextDoc(Pos));
          if (pOtherDoc!=this)
            {
            Strng *pTag;
            Strng_List OtherTags;
            int NGrfTags = pOtherDoc->GetTagList(OtherTags);
            for (Strng *pOtherTag=OtherTags.First(); pOtherTag; pOtherTag=OtherTags.Next())
              if (MyTagMap.Lookup(pOtherTag->Str(), pTag))
                pTag->SetIndex(pTag->Index()+1);
            }
          }
        }
      }

    for (Strng *pTag=MyTags.First(); pTag; pTag=MyTags.Next())
      {
      if (pTag->Index()>0)
        nTagsMultPgs++;
      }

    int Ret=IDYES;
    if (WithPrompts)
      {
      CString S;
      if (nTagsMultPgs)
        S.Format("Do you want Delete %i Units (%i Units have Multiple References)", nTags-nTagsMultPgs, nTagsMultPgs);
      else
        S.Format("Do you want Delete %i Units", nTags);
      Ret=AfxMessageBox(S, MB_ICONQUESTION|MB_YESNOCANCEL);
      }
    if (Ret==IDCANCEL)
      return -1;
    if (Ret==IDYES)
      {
      Strng_List DelTags;
      int nMdlDeletes=0;
      int nDeletesFailedCnt=0;
      for (Strng *pTag=MyTags.First(); pTag; pTag=MyTags.Next())
        {
        if (pTag->Index()==0)
          {
          DelTags.Append(pTag->Str());
          }
        }

      int RetCode = gs_Exec.DeleteTags(DelTags);
      for (Strng *pTag=DelTags.First(); pTag; pTag=MyTags.Next())
        {
        if (pTag->Index()!=EODT_DONE)
          {
          //dbgpln("Mdl Not Deleted %s", pTag->Str());
          LogError(pTag->Str(), 0, "Model not deleted");
          nDeletesFailedCnt++;
          }
        else
          {
          //dbgpln("Mdl     Deleted %s", pTag->Str());
          nMdlDeletes++;
          }
        }
      if (nDeletesFailedCnt)
        {
        CString S;
        S.Format("%i Units Failed to Delete", nDeletesFailedCnt);
        AfxMessageBox(S, MB_ICONEXCLAMATION|MB_OK);
        }
      }
    }
  return nTags;
  };
Example #22
0
// 返回SYM_STR表示不加"\0",否则加"\0"
CTobCompiler::EToken CTobCompiler::GetString(CString& str, bool change)
{
	str.Empty();
	int c, d;
	int numc = 0;
	int numw = 0;
	int nums = 0;
	CString chg;
	for(;;)
	{
		if((c = fgetc(m_fsrc)) < 0) break;
		if(c == '\n') ++m_line;
		if(!change && c < ' ') continue;
		if(c == '\'')
		{
			return change ? SYM_STRING : SYM_STR;
		}
		else if(c == '"')
		{
			if(change)
			{
				if(m_maxc >= 0 && numc > m_maxc)
				{
					m_err.Format("exceed '.maxc %d' < %d", m_maxc, numc);
					return ERR_NORMAL;
				}
				if(m_maxw >= 0 && numw > m_maxw)
				{
					m_err.Format("exceed '.maxw %d' < %d", m_maxw, numw);
					return ERR_NORMAL;
				}
				if(m_maxs >= 0 && nums > m_maxs)
				{
					m_err.Format("exceed '.maxs %d' < %d", m_maxs, nums);
					return ERR_NORMAL;
				}
			}
			return change ? SYM_STR : SYM_STRING;
		}
		else if(c == '\\')
		{
			if((c = fgetc(m_fsrc)) < 0) break;
			switch(c)
			{
			case 'n': c = '\n';   break;
			case 'r': c = '\r';   break;
			case 't': c = '\t';   break;
			case '0': c = '\0';   break;
			case '1': c = '\x01'; break;
			case '2': c = '\x02'; break;
			case '3': c = '\x03'; break;
			case '4': c = '\x04'; break;
			case '5': c = '\x05'; break;
			case '6': c = '\x06'; break;
			case '7': c = '\x07'; break;
			case '8': c = '\x08'; break;
			case '9': c = '\x09'; break;
			case 'A':
			case 'a': c = '\x0a'; break;
			case 'B':
			case 'b': c = '\x0b'; break;
			case 'C':
			case 'c': c = '\x0c'; break;
			case 'D':
			case 'd': c = '\x0d'; break;
			case 'E':
			case 'e': c = '\x0e'; break;
			case 'F':
			case 'f': c = '\x0f'; break;
			}
		}
		if(c >= 0x80)
		{
			if((d = fgetc(m_fsrc)) < 0) break;
			if(d < 0x40)
			{
				if(fseek(m_fsrc, -1, SEEK_CUR))
				{
					m_err.Format("can not seek src file at %p", ftell(m_fsrc));
					return ERR_SEVERE;
				}
				m_err.Format("found half wide char at %p", ftell(m_fsrc));
				return ERR_NORMAL;
			}
			if(change && m_change.Lookup(((U16)c<<16) + d, chg))
			{
				str += chg;
			}
			else
			{
				str += (TCHAR)c;
				str += (TCHAR)d;
			}
			numw += 1;
			nums += 2;
		}
		else
		{
			if(change && m_change.Lookup((U16)c, chg))
			{
				str += chg;
			}
			else
			{
				str += (TCHAR)c;
			}
			if(c >= ' ')
			{
				numc += 1;
				nums += 1;
			}
			else numc = numw = nums = 0;
		}
	}
	if(!feof(m_fsrc))
		m_err.Format("can not read src file at %p", ftell(m_fsrc));
	else if(!change)
		m_err = "not found ''' at the end of src file";
	else
		m_err = "not found '\"' at the end of src file";
	return ERR_SEVERE;
}