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.

111 lines
2.8 KiB

  1. #include "precomp.hxx"
  2. VOID
  3. ConvertSpacesToPlus(
  4. IN LPSTR pszString
  5. )
  6. {
  7. if ( pszString != NULL ) {
  8. while ( *pszString != '\0' ) {
  9. if ((*pszString == ' ') ||
  10. (*pszString == '\t') ) {
  11. *pszString = '+';
  12. }
  13. pszString++;
  14. }
  15. }
  16. return;
  17. }
  18. DWORD
  19. WeekOfMonth(
  20. IN LPSYSTEMTIME pstNow
  21. )
  22. /*++
  23. Finds the ordinal number of the week of current month.
  24. The numbering of weeks starts from 1 and run through 5 per month (max).
  25. The week number changes only on sundays.
  26. The calculation to be use is:
  27. 1 + ( dayOfMonth - 1)/7 + (( dayOfMonth - 1) % 7 > dayOfWeek);
  28. (a) (b) (c) (d)
  29. (a) to set the week numbers to begin from week numbered "1"
  30. (b) used to calculate the rough number of the week on which a given
  31. day falls based on the date.
  32. (c) calculates what is the offset from the start of week for a given
  33. day based on the fact that a week had 7 days.
  34. (d) is the raw day of week given to us.
  35. (c) > (d) indicates that the week is rolling forward and hence
  36. the week count should be offset by 1 more.
  37. --*/
  38. {
  39. DWORD dwTmp;
  40. dwTmp = (pstNow->wDay - 1);
  41. dwTmp = ( 1 + dwTmp/7 + (((dwTmp % 7) > pstNow->wDayOfWeek) ? 1 : 0));
  42. return ( dwTmp);
  43. } // WeekOfMonth()
  44. BOOL
  45. IsBeginningOfNewPeriod(
  46. IN DWORD dwPeriod,
  47. IN LPSYSTEMTIME pstCurrentFile,
  48. IN LPSYSTEMTIME pstNow
  49. )
  50. /*++
  51. This function checks to see if we are beginning a new period for
  52. a given periodic interval type ( specified using dwPeriod).
  53. Arguments:
  54. dwPeriod INETLOG_PERIOD specifying the periodic interval.
  55. pstCurrentFile pointer to SYSTEMTIME for the current file.
  56. pstNow pointer to SYSTEMTIME for the present time.
  57. Returns:
  58. TRUE if a new period is beginning ( ie pstNow > pstCurrentFile).
  59. FALSE otherwise.
  60. --*/
  61. {
  62. BOOL fNewPeriod = FALSE;
  63. switch ( dwPeriod) {
  64. case INET_LOG_PERIOD_HOURLY:
  65. fNewPeriod = (pstCurrentFile->wHour != pstNow->wHour);
  66. //
  67. // Fall Through
  68. //
  69. case INET_LOG_PERIOD_DAILY:
  70. fNewPeriod = fNewPeriod || (pstCurrentFile->wDay != pstNow->wDay);
  71. //
  72. // Fall Through
  73. //
  74. case INET_LOG_PERIOD_MONTHLY:
  75. fNewPeriod = fNewPeriod || (pstCurrentFile->wMonth != pstNow->wMonth);
  76. break;
  77. case INET_LOG_PERIOD_WEEKLY:
  78. fNewPeriod =
  79. (WeekOfMonth(pstCurrentFile) != WeekOfMonth(pstNow)) ||
  80. (pstCurrentFile->wMonth != pstNow->wMonth);
  81. break;
  82. case INET_LOG_PERIOD_NONE:
  83. default:
  84. break;
  85. } // switch()
  86. return(fNewPeriod);
  87. }// IsBeginningOfNewPeriod