home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / internet / httpsvr / http.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.1 KB  |  81 lines

  1. // Http.cpp : structures, functions and definitions for http service
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1997-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "Http.h"
  15. #include "Request.h"
  16. #include "resource.h"
  17.  
  18. IMPLEMENT_DYNCREATE(CHitDoc, CObject)
  19.  
  20. CHitDoc::CHitDoc( void )
  21. {
  22. }
  23.  
  24. CHitDoc::CHitDoc(  CString strFile )
  25. {
  26.     DWORD dwAttr = GetFileAttributes(strFile);
  27.     if ( dwAttr != (DWORD)(-1) && (dwAttr&FILE_ATTRIBUTE_DIRECTORY) != 0 )
  28.         m_bFolder = TRUE;
  29.     else
  30.         m_bFolder = FALSE;
  31.  
  32.     m_nHits = 0;
  33.     m_dwExecute = 0;
  34.     m_nStatus = -1;
  35.     ParseFileName( strFile );
  36. }
  37.  
  38. CHitDoc::CHitDoc( CRequest* pRequest )
  39. {
  40.     m_nHits = 1; // at least one hit....
  41.     // is it an executable?
  42.     m_dwExecute = pRequest->m_dwExecute;
  43.     // time it was hit....
  44.     m_timeLastHit = pRequest->m_timeReq;
  45.     // status....
  46.     m_nStatus = pRequest->m_uStatus;
  47.     // referring document....
  48.     m_strCommand = pRequest->GetHeaderValue( "Referer" );
  49.     // get the URL....
  50.     m_strURL = pRequest->m_strURL;
  51.     // determine file and folder names....
  52.     if ( m_nStatus == 200 || (m_nStatus==0 && m_dwExecute) )
  53.     {
  54.         m_bFolder = ((pRequest->m_dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0);
  55.         ParseFileName( pRequest->m_strFullPath );
  56.     }
  57.     else
  58.     {
  59.         m_bFolder = FALSE;
  60.         m_strFile.LoadString( pRequest->m_uStatus );
  61.     }
  62. }
  63.  
  64. int CHitDoc::operator==( CHitDoc* pHit )
  65. {
  66.     int nCmp = m_strFile.CompareNoCase( pHit->m_strFile );
  67.     if ( nCmp == 0 )
  68.         nCmp = m_strFolder.CompareNoCase( pHit->m_strFolder );
  69.     return nCmp;
  70. }
  71.  
  72. void CHitDoc::ParseFileName( const CString& strFullPath )
  73. {
  74.     int nFile = strFullPath.ReverseFind( SEPCHAR );
  75.     if ( nFile != -1 )
  76.     {
  77.         m_strFolder = strFullPath.Left( nFile+1 );
  78.         m_strFile = strFullPath.Mid( nFile+1 );
  79.     }
  80. }
  81.