Update or add comments to files and functions for use by Doxygen.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12153 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
darylm503 2011-08-17 22:54:56 +00:00
parent 4ae5165ce6
commit 61403bd7ce
7 changed files with 2440 additions and 566 deletions

View File

@ -715,8 +715,7 @@ int setvbuf (FILE * __restrict fp, char * __restrict Buff, int BufMode, si
@param[in] stream An open File specifier to which the output is sent.
@param[in] format A multi-byte character sequence containing characters
to be copied unchanged, and conversion specifiers
which convert their associated arguments. Copied and
converted characters are sent to the output stream.
which convert their associated arguments.
@param ... Variable number of parameters as required by format.
@return The fprintf function returns the number of characters

View File

@ -2,21 +2,120 @@
The header <stdlib.h> declares five types and several functions of general
utility, and defines several macros.
The files stddef.h and stdlib.h are "catch all" headers for definitions and declarations
that don't fit well in the other headers. There are two separate header files because
the contents of <stddef.h> are valid in both freestanding and hosted environment, while the
header <stdlib.h> contains elements that are only valid in a hosted environment.
The following macros are defined in this file:<BR>
@verbatim
EXIT_FAILURE An expression indicating application failure, used as an argument to exit().
EXIT_SUCCESS An expression indicating application success, used as an argument to exit().
RAND_MAX The maximum value returned by the rand function.
MB_CUR_MAX Maximum number of bytes in a multibyte character for the current locale.
ATEXIT_MAX Maximum number of routines that may be registered by the atexit function.
@endverbatim
The following types are defined in this file:<BR>
@verbatim
size_t Unsigned integer type of the result of the sizeof operator.
wchar_t The type of a wide character.
div_t Type of the value returned by the div function.
ldiv_t Type of the value returned by the ldiv function.
lldiv_t Type of the value returned by the lldiv function.
@endverbatim
The following functions are declared in this file:<BR>
@verbatim
################ Communication with the environment
void abort (void) __noreturn;
int atexit (void (*)(void));
void exit (int status) __noreturn;
void _Exit (int status) __noreturn;
char *getenv (const char *name);
int setenv (register const char * name,
register const char * value, int rewrite);
int system (const char *string);
################ Integer arithmetic functions
int abs (int j);
long labs (long j);
long long llabs (long long j);
div_t div (int numer, int denom);
ldiv_t ldiv (long numer, long denom);
lldiv_t lldiv (long long numer, long long denom);
################ Pseudo-random sequence generation functions
int rand (void);
void srand (unsigned seed);
################ Memory management functions
void *calloc (size_t Num, size_t Size);
void free (void *);
void *malloc (size_t);
void *realloc (void *Ptr, size_t NewSize);
################ Searching and Sorting utilities
void *bsearch (const void *key, const void *base0,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
void qsort (void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
################ Multibyte/wide character conversion functions
int mblen (const char *, size_t);
int mbtowc (wchar_t * __restrict, const char * __restrict, size_t);
int wctomb (char *, wchar_t);
################ Multibyte/wide string conversion functions
size_t mbstowcs (wchar_t * __restrict dest,
const char * __restrict src, size_t limit);
size_t wcstombs (char * __restrict dest,
const wchar_t * __restrict src, size_t limit);
################ Miscelaneous functions for *nix compatibility
char *realpath (char *file_name, char *resolved_name);
const char *getprogname (void);
void setprogname (const char *progname);
############ Integer Numeric conversion functions
int atoi (const char *nptr);
long atol (const char *nptr);
long long atoll (const char *nptr);
long strtol (const char * __restrict nptr,
char ** __restrict endptr, int base);
unsigned long strtoul (const char * __restrict nptr,
char ** __restrict endptr, int base);
long long strtoll (const char * __restrict nptr,
char ** __restrict endptr, int base);
unsigned long long strtoull (const char * __restrict nptr,
char ** __restrict endptr, int base);
######### Floating-point Numeric conversion functions
double atof (const char *);
double strtod (const char * __restrict nptr,
char ** __restrict endptr);
float strtof (const char * __restrict nptr,
char ** __restrict endptr);
long double strtold (const char * __restrict nptr,
char ** __restrict endptr);
@endverbatim
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _STDLIB_H
#define _STDLIB_H
#include <sys/EfiCdefs.h>
#ifdef _EFI_SIZE_T_
/** Unsigned integer type of the result of the sizeof operator. **/
typedef _EFI_SIZE_T_ size_t;
#undef _EFI_SIZE_T_
#undef _BSD_SIZE_T_
@ -24,6 +123,7 @@
#ifndef __cplusplus
#ifdef _EFI_WCHAR_T
/** Type of a wide (Unicode) character. **/
typedef _EFI_WCHAR_T wchar_t;
#undef _EFI_WCHAR_T
#undef _BSD_WCHAR_T_
@ -32,8 +132,8 @@
/// A structure type that is the type of the value returned by the div function.
typedef struct {
int quot; /* quotient */
int rem; /* remainder */
int quot; /**< quotient */
int rem; /**< remainder */
} div_t;
/// A structure type that is the type of the value returned by the ldiv function.
@ -48,17 +148,17 @@ typedef struct {
long long rem;
} lldiv_t;
/** Expand to integer constant expressions that can be used as the argument to
/** @{
Expand to integer constant expressions that can be used as the argument to
the exit function to return unsuccessful or successful termination status,
respectively, to the host environment.
**/
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
/*@}*/
/** Expands to an integer constant expression that is the maximum value
returned by the rand function.
The value of the RAND_MAX macro shall be at least 32767.
**/
#define RAND_MAX 0x7fffffff
@ -98,10 +198,13 @@ void abort(void) __noreturn;
The implementation supports the registration of up to 32 functions.
@param[in] Handler Pointer to the function to register as one of the
routines to call at application exit time.
@return The atexit function returns zero if the registration succeeds,
nonzero if it fails.
**/
int atexit(void (*)(void));
int atexit(void (*Handler)(void));
/** The exit function causes normal program termination to occur. If more than
one call to the exit function is executed by a program,
@ -118,14 +221,13 @@ int atexit(void (*)(void));
streams are closed, and all files created by the tmpfile function
are removed.
Finally, control is returned to the host environment. If the value of
status is zero, or EXIT_SUCCESS, status is returned unchanged. If the value
of status is EXIT_FAILURE, EAPPLICATION is returned.
Otherwise, status is returned unchanged.
Finally, control is returned to the host environment.
While this function does not return, it can NOT be marked as "__noreturn"
without causing a warning to be emitted because the compilers can not
determine that the function truly does not return.
@param[in] status A value to be returned when the application exits.
@return If the value of status is zero, or EXIT_SUCCESS, status is
returned unchanged. If the value of status is EXIT_FAILURE,
RETURN_ABORTED is returned. Otherwise, status is returned unchanged.
**/
void exit(int status) __noreturn;
@ -137,12 +239,14 @@ void exit(int status) __noreturn;
buffered data are not flushed, open streams are not closed, and temporary
files are not removed by abort.
While this function does not return, it can NOT be marked as "__noreturn"
without causing a warning to be emitted because the compilers can not
determine that the function truly does not return.
The status returned to the host environment is determined in the same way
as for the exit function.
@param[in] status A value to be returned when the application exits.
@return If the value of status is zero, or EXIT_SUCCESS, status is
returned unchanged. If the value of status is EXIT_FAILURE,
RETURN_ABORTED is returned. Otherwise, status is returned unchanged.
**/
void _Exit(int status) __noreturn;
@ -151,6 +255,8 @@ void _Exit(int status) __noreturn;
set of environment names and the method for altering the environment list
are determined by the underlying UEFI Shell implementation.
@param[in] name Pointer to a string naming the environment variable to retrieve.
@return The getenv function returns a pointer to a string associated with
the matched list member. The string pointed to shall not be
modified by the program, but may be overwritten by a subsequent
@ -159,16 +265,14 @@ void _Exit(int status) __noreturn;
**/
char *getenv(const char *name);
/**
Add or update a variable in the environment list
/** Add or update a variable in the environment list.
@param name Address of a zero terminated name string
@param value Address of a zero terminated value string
@param rewrite TRUE allows overwriting existing values
@retval Returns 0 upon success
@retval Returns -1 upon failure, sets errno with more information
@param[in] name Address of a zero terminated name string.
@param[in] value Address of a zero terminated value string.
@param[in] rewrite TRUE allows overwriting existing values.
@retval 0 Returns 0 upon success.
@retval -1 Returns -1 upon failure, sets errno with more information.
**/
int
setenv (
@ -184,6 +288,8 @@ setenv (
document; this might then cause the program calling system to behave in a
non-conforming manner or to terminate.
@param[in] string Pointer to the command string to be executed.
@return If the argument is a null pointer, the system function returns
nonzero only if a command processor is available. If the argument
is not a null pointer, and the system function does return, it
@ -196,17 +302,23 @@ int system(const char *string);
/** Computes the absolute value of an integer j.
@param[in] j The value to find the absolute value of.
@return The absolute value of j.
**/
int abs(int j);
/** Computes the absolute value of an integer j.
/** Computes the absolute value of a long integer j.
@param[in] j The value to find the absolute value of.
@return The absolute value of j.
**/
long labs(long j);
/** Computes the absolute value of an integer j.
/** Computes the absolute value of a long long integer j.
@param[in] j The value to find the absolute value of.
@return The absolute value of j.
**/
@ -215,6 +327,9 @@ long long
/** Computes numer / denom and numer % denom in a single operation.
@param[in] numer The numerator for the division.
@param[in] denom The denominator for the division.
@return Returns a structure of type div_t, comprising both the
quotient and the remainder.
**/
@ -222,6 +337,9 @@ div_t div(int numer, int denom);
/** Computes numer / denom and numer % denom in a single operation.
@param[in] numer The numerator for the division.
@param[in] denom The denominator for the division.
@return Returns a structure of type ldiv_t, comprising both the
quotient and the remainder.
**/
@ -229,6 +347,9 @@ ldiv_t ldiv(long numer, long denom);
/** Computes numer / denom and numer % denom in a single operation.
@param[in] numer The numerator for the division.
@param[in] denom The denominator for the division.
@return Returns a structure of type lldiv_t, comprising both the
quotient and the remainder.
**/
@ -241,7 +362,9 @@ lldiv_t lldiv(long long numer, long long denom);
equivalent to:
- atoi: (int)strtol(nptr, (char **)NULL, 10)
@return The atoi function returns the converted value.
@param[in] nptr Pointer to the string to be converted.
@return The atoi function returns the converted value.
**/
int atoi(const char *nptr);
@ -250,7 +373,9 @@ int atoi(const char *nptr);
equivalent to:
- atol: strtol(nptr, (char **)NULL, 10)
@return The atol function returns the converted value.
@param[in] nptr Pointer to the string to be converted.
@return The atol function returns the converted value.
**/
long atol(const char *nptr);
@ -259,7 +384,9 @@ long atol(const char *nptr);
is equivalent to:
- atoll: strtoll(nptr, (char **)NULL, 10)
@return The atoll function returns the converted value.
@param[in] nptr Pointer to the string to be converted.
@return The atoll function returns the converted value.
**/
long long
atoll(const char *nptr);
@ -276,7 +403,7 @@ long long
integer, and return the result.
If the value of base is zero, the expected form of the subject sequence is
that of an integer constant as described in 6.4.4.1, optionally preceded
that of an integer constant, optionally preceded
by a plus or minus sign, but not including an integer suffix. If the value
of base is between 2 and 36 (inclusive), the expected form of the subject
sequence is a sequence of letters and digits representing an integer with
@ -310,13 +437,17 @@ long long
conversion is performed; the value of nptr is stored in the object pointed
to by endptr, provided that endptr is not a null pointer.
@return The strtol, strtoll, strtoul, and strtoull functions return the
converted value, if any. If no conversion could be performed, zero
is returned. If the correct value is outside the range of
representable values, LONG_MIN, LONG_MAX, LLONG_MIN, LLONG_MAX,
ULONG_MAX, or ULLONG_MAX is returned (according to the return type
and sign of the value, if any), and the value of the macro ERANGE
is stored in errno.
@param[in] nptr Pointer to the string to be converted.
@param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
@param[in] base The base, 0 to 36, of the number represented by the input string.
@return The strtol, strtoll, strtoul, and strtoull functions return the
converted value, if any. If no conversion could be performed, zero
is returned. If the correct value is outside the range of
representable values, LONG_MIN, LONG_MAX, LLONG_MIN, LLONG_MAX,
ULONG_MAX, or ULLONG_MAX is returned (according to the return type
and sign of the value, if any), and the value of the macro ERANGE
is stored in errno.
**/
long strtol(const char * __restrict nptr, char ** __restrict endptr, int base);
@ -325,10 +456,14 @@ long strtol(const char * __restrict nptr, char ** __restrict endptr, int base
See the description for strtol for more information.
@return The strtoul function returns the converted value, if any. If no
conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, ULONG_MAX is
returned and the value of the macro ERANGE is stored in errno.
@param[in] nptr Pointer to the string to be converted.
@param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
@param[in] base The base, 0 to 36, of the number represented by the input string.
@return The strtoul function returns the converted value, if any. If no
conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, ULONG_MAX is
returned and the value of the macro ERANGE is stored in errno.
**/
unsigned long
strtoul(const char * __restrict nptr, char ** __restrict endptr, int base);
@ -338,11 +473,15 @@ unsigned long
See the description for strtol for more information.
@return The strtoll function returns the converted value, if any. If no
conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, LLONG_MIN or
LLONG_MAX is returned (according to the sign of the value, if any),
and the value of the macro ERANGE is stored in errno.
@param[in] nptr Pointer to the string to be converted.
@param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
@param[in] base The base, 0 to 36, of the number represented by the input string.
@return The strtoll function returns the converted value, if any. If no
conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, LLONG_MIN or
LLONG_MAX is returned (according to the sign of the value, if any),
and the value of the macro ERANGE is stored in errno.
**/
long long
strtoll(const char * __restrict nptr, char ** __restrict endptr, int base);
@ -352,40 +491,83 @@ long long
See the description for strtol for more information.
@return The strtoull function returns the converted value, if any. If no
conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, ULLONG_MAX is
returned and the value of the macro ERANGE is stored in errno.
@param[in] nptr Pointer to the string to be converted.
@param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
@param[in] base The base, 0 to 36, of the number represented by the input string.
@return The strtoull function returns the converted value, if any. If no
conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, ULLONG_MAX is
returned and the value of the macro ERANGE is stored in errno.
**/
unsigned long long
strtoull(const char * __restrict nptr, char ** __restrict endptr, int base);
/* ######### Floating-point Numeric conversion functions ################ */
/**
/** Convert the initial part of a string to double representation.
@return
@param[in] nptr Pointer to the string to be converted.
@return The floating-point value representing the string nptr.
**/
double atof(const char *);
double atof(const char *nptr);
/**
/** @{
The strtod, strtof, and strtold functions convert the initial portion of
the string pointed to by nptr to double, float, and long double
representation, respectively. First, they decompose the input string into
three parts: an initial, possibly empty, sequence of white-space characters
(as specified by the isspace function), a subject sequence resembling a
floating-point constant or representing an infinity or NaN; and a final
string of one or more unrecognized characters, including the terminating
null character of the input string. Then, they attempt to convert the
subject sequence to a floating-point number, and return the result.
*/
@return
/** Convert a string to a double and point to the character after the last converted.
@param[in] nptr Pointer to the string to be converted.
@param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
@return A floating-point value representing the string nptr.
A pointer to the final string is stored in the object pointed to
by endptr, provided that endptr is not a null pointer.
If the subject sequence is empty or does not have the expected
form, no conversion is performed; the value of nptr is stored in
the object pointed to by endptr, provided that endptr is not a null pointer.
**/
double strtod(const char * __restrict nptr, char ** __restrict endptr);
/**
/** Convert a string to a float and point to the character after the last converted.
@return
@param[in] nptr Pointer to the string to be converted.
@param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
@return A floating-point value representing the string nptr.
A pointer to the final string is stored in the object pointed to
by endptr, provided that endptr is not a null pointer.
If the subject sequence is empty or does not have the expected
form, no conversion is performed; the value of nptr is stored in
the object pointed to by endptr, provided that endptr is not a null pointer.
**/
float strtof(const char * __restrict nptr, char ** __restrict endptr);
/**
/** Convert a string to a long double and point to the character after the last converted.
@return
@param[in] nptr Pointer to the string to be converted.
@param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
@return A floating-point value representing the string nptr.
A pointer to the final string is stored in the object pointed to
by endptr, provided that endptr is not a null pointer.
If the subject sequence is empty or does not have the expected
form, no conversion is performed; the value of nptr is stored in
the object pointed to by endptr, provided that endptr is not a null pointer.
**/
long double
strtold(const char * __restrict nptr, char ** __restrict endptr);
/*@}*/
/* ################ Pseudo-random sequence generation functions ######### */
@ -403,6 +585,8 @@ int rand(void);
pseudo-random numbers shall be repeated. If rand is called before any calls
to srand have been made, the same sequence shall be generated as when srand
is first called with a seed value of 1.
@param[in] seed The value used to "seed" the random number generator with.
**/
void srand(unsigned seed);
@ -411,6 +595,9 @@ void srand(unsigned seed);
/** The calloc function allocates space for an array of Num objects, each of
whose size is Size. The space is initialized to all bits zero.
@param[in] Num The number of objects to allocate space for.
@param[in] Size The size, in bytes, of each object.
@return NULL is returned if the space could not be allocated and errno
contains the cause. Otherwise, a pointer to an 8-byte aligned
region of the requested size is returned.
@ -426,9 +613,8 @@ void *calloc(size_t Num, size_t Size);
realloc, the behavior is undefined.
@param Ptr Pointer to a previously allocated region of memory to be freed.
**/
void free(void *);
void free(void *Ptr);
/** The malloc function allocates space for an object whose size is specified
by size and whose value is indeterminate.
@ -437,7 +623,7 @@ void free(void *);
region of memory that is 8-byte aligned and of the specified size. The
region is allocated with type EfiLoaderData.
@param size Size, in bytes, of the region to allocate.
@param Size Size, in bytes, of the region to allocate.
@return NULL is returned if the space could not be allocated and errno
contains the cause. Otherwise, a pointer to an 8-byte aligned
@ -446,7 +632,7 @@ void free(void *);
- EINVAL: Requested Size is zero.
- ENOMEM: Memory could not be allocated.
**/
void *malloc(size_t);
void *malloc(size_t Size);
/** The realloc function changes the size of the object pointed to by Ptr to
the size specified by NewSize.
@ -483,35 +669,40 @@ void *realloc(void *Ptr, size_t NewSize);
/* ################ Searching and Sorting utilities ##################### */
/** The bsearch function searches an array of nmemb objects, the initial
element of which is pointed to by base, for an element that matches the
object pointed to by key. The size of each element of the array is
specified by size.
/** The bsearch function searches an array of Nmemb objects, the initial
element of which is pointed to by Base, for an element that matches the
object pointed to by Key. The size of each element of the array is
specified by Size.
The comparison function pointed to by compar is called with two arguments
that point to the key object and to an array element, in that order. The
The comparison function pointed to by Compar is called with two arguments
that point to the Key object and to an array element, in that order. The
function returns an integer less than, equal to, or greater than zero if
the key object is considered, respectively, to be less than, to match, or
the Key object is considered, respectively, to be less than, to match, or
to be greater than the array element. The array consists of: all the
elements that compare less than, all the elements that compare equal to,
and all the elements that compare greater than the key object,
in that order.
@return The bsearch function returns a pointer to a matching element of the
array, or a null pointer if no match is found. If two elements
compare as equal, which element is matched is unspecified.
**/
void *
bsearch( const void *key, const void *base0,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *)
);
@param[in] Key Pointer to the object to search for.
@param[in] Base Pointer to the first element of an array to search.
@param[in] Nmemb Number of objects in the search array.
@param[in] Size The size of each object in the search array.
@param[in] Compar Pointer to the function used to compare two objects.
/** The qsort function sorts an array of nmemb objects, the initial element of
which is pointed to by base. The size of each object is specified by size.
@return The bsearch function returns a pointer to a matching element of the
array, or a null pointer if no match is found. If two elements
compare as equal, which element is matched is unspecified.
**/
void *bsearch( const void *Key, const void *Base,
size_t Nmemb, size_t Size,
int (*Compar)(const void *, const void *)
);
/** The qsort function sorts an array of Nmemb objects, the initial element of
which is pointed to by Base. The size of each object is specified by Size.
The contents of the array are sorted into ascending order according to a
comparison function pointed to by compar, which is called with two
comparison function pointed to by Compar, which is called with two
arguments that point to the objects being compared. The function shall
return an integer less than, equal to, or greater than zero if the first
argument is considered to be respectively less than, equal to, or greater
@ -519,165 +710,183 @@ bsearch( const void *key, const void *base0,
If two elements compare as equal, their order in the resulting sorted array
is unspecified.
@param[in,out] Base Pointer to the first element of an array to sort.
@param[in] Nmemb Number of objects in the array.
@param[in] Size The size of each object in the array.
@param[in] Compar Pointer to the function used to compare two objects.
**/
void qsort( void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
void qsort( void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
/* ################ Multibyte/wide character conversion functions ####### */
/** Determine the number of bytes comprising a multibyte character.
If s is not a null pointer, the mblen function determines the number of bytes
contained in the multibyte character pointed to by s. Except that the
If S is not a null pointer, the mblen function determines the number of bytes
contained in the multibyte character pointed to by S. Except that the
conversion state of the mbtowc function is not affected, it is equivalent to
mbtowc((wchar_t *)0, s, n);
mbtowc((wchar_t *)0, S, N);
The implementation shall behave as if no library function calls the mblen
function.
@param[in] S NULL to query whether multibyte characters have
state-dependent encodings. Otherwise, points to a
multibyte character.
@param[in] N The maximum number of bytes in a multibyte character.
@return If s is a null pointer, the mblen function returns a nonzero or
@return If S is a null pointer, the mblen function returns a nonzero or
zero value, if multibyte character encodings, respectively, do
or do not have state-dependent encodings. If s is not a null
pointer, the mblen function either returns 0 (if s points to the
or do not have state-dependent encodings. If S is not a null
pointer, the mblen function either returns 0 (if S points to the
null character), or returns the number of bytes that are contained
in the multibyte character (if the next n or fewer bytes form a
in the multibyte character (if the next N or fewer bytes form a
valid multibyte character), or returns -1 (if they do not form a
valid multibyte character).
**/
int mblen(const char *, size_t);
int mblen(const char *S, size_t N);
/** Convert a multibyte character into a wide character.
If s is not a null pointer, the mbtowc function inspects at most n bytes
beginning with the byte pointed to by s to determine the number of bytes
If S is not a null pointer, the mbtowc function inspects at most N bytes
beginning with the byte pointed to by S to determine the number of bytes
needed to complete the next multibyte character (including any shift
sequences). If the function determines that the next multibyte character
is complete and valid, it determines the value of the corresponding wide
character and then, if pwc is not a null pointer, stores that value in
the object pointed to by pwc. If the corresponding wide character is the
character and then, if Pwc is not a null pointer, stores that value in
the object pointed to by Pwc. If the corresponding wide character is the
null wide character, the function is left in the initial conversion state.
The implementation shall behave as if no library function calls the
mbtowc function.
@param[out] Pwc Pointer to a wide-character object to receive the converted character.
@param[in] S Pointer to a multibyte character to convert.
@param[in] N Maximum number of bytes in a multibyte character.
@return If s is a null pointer, the mbtowc function returns a nonzero or
@return If S is a null pointer, the mbtowc function returns a nonzero or
zero value, if multibyte character encodings, respectively, do
or do not have state-dependent encodings. If s is not a null
pointer, the mbtowc function either returns 0 (if s points to
or do not have state-dependent encodings. If S is not a null
pointer, the mbtowc function either returns 0 (if S points to
the null character), or returns the number of bytes that are
contained in the converted multibyte character (if the next n or
contained in the converted multibyte character (if the next N or
fewer bytes form a valid multibyte character), or returns -1
(if they do not form a valid multibyte character).
In no case will the value returned be greater than n or the value
In no case will the value returned be greater than N or the value
of the MB_CUR_MAX macro.
**/
int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
int mbtowc(wchar_t * __restrict Pwc, const char * __restrict S, size_t N);
/**
The wctomb function determines the number of bytes needed to represent the multibyte
character corresponding to the wide character given by wc (including any shift
sequences), and stores the multibyte character representation in the array whose first
element is pointed to by s (if s is not a null pointer). At most MB_CUR_MAX characters
are stored. If wc is a null wide character, a null byte is stored, preceded by any shift
sequence needed to restore the initial shift state, and the function is left in the initial
conversion state.
/** Convert a wide character into a multibyte character.
The implementation shall behave as if no library function calls the wctomb function.
The wctomb function determines the number of bytes needed to represent the
multibyte character corresponding to the wide character given by WC
(including any shift sequences), and stores the multibyte character
representation in the array whose first element is pointed to by S (if S is
not a null pointer). At most MB_CUR_MAX characters are stored. If WC is a
null wide character, a null byte is stored, preceded by any shift sequence
needed to restore the initial shift state, and the function is left in the
initial conversion state.
@return
If s is a null pointer, the wctomb function returns a nonzero or zero value, if multibyte
character encodings, respectively, do or do not have state-dependent encodings. If s is
not a null pointer, the wctomb function returns -1 if the value of wc does not correspond
to a valid multibyte character, or returns the number of bytes that are contained in the
multibyte character corresponding to the value of wc.
@param[out] S Pointer to the object to receive the converted multibyte character.
@param[in] WC Wide character to be converted.
In no case will the value returned be greater than the value of the MB_CUR_MAX macro.
@return If S is a null pointer, the wctomb function returns a nonzero or
zero value, if multibyte character encodings, respectively, do or
do not have state-dependent encodings. If S is not a null pointer,
the wctomb function returns -1 if the value of WC does not
correspond to a valid multibyte character, or returns the number
of bytes that are contained in the multibyte character
corresponding to the value of WC.
In no case will the value returned be greater than the value of
the MB_CUR_MAX macro.
**/
int wctomb(char *, wchar_t);
int wctomb(char *S, wchar_t WC);
/* ################ Multibyte/wide string conversion functions ########## */
/** Convert a multibyte character string into a wide-character string.
The mbstowcs function converts a sequence of multibyte characters that
begins in the initial shift state from the array pointed to by src into
begins in the initial shift state from the array pointed to by Src into
a sequence of corresponding wide characters and stores not more than limit
wide characters into the array pointed to by dest. No multibyte
wide characters into the array pointed to by Dest. No multibyte
characters that follow a null character (which is converted into a null
wide character) will be examined or converted. Each multibyte character
is converted as if by a call to the mbtowc function, except that the
conversion state of the mbtowc function is not affected.
No more than limit elements will be modified in the array pointed to by dest.
No more than Limit elements will be modified in the array pointed to by Dest.
If copying takes place between objects that overlap,
the behavior is undefined.
@return If an invalid multibyte character is encountered, the mbstowcs
function returns (size_t)(-1). Otherwise, the mbstowcs function
returns the number of array elements modified, not including a
terminating null wide character, if any.
@param[out] Dest Pointer to the array to receive the converted string.
@param[in] Src Pointer to the string to be converted.
@param[in] Limit Maximum number of elements to be written to Dest.
@return If an invalid multibyte character is encountered, the mbstowcs
function returns (size_t)(-1). Otherwise, the mbstowcs function
returns the number of array elements modified, not including a
terminating null wide character, if any.
**/
size_t mbstowcs(wchar_t * __restrict dest, const char * __restrict src, size_t limit);
size_t mbstowcs(wchar_t * __restrict Dest, const char * __restrict Src, size_t Limit);
/** Convert a wide-character string into a multibyte character string.
The wcstombs function converts a sequence of wide characters from the
array pointed to by src into a sequence of corresponding multibyte
array pointed to by Src into a sequence of corresponding multibyte
characters that begins in the initial shift state, and stores these
multibyte characters into the array pointed to by dest, stopping if a
multibyte character would exceed the limit of limit total bytes or if a
multibyte characters into the array pointed to by Dest, stopping if a
multibyte character would exceed the limit of Limit total bytes or if a
null character is stored. Each wide character is converted as if by
a call to the wctomb function, except that the conversion state of
the wctomb function is not affected.
No more than limit bytes will be modified in the array pointed to by dest.
No more than Limit bytes will be modified in the array pointed to by Dest.
If copying takes place between objects that overlap,
the behavior is undefined.
@return If a wide character is encountered that does not correspond to a
valid multibyte character, the wcstombs function returns
(size_t)(-1). Otherwise, the wcstombs function returns the number
of bytes modified, not including a terminating null character,
if any.
@param[out] Dest Pointer to the array to receive the converted string.
@param[in] Src Pointer to the string to be converted.
@param[in] Limit Maximum number of elements to be written to Dest.
@return If a wide character is encountered that does not correspond to a
valid multibyte character, the wcstombs function returns
(size_t)(-1). Otherwise, the wcstombs function returns the number
of bytes modified, not including a terminating null character,
if any.
**/
size_t wcstombs(char * __restrict dest, const wchar_t * __restrict src, size_t limit);
size_t wcstombs(char * __restrict Dest, const wchar_t * __restrict Src, size_t Limit);
/**
The realpath() function shall derive, from the pathname pointed to by
file_name, an absolute pathname that names the same file, whose resolution
does not involve '.', '..', or symbolic links. The generated pathname shall
be stored as a null-terminated string, up to a maximum of {PATH_MAX} bytes,
in the buffer pointed to by resolved_name.
/* ################ Miscelaneous functions for *nix compatibility ########## */
If resolved_name is a null pointer, the behavior of realpath() is
implementation-defined.
/** The realpath() function shall derive, from the pathname pointed to by
file_name, an absolute pathname that names the same file, whose resolution
does not involve '.', '..', or symbolic links. The generated pathname shall
be stored as a null-terminated string, up to a maximum of {PATH_MAX} bytes,
in the buffer pointed to by resolved_name.
@param[in] file_name The filename to convert.
@param[in,out] resolved_name The resultant name.
If resolved_name is a null pointer, the behavior of realpath() is
implementation-defined.
@retval NULL An error occured.
@return resolved_name.
@param[in] file_name The filename to convert.
@param[in,out] resolved_name The resultant name.
@retval NULL An error occured.
@retval resolved_name.
**/
char * realpath(char *file_name, char *resolved_name);
/**
The getprogname() function returns the name of the program. If the name
has not been set yet, it will return NULL.
/** The getprogname() function returns the name of the program. If the name
has not been set yet, it will return NULL.
@retval The name of the program.
@retval NULL The name has not been set.
@return The getprogname function returns NULL if the program's name has not
been set, otherwise it returns the name of the program.
**/
const char * getprogname(void);
/**
The setprogname() function sets the name of the program.
/** The setprogname() function sets the name of the program.
@param[in] The name of the program. This memory must be retained
by the caller until no calls to "getprogname" will be
called.
@param[in] progname The name of the program. This memory must be retained
by the caller until no calls to "getprogname" will be
called.
**/
void setprogname(const char *progname);

View File

@ -1,29 +1,87 @@
/** @file
The header <string.h> declares one type and several functions, and defines
one macro useful for manipulating arrays of character type and other objects
treated as arrays of character type. Various methods are used for
determining the lengths of the arrays, but in all cases a char * or void *
argument points to the initial (lowest addressed) character of the array. If
an array is accessed beyond the end of an object, the behavior is undefined.
The header <string.h> declares one type and several functions, and defines
one macro useful for manipulating arrays of character type and other objects
treated as arrays of character type. Various methods are used for
determining the lengths of the arrays, but in all cases a char * or void *
argument points to the initial (lowest addressed) character of the array. If
an array is accessed beyond the end of an object, the behavior is undefined.
Where an argument declared as size_t n specifies the length of the array for
a function, n can have the value zero on a call to that function. Unless
explicitly stated otherwise in the description of those functions, pointer
arguments on such a call shall still have valid values.
Where an argument declared as size_t n specifies the length of the array for
a function, n can have the value zero on a call to that function. Unless
explicitly stated otherwise in the description of those functions, pointer
arguments on such a call must still have valid values.
For all functions declared in this header, each character shall be
interpreted as if it had the type unsigned char (and therefore every possible
object representation is valid and has a different value).
For all functions declared in this header, each character shall be
interpreted as if it had the type unsigned char (and therefore every possible
object representation is valid and has a different value).
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
The following macros are defined in this file:<BR>
@verbatim
NULL
bcopy(a,b,c) ( memcpy((void *)b, (const void *)a, (size_t)c))
bcmp(a,b,c) ( memcmp((void *)a, (void *)b, (size_t)c))
@endverbatim
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
The following types are defined in this file:<BR>
@verbatim
size_t Unsigned integer type of the result of the sizeof operator.
@endverbatim
The following functions are declared in this file:<BR>
@verbatim
################ Copying Functions
void *memcpy (void * __restrict s1, const void * __restrict s2, size_t n);
void *memmove (void *s1, const void *s2, size_t n);
char *strcpy (char * __restrict s1, const char * __restrict s2);
char *strncpy (char * __restrict s1, const char * __restrict s2, size_t n);
int strncpyX (char * __restrict s1, const char * __restrict s2, size_t n);
################ Concatenation Functions
char *strcat (char * __restrict s1, const char * __restrict s2);
char *strncat (char * __restrict s1, const char * __restrict s2, size_t n);
int strncatX (char * __restrict s1, const char * __restrict s2, size_t n);
################ Comparison Functions
int memcmp (const void *s1, const void *s2, size_t n);
int strcmp (const char *s1, const char *s2);
int strcoll (const char *s1, const char *s2);
int strncmp (const char *s1, const char *s2, size_t n);
size_t strxfrm (char * __restrict s1, const char * __restrict s2, size_t n);
################ Search Functions
void *memchr (const void *s, int c, size_t n);
char *strchr (const char *s, int c);
size_t strcspn (const char *s1, const char *s2);
char *strpbrk (const char *s1, const char *s2);
char *strrchr (const char *s, int c);
size_t strspn (const char *s1 , const char *s2);
char *strstr (const char *s1 , const char *s2);
char *strtok (char * __restrict s1, const char * __restrict s2);
################ Miscellaneous Functions
void *memset (void *s, int c, size_t n);
char *strerror (int num);
size_t strlen (const char *);
################ BSD Compatibility Functions
char *strdup (const char *);
int strerror_r (int, char *, size_t);
int strcasecmp (const char *s1, const char *s2);
void *memccpy (void *, const void *, int, size_t);
int strncasecmp (const char *s1, const char *s2, size_t n);
size_t strlcpy (char *destination, const char *source, size_t size);
size_t strlcat (char *destination, const char *source, size_t size);
char *strsep (register char **stringp, register const char *delim);
@endverbatim
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _STRING_H
#define _STRING_H
@ -39,239 +97,311 @@ __BEGIN_DECLS
/* ################ Copying Functions ################################# */
/** The memcpy function copies n characters from the object pointed to by s2
into the object pointed to by s1. If copying takes place between objects
/** The memcpy function copies N characters from the object pointed to by Src
into the object pointed to by Dest. If copying takes place between objects
that overlap, the behavior is undefined.
@return The memcpy function returns the value of s1.
@param[out] Dest Pointer to the destination of the copy operation.
@param[in] Src Pointer to the Source data to be copied.
@param[in] N Number of characters (bytes) to be copied.
@return The memcpy function returns the value of Dest.
**/
void *memcpy(void * __restrict s1, const void * __restrict s2, size_t n);
void *memcpy(void * __restrict Dest, const void * __restrict Src, size_t N);
/** The memmove function copies n characters from the object pointed to by s2
into the object pointed to by s1. Copying takes place as if the n
characters from the object pointed to by s2 are first copied into a
temporary array of n characters that does not overlap the objects pointed
to by s1 and s2, and then the n characters from the temporary array are
copied into the object pointed to by s1.
/** The memmove function copies N characters from the object pointed to by Src
into the object pointed to by Dest. Copying takes place as if the N
characters from the object pointed to by Src are first copied into a
temporary array of N characters that does not overlap the objects pointed
to by Dest and Src, and then the N characters from the temporary array are
copied into the object pointed to by Dest.
@return The memmove function returns the value of s1.
@param[out] Dest Pointer to the destination of the copy operation.
@param[in] Src Pointer to the Source data to be copied.
@param[in] N Number of characters (bytes) to be copied.
@return The memmove function returns the value of Dest.
**/
void *memmove(void *s1, const void *s2, size_t n);
void *memmove(void *Dest, const void *Src, size_t N);
/** The strcpy function copies the string pointed to by s2 (including the
terminating null character) into the array pointed to by s1. If copying
/** The strcpy function copies the string pointed to by Src (including the
terminating null character) into the array pointed to by Dest. If copying
takes place between objects that overlap, the behavior is undefined.
@return The strcpy function returns the value of s1.
**/
char *strcpy(char * __restrict s1, const char * __restrict s2);
@param[out] Dest Pointer to the destination of the copy operation.
@param[in] Src Pointer to the Source data to be copied.
/** The strncpy function copies not more than n characters (characters that
follow a null character are not copied) from the array pointed to by s2 to
the array pointed to by s1. If copying takes place between objects that
@return The strcpy function returns the value of Dest.
**/
char *strcpy(char * __restrict Dest, const char * __restrict Src);
/** The strncpy function copies not more than N characters (characters that
follow a null character are not copied) from the array pointed to by Src to
the array pointed to by Dest. If copying takes place between objects that
overlap, the behavior is undefined.
If the array pointed to by s2 is a string that is shorter than n
If the array pointed to by Src is a string that is shorter than N
characters, null characters are appended to the copy in the array pointed
to by s1, until n characters in all have been written.
to by Dest, until N characters in all have been written.
@return The strncpy function returns the value of s1.
@param[out] Dest Pointer to the destination of the copy operation.
@param[in] Src Pointer to the Source data to be copied.
@param[in] N Number of characters (bytes) to be copied.
@return The strncpy function returns the value of Dest.
**/
char *strncpy(char * __restrict s1, const char * __restrict s2, size_t n);
char *strncpy(char * __restrict Dest, const char * __restrict Src, size_t N);
/** The strncpyX function copies not more than n-1 characters (characters that
follow a null character are not copied) from the array pointed to by s2 to
the array pointed to by s1. Array s1 is guaranteed to be NULL terminated.
/** The strncpyX function copies not more than N-1 characters (characters that
follow a null character are not copied) from the array pointed to by Src to
the array pointed to by Dest. Array Dest is guaranteed to be NULL terminated.
If copying takes place between objects that overlap,
the behavior is undefined.
strncpyX exists because normal strncpy does not indicate if the copy was
terminated because of exhausting the buffer or reaching the end of s2.
terminated because of exhausting the buffer or reaching the end of Src.
@param[out] Dest Pointer to the destination of the copy operation.
@param[in] Src Pointer to the Source data to be copied.
@param[in] N Number of characters (bytes) to be copied.
@return The strncpyX function returns 0 if the copy operation was
terminated because it reached the end of s1. Otherwise,
terminated because it reached the end of Dest. Otherwise,
a non-zero value is returned indicating how many characters
remain in s1.
remain in Dest.
**/
int strncpyX(char * __restrict s1, const char * __restrict s2, size_t n);
int strncpyX(char * __restrict Dest, const char * __restrict Src, size_t N);
/* ################ Concatenation Functions ########################### */
/** The strcat function appends a copy of the string pointed to by s2
/** The strcat function appends a copy of the string pointed to by Src
(including the terminating null character) to the end of the string pointed
to by s1. The initial character of s2 overwrites the null character at the
end of s1. If copying takes place between objects that overlap, the
to by Dest. The initial character of Src overwrites the null character at the
end of Dest. If copying takes place between objects that overlap, the
behavior is undefined.
@return The strcat function returns the value of s1.
**/
char *strcat(char * __restrict s1, const char * __restrict s2);
@param[out] Dest Pointer to the destination of the concatenation operation.
@param[in] Src Pointer to the Source data to be concatenated.
/** The strncat function appends not more than n characters (a null character
@return The strcat function returns the value of Dest.
**/
char *strcat(char * __restrict Dest, const char * __restrict Src);
/** The strncat function appends not more than N characters (a null character
and characters that follow it are not appended) from the array pointed to
by s2 to the end of the string pointed to by s1. The initial character of
s2 overwrites the null character at the end of s1. A terminating null
by Src to the end of the string pointed to by Dest. The initial character of
Src overwrites the null character at the end of Dest. A terminating null
character is always appended to the result. If copying takes place
between objects that overlap, the behavior is undefined.
@return The strncat function returns the value of s1.
**/
char *strncat(char * __restrict s1, const char * __restrict s2, size_t n);
@param[out] Dest Pointer to the destination of the concatenation operation.
@param[in] Src Pointer to the Source data to be concatenated.
@param[in] N Max Number of characters (bytes) to be concatenated.
/** The strncatX function appends not more than n characters (a null character
@return The strncat function returns the value of Dest.
**/
char *strncat(char * __restrict Dest, const char * __restrict Src, size_t N);
/** The strncatX function appends not more than N characters (a null character
and characters that follow it are not appended) from the array pointed to
by s2 to the end of the string pointed to by s1. The initial character of
s2 overwrites the null character at the end of s1. The result is always
by Src to the end of the string pointed to by Dest. The initial character of
Src overwrites the null character at the end of Dest. The result is always
terminated with a null character. If copying takes place between objects
that overlap, the behavior is undefined.
strncatX exists because normal strncat does not indicate if the operation
was terminated because of exhausting n or reaching the end of s2.
was terminated because of exhausting N or reaching the end of Src.
@param[out] Dest Pointer to the destination of the concatenation operation.
@param[in] Src Pointer to the Source data to be concatenated.
@param[in] N Max Number of characters (bytes) to be concatenated.
@return The strncatX function returns 0 if the operation was terminated
because it reached the end of s1. Otherwise, a non-zero value is
returned indicating how many characters remain in s1.
because it reached the end of Dest. Otherwise, a non-zero value is
returned indicating how many characters remain in Dest.
**/
int strncatX(char * __restrict s1, const char * __restrict s2, size_t n);
/* ################ Comparison Functions ############################## */
/** The memcmp function compares the first n characters of the object pointed
to by s1 to the first n characters of the object pointed to by s2.
/** The memcmp function compares the first N characters of the object pointed
to by S1 to the first N characters of the object pointed to by S2.
@param[out] S1 Pointer to the first object to be compared.
@param[in] S2 Pointer to the object to be compared to S1.
@param[in] N Max Number of characters (bytes) to be compared.
@return The memcmp function returns an integer greater than, equal to, or
less than zero, accordingly as the object pointed to by s1 is
greater than, equal to, or less than the object pointed to by s2.
less than zero, accordingly as the object pointed to by S1 is
greater than, equal to, or less than the object pointed to by S2.
**/
int memcmp(const void *s1, const void *s2, size_t n);
int memcmp(const void *S1, const void *S2, size_t N);
/** The strcmp function compares the string pointed to by s1 to the string
pointed to by s2.
/** The strcmp function compares the string pointed to by S1 to the string
pointed to by S2.
@param[out] S1 Pointer to the first string to be compared.
@param[in] S2 Pointer to the string to be compared to S1.
@return The strcmp function returns an integer greater than, equal to, or
less than zero, accordingly as the string pointed to by s1 is
greater than, equal to, or less than the string pointed to by s2.
less than zero, accordingly as the string pointed to by S1 is
greater than, equal to, or less than the string pointed to by S2.
**/
int strcmp(const char *s1, const char *s2);
int strcmp(const char *S1, const char *S2);
/** The strcoll function compares the string pointed to by s1 to the string
pointed to by s2, both interpreted as appropriate to the LC_COLLATE
/** The strcoll function compares the string pointed to by S1 to the string
pointed to by S2, both interpreted as appropriate to the LC_COLLATE
category of the current locale.
@param[out] S1 Pointer to the first string to be compared.
@param[in] S2 Pointer to the string to be compared to S1.
@return The strcoll function returns an integer greater than, equal to,
or less than zero, accordingly as the string pointed to by s1 is
greater than, equal to, or less than the string pointed to by s2
or less than zero, accordingly as the string pointed to by S1 is
greater than, equal to, or less than the string pointed to by S2
when both are interpreted as appropriate to the current locale.
**/
int strcoll(const char *s1, const char *s2);
int strcoll(const char *S1, const char *S2);
/** The strncmp function compares not more than n characters (characters that
follow a null character are not compared) from the array pointed to by s1
to the array pointed to by s2.
/** The strncmp function compares not more than N characters (characters that
follow a null character are not compared) from the array pointed to by S1
to the array pointed to by S2.
@param[out] S1 Pointer to the first object to be compared.
@param[in] S2 Pointer to the object to be compared to S1.
@param[in] N Max Number of characters (bytes) to be compared.
@return The strncmp function returns an integer greater than, equal to,
or less than zero, accordingly as the possibly null-terminated
array pointed to by s1 is greater than, equal to, or less than
the possibly null-terminated array pointed to by s2.
array pointed to by S1 is greater than, equal to, or less than
the possibly null-terminated array pointed to by S2.
**/
int strncmp(const char *s1, const char *s2, size_t n);
int strncmp(const char *S1, const char *S2, size_t N);
/** The strxfrm function transforms the string pointed to by s2 and places the
resulting string into the array pointed to by s1. The transformation is
/** The strxfrm function transforms the string pointed to by Src and places the
resulting string into the array pointed to by Dest. The transformation is
such that if the strcmp function is applied to two transformed strings, it
returns a value greater than, equal to, or less than zero, corresponding to
the result of the strcoll function applied to the same two original
strings. No more than n characters are placed into the resulting array
pointed to by s1, including the terminating null character. If n is zero,
s1 is permitted to be a null pointer. If copying takes place between
strings. No more than N characters are placed into the resulting array
pointed to by Dest, including the terminating null character. If N is zero,
Dest is permitted to be a null pointer. If copying takes place between
objects that overlap, the behavior is undefined.
@param[out] Dest Pointer to the object to receive the transformed string.
@param[in] Src Pointer to the string to be transformed.
@param[in] N Max Number of characters (bytes) to be transformed.
@return The strxfrm function returns the length of the transformed string
(not including the terminating null character). If the value
returned is n or more, the contents of the array pointed to by s1
returned is N or more, the contents of the array pointed to by Dest
are indeterminate.
**/
size_t strxfrm(char * __restrict s1, const char * __restrict s2, size_t n);
size_t strxfrm(char * __restrict Dest, const char * __restrict Src, size_t N);
/* ################ Search Functions ################################## */
/** The memchr function locates the first occurrence of c (converted to an
unsigned char) in the initial n characters (each interpreted as
unsigned char) of the object pointed to by s.
/** The memchr function locates the first occurrence of C (converted to an
unsigned char) in the initial N characters (each interpreted as
unsigned char) of the object pointed to by S.
@param[in] S Pointer to the object to be searched.
@param[in] C The character value to search for.
@param[in] N Max Number of characters (bytes) to be searched.
@return The memchr function returns a pointer to the located character,
or a null pointer if the character does not occur in the object.
**/
void *memchr(const void *s, int c, size_t n);
void *memchr(const void *S, int C, size_t N);
/** The strchr function locates the first occurrence of c (converted to a char)
in the string pointed to by s. The terminating null character is considered
/** The strchr function locates the first occurrence of C (converted to a char)
in the string pointed to by S. The terminating null character is considered
to be part of the string.
@param[in] S Pointer to the object to be searched.
@param[in] C The character value to search for.
@return The strchr function returns a pointer to the located character,
or a null pointer if the character does not occur in the string.
**/
char *strchr(const char *s, int c);
char *strchr(const char *S, int C);
/** The strcspn function computes the length of the maximum initial segment of
the string pointed to by s1 which consists entirely of characters NOT from
the string pointed to by s2.
the string pointed to by S1 which consists entirely of characters NOT from
the string pointed to by S2.
@param[in] S1 Pointer to the object to be searched.
@param[in] S2 Pointer to the list of characters to search for.
@return The strcspn function returns the length of the segment.
**/
size_t strcspn(const char *s1, const char *s2);
size_t strcspn(const char *S1, const char *S2);
/** The strpbrk function locates the first occurrence in the string pointed to
by s1 of any character from the string pointed to by s2.
by S1 of any character from the string pointed to by S2.
@param[in] S1 Pointer to the object to be searched.
@param[in] S2 Pointer to the list of characters to search for.
@return The strpbrk function returns a pointer to the character, or a
null pointer if no character from s2 occurs in s1.
null pointer if no character from S2 occurs in S1.
**/
char *strpbrk(const char *s1, const char *s2);
char *strpbrk(const char *S1, const char *S2);
/** The strrchr function locates the last occurrence of c (converted to a char)
in the string pointed to by s. The terminating null character is considered
/** The strrchr function locates the last occurrence of C (converted to a char)
in the string pointed to by S. The terminating null character is considered
to be part of the string.
@param[in] S Pointer to the object to be searched.
@param[in] C The character value to search for.
@return The strrchr function returns a pointer to the character, or a
null pointer if c does not occur in the string.
null pointer if C does not occur in the string.
**/
char *strrchr(const char *s, int c);
char *strrchr(const char *S, int C);
/** The strspn function computes the length of the maximum initial segment of
the string pointed to by s1 which consists entirely of characters from the
string pointed to by s2.
the string pointed to by S1 which consists entirely of characters from the
string pointed to by S2.
@param[in] S1 Pointer to the object to be searched.
@param[in] S2 Pointer to the list of characters to search for.
@return The strspn function returns the length of the segment.
**/
size_t strspn(const char *s1 , const char *s2);
size_t strspn(const char *S1 , const char *S2);
/** The strstr function locates the first occurrence in the string pointed to
by s1 of the sequence of characters (excluding the terminating null
character) in the string pointed to by s2.
by S1 of the sequence of characters (excluding the terminating null
character) in the string pointed to by S2.
@param[in] S1 Pointer to the object to be searched.
@param[in] S2 Pointer to the sequence of characters to search for.
@return The strstr function returns a pointer to the located string, or a
null pointer if the string is not found. If s2 points to a string
with zero length, the function returns s1.
null pointer if the string is not found. If S2 points to a string
with zero length, the function returns S1.
**/
char *strstr(const char *s1 , const char *s2);
char *strstr(const char *S1 , const char *S2);
/** A sequence of calls to the strtok function breaks the string pointed to by
s1 into a sequence of tokens, each of which is delimited by a character
from the string pointed to by s2. The first call in the sequence has a
/** Break a string into a sequence of tokens.
A sequence of calls to the strtok function breaks the string pointed to by
S1 into a sequence of tokens, each of which is delimited by a character
from the string pointed to by S2. The first call in the sequence has a
non-null first argument; subsequent calls in the sequence have a null first
argument. The separator string pointed to by s2 may be different from call
argument. The separator string pointed to by S2 may be different from call
to call.
The first call in the sequence searches the string pointed to by s1 for the
The first call in the sequence searches the string pointed to by S1 for the
first character that is not contained in the current separator string
pointed to by s2. If no such character is found, then there are no tokens
in the string pointed to by s1 and the strtok function returns a null
pointed to by S2. If no such character is found, then there are no tokens
in the string pointed to by S1 and the strtok function returns a null
pointer. If such a character is found, it is the start of the first token.
The strtok function then searches from there for a character that is
contained in the current separator string. If no such character is found,
the current token extends to the end of the string pointed to by s1, and
the current token extends to the end of the string pointed to by S1, and
subsequent searches for a token will return a null pointer. If such a
character is found, it is overwritten by a null character, which terminates
the current token. The strtok function saves a pointer to the following
@ -281,40 +411,48 @@ char *strstr(const char *s1 , const char *s2);
argument, starts searching from the saved pointer and behaves as
described above.
@param[in] S1 Pointer to the string to be tokenized.
@param[in] S2 Pointer to a list of separator characters.
@return The strtok function returns a pointer to the first character of a
token, or a null pointer if there is no token.
**/
char *strtok(char * __restrict s1, const char * __restrict s2);
char *strtok(char * __restrict S1, const char * __restrict S2);
/* ################ Miscellaneous Functions ########################### */
/** The memset function copies the value of c (converted to an unsigned char)
into each of the first n characters of the object pointed to by s.
/** The memset function copies the value of C (converted to an unsigned char)
into each of the first N characters of the object pointed to by S.
@return The memset function returns the value of s.
@param[out] S Pointer to the first element of the object to be set.
@param[in] C Value to store in each element of S.
@param[in] N Number of elements in S to be set.
@return The memset function returns the value of S.
**/
void *memset(void *s, int c, size_t n);
void *memset(void *S, int C, size_t N);
/** The strerror function maps the number in errnum to a message string.
Typically, the values for errnum come from errno, but strerror shall map
/** The strerror function maps the number in Num to a message string.
Typically, the values for Num come from errno, but strerror shall map
any value of type int to a message.
The implementation shall behave as if no library function calls the
strerror function.
@param[in] Num A value to be converted to a message.
@return The strerror function returns a pointer to the string, the
contents of which are locale specific. The array pointed to
shall not be modified by the program, but may be overwritten by
must not be modified by the program, but may be overwritten by
a subsequent call to the strerror function.
**/
char *strerror(int num);
char *strerror(int Num);
/** The strlen function computes the length of the string pointed to by s.
/** The strlen function computes the length of the string pointed to by S.
@param[in] S Pointer to the string to determine the length of.
@return The strlen function returns the number of characters that
precede the terminating null character.
**/
size_t strlen(const char *);
size_t strlen(const char *S);
/* ################ BSD Compatibility Functions ####################### */

View File

@ -1,17 +1,74 @@
/** @file
Function declarations for UEFI "system calls".
Concept derived from NetBSD's unistd.h file.
The following macros are defined in this file:<BR>
@verbatim
STDIN_FILENO 0 standard input file descriptor
STDOUT_FILENO 1 standard output file descriptor
STDERR_FILENO 2 standard error file descriptor
F_OK 0 test for existence of file
X_OK 0x01 test for execute or search permission
W_OK 0x02 test for write permission
R_OK 0x04 test for read permission
SEEK_SET 0 set file offset to offset
SEEK_CUR 1 set file offset to current plus offset
SEEK_END 2 set file offset to EOF plus offset
VALID_OPEN 1
VALID_CLOSED 0
VALID_DONT_CARE -1
@endverbatim
The following types are defined in this file:<BR>
@verbatim
struct stat; Structure declared in <sys/stat.h>
@endverbatim
The following functions are declared in this file:<BR>
@verbatim
############### System Calls used in stdio.
int close (int fd);
ssize_t read (int fd, void *buf, size_t n);
ssize_t write (int fd, const void *buf, size_t n);
int unlink (const char *name);
int dup2 (int, int);
int rmdir (const char *);
int isatty (int);
############### System Calls which are also declared in sys/fcntl.h.
int open (const char *name, int oflags, int mode);
int creat (const char *, mode_t);
int fcntl (int, int, ...);
############### System Calls which are also declared in stat.h.
int mkdir (const char *, mode_t);
int fstat (int, struct stat *);
int lstat (const char *, struct stat *);
int stat (const char *, void *);
int chmod (const char *, mode_t);
############### System Calls which are also declared in sys/types.h.
off_t lseek (int, off_t, int);
int truncate (const char *, off_t);
int ftruncate (int, off_t); // IEEE Std 1003.1b-93
############### EFI-specific Functions.
int DeleteOnClose (int fd); Mark an open file to be deleted when closed.
int FindFreeFD (int MinFd);
BOOLEAN ValidateFD (int fd, int IsOpen);
############### Functions added for compatibility.
char *getcwd (char *, size_t);
int chdir (const char *);
@endverbatim
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _EFI_SYS_CALL_H
#define _EFI_SYS_CALL_H
@ -21,27 +78,27 @@
struct stat; /* Structure declared in <sys/stat.h> */
#define STDIN_FILENO 0 /* standard input file descriptor */
#define STDOUT_FILENO 1 /* standard output file descriptor */
#define STDERR_FILENO 2 /* standard error file descriptor */
#define STDIN_FILENO 0 /**< standard input file descriptor */
#define STDOUT_FILENO 1 /**< standard output file descriptor */
#define STDERR_FILENO 2 /**< standard error file descriptor */
/* access function */
#define F_OK 0 /* test for existence of file */
#define X_OK 0x01 /* test for execute or search permission */
#define W_OK 0x02 /* test for write permission */
#define R_OK 0x04 /* test for read permission */
#define F_OK 0 /**< test for existence of file */
#define X_OK 0x01 /**< test for execute or search permission */
#define W_OK 0x02 /**< test for write permission */
#define R_OK 0x04 /**< test for read permission */
/* whence values for lseek(2)
Always ensure that these are consistent with <stdio.h> and <unistd.h>!
*/
#ifndef SEEK_SET
#define SEEK_SET 0 /* set file offset to offset */
#define SEEK_SET 0 /**< set file offset to offset */
#endif
#ifndef SEEK_CUR
#define SEEK_CUR 1 /* set file offset to current plus offset */
#define SEEK_CUR 1 /**< set file offset to current plus offset */
#endif
#ifndef SEEK_END
#define SEEK_END 2 /* set file offset to EOF plus offset */
#define SEEK_END 2 /**< set file offset to EOF plus offset */
#endif
// Parameters for the ValidateFD function.
@ -50,44 +107,234 @@ struct stat; /* Structure declared in <sys/stat.h> */
#define VALID_DONT_CARE -1
__BEGIN_DECLS
/* EFI versions of BSD system calls used in stdio */
int close (int fd);
ssize_t read (int fd, void *buf, size_t n);
ssize_t write (int fd, const void *buf, size_t n);
int unlink (const char *name);
int dup2 (int, int);
int rmdir (const char *);
int isatty (int);
/** Close a file or device.
@param[in] fd File Descriptor for the file or device to close.
@retval 0 Successful completion.
@retval -1 An error occurred, identified by errno.
- EBADF fd is not a valid File Descriptor.
- EINTR The function was interrupted by a signal.
- EIO An I/O error occurred.
**/
int close (int fd);
/** Read from a file or device.
@param[in] fd File Descriptor for the file or device to read.
@param[in] buf Buffer to read data into.
@param[in] N Maximum number of bytes to read.
@return On successful completion, read returns a non-negative integer
indicating the number of bytes actually read. Otherwise, it
returns -1 and sets errno as follows:
- EAGAIN
- EWOULDBLOCK
- EBADF
- EBADMSG
- EINTR
- EINVAL
- EIO
- EISDIR
- EOVERFLOW
- ECONNRESET
- ENOTCONN
- ETIMEDOUT
- ENOBUFS
- ENOMEM
- ENXIO
**/
ssize_t read (int fd, void *buf, size_t n);
/** Write to a file or device.
@param[in] fd File Descriptor for the file or device to write.
@param[in] buf Buffer to write data from.
@param[in] N Maximum number of bytes to write.
@return On successful completion, write returns a non-negative integer
indicating the number of bytes actually written. Otherwise, it
returns -1 and sets errno as follows:
- EAGAIN
- EWOULDBLOCK
- EBADF
- EFBIG
- EINTR
- EINVAL
- EIO
- ENOSPC
- EPIPE
- ERANGE
- ECONNRESET
- ENOBUFS
- ENXIO
- ENETDOWN
- ENETUNREACH
**/
ssize_t write (int fd, const void *buf, size_t n);
/** Unlink (delete) a file.
@param[in] name The name of the file to be deleted.
@retval 0 Successful completion.
@retval -1 Unable to perform operation, errno contains further
information. The file name is unchanged.
**/
int unlink (const char *name);
/** Make file descriptor Fd2 a duplicate of file descriptor Fd1.
@param[in] Fd1 File descriptor to be duplicated
@param[in] Fd2 File descriptor to become a duplicate of Fd1.
@retval 0 Successful completion.
@retval -1 Unable to perform operation, errno contains further
information.
**/
int dup2 (int Fd1, int Fd2);
/** Remove a directory.
@param[in] Path Path to the directory to be deleted.
@retval 0 Successful completion.
@retval -1 Unable to perform operation, errno contains further
information. The named directory remains unchanged.
**/
int rmdir (const char *Path);
/** Determine if fd refers to an interactive terminal device.
@param[in] fd The file descriptor to be tested.
@retval 0 The file descriptor, fd, is not for a terminal. errno is set
indicating the cause for failure.
- EBADF fd is not a valid open file descriptor.
- ENOTTY fd does not refer to a terminal.
@retval 1 The file descriptor, fd, is for a terminal.
**/
int isatty (int fd);
/* These system calls are also declared in sys/fcntl.h */
#ifndef __FCNTL_SYSCALLS_DECLARED
#define __FCNTL_SYSCALLS_DECLARED
/** Open or create a file named by name.
The file name may be one of:
- An absolute path beginning with '/'.
- A relative path beginning with "." or ".." or a directory name
- A file name
- A mapped path which begins with a name followed by a colon, ':'.
Mapped paths are use to refer to specific mass storage volumes or devices.
In a Shell-hosted environment, the map command will list valid map names
for both file system and block devices. Mapped paths can also refer to
devices such as the UEFI console. Supported UEFI console mapped paths are:
- stdin: Standard Input (from the System Table)
- stdout: Standard Output (from the System Table)
- stderr: Standard Error Output (from the System Table)
@param[in] name
@param[in] oflags
@param[in] mode
@return
**/
int open (const char *name, int oflags, int mode);
/**
@param[in]
@return
**/
int creat (const char *, mode_t);
/**
@param[in]
@return
**/
int fcntl (int, int, ...);
#endif // __FCNTL_SYSCALLS_DECLARED
/* These system calls are also declared in stat.h */
#ifndef __STAT_SYSCALLS_DECLARED
#define __STAT_SYSCALLS_DECLARED
/**
@param[in]
@return
**/
int mkdir (const char *, mode_t);
/**
@param[in]
@return
**/
int fstat (int, struct stat *);
/**
@param[in]
@return
**/
int lstat (const char *, struct stat *);
/**
@param[in]
@return
**/
int stat (const char *, void *);
/**
@param[in]
@return
**/
int chmod (const char *, mode_t);
#endif // __STAT_SYSCALLS_DECLARED
// These are also declared in sys/types.h
#ifndef __OFF_T_SYSCALLS_DECLARED
#define __OFF_T_SYSCALLS_DECLARED
/**
@param[in]
@return
**/
off_t lseek (int, off_t, int);
/**
@param[in]
@return
**/
int truncate (const char *, off_t);
/**
@param[in]
@return
**/
int ftruncate (int, off_t); // IEEE Std 1003.1b-93
#endif /* __OFF_T_SYSCALLS_DECLARED */
/* EFI-specific Functions. */
int DeleteOnClose(int fd); /* Mark an open file to be deleted when closed. */
/**
@param[in]
@return
**/
int DeleteOnClose(int fd); /* Mark an open file to be deleted when closed. */
/* Find and reserve a free File Descriptor.
@ -97,7 +344,7 @@ int DeleteOnClose(int fd); /* Mark an open file to be deleted when clos
@return Returns -1 if there are no free FDs. Otherwise returns the
found fd.
*/
int FindFreeFD (int MinFd);
int FindFreeFD (int MinFd);
/* Validate that fd refers to a valid file descriptor.
IsOpen is interpreted as follows:
@ -108,15 +355,26 @@ int FindFreeFD (int MinFd);
@retval TRUE fd is VALID
@retval FALSE fd is INVALID
*/
BOOLEAN ValidateFD (int fd, int IsOpen);
BOOLEAN ValidateFD (int fd, int IsOpen);
char *getcwd (char *, size_t);
int chdir (const char *);
/**
@param[in]
@return
**/
char *getcwd (char *, size_t);
/**
@param[in]
@return
**/
int chdir (const char *);
/* These system calls don't YET have EFI implementations. */
int access (const char *path, int amode);
int reboot (int, char *);
int access (const char *path, int amode);
int reboot (int, char *);
__END_DECLS
#endif /* _EFI_SYS_CALL_H */

View File

@ -33,6 +33,40 @@
if Daylight Saving Time is not in effect, and negative if the information
is not available.
The following macros are defined in this file:<BR>
@verbatim
NULL
CLOCKS_PER_SEC The number of values per second returned by the clock function.
@endverbatim
The following types are defined in this file:<BR>
@verbatim
size_t Unsigned integer type of the result of the sizeof operator.
clock_t Arithmetic type capable of representing a time from the clock function.
time_t Arithmetic type capable of representing a time.
struct tm Holds the components of a calendar time; or broken-down time.
@endverbatim
The following functions are declared in this file:<BR>
@verbatim
############### Time Manipulation Functions
clock_t clock (void);
double difftime (time_t time1, time_t time0);
time_t mktime (struct tm *timeptr);
time_t time (time_t *timer);
################# Time Conversion Functions
char * asctime (const struct tm *timeptr);
char * ctime (const time_t *timer);
struct tm * gmtime (const time_t *timer);
time_t timegm (struct tm*);
struct tm * localtime (const time_t *timer);
size_t strftime (char * __restrict s, size_t maxsize,
const char * __restrict format,
const struct tm * __restrict timeptr);
char * strptime (const char *, const char * format, struct tm*);
@endverbatim
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
@ -41,7 +75,6 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _TIME_H
#define _TIME_H
@ -55,26 +88,25 @@
#undef _BSD_SIZE_T_
#endif
/** An arithmetic type capable of representing values returned by clock(); **/
#ifdef _EFI_CLOCK_T
/** An arithmetic type capable of representing values returned by clock(); **/
typedef _EFI_CLOCK_T clock_t;
#undef _EFI_CLOCK_T
#endif
/** An arithmetic type capable of representing values returned as calendar time
values, such as that returned by mktime();
**/
#ifdef _EFI_TIME_T
/** An arithmetic type capable of representing values returned as calendar time
values, such as that returned by mktime();
**/
typedef _EFI_TIME_T time_t;
#undef _EFI_TIME_T
#endif
/** Value added to tm_year to get the full year value. TM_YEAR_BASE + 110 --> 2010
**/
/** Value added to tm_year to get the full year value. TM_YEAR_BASE + 110 --> 2010 **/
#define TM_YEAR_BASE 1900
/** Values for the tm_wday member of struct tm.
@{
/** @{
Values for the tm_wday member of struct tm.
**/
#define TM_SUNDAY 0
#define TM_MONDAY 1
@ -83,10 +115,10 @@
#define TM_THURSDAY 4
#define TM_FRIDAY 5
#define TM_SATURDAY 6
/** @} **/
/*@}*/
/** Values for the tm_mon member of struct tm.
@{
/** @{
Values for the tm_mon member of struct tm.
**/
#define TM_JANUARY 0
#define TM_FEBRUARY 1
@ -100,7 +132,7 @@
#define TM_OCTOBER 9
#define TM_NOVEMBER 10
#define TM_DECEMBER 11
/** @} **/
/*@}*/
/** A structure holding the components of a calendar time, called the
broken-down time. The first nine (9) members are as mandated by the
@ -133,17 +165,21 @@ struct tm {
the macro CLOCKS_PER_SEC. If the processor time used is not
available or its value cannot be represented, the function
returns the value (clock_t)(-1).
On IA32 or X64 platforms, the value returned is the number of
CPU TimeStamp Counter ticks since the appliation started.
**/
clock_t clock(void);
/**
/** Compute the difference between two calendar times: time1 - time0.
@param[in] time1 An arithmetic calendar time.
@param[in] time2 Another arithmetic calendar time.
@return The difference between the two times expressed in seconds.
**/
double difftime(time_t time1, time_t time0);
/** The mktime function converts the broken-down time, expressed as local time,
/** Convert a broken-down time into an arithmetic calendar time.
The mktime function converts the broken-down time, expressed as local time,
in the structure pointed to by timeptr into a calendar time value with the
same encoding as that of the values returned by the time function. The
original values of the tm_wday and tm_yday components of the structure are
@ -155,6 +191,8 @@ double difftime(time_t time1, time_t time0);
the final value of tm_mday is not set until tm_mon and tm_year
are determined.
@param[in] timeptr Pointer to a broken-down time to be converted.
@return The mktime function returns the specified calendar time encoded
as a value of type time_t. If the calendar time cannot be
represented, the function returns the value (time_t)(-1).
@ -163,7 +201,10 @@ time_t mktime(struct tm *timeptr);
/** The time function determines the current calendar time.
The encoding of the value is unspecified.
The encoding of the value is unspecified and undocumented.
@param[out] timer An optional pointer to an object in which to
store the calendar time.
@return The time function returns the implementation's best approximation
of the current calendar time. The value (time_t)(-1) is returned
@ -176,23 +217,33 @@ time_t time(time_t *timer);
/* ################# Time Conversion Functions ########################## */
/** The asctime function converts the broken-down time in the structure pointed
to by timeptr into a string in the form
to by timeptr into a string in the form<BR>
@verbatim
Sun Sep 16 01:03:52 1973\n\0
@endverbatim
@param[in] timeptr A pointer to a broken-down time to convert.
@return The asctime function returns a pointer to the string.
**/
char * asctime(const struct tm *timeptr);
/** The ctime function converts the calendar time pointed to by timer to local
/** The ctime function converts the calendar time pointed to by timer to a local
time in the form of a string. It is equivalent to asctime(localtime(timer))
@param[in] timer Pointer to a calendar time value to convert into a
string representation.
@return The ctime function returns the pointer returned by the asctime
function with that broken-down time as argument.
**/
char * ctime(const time_t *timer);
/** The gmtime function converts the calendar time pointed to by timer into a
brokendown time, expressed as UTC.
broken-down time, expressed as UTC.
@param[in] timer Pointer to a calendar time value to convert into a
broken-down time.
@return The gmtime function returns a pointer to the broken-down time,
or a null pointer if the specified time cannot be converted to UTC.
@ -201,6 +252,9 @@ struct tm * gmtime(const time_t *timer);
/** The timegm function is the opposite of gmtime.
@param[in] tm Pointer to a broken-down time to convert into a
calendar time.
@return The calendar time expressed as UTC.
**/
time_t timegm(struct tm*);
@ -208,6 +262,8 @@ time_t timegm(struct tm*);
/** The localtime function converts the calendar time pointed to by timer into
a broken-down time, expressed as local time.
@param[in] timer Pointer to a calendar time value to be converted.
@return The localtime function returns a pointer to the broken-down time,
or a null pointer if the specified time cannot be converted to
local time.

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,46 @@
/** @file
Wide character classification functions and macros.
Wide character classification and mapping utilities.
The following macros are defined in this file:<BR>
@verbatim
WEOF Wide char version of end-of-file.
@endverbatim
The following types are defined in this file:<BR>
@verbatim
wint_t Type capable of holding all wchar_t values and WEOF.
wctrans_t A type for holding locale-specific character mappings.
wctype_t Type for holding locale-specific character classifications.
@endverbatim
The following functions are declared in this file:<BR>
@verbatim
############### Wide Character Classification Functions
int iswalnum (wint_t);
int iswalpha (wint_t);
int iswcntrl (wint_t);
int iswdigit (wint_t);
int iswgraph (wint_t);
int iswlower (wint_t);
int iswprint (wint_t);
int iswpunct (wint_t);
int iswblank (wint_t);
int iswspace (wint_t);
int iswupper (wint_t);
int iswxdigit (wint_t);
############### Extensible Wide Character Classification Functions
wctype_t wctype (const char *);
int iswctype (wint_t, wctype_t);
############### Wide Character Case Mapping Utilities
wint_t towlower (wint_t);
wint_t towupper (wint_t);
############### Extensible Wide Character Case Mapping Utilities
wctrans_t wctrans (const char *);
wint_t towctrans (wint_t, wctrans_t);
@endverbatim
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
@ -45,44 +86,258 @@
#include <machine/ansi.h>
#ifdef _EFI_WINT_T
/** wint_t is an integer type unchanged by default argument promotions that can
hold any value corresponding to members of the extended character set, as
well as at least one value that does not correspond to any member of the
extended character set: WEOF.
*/
typedef _EFI_WINT_T wint_t;
#undef _BSD_WINT_T_
#undef _EFI_WINT_T
#endif
#ifdef _BSD_WCTRANS_T_
typedef wint_t (*wctrans_t)(wint_t);
#undef _BSD_WCTRANS_T_
/** A scalar type for holding locale-specific character mappings. */
typedef wint_t (*wctrans_t)(wint_t);
#undef _BSD_WCTRANS_T_
#endif
#ifdef _BSD_WCTYPE_T_
typedef _BSD_WCTYPE_T_ wctype_t;
#undef _BSD_WCTYPE_T_
/** A scalar type capable of holding values representing locale-specific
character classifications. */
typedef _BSD_WCTYPE_T_ wctype_t;
#undef _BSD_WCTYPE_T_
#endif
#ifndef WEOF
#define WEOF ((wint_t)-1)
/** WEOF expands to a constant expression of type wint_t whose value does not
correspond to any member of the extended character set. It is accepted
(and returned) by several functions, declared in this file, to indicate
end-of-file, that is, no more input from a stream. It is also used as a
wide character value that does not correspond to any member of the
extended character set.
*/
#define WEOF ((wint_t)-1)
#endif
__BEGIN_DECLS
int /*EFIAPI*/ iswalnum(wint_t);
int /*EFIAPI*/ iswalpha(wint_t);
int /*EFIAPI*/ iswcntrl(wint_t);
int /*EFIAPI*/ iswctype(wint_t, wctype_t);
int /*EFIAPI*/ iswdigit(wint_t);
int /*EFIAPI*/ iswgraph(wint_t);
int /*EFIAPI*/ iswlower(wint_t);
int /*EFIAPI*/ iswprint(wint_t);
int /*EFIAPI*/ iswpunct(wint_t);
int /*EFIAPI*/ iswblank(wint_t);
int /*EFIAPI*/ iswspace(wint_t);
int /*EFIAPI*/ iswupper(wint_t);
int /*EFIAPI*/ iswxdigit(wint_t);
wint_t /*EFIAPI*/ towctrans(wint_t, wctrans_t);
wint_t /*EFIAPI*/ towlower(wint_t);
wint_t /*EFIAPI*/ towupper(wint_t);
wctrans_t /*EFIAPI*/ wctrans(const char *);
wctype_t /*EFIAPI*/ wctype(const char *);
/** Test for any wide character for which iswalpha or iswdigit is TRUE.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswalnum (wint_t WC);
/** Test for any wide character for which iswupper or iswlower is TRUE,
OR, a locale-specific character where none of iswcntrl, iswdigit,
iswpunct, or iswspace is TRUE.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswalpha (wint_t WC);
/** Test for any wide control character.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswcntrl (wint_t WC);
/** Test if the value of WC is a wide character that corresponds to a decimal digit.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswdigit (wint_t WC);
/** Test for wide characters for which iswprint is TRUE and iswspace is FALSE.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswgraph (wint_t WC);
/** The iswlower function tests for any wide character that corresponds to a
lowercase letter or is one of a locale-specific set of wide characters
for which none of iswcntrl, iswdigit, iswpunct, or iswspace is TRUE.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswlower (wint_t WC);
/** Test for any printing wide character.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswprint (wint_t WC);
/** The iswpunct function tests for any printing wide character that is one
of a locale-specific set of punctuation wide characters for which
neither iswspace nor iswalnum is TRUE.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswpunct (wint_t WC);
/** Test for standard blank characters or locale-specific characters
for which iswspace is TRUE and are used to separate words within a line
of text. In the "C" locale, iswblank only returns TRUE for the standard
blank characters space (L' ') and horizontal tab (L'\t').
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswblank (wint_t WC);
/** The iswspace function tests for any wide character that corresponds to a
locale-specific set of white-space wide characters for which none of
iswalnum, iswgraph, or iswpunct is TRUE.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswspace (wint_t WC);
/** Tests for any wide character that corresponds to an uppercase letter or
is one of a locale-specific set of wide characters for which none of
iswcntrl, iswdigit, iswpunct, or iswspace is TRUE.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswupper (wint_t WC);
/** The iswxdigit function tests for any wide character that corresponds to a
hexadecimal-digit character.
@param[in] WC The wide character to be classified.
@return Returns non-zero (TRUE) if and only if the value of WC conforms
to the classification described for this function.
*/
int iswxdigit (wint_t WC);
/** Construct a value that describes a class of wide characters, identified
by the string pointed to by Desc. The constructed value is suitable for
use as the second argument to the iswctype function.
The following strings name classes of wide characters that the iswctype
function is able to test against. These strings are valid in all locales
as Desc arguments to wctype().
- "alnum"
- "alpha"
- "blank"
- "cntrl"
- "digit"
- "graph"
- "lower"
- "print"
- "punct"
- "space"
- "upper"
- "xdigit
@param[in] Desc A pointer to a multibyte character string naming a
class of wide characters.
@return If Desc identifies a valid class of wide characters in the
current locale, the wctype function returns a nonzero value that
is valid as the second argument to the iswctype function;
otherwise, it returns zero.
*/
wctype_t wctype (const char *Desc);
/** Determine whether the wide character WC has the property described by Wct.
@param[in] WC The wide character to be classified.
@param[in] Wct A value describing a class of wide characters.
@return The iswctype function returns nonzero (TRUE) if and only if the
value of the wide character WC has the property described by Wct.
*/
int iswctype (wint_t WC, wctype_t Wct);
/** Convert an uppercase letter to a corresponding lowercase letter.
@param[in] WC The wide character to be converted.
@return If the argument is a wide character for which iswupper is TRUE
and there are one or more corresponding wide characters, as
specified by the current locale, for which iswlower is TRUE, the
towlower function returns one of the corresponding wide
characters (always the same one for any given locale); otherwise,
the argument is returned unchanged.
*/
wint_t towlower (wint_t WC);
/** Convert a lowercase letter to a corresponding uppercase letter.
@param[in] WC The wide character to be converted.
@return If the argument is a wide character for which iswlower is TRUE
and there are one or more corresponding wide characters, as
specified by the current locale, for which iswupper is TRUE, the
towupper function returns one of the corresponding wide
characters (always the same one for any given locale); otherwise,
the argument is returned unchanged.
*/
wint_t towupper (wint_t WC);
/** Construct a value that describes a mapping between wide characters
identified by the string argument, S.
The strings listed below are valid in all locales as the S argument to
the wctrans function.
- "tolower"
- "toupper"
@param[in] S A pointer to a multibyte character string naming a
mapping between wide characters.
@return If S identifies a valid mapping of wide characters in the current
locale, the wctrans function returns a nonzero value that is
valid as the second argument to the towctrans function;
otherwise, it returns zero.
*/
wctrans_t wctrans (const char *S);
/** Map the wide character WC using the mapping described by WTr. The current
locale will be the same as during the call to wctrans that returned
the value WTr.
@param[in] WC The wide character to be converted.
@param[in] WTr A value describing a mapping of wide characters in the
current locale.
@return Returns the mapped value of WC using the mapping selected by WTr.
*/
wint_t towctrans (wint_t WC, wctrans_t WTr);
__END_DECLS
#endif /* _WCTYPE_H_ */