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.

130 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. fmt.cxx
  5. Abstract:
  6. Contains the entry points for the Winnet Connection API supported by the
  7. Multi-Provider Router.
  8. Contains:
  9. WNetFormatNetworkNameW
  10. Author:
  11. Bruce Forstall (brucefo) 15-Mar-1996
  12. Environment:
  13. User Mode -Win32
  14. Notes:
  15. Revision History:
  16. 15-Mar-1996 brucefo
  17. created from old MPRUI code
  18. 05-May-1999 jschwart
  19. Make provider addition/removal dynamic
  20. --*/
  21. //
  22. // INCLUDES
  23. //
  24. #include "precomp.hxx"
  25. /*******************************************************************
  26. NAME: WNetFormatNetworkNameW
  27. SYNOPSIS: Private Shell API for getting the formatted network name
  28. Unicode version
  29. ENTRY: lpProvider - Name of network provider
  30. lpRemoteName - Remote name to format
  31. lpFormattedName - Buffer to receive name
  32. lpnLength - size of lpFormattedName buffer
  33. dwFlags - Formatting flags
  34. dwAveCharePerLine - Avg. characters per line
  35. NOTES: Since this is an unpublished API, we don't do as much
  36. parameter validation as we would for a published API. Also,
  37. since the shell calls this thousands of times to display
  38. things in the Network Neighborhood, we optimize for speed
  39. of the success case.
  40. HISTORY:
  41. Johnl 29-Dec-1992 Created
  42. BruceFo 19-Mar-1996 Optimized for the shell
  43. ********************************************************************/
  44. DWORD
  45. WNetFormatNetworkNameW(
  46. LPCWSTR lpProvider,
  47. LPCWSTR lpRemoteName,
  48. LPWSTR lpFormattedName,
  49. LPDWORD lpnLength, // In characters!
  50. DWORD dwFlags,
  51. DWORD dwAveCharPerLine
  52. )
  53. {
  54. DWORD status = WN_SUCCESS;
  55. MprCheckProviders();
  56. CProviderSharedLock PLock;
  57. INIT_IF_NECESSARY(NETWORK_LEVEL,status);
  58. __try
  59. {
  60. LPPROVIDER provider = MprFindProviderByName(lpProvider);
  61. if (NULL == provider)
  62. {
  63. status = WN_BAD_PROVIDER;
  64. }
  65. else
  66. {
  67. if (NULL == provider->FormatNetworkName)
  68. {
  69. status = WN_NOT_SUPPORTED;
  70. }
  71. else
  72. {
  73. //**************************************
  74. // Actual call to Provider.
  75. //**************************************
  76. status = provider->FormatNetworkName(
  77. (LPWSTR) lpRemoteName, // cast away const
  78. (LPWSTR) lpFormattedName, // cast away const
  79. lpnLength,
  80. dwFlags,
  81. dwAveCharPerLine);
  82. }
  83. }
  84. }
  85. __except(MPR_EXCEPTION_FILTER)
  86. {
  87. status = GetExceptionCode();
  88. if (status != EXCEPTION_ACCESS_VIOLATION)
  89. {
  90. MPR_LOG(ERROR,"WNetFormatNetworkName: "
  91. "Unexpected Exception 0x%lx\n",status);
  92. }
  93. status = WN_BAD_POINTER;
  94. }
  95. if (status != WN_SUCCESS)
  96. {
  97. SetLastError(status);
  98. }
  99. return status;
  100. }