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.

117 lines
3.1 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996, Microsoft Corporation
  4. //
  5. // File: ftdfs.c
  6. //
  7. // Contents: Support for ftdfs resolution
  8. //
  9. // Classes: None
  10. //
  11. // Functions:
  12. //
  13. //-----------------------------------------------------------------------------
  14. #define Dbg DEBUG_TRACE_ROOT_EXPANSION
  15. #include "dfsprocs.h"
  16. #include "ftdfs.h"
  17. #include "know.h"
  18. #ifdef ALLOC_PRAGMA
  19. #pragma alloc_text( PAGE, DfspParsePath )
  20. #endif // ALLOC_PRAGMA
  21. //+----------------------------------------------------------------------------
  22. //
  23. // Function: DfspParsePrefix
  24. //
  25. // Synopsis: Helper routine to break a path into domain, share, remainder
  26. //
  27. // Arguments: [Path] -- PUNICODE string of path to parse
  28. //
  29. // Returns: [DomainName] -- UNICODE_STRING containing DomainName, if present
  30. // [ShareName] -- UNICODE_STRING containing ShareName, if present
  31. // [Remainder] -- UNICODE_STRING containing remainder of Path
  32. //
  33. //-----------------------------------------------------------------------------
  34. VOID
  35. DfspParsePath(
  36. PUNICODE_STRING PathName,
  37. PUNICODE_STRING DomainName,
  38. PUNICODE_STRING ShareName,
  39. PUNICODE_STRING Remainder)
  40. {
  41. LPWSTR ustrp, ustart, uend;
  42. DebugTrace(+1, Dbg, "DfspParsePath(%wZ)\n", PathName);
  43. RtlInitUnicodeString(DomainName, NULL);
  44. RtlInitUnicodeString(ShareName, NULL);
  45. RtlInitUnicodeString(Remainder, NULL);
  46. // Be sure there's something to do
  47. if (PathName->Length == 0) {
  48. DebugTrace(-1, Dbg, "PathName is empty\n",0 );
  49. return;
  50. }
  51. // Skip leading '\'s
  52. ustart = ustrp = PathName->Buffer;
  53. uend = &PathName->Buffer[PathName->Length / sizeof(WCHAR)] - 1;
  54. // strip trailing nulls
  55. while (uend >= ustart && *uend == UNICODE_NULL)
  56. uend--;
  57. while (ustrp <= uend && *ustrp == UNICODE_PATH_SEP)
  58. ustrp++;
  59. // DomainName
  60. ustart = ustrp;
  61. while (ustrp <= uend && *ustrp != UNICODE_PATH_SEP)
  62. ustrp++;
  63. if (ustrp != ustart) {
  64. DomainName->Buffer = ustart;
  65. DomainName->Length = (USHORT)((ustrp - ustart)) * sizeof(WCHAR);
  66. DomainName->MaximumLength = DomainName->Length;
  67. // ShareName
  68. ustart = ++ustrp;
  69. while (ustrp <= uend && *ustrp != UNICODE_PATH_SEP)
  70. ustrp++;
  71. if (ustrp != ustart) {
  72. ShareName->Buffer = ustart;
  73. ShareName->Length = (USHORT)((ustrp - ustart)) * sizeof(WCHAR);
  74. ShareName->MaximumLength = ShareName->Length;
  75. // Remainder is whatever's left
  76. ustart = ++ustrp;
  77. while (ustrp <= uend)
  78. ustrp++;
  79. if (ustrp != ustart) {
  80. Remainder->Buffer = ustart;
  81. Remainder->Length = (USHORT)((ustrp - ustart)) * sizeof(WCHAR);
  82. Remainder->MaximumLength = Remainder->Length;
  83. }
  84. }
  85. }
  86. DebugTrace( 0, Dbg, "DfspParsePath: DomainName -> %wZ\n", DomainName);
  87. DebugTrace( 0, Dbg, " ShareName -> %wZ\n", ShareName);
  88. DebugTrace(-1, Dbg, " Remainder -> %wZ\n", Remainder);
  89. }