]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/Include/stdlib.h
Add device abstraction code for the UEFI Console and UEFI Shell-based file systems.
[mirror_edk2.git] / StdLib / Include / stdlib.h
index 2b19fd224b0b8db92bfa11d4bd744a26574aaaaa..2cfc9fe1ff2731bd977cd4771eadb53b78021d47 100644 (file)
@@ -2,7 +2,7 @@
   The header <stdlib.h> declares five types and several functions of general\r
   utility, and defines several macros.\r
 \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available under\r
   the terms and conditions of the BSD License that accompanies this distribution.\r
   The full text of the license may be found at\r
@@ -133,10 +133,14 @@ void    exit(int status) __noreturn;
     buffered data are not flushed, open streams are not closed, and temporary\r
     files are not removed by abort.\r
 \r
+    While this function does not return, it can NOT be marked as "__noreturn"\r
+    without causing a warning to be emitted because the compilers can not\r
+    determine that the function truly does not return.\r
+\r
     The status returned to the host environment is determined in the same way\r
     as for the exit function.\r
 **/\r
-void    _Exit(int status) __noreturn;\r
+void    _Exit(int status);\r
 \r
 /** The getenv function searches an environment list, provided by the host\r
     environment, for a string that matches the string pointed to by name.  The\r
@@ -151,6 +155,24 @@ void    _Exit(int status) __noreturn;
 **/\r
 char   *getenv(const char *name);\r
 \r
+/**\r
+  Add or update a variable in the environment list\r
+\r
+  @param name     Address of a zero terminated name string\r
+  @param value    Address of a zero terminated value string\r
+  @param rewrite  TRUE allows overwriting existing values\r
+\r
+  @retval Returns 0 upon success\r
+  @retval Returns -1 upon failure, sets errno with more information\r
+\r
+**/\r
+int\r
+setenv (\r
+  register const char * name,\r
+  register const char * value,\r
+  int rewrite\r
+  );\r
+\r
 /** If string is a null pointer, the system function determines whether the\r
     host environment has a command processor. If string is not a null pointer,\r
     the system function passes the string pointed to by string to that command\r
@@ -499,37 +521,125 @@ void qsort( void *base, size_t nmemb, size_t size,
 \r
 /* ################  Multibyte/wide character conversion functions  ####### */\r
 \r
-/**\r
+/** Determine the number of bytes comprising a multibyte character.\r
 \r
-  @return\r
+  If s is not a null pointer, the mblen function determines the number of bytes\r
+  contained in the multibyte character pointed to by s. Except that the\r
+  conversion state of the mbtowc function is not affected, it is equivalent to\r
+    mbtowc((wchar_t *)0, s, n);\r
+\r
+  The implementation shall behave as if no library function calls the mblen\r
+  function.\r
+\r
+  @return   If s is a null pointer, the mblen function returns a nonzero or\r
+            zero value, if multibyte character encodings, respectively, do\r
+            or do not have state-dependent encodings. If s is not a null\r
+            pointer, the mblen function either returns 0 (if s points to the\r
+            null character), or returns the number of bytes that are contained\r
+            in the multibyte character (if the next n or fewer bytes form a\r
+            valid multibyte character), or returns -1 (if they do not form a\r
+            valid multibyte character).\r
 **/\r
 int     mblen(const char *, size_t);\r
 \r
-/**\r
+/** Convert a multibyte character into a wide character.\r
 \r
-  @return\r
+    If s is not a null pointer, the mbtowc function inspects at most n bytes\r
+    beginning with the byte pointed to by s to determine the number of bytes\r
+    needed to complete the next multibyte character (including any shift\r
+    sequences). If the function determines that the next multibyte character\r
+    is complete and valid, it determines the value of the corresponding wide\r
+    character and then, if pwc is not a null pointer, stores that value in\r
+    the object pointed to by pwc. If the corresponding wide character is the\r
+    null wide character, the function is left in the initial conversion state.\r
+\r
+    The implementation shall behave as if no library function calls the\r
+    mbtowc function.\r
+\r
+    @return   If s is a null pointer, the mbtowc function returns a nonzero or\r
+              zero value, if multibyte character encodings, respectively, do\r
+              or do not have state-dependent encodings. If s is not a null\r
+              pointer, the mbtowc function either returns 0 (if s points to\r
+              the null character), or returns the number of bytes that are\r
+              contained in the converted multibyte character (if the next n or\r
+              fewer bytes form a valid multibyte character), or returns -1\r
+              (if they do not form a valid multibyte character).\r
+\r
+              In no case will the value returned be greater than n or the value\r
+              of the MB_CUR_MAX macro.\r
 **/\r
 int     mbtowc(wchar_t * __restrict, const char * __restrict, size_t);\r
 \r
 /**\r
+The wctomb function determines the number of bytes needed to represent the multibyte\r
+character corresponding to the wide character given by wc (including any shift\r
+sequences), and stores the multibyte character representation in the array whose first\r
+element is pointed to by s (if s is not a null pointer). At most MB_CUR_MAX characters\r
+are stored. If wc is a null wide character, a null byte is stored, preceded by any shift\r
+sequence needed to restore the initial shift state, and the function is left in the initial\r
+conversion state.\r
+\r
+The implementation shall behave as if no library function calls the wctomb function.\r
 \r
   @return\r
+If s is a null pointer, the wctomb function returns a nonzero or zero value, if multibyte\r
+character encodings, respectively, do or do not have state-dependent encodings. If s is\r
+not a null pointer, the wctomb function returns -1 if the value of wc does not correspond\r
+to a valid multibyte character, or returns the number of bytes that are contained in the\r
+multibyte character corresponding to the value of wc.\r
+\r
+In no case will the value returned be greater than the value of the MB_CUR_MAX macro.\r
+\r
 **/\r
 int     wctomb(char *, wchar_t);\r
 \r
 /* ################  Multibyte/wide string conversion functions  ########## */\r
 \r
-/**\r
+/** Convert a multibyte character string into a wide-character string.\r
+\r
+    The mbstowcs function converts a sequence of multibyte characters that\r
+    begins in the initial shift state from the array pointed to by src into\r
+    a sequence of corresponding wide characters and stores not more than limit\r
+    wide characters into the array pointed to by dest.  No multibyte\r
+    characters that follow a null character (which is converted into a null\r
+    wide character) will be examined or converted. Each multibyte character\r
+    is converted as if by a call to the mbtowc function, except that the\r
+    conversion state of the mbtowc function is not affected.\r
+\r
+    No more than limit elements will be modified in the array pointed to by dest.\r
+    If copying takes place between objects that overlap,\r
+    the behavior is undefined.\r
+\r
+  @return   If an invalid multibyte character is encountered, the mbstowcs\r
+            function returns (size_t)(-1). Otherwise, the mbstowcs function\r
+            returns the number of array elements modified, not including a\r
+            terminating null wide character, if any.\r
 \r
-  @return\r
 **/\r
-size_t  mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);\r
+size_t  mbstowcs(wchar_t * __restrict dest, const char * __restrict src, size_t limit);\r
 \r
-/**\r
+/** Convert a wide-character string into a multibyte character string.\r
 \r
-  @return\r
+    The wcstombs function converts a sequence of wide characters from the\r
+    array pointed to by src into a sequence of corresponding multibyte\r
+    characters that begins in the initial shift state, and stores these\r
+    multibyte characters into the array pointed to by dest, stopping if a\r
+    multibyte character would exceed the limit of limit total bytes or if a\r
+    null character is stored. Each wide character is converted as if by\r
+    a call to the wctomb function, except that the conversion state of\r
+    the wctomb function is not affected.\r
+\r
+    No more than limit bytes will be modified in the array pointed to by dest.\r
+    If copying takes place between objects that overlap,\r
+    the behavior is undefined.\r
+\r
+  @return   If a wide character is encountered that does not correspond to a\r
+            valid multibyte character, the wcstombs function returns\r
+            (size_t)(-1). Otherwise, the wcstombs function returns the number\r
+            of bytes modified, not including a terminating null character,\r
+            if any.\r
 **/\r
-size_t  wcstombs(char * __restrict, const wchar_t * __restrict, size_t);\r
+size_t  wcstombs(char * __restrict dest, const wchar_t * __restrict src, size_t limit);\r
 \r
 __END_DECLS\r
 \r