mirror of
https://github.com/acpica/acpica/
synced 2025-02-25 18:04:08 +03:00
Clib/EFI: Add fgetc()/fputc() to improve portability
This patch added two new Clibrary functions: fgetc()/fputc() for EFI environment, they are implemented using fread()/fwrite(). Note in this patch, stdin is simply defined as NULL for EFI environment. Its EFI support should be implemented by further patches. Signed-off-by: Lv Zheng <lv.zheng@intel.com>
This commit is contained in:
parent
c684c88bd9
commit
4dbfe66bf1
@ -304,6 +304,10 @@ sprintf (
|
||||
*/
|
||||
extern int errno;
|
||||
|
||||
#ifndef EOF
|
||||
#define EOF (-1)
|
||||
#endif
|
||||
|
||||
int
|
||||
vprintf (
|
||||
const char *Format,
|
||||
@ -358,6 +362,15 @@ fseek (
|
||||
long
|
||||
ftell (
|
||||
FILE *File);
|
||||
|
||||
int
|
||||
fgetc (
|
||||
FILE *File);
|
||||
|
||||
int
|
||||
fputc (
|
||||
FILE *File,
|
||||
char c);
|
||||
#endif
|
||||
|
||||
#endif /* _ACCLIB_H */
|
||||
|
@ -335,6 +335,76 @@ fclose (
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: fgetc
|
||||
*
|
||||
* PARAMETERS: File - File descriptor
|
||||
*
|
||||
* RETURN: The character read or EOF on the end of the file or error
|
||||
*
|
||||
* DESCRIPTION: Read a character from the file.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int
|
||||
fgetc (
|
||||
FILE *File)
|
||||
{
|
||||
UINT8 Byte;
|
||||
int Length;
|
||||
|
||||
|
||||
Length = fread (ACPI_CAST_PTR (void, &Byte), 1, 1, File);
|
||||
if (Length == 0)
|
||||
{
|
||||
Length = EOF;
|
||||
}
|
||||
else if (Length == 1)
|
||||
{
|
||||
Length = (int) Byte;
|
||||
}
|
||||
|
||||
return (Length);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: fputc
|
||||
*
|
||||
* PARAMETERS: File - File descriptor
|
||||
* c - Character byte
|
||||
*
|
||||
* RETURN: The character written or EOF on the end of the file or error
|
||||
*
|
||||
* DESCRIPTION: Write a character to the file.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int
|
||||
fputc (
|
||||
FILE *File,
|
||||
char c)
|
||||
{
|
||||
UINT8 Byte = (UINT8) c;
|
||||
int Length;
|
||||
|
||||
|
||||
Length = fwrite (ACPI_CAST_PTR (void, &Byte), 1, 1, File);
|
||||
if (Length == 0)
|
||||
{
|
||||
Length = EOF;
|
||||
}
|
||||
else if (Length == 1)
|
||||
{
|
||||
Length = (int) Byte;
|
||||
}
|
||||
|
||||
return (Length);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: fread
|
||||
|
Loading…
x
Reference in New Issue
Block a user