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.

165 lines
5.0 KiB

  1. /*
  2. * stock.h - Stock header file.
  3. */
  4. /* Constants
  5. ************/
  6. #define FOREVER for (;;)
  7. #define INVALID_SEEK_POSITION (0xffffffff)
  8. #define EMPTY_STRING TEXT("")
  9. #define SLASH_SLASH TEXT("\\\\")
  10. #define EQUAL TEXT('=')
  11. #define SPACE TEXT(' ')
  12. #define TAB TEXT('\t')
  13. #define COLON TEXT(':')
  14. #define COMMA TEXT(',')
  15. #define PERIOD TEXT('.')
  16. #define SLASH TEXT('\\')
  17. #define BACKSLASH TEXT('/')
  18. #define ASTERISK TEXT('*')
  19. #define QMARK TEXT('?')
  20. /* linkage */
  21. /* #pragma data_seg() doesn't work for variables defined extern. */
  22. #define PUBLIC_CODE
  23. #define PUBLIC_DATA
  24. /* Make private functions and data public for profiling and debugging. */
  25. #define PRIVATE_CODE PUBLIC_CODE
  26. #define PRIVATE_DATA PUBLIC_DATA
  27. #define INLINE __inline
  28. /* limits */
  29. #define WORD_MAX USHRT_MAX
  30. #define DWORD_MAX ULONG_MAX
  31. #define SIZE_T_MAX DWORD_MAX
  32. #define PTR_MAX ((PCVOID)MAXULONG_PTR)
  33. /* file system constants */
  34. #define MAX_PATH_LEN MAX_PATH
  35. #define MAX_NAME_LEN MAX_PATH
  36. #define MAX_FOLDER_DEPTH (MAX_PATH / 2)
  37. #define DRIVE_ROOT_PATH_LEN (4)
  38. /* size macros */
  39. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  40. #define SIZEOF(a) sizeof(a)
  41. /* invalid thread ID */
  42. #define INVALID_THREAD_ID (0xffffffff)
  43. /* file-related flag combinations */
  44. #define ALL_FILE_ACCESS_FLAGS (GENERIC_READ |\
  45. GENERIC_WRITE)
  46. #define ALL_FILE_SHARING_FLAGS (FILE_SHARE_READ |\
  47. FILE_SHARE_WRITE)
  48. #define ALL_FILE_ATTRIBUTES (FILE_ATTRIBUTE_READONLY |\
  49. FILE_ATTRIBUTE_HIDDEN |\
  50. FILE_ATTRIBUTE_SYSTEM |\
  51. FILE_ATTRIBUTE_DIRECTORY |\
  52. FILE_ATTRIBUTE_ARCHIVE |\
  53. FILE_ATTRIBUTE_NORMAL |\
  54. FILE_ATTRIBUTE_TEMPORARY)
  55. #define ALL_FILE_FLAGS (FILE_FLAG_WRITE_THROUGH |\
  56. FILE_FLAG_OVERLAPPED |\
  57. FILE_FLAG_NO_BUFFERING |\
  58. FILE_FLAG_RANDOM_ACCESS |\
  59. FILE_FLAG_SEQUENTIAL_SCAN |\
  60. FILE_FLAG_DELETE_ON_CLOSE |\
  61. FILE_FLAG_BACKUP_SEMANTICS |\
  62. FILE_FLAG_POSIX_SEMANTICS)
  63. #define ALL_FILE_ATTRIBUTES_AND_FLAGS (ALL_FILE_ATTRIBUTES |\
  64. ALL_FILE_FLAGS)
  65. /* Macros *********/
  66. #ifndef DECLARE_STANDARD_TYPES
  67. /*
  68. * For a type "FOO", define the standard derived types PFOO, CFOO, and PCFOO.
  69. */
  70. #define DECLARE_STANDARD_TYPES(type) typedef type *P##type; \
  71. typedef const type C##type; \
  72. typedef const type *PC##type;
  73. #endif
  74. /* character manipulation */
  75. #define IS_SLASH(ch) ((ch) == SLASH || (ch) == BACKSLASH)
  76. /* bit flag manipulation */
  77. #define SET_FLAG(dwAllFlags, dwFlag) ((dwAllFlags) |= (dwFlag))
  78. #define CLEAR_FLAG(dwAllFlags, dwFlag) ((dwAllFlags) &= (~dwFlag))
  79. #define IS_FLAG_SET(dwAllFlags, dwFlag) ((BOOL)((dwAllFlags) & (dwFlag)))
  80. #define IS_FLAG_CLEAR(dwAllFlags, dwFlag) (! (IS_FLAG_SET(dwAllFlags, dwFlag)))
  81. /* array element count */
  82. #define ARRAY_ELEMENTS(rg) (sizeof(rg) / sizeof((rg)[0]))
  83. /* file attribute manipulation */
  84. #define IS_ATTR_DIR(attr) (IS_FLAG_SET((attr), FILE_ATTRIBUTE_DIRECTORY))
  85. #define IS_ATTR_VOLUME(attr) (IS_FLAG_SET((attr), FILE_ATTRIBUTE_VOLUME))
  86. /* Types ********/
  87. typedef const void *PCVOID;
  88. typedef const INT CINT;
  89. typedef const INT *PCINT;
  90. typedef const UINT CUINT;
  91. typedef const UINT *PCUINT;
  92. typedef const BYTE CBYTE;
  93. typedef const BYTE *PCBYTE;
  94. typedef const WORD CWORD;
  95. typedef const WORD *PCWORD;
  96. typedef const DWORD CDWORD;
  97. typedef const DWORD *PCDWORD;
  98. typedef const CRITICAL_SECTION CCRITICAL_SECTION;
  99. typedef const CRITICAL_SECTION *PCCRITICAL_SECTION;
  100. typedef const FILETIME CFILETIME;
  101. typedef const FILETIME *PCFILETIME;
  102. typedef const SECURITY_ATTRIBUTES CSECURITY_ATTRIBUTES;
  103. typedef const SECURITY_ATTRIBUTES *PCSECURITY_ATTRIBUTES;
  104. typedef const WIN32_FIND_DATA CWIN32_FIND_DATA;
  105. typedef const WIN32_FIND_DATA *PCWIN32_FIND_DATA;
  106. DECLARE_STANDARD_TYPES(HICON);
  107. DECLARE_STANDARD_TYPES(NMHDR);
  108. #ifndef _COMPARISONRESULT_DEFINED_
  109. /* comparison result */
  110. typedef enum _comparisonresult
  111. {
  112. CR_FIRST_SMALLER = -1,
  113. CR_EQUAL = 0,
  114. CR_FIRST_LARGER = +1
  115. }
  116. COMPARISONRESULT;
  117. DECLARE_STANDARD_TYPES(COMPARISONRESULT);
  118. #define _COMPARISONRESULT_DEFINED_
  119. #endif