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.

194 lines
3.2 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1992 - 1999
  3. Module Name:
  4. nsiutil.hxx
  5. Abstract:
  6. This module contains utility functions used by the NSI client wrappers.
  7. Author:
  8. Steven Zeck (stevez) 03/27/92
  9. --*/
  10. #define UNUSED(t) (void) t
  11. extern "C" {
  12. #if !defined(NTENV)
  13. #ifdef DBG
  14. void
  15. RtlAssert(
  16. void * FailedAssertion,
  17. void * FileName,
  18. unsigned long LineNumber,
  19. char * Message
  20. );
  21. #define ASSERT( exp ) \
  22. if (!(exp)) \
  23. RtlAssert( #exp, __FILE__, __LINE__, 0 )
  24. #else
  25. #define ASSERT( exp )
  26. #endif
  27. #endif
  28. }
  29. unsigned char *
  30. CopyString(
  31. IN char * String
  32. );
  33. unsigned char *
  34. RegGetString(
  35. IN void * RegHandle,
  36. IN char * KeyName
  37. );
  38. void
  39. GetDefaultEntrys(
  40. IN void * Key
  41. );
  42. #ifdef NTENV
  43. extern void
  44. GlobalMutexRequest (
  45. void
  46. );
  47. extern void
  48. GlobalMutexClear (
  49. void
  50. );
  51. #define RequestGlobalMutex() GlobalMutexRequest()
  52. #define ClearGlobalMutex() GlobalMutexClear()
  53. #else
  54. #define RequestGlobalMutex()
  55. #define ClearGlobalMutex()
  56. #endif
  57. extern RPC_STATUS NsiToRpcStatus[];
  58. inline RPC_STATUS
  59. NsiMapStatus(
  60. IN UNSIGNED16 Status
  61. )
  62. {
  63. ASSERT(Status < NSI_S_STATUS_MAX);
  64. return((Status < NSI_S_STATUS_MAX)?
  65. NsiToRpcStatus[Status]: RPC_S_INTERNAL_ERROR);
  66. }
  67. /*++
  68. Class Definition:
  69. WIDE_STRING
  70. Abstract:
  71. This class abstracts the creation of unicode strings. It is normaly
  72. used as an automatic variable to a wrapper function that has an
  73. ASCII interface over a UNICODE one.
  74. --*/
  75. class WIDE_STRING
  76. {
  77. private:
  78. typedef enum { // Indicate how the string was allocated
  79. AllocMemory, // Allocated memory, which must be freed
  80. AllocReference, // Referenced a existing UNICODE string
  81. AllocError // Out of memory indicator
  82. } ALLOC_TYPE;
  83. unsigned short * String; // Unicode string
  84. ALLOC_TYPE AllocMode; // Allocation type
  85. public:
  86. // Construct a unicode string from a ASCII or UNICODE
  87. WIDE_STRING(
  88. IN unsigned char * String
  89. );
  90. WIDE_STRING(
  91. IN unsigned short * StringIn
  92. )
  93. {
  94. AllocMode = AllocReference;
  95. String = StringIn;
  96. }
  97. ~WIDE_STRING()
  98. {
  99. if (AllocMode == AllocMemory)
  100. I_RpcFree(String);
  101. }
  102. // Check to see of constructor failed due to out of memory.
  103. int
  104. OutOfMemory(
  105. )
  106. {
  107. return(AllocMode == AllocError);
  108. }
  109. // Return a pointer to the string.
  110. unsigned short *
  111. operator &()
  112. {
  113. return(String);
  114. }
  115. };
  116. #ifdef NTENV
  117. #define UnicodeToRtString(UnicodeString) RPC_S_OK
  118. void
  119. AsciiToUnicodeNT(
  120. OUT unsigned short *String,
  121. IN unsigned char *AsciiString
  122. );
  123. #else
  124. #define UnicodeToRtString(UnicodeString) UnicodeToAscii(UnicodeString)
  125. #endif
  126. int
  127. UnicodeToAscii(
  128. unsigned short *UnicodeString
  129. );
  130. UNSIGNED16
  131. MapException(
  132. IN RPC_STATUS Exception
  133. );
  134. extern WIDE_STRING *DefaultName;
  135. extern long DefaultSyntax;
  136. extern int fSyntaxDefaultsLoaded;