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.

201 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. bind.c
  5. Abstract:
  6. Contains the RPC bind and un-bind routines
  7. Author:
  8. Dave Snipp (davesn) 01-Jun-1991
  9. Environment:
  10. User Mode -Win32
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. #include "client.h"
  16. LPWSTR InterfaceAddress = L"\\pipe\\spoolss";
  17. /* Security=[Impersonation | Identification | Anonymous] [Dynamic | Static] [True | False]
  18. * (where True | False corresponds to EffectiveOnly)
  19. */
  20. LPWSTR StringBindingOptions = L"Security=Impersonation Dynamic False";
  21. handle_t GlobalBindHandle;
  22. handle_t
  23. PRINTER_HANDLE_bind (
  24. PRINTER_HANDLE hPrinter)
  25. /*++
  26. Routine Description:
  27. This routine is used to obtain a binding to the printer spooler.
  28. Arguments:
  29. Server - Supplies the name of the server where the printer spooler
  30. should be binded with.
  31. Return Value:
  32. A binding to the server will be returned, unless an error occurs,
  33. in which case zero will be returned.
  34. --*/
  35. {
  36. RPC_STATUS RpcStatus;
  37. LPWSTR StringBinding;
  38. handle_t BindingHandle;
  39. RpcStatus = RpcStringBindingComposeW(0, L"ncalrpc", 0, L"spoolss",
  40. StringBindingOptions, &StringBinding);
  41. if ( RpcStatus != RPC_S_OK ) {
  42. return( 0 );
  43. }
  44. RpcStatus = RpcBindingFromStringBindingW(StringBinding, &BindingHandle);
  45. RpcStringFreeW(&StringBinding);
  46. if ( RpcStatus != RPC_S_OK ) {
  47. return(0);
  48. }
  49. return(BindingHandle);
  50. }
  51. void
  52. PRINTER_HANDLE_unbind (
  53. PRINTER_HANDLE hPrinter,
  54. handle_t BindingHandle)
  55. /*++
  56. Routine Description:
  57. This routine calls a common unbind routine that is shared by
  58. all services.
  59. This routine is called from the server service client stubs when
  60. it is necessary to unbind to a server.
  61. Arguments:
  62. ServerName - This is the name of the server from which to unbind.
  63. BindingHandle - This is the binding handle that is to be closed.
  64. Return Value:
  65. none.
  66. --*/
  67. {
  68. RPC_STATUS RpcStatus;
  69. RpcStatus = RpcBindingFree(&BindingHandle);
  70. ASSERT(RpcStatus == RPC_S_OK);
  71. return;
  72. }
  73. handle_t
  74. STRING_HANDLE_bind (
  75. STRING_HANDLE lpStr)
  76. /*++
  77. Routine Description:
  78. This routine calls a common bind routine that is shared by all services.
  79. This routine is called from the server service client stubs when
  80. it is necessary to bind to a server.
  81. Arguments:
  82. ServerName - A pointer to a string containing the name of the server
  83. to bind with.
  84. Return Value:
  85. The binding handle is returned to the stub routine. If the
  86. binding is unsuccessful, a NULL will be returned.
  87. --*/
  88. {
  89. RPC_STATUS RpcStatus;
  90. LPWSTR StringBinding;
  91. handle_t BindingHandle;
  92. RpcStatus = RpcStringBindingComposeW(0, L"ncalrpc", 0, L"spoolss",
  93. StringBindingOptions, &StringBinding);
  94. if ( RpcStatus != RPC_S_OK ) {
  95. return( 0 );
  96. }
  97. RpcStatus = RpcBindingFromStringBindingW(StringBinding, &BindingHandle);
  98. RpcStringFreeW(&StringBinding);
  99. if ( RpcStatus != RPC_S_OK ) {
  100. return(0);
  101. }
  102. return(BindingHandle);
  103. }
  104. void
  105. STRING_HANDLE_unbind (
  106. STRING_HANDLE lpStr,
  107. handle_t BindingHandle)
  108. /*++
  109. Routine Description:
  110. This routine calls a common unbind routine that is shared by
  111. all services.
  112. This routine is called from the server service client stubs when
  113. it is necessary to unbind to a server.
  114. Arguments:
  115. ServerName - This is the name of the server from which to unbind.
  116. BindingHandle - This is the binding handle that is to be closed.
  117. Return Value:
  118. none.
  119. --*/
  120. {
  121. RPC_STATUS RpcStatus;
  122. RpcStatus = RpcBindingFree(&BindingHandle);
  123. ASSERT(RpcStatus == RPC_S_OK);
  124. return;
  125. }