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.

264 lines
7.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: drtc.orig.cxx
  8. //
  9. //--------------------------------------------------------------------------
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <ctype.h>
  13. #include "drt.h" // header file generated by MIDL compiler
  14. void __cdecl main(int argc, char **argv)
  15. {
  16. unsigned char * pszString = (unsigned char *)"drt";
  17. WCHAR * pszEntryName = L"/.:/drtsrv_01";
  18. WCHAR * pszGrpEntryName1 = L"/.:/drtgrp_01";
  19. WCHAR * pszPrfEntryName1 = L"/.:/drtprf_01";
  20. WCHAR * pszStrBinding = NULL;
  21. RPC_NS_HANDLE hdrt;
  22. RPC_BINDING_HANDLE bhdrt;
  23. RPC_IF_ID ifid;
  24. unsigned long fNameSyntaxType = RPC_C_NS_SYNTAX_DEFAULT;
  25. RPC_STATUS status;
  26. unsigned long ulCode;
  27. short fSuccess = 0;
  28. short fContinue = 1;
  29. short i;
  30. WCHAR *pMemberName;
  31. WCHAR *pAnnotation;
  32. ULONG dwPriority = 0;
  33. RpcTryExcept {
  34. status = RpcNsProfileEltInqBegin(
  35. fNameSyntaxType,
  36. pszPrfEntryName1,
  37. RPC_C_PROFILE_ALL_ELT,
  38. NULL,
  39. 0,
  40. fNameSyntaxType,
  41. NULL,
  42. &hdrt
  43. );
  44. printf(" RpcNsProfileEltInqBegin returned 0x%x\n", status);
  45. }
  46. RpcExcept(1) {
  47. ulCode = RpcExceptionCode();
  48. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  49. fContinue = 0;
  50. }
  51. RpcEndExcept
  52. RpcTryExcept {
  53. status = RpcNsProfileEltInqNext(
  54. hdrt,
  55. &ifid,
  56. &pMemberName,
  57. &dwPriority,
  58. &pAnnotation
  59. );
  60. printf("RpcNsProfileEltInqNext returned 0x%x\n", status);
  61. if (!status)
  62. {
  63. wprintf(L"Annotation: %s\n", pAnnotation);
  64. wprintf(L"MemberName: %s, Priority %d\n", pMemberName, dwPriority);
  65. }
  66. }
  67. RpcExcept(1) {
  68. ulCode = RpcExceptionCode();
  69. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  70. fContinue = 0;
  71. }
  72. RpcEndExcept
  73. RpcTryExcept {
  74. status = RpcNsProfileEltInqNext(
  75. hdrt,
  76. &ifid,
  77. &pMemberName,
  78. &dwPriority,
  79. &pAnnotation
  80. );
  81. printf("RpcNsProfileEltInqNext returned 0x%x\n", status);
  82. if (!status)
  83. {
  84. wprintf(L"Annotation: %s\n", pAnnotation);
  85. wprintf(L"MemberName: %s, Priority %d\n", pMemberName, dwPriority);
  86. }
  87. }
  88. RpcExcept(1) {
  89. ulCode = RpcExceptionCode();
  90. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  91. fContinue = 0;
  92. }
  93. RpcEndExcept
  94. RpcTryExcept {
  95. status = RpcNsProfileEltInqDone(
  96. &hdrt
  97. );
  98. printf("RpcNsProfileEltInqDone returned 0x%x\n", status);
  99. }
  100. RpcExcept(1) {
  101. ulCode = RpcExceptionCode();
  102. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  103. fContinue = 0;
  104. }
  105. RpcEndExcept
  106. RpcTryExcept {
  107. status = RpcNsGroupMbrInqBegin(
  108. fNameSyntaxType,
  109. pszGrpEntryName1,
  110. fNameSyntaxType,
  111. &hdrt
  112. );
  113. printf(" RpcNsGroupMbrInqBegin returned 0x%x\n", status);
  114. }
  115. RpcExcept(1) {
  116. ulCode = RpcExceptionCode();
  117. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  118. fContinue = 0;
  119. }
  120. RpcEndExcept
  121. *pMemberName = '\0';
  122. RpcTryExcept {
  123. status = RpcNsGroupMbrInqNext(
  124. hdrt,
  125. &pMemberName
  126. );
  127. printf("RpcNsGroupMbrInqNext returned 0x%x\n", status);
  128. if (!status)
  129. {
  130. wprintf(L"MemberName: %s\n", pMemberName);
  131. }
  132. }
  133. RpcExcept(1) {
  134. ulCode = RpcExceptionCode();
  135. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  136. fContinue = 0;
  137. }
  138. RpcEndExcept
  139. RpcTryExcept {
  140. status = RpcNsGroupMbrInqDone(
  141. &hdrt
  142. );
  143. printf("RpcNsGroupMbrInqDone returned 0x%x\n", status);
  144. }
  145. RpcExcept(1) {
  146. ulCode = RpcExceptionCode();
  147. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  148. fContinue = 0;
  149. }
  150. RpcEndExcept
  151. RpcTryExcept {
  152. status = RpcNsBindingImportBegin(fNameSyntaxType,
  153. pszGrpEntryName1,
  154. drtsrv_01_v1_0_c_ifspec,
  155. NULL,
  156. &hdrt);
  157. printf("RpcNsBindingImportBegin returned 0x%x\n", status);
  158. }
  159. RpcExcept(1) {
  160. ulCode = RpcExceptionCode();
  161. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  162. fContinue = 0;
  163. }
  164. RpcEndExcept
  165. if ( status != RPC_S_OK )
  166. fContinue = 0;
  167. /* The loop is present because the name service may contain "stale" */
  168. /* and unusable binding handlers. This is part of the DCE design. */
  169. while( fContinue )
  170. {
  171. status = RpcNsBindingImportNext(hdrt,
  172. &bhdrt);
  173. printf("RpcNsBindingImportNext returned 0x%x\n", status);
  174. if ( (status == RPC_S_NO_MORE_BINDINGS) ||
  175. (status == RPC_S_NAME_SERVICE_UNAVAILABLE ) )
  176. break;
  177. if (status != RPC_S_OK)
  178. continue;
  179. RpcBindingToStringBinding( bhdrt, &pszStrBinding );
  180. printf("StringBinding: %s\n", pszStrBinding );
  181. RpcStringFree(&pszStrBinding);
  182. RpcTryExcept {
  183. printf("Calling remote procedure HelloProc with string %s\n",
  184. pszString);
  185. HelloProc(bhdrt, pszString);
  186. fContinue = 0;
  187. fSuccess = 1;
  188. }
  189. RpcExcept(1) {
  190. ulCode = RpcExceptionCode();
  191. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  192. status = RpcBindingFree(&bhdrt);
  193. printf("RpcBindingFree returned 0x%x\n", status);
  194. fContinue = 1;
  195. }
  196. RpcEndExcept
  197. }
  198. RpcTryExcept {
  199. status = RpcNsBindingImportDone(&hdrt);
  200. printf("RpcNsBindingImportDone returned 0x%x\n", status);
  201. }
  202. RpcExcept(1) {
  203. ulCode = RpcExceptionCode();
  204. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  205. fContinue = 0;
  206. }
  207. RpcEndExcept
  208. if ( fSuccess )
  209. {
  210. RpcTryExcept {
  211. Shutdown(bhdrt); // Shutdown is a remote procedure
  212. }
  213. RpcExcept(1) {
  214. ulCode = RpcExceptionCode();
  215. printf("RPC runtime raised exception 0x%x\n", ulCode);
  216. }
  217. RpcEndExcept
  218. status = RpcBindingFree(&bhdrt);
  219. printf("RpcBindingFree returned 0x%x\n", status);
  220. }
  221. exit(0);
  222. } // end main()
  223. /*********************************************************************/
  224. /* MIDL allocate and free */
  225. /*********************************************************************/
  226. void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
  227. {
  228. return(malloc(len));
  229. }
  230. void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
  231. {
  232. free(ptr);
  233. }
  234. /* end file drtc.c */