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.

154 lines
4.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: drts.cxx
  8. //
  9. //--------------------------------------------------------------------------
  10. #include <windows.h>
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <ctype.h>
  14. #include "drt.h" // header file generated by MIDL compiler
  15. void __cdecl main(int argc, char * argv[])
  16. {
  17. RPC_STATUS status;
  18. RPC_BINDING_VECTOR * pBindingVector = NULL;
  19. WCHAR * pszEntryName = L"/.:/drtsrv_01";
  20. WCHAR * pszGrpEntryName1 = L"/.:/drtgrp_01";
  21. WCHAR * pszPrfEntryName1 = L"/.:/drtprf_01";
  22. unsigned char * pszSecurity = NULL;
  23. unsigned int cMinCalls = 1;
  24. unsigned int cMaxCalls = 20;
  25. unsigned int fDontWait = 0;
  26. unsigned int fNameSyntaxType = RPC_C_NS_SYNTAX_DEFAULT;
  27. unsigned int fRegistered = 0;
  28. unsigned int fEndpoint = 0;
  29. unsigned int fExported = 0;
  30. // abcdefab-abcd-abcd-abcd-abcdefabcdef
  31. RPC_IF_ID ifid = {{ 0xabcdefab, 0xabcd, 0xabcd, { 0xab, 0xcd, 0xab, 0xcd, 0xef, 0xab, 0xcd, 0xef } },
  32. 1, 0};
  33. int i;
  34. printf("CallingRpcServerUseAllProtseqs...\n");
  35. status = RpcServerUseAllProtseqs(cMaxCalls, // max concurrent calls
  36. pszSecurity); // Security descriptor
  37. printf("RpcServerUseAllProtseqs returned 0x%x\n", status);
  38. if (status) {
  39. goto cleanup;
  40. }
  41. status = RpcServerRegisterIf(drtsrv_01_v1_0_s_ifspec, // interface to register
  42. NULL, // MgrTypeUuid
  43. NULL); // MgrEpv; null means use default
  44. printf("RpcServerRegisterIf returned 0x%x\n", status);
  45. if (status) {
  46. goto cleanup;
  47. }
  48. else
  49. fRegistered = 1;
  50. status = RpcServerInqBindings(&pBindingVector);
  51. printf("RpcServerInqBindings returned 0x%x\n", status);
  52. if (status) {
  53. goto cleanup;
  54. }
  55. status = RpcEpRegister(drtsrv_01_v1_0_s_ifspec,
  56. pBindingVector,
  57. NULL,
  58. L"");
  59. printf("RpcEpRegister returned 0x%x\n", status);
  60. if (status) {
  61. goto cleanup;
  62. }
  63. else
  64. fEndpoint = 1;
  65. status = RpcNsBindingExport(fNameSyntaxType, // name syntax type
  66. pszEntryName, // nsi entry name
  67. drtsrv_01_v1_0_s_ifspec,
  68. pBindingVector, // set in previous call
  69. NULL); // UUID vector
  70. printf("RpcNsBindingExport returned 0x%x\n", status);
  71. if (status) {
  72. goto cleanup;
  73. }
  74. else
  75. fExported = 1;
  76. printf("Calling RpcServerListen: Case 1:\n");
  77. status = RpcServerListen(cMinCalls,
  78. cMaxCalls,
  79. fDontWait); // wait flag
  80. printf("RpcServerListen returned: 0x%x\n", status);
  81. if (status) {
  82. goto cleanup;
  83. }
  84. if (fDontWait) {
  85. printf("Calling RpcMgmtWaitServerListen\n");
  86. status = RpcMgmtWaitServerListen(); // wait operation
  87. printf("RpcMgmtWaitServerListen returned: 0x%x\n", status);
  88. }
  89. cleanup:
  90. if ( fExported )
  91. {
  92. status = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  93. pszEntryName, // nsi entry name
  94. drtsrv_01_v1_0_s_ifspec,
  95. NULL); // UUID vector
  96. printf( "RpcNsBindingUnexport returned 0x%x\n", status);
  97. }
  98. if ( fEndpoint )
  99. {
  100. status = RpcEpUnregister(drtsrv_01_v1_0_s_ifspec,
  101. pBindingVector,
  102. NULL);
  103. printf( "RpcEpUnregister returned 0x%x\n", status);
  104. }
  105. if ( pBindingVector )
  106. {
  107. status = RpcBindingVectorFree(&pBindingVector);
  108. printf( "RpcBindingVectorFree returned 0x%x\n", status);
  109. }
  110. if ( fRegistered )
  111. {
  112. status = RpcServerUnregisterIf(drtsrv_01_v1_0_s_ifspec, // interface to register
  113. NULL, // MgrTypeUuid
  114. 1); // wait for outstanding calls
  115. printf( "RpcServerUnregisterIf returned 0x%x\n", status);
  116. }
  117. } // end main()
  118. /*********************************************************************/
  119. /* MIDL allocate and free */
  120. /*********************************************************************/
  121. void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
  122. {
  123. return(malloc(len));
  124. }
  125. void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
  126. {
  127. free(ptr);
  128. }
  129. /* end file drts.c */