Source code of Windows XP (NT5)
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.

136 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. iisdef.h
  5. Abstract:
  6. The IIS shared definitions header.
  7. Author:
  8. Seth Pollack (sethp) 01-Dec-1998
  9. Revision History:
  10. --*/
  11. #ifndef _IISDEF_H_
  12. #define _IISDEF_H_
  13. //
  14. // Define some standard 64-bit stuff here
  15. //
  16. //
  17. // The DIFF macro should be used around an expression involving pointer
  18. // subtraction. The expression passed to DIFF is cast to a size_t type,
  19. // allowing the result to be easily assigned to any 32-bit variable or
  20. // passed to a function expecting a 32-bit argument.
  21. //
  22. #define DIFF(x) ((size_t)(x))
  23. //
  24. // Signature helpers
  25. //
  26. //
  27. // Create a signature that reads the same way in the debugger as how you
  28. // define it in code. Done by byte-swapping the DWORD passed into it.
  29. //
  30. // Typical usage:
  31. //
  32. // #define FOOBAR_SIGNATURE CREATE_SIGNATURE( 'FBAR' )
  33. // #define FOOBAR_SIGNATURE_FREED CREATE_SIGNATURE( 'fbaX' )
  34. //
  35. #define CREATE_SIGNATURE( Value ) \
  36. ( \
  37. ( ( ( ( DWORD ) Value ) & 0xFF000000 ) >> 24 ) | \
  38. ( ( ( ( DWORD ) Value ) & 0x00FF0000 ) >> 8 ) | \
  39. ( ( ( ( DWORD ) Value ) & 0x0000FF00 ) << 8 ) | \
  40. ( ( ( ( DWORD ) Value ) & 0x000000FF ) << 24 ) \
  41. ) \
  42. #ifndef __HTTP_SYS__
  43. //
  44. // Error handling helpers
  45. //
  46. #ifdef __cplusplus
  47. //
  48. // Recover the Win32 error from an HRESULT.
  49. //
  50. // The HRESULT must be a failure, i.e. FAILED(hr) must be true.
  51. // If these conditions are not met, then it returns the error code
  52. // ERROR_INVALID_PARAMETER.
  53. //
  54. inline DWORD WIN32_FROM_HRESULT(
  55. IN HRESULT hr
  56. )
  57. {
  58. if ( ( FAILED( hr ) ) &&
  59. ( HRESULT_FACILITY( hr ) == FACILITY_WIN32 ) )
  60. {
  61. return ( HRESULT_CODE( hr ) );
  62. }
  63. else
  64. {
  65. // invalid parameter!
  66. // BUGBUG would be nice to assert here
  67. return ERROR_INVALID_PARAMETER;
  68. }
  69. }
  70. # else
  71. # define WIN32_FROM_HRESULT(hr) \
  72. (( (FAILED(hr)) && \
  73. (HRESULT_FACILITY(hr) == FACILITY_WIN32) \
  74. ) \
  75. ? \
  76. HRESULT_CODE(hr) \
  77. : ERROR_INVALID_PARAMETER \
  78. )
  79. #endif // _cplusplus
  80. #endif // !__HTTP_SYS__
  81. //
  82. // Generate an HRESULT from a LK_RETCODE.
  83. //
  84. // BUGBUG temporary; really we need a fix in the lkhash code.
  85. //
  86. #define HRESULT_FROM_LK_RETCODE( LkRetcode ) \
  87. ( ( LkRetcode == LK_SUCCESS ) ? S_OK : E_FAIL )
  88. //
  89. // DNLEN is set to short value (15) that is good enough only for NetBIOS names
  90. // Until there is more suitable constant let's use our own
  91. //
  92. #define IIS_DNLEN (256)
  93. #endif // _IISDEF_H_