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.

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