[coreboot] [commit] r6358 - in trunk/payloads/libpayload: include libc
repository service
svn at coreboot.org
Mon Feb 14 20:25:28 CET 2011
Author: oxygene
Date: Mon Feb 14 20:25:27 2011
New Revision: 6358
URL: https://tracker.coreboot.org/trac/coreboot/changeset/6358
Log:
Stub out FILE*, stdout/stdin/stderr and implement fprintf on these
- Add FILE*
- Add stdout, stdin, stderr stubs
- Add fprintf that redirects to printf for stdout and stderr and fails otherwise
Signed-off-by: Patrick Georgi <patrick.georgi at secunet.com>
Acked-by: Stefan Reinauer <stefan.reinauer at coreboot.org>
Modified:
trunk/payloads/libpayload/include/stdio.h
trunk/payloads/libpayload/libc/printf.c
Modified: trunk/payloads/libpayload/include/stdio.h
==============================================================================
--- trunk/payloads/libpayload/include/stdio.h Mon Feb 14 20:24:37 2011 (r6357)
+++ trunk/payloads/libpayload/include/stdio.h Mon Feb 14 20:25:27 2011 (r6358)
@@ -32,6 +32,15 @@
#include <stddef.h>
+struct _FILE {
+} _stdout, _stdin, _stderr;
+
+typedef struct _FILE FILE;
+
+FILE *stdout = &_stdout;
+FILE *stdin = &_stdin;
+FILE *stderr = &_stderr;
+
/**
* @defgroup printf Print functions
* @{
@@ -39,6 +48,7 @@
int snprintf(char *str, size_t size, const char *fmt, ...);
int sprintf(char *str, const char *fmt, ...);
int printf(const char *fmt, ...);
+int fprintf(FILE *file, const char *fmt, ...);
/** @} */
void perror(const char *s);
@@ -47,5 +57,4 @@
#define SEEK_CUR 1 /**< The seek offset is against the current position. */
#define SEEK_END 2 /**< The seek offset is against the end of the file. */
-
#endif
Modified: trunk/payloads/libpayload/libc/printf.c
==============================================================================
--- trunk/payloads/libpayload/libc/printf.c Mon Feb 14 20:24:37 2011 (r6357)
+++ trunk/payloads/libpayload/libc/printf.c Mon Feb 14 20:25:27 2011 (r6358)
@@ -723,6 +723,20 @@
return ret;
}
+int fprintf(FILE *file, const char *fmt, ...)
+{
+ int ret;
+ if ((file == stdout) || (file == stderr)) {
+ va_list args;
+ va_start(args, fmt);
+ ret = vprintf(fmt, args);
+ va_end(args);
+
+ return ret;
+ }
+ return -1;
+}
+
struct vsnprintf_data {
size_t size; /* Total space for string */
size_t len; /* Count of currently used characters */
More information about the coreboot
mailing list