]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /** @file\r |
2 | Copying Functions for <wchar.h>.\r | |
3 | \r | |
4 | Unless explicitly stated otherwise, if the execution of a function declared\r | |
5 | in this file causes copying to take place between objects that overlap, the\r | |
6 | behavior is undefined.\r | |
7 | \r | |
8 | Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r | |
9 | This program and the accompanying materials are licensed and made available under\r | |
10 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
11 | The full text of the license may be found at\r | |
12 | http://opensource.org/licenses/bsd-license.php.\r | |
13 | \r | |
14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
16 | **/\r | |
17 | #include <Uefi.h>\r | |
18 | #include <Library/BaseLib.h>\r | |
19 | #include <Library/BaseMemoryLib.h>\r | |
20 | \r | |
21 | #include <LibConfig.h>\r | |
22 | \r | |
23 | #include <wchar.h>\r | |
24 | \r | |
25 | /** The wcscpy function copies the wide string pointed to by s2 (including the\r | |
26 | terminating null wide character) into the array pointed to by s1.\r | |
27 | \r | |
28 | @return The wcscpy function returns the value of s1.\r | |
29 | **/\r | |
30 | wchar_t *wcscpy(wchar_t * __restrict s1, const wchar_t * __restrict s2)\r | |
31 | {\r | |
32 | return (wchar_t *)StrCpy( (CHAR16 *)s1, (CONST CHAR16 *)s2);\r | |
33 | }\r | |
34 | \r | |
35 | /** The wcsncpy function copies not more than n wide characters (those that\r | |
36 | follow a null wide character are not copied) from the array pointed to by\r | |
37 | s2 to the array pointed to by s1.\r | |
38 | \r | |
39 | If the array pointed to by s2 is a wide string that is shorter than n wide\r | |
40 | characters, null wide characters are appended to the copy in the array\r | |
41 | pointed to by s1, until n wide characters in all have been written.\r | |
42 | \r | |
43 | @return The wcsncpy function returns the value of s1.\r | |
44 | **/\r | |
45 | wchar_t *wcsncpy(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)\r | |
46 | {\r | |
47 | return (wchar_t *)StrnCpy( (CHAR16 *)s1, (CONST CHAR16 *)s2, (UINTN)n);\r | |
48 | }\r | |
49 | \r | |
50 | /** The wmemcpy function copies n wide characters from the object pointed to by\r | |
51 | s2 to the object pointed to by s1.\r | |
52 | \r | |
53 | Use this function if you know that s1 and s2 DO NOT Overlap. Otherwise,\r | |
54 | use wmemmove.\r | |
55 | \r | |
56 | @return The wmemcpy function returns the value of s1.\r | |
57 | **/\r | |
58 | wchar_t *wmemcpy(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)\r | |
59 | {\r | |
60 | return (wchar_t *)CopyMem( s1, s2, (UINTN)(n * sizeof(wchar_t)));\r | |
61 | }\r | |
62 | \r | |
63 | /** The wmemmove function copies n wide characters from the object pointed to by\r | |
64 | s2 to the object pointed to by s1. The objects pointed to by s1 and s2 are\r | |
65 | allowed to overlap.\r | |
66 | \r | |
67 | Because the UEFI BaseMemoryLib function CopyMem explicitly handles\r | |
68 | overlapping source and destination objects, this function and wmemcpy are\r | |
69 | implemented identically.\r | |
70 | \r | |
71 | For programming clarity, it is recommended that you use wmemcpy if you know\r | |
72 | that s1 and s2 DO NOT Overlap. If s1 and s2 might possibly overlap, then\r | |
73 | use wmemmove.\r | |
74 | \r | |
75 | @return The wmemmove function returns the value of s1.\r | |
76 | **/\r | |
77 | wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2, size_t n)\r | |
78 | {\r | |
79 | return (wchar_t *)CopyMem( s1, s2, (UINTN)(n * sizeof(wchar_t)));\r | |
80 | }\r |