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.

99 lines
1.6 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. lsastr.c
  5. Abstract:
  6. Common string operations.
  7. Author:
  8. 24-March-1999 kumarp
  9. --*/
  10. #include <lsapch2.h>
  11. VOID
  12. LsapTruncateUnicodeString(
  13. IN OUT PUNICODE_STRING String,
  14. IN USHORT TruncateToNumChars)
  15. /*++
  16. Routine Description:
  17. If a string is longer than TruncateToNumChars then truncate it
  18. to TruncateToNumChars.
  19. Arguments:
  20. String - pointer to string
  21. TruncateToNumChars - number of chars to truncate to
  22. Return Value:
  23. None
  24. Notes:
  25. No memory (de)allocations are involved.
  26. --*/
  27. {
  28. USHORT TruncateToLength = TruncateToNumChars*sizeof(WCHAR);
  29. if (String->Length > TruncateToLength) {
  30. String->Length = TruncateToLength;
  31. String->Buffer[TruncateToNumChars] = UNICODE_NULL;
  32. }
  33. }
  34. BOOLEAN
  35. LsapRemoveTrailingDot(
  36. IN OUT PUNICODE_STRING String,
  37. IN BOOLEAN AdjustLengthOnly)
  38. /*++
  39. Routine Description:
  40. If there is a '.' at the end of a string, remove it.
  41. Arguments:
  42. String - pointer to unicode string
  43. AdjustLengthOnly - If TRUE only decrements the Length member of
  44. String otherwise replaces dot with UNICODE_NULL as well.
  45. Return Value:
  46. TRUE if trailing dot was present, FALSE otherwise.
  47. Notes:
  48. --*/
  49. {
  50. USHORT NumCharsInString;
  51. NumCharsInString = String->Length / sizeof(WCHAR);
  52. if (NumCharsInString &&
  53. (String->Buffer[NumCharsInString-1] == L'.')) {
  54. String->Length -= sizeof(WCHAR);
  55. if (!AdjustLengthOnly) {
  56. String->Buffer[NumCharsInString-1] = UNICODE_NULL;
  57. }
  58. return TRUE;
  59. }
  60. return FALSE;
  61. }