troubleshooting Question

Compiling problem while trying to modify ISAPI Filter (C++)

Avatar of Sven
SvenFlag for Germany asked on
C++Editors IDEs
6 Comments1 Solution445 ViewsLast Modified:
I am trying to enhance a ISAPI filter written in Visual C++ 6.0 for IIS 6.0 but I am a beginner on C++ programming. When compiling the below code (only fragment of it) I receive the error message:

"error C2228: Der linke Teil von '.erase' muss eine Klasse/Struktur/Union sein"
in english s.th. like "error C2228: The left part of '.erase' have to be a Class/Structure/Union"

Error is on line:
szNewUrl.Left(_tcsstr(szUrl, ";DECLARE")-1);

What am I doing wrong? I am only trying to add the block:

      if (_tcsstr(szUrl, ";DECLARE"))
      {
            _tcscat(szNewUrl,szUrl);
            szNewUrl.Left(_tcsstr(szUrl, ";DECLARE")-1);
            //szNewUrl.erase(_tcsstr(szUrl, ";DECLARE"));
            pHeaders->SetHeader(pCtxt->m_pFC, "url", szNewUrl);
            return SF_STATUS_REQ_NEXT_NOTIFICATION;
      }

All characters after the string ;DECLARE in the URL should be erased from the URL.
DWORD CURLMapperFilter::OnPreprocHeaders(CHttpFilterContext *pCtxt, PHTTP_FILTER_PREPROC_HEADERS pHeaders)
{
	CHAR szUrl[1024];
	CHAR szNewUrl[2048] = "";
	DWORD BufSize;
	char *c;
	int i;
	BufSize = 1024;
	pHeaders->GetHeader(pCtxt->m_pFC, "url", szUrl, &BufSize);
 
	_tcslwr(szUrl);
 
	// Ausschlussliste zur schnelleren Bearbeitung
	if (_tcsstr(szUrl,"_vti")) return SF_STATUS_REQ_NEXT_NOTIFICATION;
	if (_tcsstr(szUrl,"/images")) return SF_STATUS_REQ_NEXT_NOTIFICATION;
	if (_tcsstr(szUrl,"include")) return SF_STATUS_REQ_NEXT_NOTIFICATION;
 
	// Trefferliste
 
	if (_tcsnicmp(szUrl, "/goto/", 6) == 0) 
	{
		c = szUrl;
		i = 0;
		while (szUrl[i] != '\0')
		{
			if (szUrl[i] == '?') 
			{
				szUrl[i] = '&';
				break;
			}
			i++;
		}
 
		for (i=0;i<6;++i)
			c = _tcsinc(c);
 
		_tcscat(szNewUrl,"/go_to.asp?dest=");
		_tcscat(szNewUrl,c);
		pHeaders->SetHeader(pCtxt->m_pFC, "url", szNewUrl);
		return SF_STATUS_REQ_NEXT_NOTIFICATION;
	}
 
	if ((_tcsnicmp(szUrl, "/products/", 10) == 0) ||
	    (_tcsnicmp(szUrl, "/product/", 9) == 0) ||
		(_tcsnicmp(szUrl, "/groups/", 8) == 0) ||
		(_tcsnicmp(szUrl, "/group/", 7) == 0) ||
		(_tcsnicmp(szUrl, "/manus/", 7) == 0) ||
		(_tcsnicmp(szUrl, "/manu/", 6) == 0) || 
		(_tcsnicmp(szUrl, "/map/", 5) == 0))
	{
		i = 0;
		while (szUrl[i] != '\0')
		{
			if (szUrl[i] == '?') 
			{
				szUrl[i] = '&';
				break;
			}
			i++;
		}
		_tcscat(szNewUrl,"/urlmapper2.asp?mapurl=");
		_tcscat(szNewUrl,szUrl);
		_tcscat(szNewUrl,"&urlmapped=true");
		pHeaders->SetHeader(pCtxt->m_pFC, "url", szNewUrl);
		return SF_STATUS_REQ_NEXT_NOTIFICATION;
	}
 
	if (_tcsstr(szUrl, ";DECLARE"))
	{
		_tcscat(szNewUrl,szUrl);
		szNewUrl.Left(_tcsstr(szUrl, ";DECLARE")-1);
		//szNewUrl.erase(_tcsstr(szUrl, ";DECLARE"));
		pHeaders->SetHeader(pCtxt->m_pFC, "url", szNewUrl);
		return SF_STATUS_REQ_NEXT_NOTIFICATION;
	}
	
	// Keine Treffer gefunden
	return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros