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.

100 lines
2.7 KiB

  1. /*
  2. * C A L C O M . H
  3. *
  4. * Simple things, safe for use in ALL of CAL.
  5. * Items in this file should NOT require other CAL libs to be linked in!
  6. * Items is this file should NOT throw exceptions (not safe in exdav/exoledb).
  7. *
  8. * Copyright 1986-1997 Microsoft Corporation, All Rights Reserved
  9. */
  10. #ifndef _EX_CALCOM_H_
  11. #define _EX_CALCOM_H_
  12. #include <caldbg.h>
  13. // Useful defines ------------------------------------------------------------
  14. //
  15. // These are used to declare global and const vars in header files!
  16. // This means you can do this in a header file:
  17. //
  18. // DEC_CONST CHAR gc_szFoo[] = "Foo";
  19. // DEC_CONST UINT gc_cchszFoo = CchConstString(gc_szFoo);
  20. //
  21. #define DEC_GLOBAL __declspec(selectany)
  22. #define DEC_CONST extern const __declspec(selectany)
  23. // Helper Macros -------------------------------------------------------------
  24. // CElems -- Count of elements in an array
  25. // CbSizeWsz -- byte-size of a wide string, including space for final NULL
  26. //
  27. #define CElems(_rg) (sizeof(_rg)/sizeof(_rg[0]))
  28. #define CbSizeWsz(_cch) (((_cch) + 1) * sizeof(WCHAR))
  29. // Const string length -------------------------------------------------------
  30. //
  31. #define CchConstString(_s) ((sizeof(_s)/sizeof(_s[0])) - 1)
  32. // The whitespace checker
  33. //
  34. inline
  35. BOOL FIsWhiteSpace ( IN LPCSTR pch )
  36. {
  37. return
  38. *pch == ' ' ||
  39. *pch == '\t' ||
  40. *pch == '\r' ||
  41. *pch == '\n';
  42. }
  43. // Global enum for DEPTH specification
  44. // NOTE: Not all values are valid on all calls.
  45. // I have tried to list the most common values first.
  46. //
  47. enum
  48. {
  49. DEPTH_UNKNOWN = -1,
  50. DEPTH_ZERO,
  51. DEPTH_ONE,
  52. DEPTH_INFINITY,
  53. DEPTH_ONE_NOROOT,
  54. DEPTH_INFINITY_NOROOT,
  55. };
  56. // Global enum for OVERWRITE/ALLOW-RENAME headers
  57. // Overwrite_rename is when overwrite header is absent or "f" and allow-reanme header is "t".
  58. // when overwrite header is explicitly "t", allow-rename is ignored. Combining these two,
  59. // very much dependent, headers saves us a tag in the DAVEX DIM.
  60. //
  61. enum
  62. {
  63. OVERWRITE_UNKNOWN = 0,
  64. OVERWRITE_YES = 0x8,
  65. OVERWRITE_RENAME = 0x4
  66. };
  67. // Inline functions to type cast FileTime structures to __int64 and back.
  68. //
  69. // For safety, these cast using the UNALIGNED keyword to avoid any problems
  70. // on the Alpha if someone were to do this:
  71. // struct {
  72. // DWORD dwFoo;
  73. // FILETIME ft;
  74. // }
  75. // In this case, the FILETIME would be aligned on a 32-bit rather than a
  76. // 64-bit boundary, which would be bad without UNALIGNED!
  77. //
  78. inline
  79. __int64 & FileTimeCastToI64(FILETIME & ft)
  80. {
  81. return *(reinterpret_cast<__int64 UNALIGNED *>(&ft));
  82. }
  83. inline
  84. FILETIME & I64CastToFileTime(__int64 & i64)
  85. {
  86. return *(reinterpret_cast<FILETIME UNALIGNED *>(&i64));
  87. }
  88. #endif // _EX_CALCOM_H_