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