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.

80 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. parseini.c
  5. Abstract:
  6. This module implements functions to parse a .INI file
  7. Author:
  8. John Vert (jvert) 7-Oct-1993
  9. Revision History:
  10. John Vert (jvert) 7-Oct-1993 - largely lifted from splib\spinf.c
  11. --*/
  12. #include "parseini.h"
  13. #include <string.h>
  14. #include <ctype.h>
  15. #include <stdlib.h>
  16. PWCHAR
  17. SlCopyStringAW(
  18. IN PCHAR String
  19. )
  20. /*++
  21. Routine Description:
  22. Converts an ANSI string into UNICODE and copies it into the loader heap.
  23. Arguments:
  24. String - Supplies the string to be copied.
  25. Return Value:
  26. PWCHAR - pointer into the loader heap where the string was copied to.
  27. --*/
  28. {
  29. PWCHAR Buffer;
  30. ANSI_STRING aString;
  31. UNICODE_STRING uString;
  32. USHORT Length;
  33. if (String==NULL) {
  34. SlNoMemoryError();
  35. return NULL;
  36. }
  37. Length = RESET_SIZE_AT_USHORT_MAX(sizeof(WCHAR)*(strlen(String) + 1));
  38. Buffer = BlAllocateHeap(Length);
  39. if (Buffer==NULL) {
  40. SlNoMemoryError();
  41. } else {
  42. RtlInitAnsiString( &aString, String );
  43. uString.Buffer = Buffer;
  44. uString.MaximumLength = Length;
  45. RtlAnsiStringToUnicodeString( &uString, &aString, FALSE );
  46. Buffer[strlen(String)] = L'\0';
  47. }
  48. return(Buffer);
  49. }