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.

136 lines
4.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: drtc.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 = RpcNsBindingImportBegin(fNameSyntaxType,
  35. pszEntryName,
  36. drtsrv_01_v1_0_c_ifspec,
  37. NULL,
  38. &hdrt);
  39. printf("RpcNsBindingImportBegin returned 0x%x\n", status);
  40. }
  41. RpcExcept(1) {
  42. ulCode = RpcExceptionCode();
  43. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  44. fContinue = 0;
  45. }
  46. RpcEndExcept
  47. if ( status != RPC_S_OK )
  48. fContinue = 0;
  49. /* The loop is present because the name service may contain "stale" */
  50. /* and unusable binding handlers. This is part of the DCE design. */
  51. while( fContinue )
  52. {
  53. status = RpcNsBindingImportNext(hdrt,
  54. &bhdrt);
  55. printf("RpcNsBindingImportNext returned 0x%x\n", status);
  56. if ( (status == RPC_S_NO_MORE_BINDINGS) ||
  57. (status == RPC_S_NAME_SERVICE_UNAVAILABLE ) )
  58. break;
  59. if (status != RPC_S_OK)
  60. continue;
  61. RpcBindingToStringBinding( bhdrt, &pszStrBinding );
  62. printf("StringBinding: %s\n", pszStrBinding );
  63. RpcStringFree(&pszStrBinding);
  64. RpcTryExcept {
  65. printf("Calling remote procedure HelloProc with string %s\n",
  66. pszString);
  67. HelloProc(bhdrt, pszString);
  68. fContinue = 0;
  69. fSuccess = 1;
  70. }
  71. RpcExcept(1) {
  72. ulCode = RpcExceptionCode();
  73. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  74. status = RpcBindingFree(&bhdrt);
  75. printf("RpcBindingFree returned 0x%x\n", status);
  76. fContinue = 1;
  77. }
  78. RpcEndExcept
  79. }
  80. RpcTryExcept {
  81. status = RpcNsBindingImportDone(&hdrt);
  82. printf("RpcNsBindingImportDone returned 0x%x\n", status);
  83. }
  84. RpcExcept(1) {
  85. ulCode = RpcExceptionCode();
  86. printf("RPC Runtime raised exception 0x%x\n", ulCode);
  87. fContinue = 0;
  88. }
  89. RpcEndExcept
  90. if ( fSuccess )
  91. {
  92. RpcTryExcept {
  93. Shutdown(bhdrt); // Shutdown is a remote procedure
  94. }
  95. RpcExcept(1) {
  96. ulCode = RpcExceptionCode();
  97. printf("RPC runtime raised exception 0x%x\n", ulCode);
  98. }
  99. RpcEndExcept
  100. status = RpcBindingFree(&bhdrt);
  101. printf("RpcBindingFree returned 0x%x\n", status);
  102. }
  103. exit(0);
  104. } // end main()
  105. /*********************************************************************/
  106. /* MIDL allocate and free */
  107. /*********************************************************************/
  108. void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
  109. {
  110. return(malloc(len));
  111. }
  112. void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
  113. {
  114. free(ptr);
  115. }
  116. /* end file drtc.c */