home *** CD-ROM | disk | FTP | other *** search
- // UCASE.CPP - Implementation file for your Internet Server
- // UCase Filter
-
- #include "stdafx.h"
- #include "UCase.h"
-
- ///////////////////////////////////////////////////////////////////////
- // The one and only CUCaseFilter object
- CUCaseFilter theFilter;
-
- ///////////////////////////////////////////////////////////////////////
- // CUCaseFilter implementation
- CUCaseFilter::CUCaseFilter()
- {
- }
-
- CUCaseFilter::~CUCaseFilter()
- {
- }
-
- BOOL CUCaseFilter::GetFilterVersion(PHTTP_FILTER_VERSION pVer)
- {
- // Call default implementation for initialization
- CHttpFilter::GetFilterVersion(pVer);
-
- // Clear the flags set by base class
- pVer->dwFlags &= ~SF_NOTIFY_ORDER_MASK;
-
- // Set the flags we are interested in
- pVer->dwFlags |= SF_NOTIFY_ORDER_MEDIUM
- | SF_NOTIFY_NONSECURE_PORT
- | SF_NOTIFY_SEND_RAW_DATA
- | SF_NOTIFY_URL_MAP;
-
- // Load description string
- TCHAR sz[SF_MAX_FILTER_DESC_LEN+1];
- ISAPIVERIFY(::LoadString(AfxGetResourceHandle(),
- IDS_FILTER, sz, SF_MAX_FILTER_DESC_LEN));
- _tcscpy(pVer->lpszFilterDesc, sz);
- return TRUE;
- }
-
- DWORD CUCaseFilter::OnUrlMap(CHttpFilterContext* pCtxt,
- PHTTP_FILTER_URL_MAP pMapInfo)
- {
- // We'll need the physical path in lower case.
- LPTSTR pstrPhysPath = pMapInfo->pszPhysicalPath;
- strlwr(pstrPhysPath);
-
- // The string we're searching for is "uppercase\"
- static LPCTSTR pstrSearch = "uppercase\\";
-
- // Determine if the request contains pstrSearch. If so, do 2 things.
- // First, remove "uppercase" from the Physical Path, since
- // that symbol is NOT part of the filename.
- // Second, set the filter context as a flag to
- // indicate to OnSendRawData that it should act on the
- // outgoing data. The number 1111 carries no special significance.
- // However. being an odd number it won't be a pointer to dynamically
- // allocated memory. See OnSendRawData to determine how it's used.
- LPTSTR p1 = strstr (pstrPhysPath, pstrSearch);
- if (0 != p1)
- {
- LPTSTR p2 = p1 + lstrlen(pstrSearch);
- lstrcpy(p1, p2);
- pCtxt->m_pFC->pFilterContext = (PVOID) 1111;
- }
-
- return SF_STATUS_REQ_NEXT_NOTIFICATION;
- }
-
- DWORD CUCaseFilter::OnSendRawData(CHttpFilterContext* pCtxt,
- PHTTP_FILTER_RAW_DATA pRawData)
- {
- // This function is called twice to transmit the data
- // back to the client. First time for the header,
- // second time for the body.
- LPTSTR pstrIn;
-
- // If the context flag = 1111 then it's a header for a message
- // this filter is interested in. Bump it to 1113 and return.
- if ((PVOID) 1111 == pCtxt->m_pFC->pFilterContext)
- {
- pCtxt->m_pFC->pFilterContext = (VOID*) 1113;
- return SF_STATUS_REQ_NEXT_NOTIFICATION;
- }
-
- // At this point, if it's not 1113 it's some other page
- // so just return.
- if ((PVOID) 1113 != pCtxt->m_pFC->pFilterContext)
- {
- return SF_STATUS_REQ_NEXT_NOTIFICATION;
- }
-
- // If we get to here, it's either the crlf pair or the body
- // for the page I'm converting to upper case, so go to work.
- pstrIn = (LPTSTR) pRawData->pvInData;
-
- while (*pstrIn)
- {
- *pstrIn = toupper(*pstrIn);
- pstrIn++;
- }
-
- return SF_STATUS_REQ_NEXT_NOTIFICATION;
- }
-
- // Do not edit the following lines, which are needed by ClassWizard.
- #if 0
- BEGIN_MESSAGE_MAP(CUCaseFilter, CHttpFilter)
- //{{AFX_MSG_MAP(CUCaseFilter)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- #endif // 0
-