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.

164 lines
4.3 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /* NPCOMMON.H -- Internal standard header for network provider common library.
  6. *
  7. * ATTENTION: This file is used by 16bit components and should be
  8. * maintained as such.
  9. *
  10. * History:
  11. * 03/22/93 gregj Created
  12. * 04/02/93 lens Added _INC_NPDEFS define and _INC_WINDOWS test.
  13. *
  14. */
  15. #ifndef _INC_NPDEFS
  16. #define _INC_NPDEFS
  17. #ifndef RC_INVOKED
  18. #pragma warning(disable:4147) // warning about ignoring __loadds on function
  19. // ptr decls, of which there are 5 in windows.h
  20. #pragma warning(disable:4118) // warning about not accepting the intrinsic function pragma
  21. // during a fast compile
  22. // Macro to quiet compiler for an unused formal parameter.
  23. #define UNUSED(x) ((void)(x))
  24. #endif
  25. #ifndef _INC_WINDOWS
  26. #include <windows.h>
  27. #endif
  28. #ifdef IS_32
  29. #ifndef _INC_NETSPI
  30. #include <netspi.h>
  31. #endif
  32. #ifndef _STRING_HXX_
  33. #include <npstring.h>
  34. #endif
  35. #endif /* IS_32 */
  36. // Fixup for when RESOURCETYPE_ANY was not compatible with NT.
  37. // Codework: remove from system.
  38. #define RESOURCETYPE_ANY1 RESOURCETYPE_RESERVED
  39. #define CHAR char
  40. #define INT int
  41. typedef unsigned short WCHAR;
  42. typedef unsigned short USHORT;
  43. typedef WORD HANDLE16;
  44. #ifndef APIENTRY
  45. #define APIENTRY FAR PASCAL
  46. #endif
  47. #define FAR_NETLIB /* our netlib is in netapi.dll, and always far */
  48. #ifndef IS_32
  49. #ifndef LOADDS
  50. #define LOADDS __loadds
  51. #endif
  52. #else
  53. #define LOADDS
  54. #endif
  55. #ifndef HNRES
  56. typedef HANDLE HNRES;
  57. #endif
  58. // That is common return type used in both common and mnr projects
  59. #ifndef MNRSTATUS
  60. #ifdef IS_32
  61. #define MNRSTATUS UINT
  62. #else
  63. #define MNRSTATUS WORD
  64. #endif
  65. #endif
  66. #define MNRENTRY DWORD APIENTRY
  67. // Find size of structure upto and including a field that may be the last field in the structure.
  68. #define SIZE_TO_FIELD(s,f) (sizeof(((s *)NULL)->f) + (LPBYTE)&(((s *)NULL)->f) - (LPBYTE)NULL)
  69. // Null strings are quite often taken to be either a NULL pointer or a zero
  70. #define IS_EMPTY_STRING(pch) ( !pch || !*(pch) )
  71. /*******************************************************************
  72. Macro Description:
  73. This macro is used to test that a LoadLibrary call succeeded.
  74. Arguments:
  75. hModule - the handle returned from the LoadLibrary call.
  76. Notes:
  77. Win31 documentation says that errors are less than HINSTANCE_ERROR
  78. and that success is greater than 32. Since HINSTANCE_ERROR is 32,
  79. this leaves the value of 32 as being undefined!
  80. *******************************************************************/
  81. #ifdef IS_32
  82. #define MNRVALIDDLLHANDLE(hdll) (hdll != NULL)
  83. #else
  84. #define MNRVALIDDLLHANDLE(hdll) (hdll > HINSTANCE_ERROR)
  85. #endif
  86. /*******************************************************************
  87. Macro Description:
  88. This macro is used to determine if a buffer passed in has valid
  89. addresses and writeable memory.
  90. Arguments:
  91. lpBuffer - the address of the buffer.
  92. lpcbBuffer - the address of a DWORD containing the size of the
  93. buffer that is filled in on return with the
  94. required size of the buffer if the buffer
  95. is not large enough.
  96. Evalutes to:
  97. An expression that returns TRUE or FALSE.
  98. Notes:
  99. Only valid for Win32 applications to call.
  100. The macro does weak validation as it is used generically in many APIs.
  101. In particular, this means that the macro succeeds a NULL lpcbBuffer,
  102. and zero *lpcbBuffer. In neither of these cases does it validate
  103. that lpBuffer is a valid address (and relies upon the behavior of
  104. IsBadWritePtr when *lpcbBuffer is zero).
  105. *******************************************************************/
  106. #define IS_BAD_WRITE_BUFFER(lpBuffer,lpcbBuffer) \
  107. ((lpcbBuffer != NULL) && \
  108. (IsBadWritePtr(lpcbBuffer, sizeof(DWORD)) || \
  109. IsBadWritePtr(lpBuffer, *lpcbBuffer)))
  110. #ifdef IS_32
  111. extern "C" { /* Know we're using C++ internally */
  112. NLS_STR FAR * NPSERVICE NPSGetStatusText(DWORD dwError,
  113. LPBOOL pbStatic);
  114. DWORD NPSERVICE NPSCopyNLS(NLS_STR FAR *pnlsSourceString,
  115. LPVOID lpDestBuffer,
  116. LPDWORD lpBufferSize);
  117. }
  118. #endif /* IS_32 */
  119. #endif /* !_INC_NPDEFS */