]>
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 /** The memset function copies the value of c (converted to an unsigned char)
30 into each of the first n characters of the object pointed to by s.
32 @return The memset function returns the value of s.
35 memset(void *s
, int c
, size_t n
)
37 return SetMem( s
, (UINTN
)n
, (UINT8
)c
);
41 strerror_r(int errnum
, char *buf
, size_t buflen
)
47 if( (errnum
< 0) || (errnum
>= EMAXERRORVAL
)) {
48 (void) AsciiSPrint( buf
, ASCII_STRING_MAX
, "Unknown Error: %d.", errnum
);
52 estring
= sys_errlist
[errnum
];
53 for( i
= buflen
; i
> 0; --i
) {
54 if( (*buf
++ = *estring
++) == '\0') {
65 /** The strerror function maps the number in errnum to a message string.
66 Typically, the values for errnum come from errno, but strerror shall map
67 any value of type int to a message.
69 The implementation shall behave as if no library function calls the
72 @return The strerror function returns a pointer to the string, the
73 contents of which are locale specific. The array pointed to
74 shall not be modified by the program, but may be overwritten by
75 a subsequent call to the strerror function.
80 static char errorbuf
[ASCII_STRING_MAX
];
83 status
= strerror_r(errnum
, errorbuf
, sizeof(errorbuf
));
90 /** The strlen function computes the length of the string pointed to by s.
92 @return The strlen function returns the number of characters that
93 precede the terminating null character.
98 return (size_t)AsciiStrLen( s
);