]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/String/Misc.c
2 Miscellaneous Functions for <string.h>.
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 //#include <sys/EfiCdefs.h>
16 #include <Library/BaseLib.h>
17 #include <Library/BaseMemoryLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/PrintLib.h>
21 #include <LibConfig.h>
27 extern char *sys_errlist
[];
29 #if !((defined(MDE_CPU_ARM) || defined(MDE_CPU_AARCH64)) && defined(__GNUC__))
30 /** The memset function copies the value of c (converted to an unsigned char)
31 into each of the first n characters of the object pointed to by s.
33 @return The memset function returns the value of s.
36 memset(void *s
, int c
, size_t n
)
38 return SetMem( s
, (UINTN
)n
, (UINT8
)c
);
43 strerror_r(int errnum
, char *buf
, size_t buflen
)
49 if( (errnum
< 0) || (errnum
>= EMAXERRORVAL
)) {
50 (void) AsciiSPrint( buf
, ASCII_STRING_MAX
, "Unknown Error: %d.", errnum
);
54 estring
= sys_errlist
[errnum
];
55 for( i
= buflen
; i
> 0; --i
) {
56 if( (*buf
++ = *estring
++) == '\0') {
67 /** The strerror function maps the number in errnum to a message string.
68 Typically, the values for errnum come from errno, but strerror shall map
69 any value of type int to a message.
71 The implementation shall behave as if no library function calls the
74 @return The strerror function returns a pointer to the string, the
75 contents of which are locale specific. The array pointed to
76 shall not be modified by the program, but may be overwritten by
77 a subsequent call to the strerror function.
82 static char errorbuf
[ASCII_STRING_MAX
];
85 status
= strerror_r(errnum
, errorbuf
, sizeof(errorbuf
));
92 /** The strlen function computes the length of the string pointed to by s.
94 @return The strlen function returns the number of characters that
95 precede the terminating null character.
100 return (size_t)AsciiStrLen( s
);