/** @file
Copyright (c) 2004 - 2008, 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
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Abstract:
This contains some useful functions for accessing files.
**/
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "CommonLib.h"
#include "MemoryFile.h"
//
// Local (static) function prototypes
//
);
//
// Function implementations
//
)
/*++
Routine Description:
This opens a file, reads it into memory and returns a memory file
object.
Arguments:
InputFile Memory file image.
OutputMemoryFile Handle to memory file
Returns:
EFI_STATUS
OutputMemoryFile is valid if !EFI_ERROR
--*/
{
return Status;
}
if (NewMemoryFile == NULL) {
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
)
/*++
Routine Description:
Frees all memory associated with the input memory file.
Arguments:
InputMemoryFile Handle to memory file
Returns:
EFI_STATUS
--*/
{
//
// Invalidate state of MEMORY_FILE structure to catch invalid usage.
//
free (MemoryFile);
return EFI_SUCCESS;
}
CHAR8 *
)
/*++
Routine Description:
This function reads a line from the memory file. The newline characters
are stripped and a null terminated string is returned.
If the string pointer returned is non-NULL, then the caller must free the
memory associated with this string.
Arguments:
InputMemoryFile Handle to memory file
Returns:
NULL if error or EOF
NULL character termincated string otherwise (MUST BE FREED BY CALLER)
--*/
{
//
// Verify input parameters are not null
//
//
// Check for end of file condition
//
return NULL;
}
//
// Determine the number of bytes remaining until the EOF
//
//
// Find the next newline char
//
//
// Determine the number of characters to copy.
//
if (EndOfLine == 0) {
//
// If no newline found, copy to the end of the file.
//
} else {
//
// Newline found in the file.
//
}
if (OutputString == NULL) {
return NULL;
}
//
// Copy the line.
//
//
// Add the null termination over the 0x0D
//
} else {
}
//
// Increment the current file pointer (include the 0x0A)
//
//
// Return the string
//
return OutputString;
}
)
{
}