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.

342 lines
7.6 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. msgstub.c
  5. Abstract:
  6. These are the Messenger Service API RPC client stubs.
  7. Author:
  8. Dan Lafferty (danl) 06-Feb-1991
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. 27-Aug-1992 Danl
  13. Added downlevel support & removed error mapping for RPC errors.
  14. 06-Feb-1991 Danl
  15. Created
  16. --*/
  17. //
  18. // INCLUDES
  19. //
  20. #include <nt.h> // DbgPrint prototype
  21. #include <ntrtl.h> // DbgPrint prototype
  22. #include <rpc.h> // DataTypes and runtime APIs
  23. #include <msgsvc.h> // generated by the MIDL complier
  24. #include <rpcutil.h> // NetRpc utils
  25. #include <lmsvc.h>
  26. #include <lmcons.h> // NET_API_STATUS
  27. #include <lmerr.h> // NetError codes
  28. #include <rxmsg.h> // RxNetMessage API
  29. #include <netlib.h> // NetpServiceIsStarted() (needed by netrpc.h).
  30. #include <netdebug.h> // needed for netrpc.h
  31. #include <netrpc.h> // NET_REMOTE macros.
  32. NET_API_STATUS NET_API_FUNCTION
  33. NetMessageNameAdd (
  34. IN LPCWSTR servername,
  35. IN LPCWSTR msgname
  36. )
  37. /*++
  38. Routine Description:
  39. This is the DLL entrypoint for NetMessageNameAdd. This API adds a name
  40. to the message name table.
  41. Arguments:
  42. servername - Pointer to a string containing the name of the computer
  43. that is to execute the API function.
  44. msgname - Pointer to a string containing the name to be added.
  45. Return Value:
  46. NERR_Success - The operation was successful.
  47. --*/
  48. {
  49. NET_API_STATUS apiStatus;
  50. DWORD OptionsSupported = 0;
  51. NET_REMOTE_TRY_RPC
  52. apiStatus = NetrMessageNameAdd ((LPWSTR)servername,(LPWSTR)msgname);
  53. NET_REMOTE_RPC_FAILED("NetMessageNameAdd",
  54. (LPWSTR)servername,
  55. apiStatus,
  56. NET_REMOTE_FLAG_NORMAL,
  57. SERVICE_MESSENGER)
  58. //
  59. // Call downlevel version of the API.
  60. //
  61. apiStatus = RxNetMessageNameAdd((LPWSTR)servername,(LPWSTR)msgname);
  62. NET_REMOTE_END
  63. return(apiStatus);
  64. }
  65. NET_API_STATUS NET_API_FUNCTION
  66. NetMessageNameEnum (
  67. IN LPCWSTR servername,
  68. IN DWORD level,
  69. OUT LPBYTE *bufptr,
  70. IN DWORD prefmaxlen,
  71. OUT LPDWORD entriesread,
  72. OUT LPDWORD totalentries,
  73. IN OUT LPDWORD resume_handle
  74. )
  75. /*++
  76. Routine Description:
  77. This is the DLL entrypoint for NetMessageNameEnum.
  78. Arguments:
  79. servername - Pointer to a string containing the name of the computer
  80. that is to execute the API function.
  81. level - This indicates the level of information that is desired.
  82. bufptr - A pointer to the location where the pointer to the returned
  83. array of info structures is to be placed.
  84. prefmaxlen - Indicates a maximum size limit that the caller will allow
  85. for the return buffer.
  86. entriesread - A pointer to the location where the number of entries
  87. (data structures)read is to be returned.
  88. totalentries - A pointer to the location which upon return indicates
  89. the total number of entries in the table.
  90. resumehandle - Pointer to a value that indicates where to resume
  91. enumerating data.
  92. Return Value:
  93. Nerr_Success - The operation was successful.
  94. Note:
  95. --*/
  96. {
  97. NET_API_STATUS apiStatus;
  98. GENERIC_ENUM_STRUCT infoStruct;
  99. GENERIC_INFO_CONTAINER genericInfoContainer;
  100. DWORD OptionsSupported = 0;
  101. if (level != 0 && level != 1)
  102. {
  103. //
  104. // Return ERROR_INVALID_LEVEL rather than the RPC
  105. // "invalid level" error when it tries to assemble
  106. // the union with a bogus level in the stub.
  107. //
  108. return ERROR_INVALID_LEVEL;
  109. }
  110. genericInfoContainer.Buffer = NULL;
  111. genericInfoContainer.EntriesRead = 0;
  112. infoStruct.Container = &genericInfoContainer;
  113. infoStruct.Level = level;
  114. NET_REMOTE_TRY_RPC
  115. apiStatus = NetrMessageNameEnum (
  116. (LPWSTR)servername,
  117. (LPMSG_ENUM_STRUCT) &infoStruct,
  118. prefmaxlen,
  119. totalentries,
  120. resume_handle);
  121. if (apiStatus == NERR_Success || apiStatus == ERROR_MORE_DATA) {
  122. *bufptr = (LPBYTE) genericInfoContainer.Buffer;
  123. *entriesread = genericInfoContainer.EntriesRead;
  124. }
  125. NET_REMOTE_RPC_FAILED("NetMessageNameEnum",
  126. (LPWSTR)servername,
  127. apiStatus,
  128. NET_REMOTE_FLAG_NORMAL,
  129. SERVICE_MESSENGER )
  130. //
  131. // Call downlevel version of the API.
  132. //
  133. apiStatus = RxNetMessageNameEnum(
  134. (LPWSTR)servername,
  135. level,
  136. bufptr,
  137. prefmaxlen,
  138. entriesread,
  139. totalentries,
  140. resume_handle);
  141. NET_REMOTE_END
  142. return(apiStatus);
  143. }
  144. NET_API_STATUS NET_API_FUNCTION
  145. NetMessageNameGetInfo (
  146. IN LPCWSTR servername,
  147. IN LPCWSTR msgname,
  148. IN DWORD level,
  149. OUT LPBYTE *bufptr
  150. )
  151. /*++
  152. Routine Description:
  153. This is the DLL entrypoint for NetMessageNameGetInfo.
  154. Arguments:
  155. servername - Pointer to a string containing the name of the computer
  156. that is to execute the API function. Since this function is
  157. executing on that computer, this information is not useful
  158. by the time it gets here. It is really only useful on the RPC
  159. client side.
  160. msgname - Pointer to a string containing the name in the table
  161. for which information is desired.
  162. level - This indicates the level of information that is desired.
  163. bufptr - Pointer to a Location where the pointer to the returned
  164. information structure is to be placed.
  165. Return Value:
  166. NERR_Success - The operation was successful.
  167. --*/
  168. {
  169. NET_API_STATUS apiStatus;
  170. DWORD OptionsSupported = 0;
  171. *bufptr = NULL; // Must be NULL so RPC knows to till it in.
  172. NET_REMOTE_TRY_RPC
  173. apiStatus = NetrMessageNameGetInfo (
  174. (LPWSTR)servername,
  175. (LPWSTR)msgname,
  176. level,
  177. (LPMSG_INFO) bufptr);
  178. NET_REMOTE_RPC_FAILED("NetMessageNameGetInfo",
  179. (LPWSTR)servername,
  180. apiStatus,
  181. NET_REMOTE_FLAG_NORMAL,
  182. SERVICE_MESSENGER)
  183. //
  184. // Call downlevel version of the API.
  185. //
  186. apiStatus = RxNetMessageNameGetInfo(
  187. (LPWSTR)servername,
  188. (LPWSTR)msgname,
  189. level,
  190. bufptr);
  191. NET_REMOTE_END
  192. return(apiStatus);
  193. }
  194. NET_API_STATUS NET_API_FUNCTION
  195. NetMessageNameDel (
  196. IN LPCWSTR servername,
  197. IN LPCWSTR msgname
  198. )
  199. /*++
  200. Routine Description:
  201. This is the DLL entrypoint for NetMessageNameDel. This API deletes
  202. a name from the message name table.
  203. Arguments:
  204. servername - Points to a string containing the name of the computer
  205. that is to execute the API function.
  206. msgname - Points to a string containing the name that is to be deleted
  207. from the message name table.
  208. Return Value:
  209. NERR_Success - The operation was successful
  210. --*/
  211. {
  212. NET_API_STATUS apiStatus;
  213. DWORD OptionsSupported = 0;
  214. NET_REMOTE_TRY_RPC
  215. apiStatus = NetrMessageNameDel ((LPWSTR)servername, (LPWSTR)msgname);
  216. NET_REMOTE_RPC_FAILED("NetMessageNameDel",
  217. (LPWSTR)servername,
  218. apiStatus,
  219. NET_REMOTE_FLAG_NORMAL,
  220. SERVICE_MESSENGER)
  221. //
  222. // Call downlevel version of the API.
  223. //
  224. apiStatus = RxNetMessageNameDel((LPWSTR)servername,(LPWSTR)msgname);
  225. NET_REMOTE_END
  226. return(apiStatus);
  227. }