VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/StdLib/LibC/String/Misc.c@ 77599

最後變更 在這個檔案從77599是 48674,由 vboxsync 提交於 11 年 前

EFI: Export newly imported tinaocore UEFI sources to OSE.

  • 屬性 svn:eol-style 設為 native
檔案大小: 2.7 KB
 
1/** @file
2 Miscellaneous Functions for <string.h>.
3
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.
9
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.
12**/
13//#include <sys/EfiCdefs.h>
14
15#include <Uefi.h>
16#include <Library/BaseLib.h>
17#include <Library/BaseMemoryLib.h>
18#include <Library/PcdLib.h>
19#include <Library/PrintLib.h>
20
21#include <LibConfig.h>
22
23#include <errno.h>
24#include <limits.h>
25#include <string.h>
26
27extern char *sys_errlist[];
28
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.
31
32 @return The memset function returns the value of s.
33**/
34void *
35memset(void *s, int c, size_t n)
36{
37 return SetMem( s, (UINTN)n, (UINT8)c);
38}
39
40int
41strerror_r(int errnum, char *buf, size_t buflen)
42{
43 const char *estring;
44 INTN i;
45 int retval = 0;
46
47 if( (errnum < 0) || (errnum >= EMAXERRORVAL)) {
48 (void) AsciiSPrint( buf, ASCII_STRING_MAX, "Unknown Error: %d.", errnum);
49 retval = EINVAL;
50 }
51 else {
52 estring = sys_errlist[errnum];
53 for( i = buflen; i > 0; --i) {
54 if( (*buf++ = *estring++) == '\0') {
55 break;
56 }
57 }
58 if(i == 0) {
59 retval = ERANGE;
60 }
61 }
62 return retval;
63}
64
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.
68
69 The implementation shall behave as if no library function calls the
70 strerror function.
71
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.
76**/
77char *
78strerror(int errnum)
79{
80 static char errorbuf[ASCII_STRING_MAX];
81 int status;
82
83 status = strerror_r(errnum, errorbuf, sizeof(errorbuf));
84 if(status != 0) {
85 errno = status;
86 }
87 return errorbuf;
88}
89
90/** The strlen function computes the length of the string pointed to by s.
91
92 @return The strlen function returns the number of characters that
93 precede the terminating null character.
94**/
95size_t
96strlen(const char *s)
97{
98 return (size_t)AsciiStrLen( s);
99}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette