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.

135 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Copyright (c) 1993 Micro Computer Systems, Inc.
  4. Module Name:
  5. net\svcdlls\nwsap\client\init.c
  6. Abstract:
  7. This routine initializes the SAP Library
  8. Author:
  9. Brian Walker (MCS) 06-15-1993
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. /** Global Variables **/
  15. INT SapLibInitialized = 0;
  16. HANDLE SapXsPortHandle;
  17. /*++
  18. *******************************************************************
  19. S a p L i b I n i t
  20. Routine Description:
  21. This routine initializes the SAP interface for a program
  22. Arguments:
  23. None
  24. Return Value:
  25. 0 = Ok
  26. Else = Error
  27. *******************************************************************
  28. --*/
  29. DWORD
  30. SapLibInit(
  31. VOID)
  32. {
  33. UNICODE_STRING unistring;
  34. NTSTATUS status;
  35. SECURITY_QUALITY_OF_SERVICE qos;
  36. /** If already initialized - return ok **/
  37. if (SapLibInitialized) {
  38. return 0;
  39. }
  40. /** Connect the port **/
  41. /** Fill out the security quality of service **/
  42. qos.Length = sizeof(qos);
  43. qos.ImpersonationLevel = SecurityImpersonation;
  44. qos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
  45. qos.EffectiveOnly = TRUE;
  46. /** Setup the unicode string of the port name **/
  47. RtlInitUnicodeString(&unistring, NWSAP_BIND_PORT_NAME_W);
  48. /** Do the connect **/
  49. status = NtConnectPort(
  50. &SapXsPortHandle, /* We get a handle back */
  51. &unistring, /* Port name to connect to */
  52. &qos, /* Quality of service */
  53. NULL, /* Client View */
  54. NULL, /* Server View */
  55. NULL, /* MaxMessageLength */
  56. NULL, /* ConnectionInformation */
  57. NULL); /* ConnectionInformationLength */
  58. /** If error - just return it **/
  59. if (!NT_SUCCESS(status))
  60. return status;
  61. /** All Done **/
  62. SapLibInitialized = 1;
  63. return 0;
  64. }
  65. /*++
  66. *******************************************************************
  67. S a p L i b S h u t d o w n
  68. Routine Description:
  69. This routine shuts down the SAP interface for a program
  70. Arguments:
  71. None
  72. Return Value:
  73. 0 = Ok
  74. Else = Error
  75. *******************************************************************
  76. --*/
  77. DWORD
  78. SapLibShutdown(
  79. VOID)
  80. {
  81. /** If not initialized - leave **/
  82. if (!SapLibInitialized)
  83. return 0;
  84. /** Close the port **/
  85. NtClose(SapXsPortHandle);
  86. /** All Done **/
  87. SapLibInitialized = 0;
  88. return 0;
  89. }
  90.