Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name :
  4. stats.cxx
  5. Abstract:
  6. Defines functions required for FTP server statistics
  7. Author:
  8. Murali R. Krishnan ( MuraliK ) 04-Nov-1994
  9. Project:
  10. Web Server DLL
  11. Functions Exported:
  12. FTP_SERVER_STATISTICS::FTP_SERVER_STATISTICS( VOID)
  13. VOID FTP_SERVER_STATISTICS::ClearStatistics( VOID)
  14. DWORD CopyToStatsBuffer( LPFTP_STATISTICS_0 lpStat)
  15. Revision History:
  16. Sophia Chung ( SophiaC ) 20-Nov-1996
  17. --*/
  18. /************************************************************
  19. * Include Headers
  20. ************************************************************/
  21. #include "ftpdp.hxx"
  22. #include <timer.h>
  23. #include <time.h>
  24. /************************************************************
  25. * Functions
  26. ************************************************************/
  27. FTP_SERVER_STATISTICS::FTP_SERVER_STATISTICS( VOID)
  28. /*++
  29. Initializes statistics information for server.
  30. --*/
  31. {
  32. INITIALIZE_CRITICAL_SECTION( & m_csStatsLock);
  33. ClearStatistics();
  34. } // FTP_SERVER_STATISTICS::FTP_SERVER_STATISTICS();
  35. VOID
  36. FTP_SERVER_STATISTICS::ClearStatistics( VOID)
  37. /*++
  38. Clears the counters used for statistics information
  39. --*/
  40. {
  41. LockStatistics();
  42. memset( &m_FTPStats, 0, sizeof(m_FTPStats) );
  43. m_FTPStats.TimeOfLastClear = GetCurrentTimeInSeconds();
  44. UnlockStatistics();
  45. } // FTP_SERVER_STATISTICS::ClearStatistics()
  46. DWORD
  47. FTP_SERVER_STATISTICS::CopyToStatsBuffer( LPFTP_STATISTICS_0 lpStat)
  48. /*++
  49. Description:
  50. copies the statistics data from the server statistcs structure
  51. to the FTP_STATISTICS_0 structure for RPC access.
  52. Arugments:
  53. lpStat pointer to FTP_STATISTICS_0 object which contains the
  54. data on successful return
  55. Returns:
  56. Win32 error codes. NO_ERROR on success.
  57. --*/
  58. {
  59. DBG_ASSERT( lpStat != NULL);
  60. LockStatistics();
  61. CopyMemory( lpStat, &m_FTPStats, sizeof(*lpStat) );
  62. if (lpStat->ServiceUptime)
  63. {
  64. lpStat->ServiceUptime = GetCurrentTimeInSeconds() - lpStat->ServiceUptime;
  65. }
  66. UnlockStatistics();
  67. return ( NO_ERROR);
  68. } // CopyToStatsBuffer()
  69. // gets currenttime and stores it inside stats structure
  70. void
  71. FTP_SERVER_STATISTICS::UpdateStartTime()
  72. {
  73. m_FTPStats.ServiceUptime = GetCurrentTimeInSeconds();
  74. }
  75. void
  76. FTP_SERVER_STATISTICS::UpdateStopTime()
  77. {
  78. m_FTPStats.ServiceUptime = 0;
  79. }
  80. /************************ End of File ***********************/