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.

113 lines
2.8 KiB

  1. /********************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. sfprpcs.cpp
  5. Abstract:
  6. implements server rpc thread - exported in SFPSAPI.LIB
  7. server shutdown - exported in SFPSAPI.LIB
  8. Revision History:
  9. Brijesh Krishnaswami (brijeshk) - 06/16/99 - Created
  10. ********************************************************************/
  11. #include <windows.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include "srrpc.h" // header file generated by MIDL compiler
  15. #include "srdefs.h"
  16. #include "utils.h"
  17. #include <dbgtrace.h>
  18. #ifdef THIS_FILE
  19. #undef THIS_FILE
  20. #endif
  21. static char __szTraceSourceFile[] = __FILE__;
  22. #define THIS_FILE __szTraceSourceFile
  23. #define MIN_RPC_CALLS 1
  24. #define MAX_RPC_CALLS 5
  25. // RPC Server
  26. // registers as an rpc server and waits for requests
  27. extern "C" DWORD WINAPI
  28. RpcServerStart()
  29. {
  30. RPC_STATUS status;
  31. TENTER("RpcServerStart");
  32. // specify to use the local rpc protocol sequence
  33. status = RpcServerUseProtseqEp(s_cszRPCProtocol,
  34. MAX_RPC_CALLS,
  35. s_cszRPCEndPoint,
  36. NULL); // Security descriptor
  37. if (status != 0 && status != RPC_S_DUPLICATE_ENDPOINT)
  38. {
  39. TRACE(0, "! RpcServerUseProtseqEp : %ld", status);
  40. goto exit;
  41. }
  42. // register the srrpc interface
  43. status = RpcServerRegisterIfEx(srrpc_ServerIfHandle, // interface to register
  44. NULL, // MgrTypeUuid
  45. NULL, // MgrEpv; null means use default
  46. RPC_IF_AUTOLISTEN, // auto-listen interface
  47. MAX_RPC_CALLS, // max concurrent calls
  48. NULL); // callback
  49. if (status)
  50. {
  51. TRACE(0, "! RpcServerRegisterIfEx : %ld", status);
  52. goto exit;
  53. }
  54. TRACE(0, "Started to listen to RPC calls");
  55. exit:
  56. TLEAVE();
  57. return status;
  58. }
  59. // function to shut down the rpc server
  60. extern "C" DWORD WINAPI
  61. RpcServerShutdown()
  62. {
  63. RPC_STATUS status;
  64. TENTER("RpcServerShutdown");
  65. // unregister the server endpoint
  66. status = RpcServerUnregisterIf(srrpc_ServerIfHandle, NULL, TRUE);
  67. if (status)
  68. {
  69. TRACE(0, "! RpcServerUnregisterIf : %ld", status);
  70. goto exit;
  71. }
  72. exit:
  73. TLEAVE();
  74. return status;
  75. }
  76. // functions used by midl compiler to allocate and free memory
  77. void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
  78. {
  79. return(SRMemAlloc((DWORD) len));
  80. }
  81. void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
  82. {
  83. SRMemFree(ptr);
  84. }