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.

186 lines
5.8 KiB

  1. /*
  2. * stock.h - Stock header file.
  3. *
  4. * Taken from URL code by ChrisPi 9-11-95
  5. *
  6. */
  7. #ifndef _STOCK_H_
  8. #define _STOCK_H_
  9. /* Constants
  10. ************/
  11. #define ASTERISK '*'
  12. #define BACKSLASH '/'
  13. #define COLON ':'
  14. #define COMMA ','
  15. #define EQUAL '='
  16. #define PERIOD '.'
  17. #define POUND '#'
  18. #define QMARK '?'
  19. #define QUOTE '\''
  20. #define QUOTES '"'
  21. #define SLASH '\\'
  22. #define SPACE ' '
  23. #define TAB '\t'
  24. /* linkage */
  25. #ifdef __cplusplus
  26. #define INLINE inline
  27. #else
  28. #define INLINE __inline
  29. #endif
  30. /* Win32 HRESULTs */
  31. #define E_FILE_NOT_FOUND MAKE_SCODE(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
  32. #define E_PATH_NOT_FOUND MAKE_SCODE(SEVERITY_ERROR, FACILITY_WIN32, ERROR_PATH_NOT_FOUND)
  33. /* file-related flag combinations */
  34. #define ALL_FILE_ACCESS_FLAGS (GENERIC_READ |\
  35. GENERIC_WRITE)
  36. #define ALL_FILE_SHARING_FLAGS (FILE_SHARE_READ |\
  37. FILE_SHARE_WRITE)
  38. #define ALL_FILE_ATTRIBUTES (FILE_ATTRIBUTE_READONLY |\
  39. FILE_ATTRIBUTE_HIDDEN |\
  40. FILE_ATTRIBUTE_SYSTEM |\
  41. FILE_ATTRIBUTE_DIRECTORY |\
  42. FILE_ATTRIBUTE_ARCHIVE |\
  43. FILE_ATTRIBUTE_NORMAL |\
  44. FILE_ATTRIBUTE_TEMPORARY |\
  45. FILE_ATTRIBUTE_ATOMIC_WRITE |\
  46. FILE_ATTRIBUTE_XACTION_WRITE)
  47. #define ALL_FILE_FLAGS (FILE_FLAG_WRITE_THROUGH |\
  48. FILE_FLAG_OVERLAPPED |\
  49. FILE_FLAG_NO_BUFFERING |\
  50. FILE_FLAG_RANDOM_ACCESS |\
  51. FILE_FLAG_SEQUENTIAL_SCAN |\
  52. FILE_FLAG_DELETE_ON_CLOSE |\
  53. FILE_FLAG_BACKUP_SEMANTICS |\
  54. FILE_FLAG_POSIX_SEMANTICS)
  55. #define ALL_FILE_ATTRIBUTES_AND_FLAGS (ALL_FILE_ATTRIBUTES |\
  56. ALL_FILE_FLAGS)
  57. /* Macros
  58. *********/
  59. #ifndef DECLARE_STANDARD_TYPES
  60. /*
  61. * For a type "FOO", define the standard derived types PFOO, CFOO, and PCFOO.
  62. */
  63. #define DECLARE_STANDARD_TYPES(type) typedef type *P##type; \
  64. typedef const type C##type; \
  65. typedef const type *PC##type;
  66. #endif
  67. /* character manipulation */
  68. #define IS_SLASH(ch) ((ch) == SLASH || (ch) == BACKSLASH)
  69. /* bit flag manipulation */
  70. #define SET_FLAG(dwAllFlags, dwFlag) ((dwAllFlags) |= (dwFlag))
  71. /* ChrisPi: DCL also defines this - override their definition */
  72. #ifdef CLEAR_FLAG
  73. #undef CLEAR_FLAG
  74. #endif /* CLEAR_FLAG */
  75. #define CLEAR_FLAG(dwAllFlags, dwFlag) ((dwAllFlags) &= (~dwFlag))
  76. #define IS_FLAG_SET(dwAllFlags, dwFlag) ((BOOL)((dwAllFlags) & (dwFlag)))
  77. #define IS_FLAG_CLEAR(dwAllFlags, dwFlag) (! (IS_FLAG_SET(dwAllFlags, dwFlag)))
  78. /* array element count */
  79. #define ARRAY_ELEMENTS(rg) (sizeof(rg) / sizeof((rg)[0]))
  80. #define CCHMAX(rg) ARRAY_ELEMENTS(rg)
  81. /* clearing bytes */
  82. #define ClearStruct(lpv) ZeroMemory((LPVOID) (lpv), sizeof(*(lpv)))
  83. #define InitStruct(lpv) {ClearStruct(lpv); (* (LPDWORD)(lpv)) = sizeof(*(lpv));}
  84. /* string safety */
  85. #define CHECK_STRING(psz) ((psz) ? (psz) : "(null)")
  86. /* file attribute manipulation */
  87. #define IS_ATTR_DIR(attr) (IS_FLAG_SET((attr), FILE_ATTRIBUTE_DIRECTORY))
  88. #define IS_ATTR_VOLUME(attr) (IS_FLAG_SET((attr), FILE_ATTRIBUTE_VOLUME))
  89. /* stuff a point value packed in an LPARAM into a POINT */
  90. #define LPARAM_TO_POINT(lparam, pt) ((pt).x = (short)LOWORD(lparam), \
  91. (pt).y = (short)HIWORD(lparam))
  92. /* Types
  93. ********/
  94. typedef const void *PCVOID;
  95. typedef const INT CINT;
  96. typedef const INT *PCINT;
  97. typedef const UINT CUINT;
  98. typedef const UINT *PCUINT;
  99. typedef const LONG CULONG;
  100. typedef const LONG *PCULONG;
  101. typedef const BYTE CBYTE;
  102. typedef const BYTE *PCBYTE;
  103. typedef const WORD CWORD;
  104. typedef const WORD *PCWORD;
  105. typedef const DWORD CDWORD;
  106. typedef const DWORD *PCDWORD;
  107. typedef const CRITICAL_SECTION CCRITICAL_SECTION;
  108. typedef const CRITICAL_SECTION *PCCRITICAL_SECTION;
  109. typedef const FILETIME CFILETIME;
  110. typedef const FILETIME *PCFILETIME;
  111. typedef const BITMAPINFO CBITMAPINFO;
  112. typedef const BITMAPINFO *PCBITMAPINFO;
  113. typedef const POINT CPOINT;
  114. typedef const POINT *PCPOINT;
  115. typedef const POINTL CPOINTL;
  116. typedef const POINTL *PCPOINTL;
  117. typedef const SECURITY_ATTRIBUTES CSECURITY_ATTRIBUTES;
  118. typedef const SECURITY_ATTRIBUTES *PCSECURITY_ATTRIBUTES;
  119. typedef const WIN32_FIND_DATA CWIN32_FIND_DATA;
  120. typedef const WIN32_FIND_DATA *PCWIN32_FIND_DATA;
  121. DECLARE_STANDARD_TYPES(HGLOBAL);
  122. DECLARE_STANDARD_TYPES(HICON);
  123. DECLARE_STANDARD_TYPES(HMENU);
  124. DECLARE_STANDARD_TYPES(HWND);
  125. DECLARE_STANDARD_TYPES(NMHDR);
  126. #ifndef _COMPARISONRESULT_DEFINED_
  127. /* comparison result */
  128. typedef enum _comparisonresult
  129. {
  130. CR_FIRST_SMALLER = -1,
  131. CR_EQUAL = 0,
  132. CR_FIRST_LARGER = +1
  133. }
  134. COMPARISONRESULT;
  135. DECLARE_STANDARD_TYPES(COMPARISONRESULT);
  136. #define _COMPARISONRESULT_DEFINED_
  137. #endif
  138. #endif /* _STOCK_H_ */