Add Socket Libraries.

Add Posix functions for porting compatibility.
Fix compliance issues with ISO/IEC 9899:199409
New Functions:
  setenv(), fparseln(), GetFileNameFromPath(), rename(),
  realpath(), setprogname(), getprogname(), strlcat(), strlcpy(),
  strsep(), setitimer(), getitimer(), timegm(), getopt(), basename(),
  mkstemp(), ffs(), vsnprintf(), snprintf(), getpass(), usleep(), select(),
  writev(), strcasecmp(), getcwd(), chdir(), tcgetpgrp(), getpgrp(), gettimeofday(),
  bcopy(), 


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12061 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
darylm503
2011-07-30 00:30:44 +00:00
parent f766dd76fd
commit d7ce700605
199 changed files with 36115 additions and 686 deletions

View File

@@ -248,10 +248,16 @@ PathAlias(
/** Parse a path producing the target device, device instance, and file path.
It is the caller's responsibility to free() FullPath and MapPath when they
are no longer needed.
@param[in] path
@param[out] FullPath
@param[out] DevNode
@param[out] Which
@param[out] MapPath OPTIONAL. If not NULL, it points to the place to save a pointer
to the extracted map name. If the path didn't have a map name,
then *MapPath is set to NULL.
@retval RETURN_SUCCESS The path was parsed successfully.
@retval RETURN_NOT_FOUND The path does not map to a valid device.
@@ -266,7 +272,8 @@ ParsePath(
IN const char *path,
OUT wchar_t **FullPath,
OUT DeviceNode **DevNode,
OUT int *Which
OUT int *Which,
OUT wchar_t **MapPath
)
{
int MapLen;
@@ -301,7 +308,7 @@ reclassify:
// Get the Map Name, including the trailing ':'. */
MPath = calloc(MapLen+2, sizeof(wchar_t));
if(MPath != NULL) {
wmemcpy(MPath, WPath, MapLen+2);
wmemcpy(MPath, WPath, MapLen+1);
}
else {
errno = ENOMEM;
@@ -346,6 +353,12 @@ reclassify:
if(!RETURN_ERROR(Status)) {
*FullPath = WPath;
*Which = Instance;
if(MapPath != NULL) {
*MapPath = MPath;
}
else if(MPath != NULL) {
free(MPath); /* Caller doesn't want it so let MPath go free */
}
/* At this point, WPath is an absolute path,
MPath is either NULL or points to the Map Name,
@@ -359,6 +372,9 @@ reclassify:
if(Node != NULL) {
Status = RETURN_SUCCESS;
}
else {
Status = RETURN_NOT_FOUND;
}
}
else {
/* This is a mapped path. */
@@ -375,8 +391,41 @@ reclassify:
*DevNode = Node;
}
}
if(MPath != NULL) {
free(MPath); // We don't need this any more.
}
return Status;
}
/**
Parses a normalized wide character path and returns a pointer to the entry
following the last \. If a \ is not found in the path the return value will
be the same as the input value. All error conditions return NULL.
The behavior when passing in a path that has not been normalized is undefined.
@param Path - A pointer to a wide character string containing a path to a
directory or a file.
@return Pointer to the file name or terminal directory. NULL if an error is
detected.
**/
wchar_t *
EFIAPI
GetFileNameFromPath (
const wchar_t *Path
)
{
wchar_t *Tail;
if (Path == NULL) {
return NULL;
}
Tail = wcsrchr(Path, L'\\');
if(Tail == NULL) {
Tail = (wchar_t *) Path;
} else {
// Move to the next character after the '\\' to get the file name.
Tail++;
}
return Tail;
}