Link to home
Start Free TrialLog in
Avatar of Sven
SvenFlag for Germany

asked on

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

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;
}

Open in new window

Avatar of alb66
alb66
Flag of Italy image

szNewUrl.Left(_tcsstr(szUrl, ";DECLARE")-1);

szNewUrl is an array of char, so it hasn't the Left method (it is not a class)

If I understand what you want to do you must write:

char* pp = _tcsstr(szUrl, ";DECLARE" );
if ( pp != NULL )
{
  int nLen = pp - szUrl;
  strncpy( szNewUrl, szUrl, nLen;
}


ASKER CERTIFIED SOLUTION
Avatar of alb66
alb66
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sven

ASKER

I do not know if this works, cause now I have the problem that I can not debug the ISAPI extension. I followed the instruction spreaded over the internet but there is some problem with the project. So you have to patient until I can grant you the points!
Don't worry...
the important is that you can solve your problem
Avatar of Sven

ASKER

Compiling worked now but it does not work as I want:

char* pp = _tcsstr(szUrl, ";DECLARE" );
if ( pp != NULL )
{
  int nLen = pp - szUrl;
  _tcsncpy( szNewUrl, szUrl, nLen );
}

What I want is, that a string szUrl is cut to a new string szNewUrl, like:

  http://www.mydomain.com/default.asp?v=123;DECLARE%20@S

is cut to:

  http://www.mydomain.com/default.asp?v=123
Avatar of Sven

ASKER

Now it works as alb66 suggested!