switch-coreboot/lib/vsprintf.c
Stefan Reinauer 6220b632e7 Now version 3: LinuxBIOS -> coreboot rename.
- I left LB_TAG_ intact because they are used by the payloads
- file renames are still missing. see next commit
- some lb_ renames might be missing. feel free to provide patches.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/coreboot-v3@564 f3766cd6-281f-0410-b1cd-43a5c92072e9
2008-01-27 18:54:57 +00:00

45 lines
1.1 KiB
C

/*
* This file is part of the coreboot project.
*
* It is based on the Linux kernel (lib/vsprintf.c).
*
* Modifications are:
* Copyright (C) 2007 Ronald G. Minnich <rminnich@gmail.com>
*/
/* Copyright (C) 1991, 1992 Linus Torvalds */
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
/* Wirzenius wrote this portably, Torvalds fucked it up :-) */
#include <stdarg.h>
#include <string.h>
#include <console.h>
int vtxprintf(void (*tx_byte) (unsigned char byte, void *arg), void *arg, const char *fmt,
va_list args);
/* the arg is the char ** for the buffer */
static void str_tx_byte(unsigned char byte, void *arg)
{
unsigned char *cp = *(unsigned char **) arg;
*cp = byte;
cp++;
/* paranoia, make sure it will be null terminated. The cost for this is small,
* the benefit large.
*/
*cp = 0;
*(unsigned char **) arg = cp;
}
int sprintf(char *buf, const char *fmt, ...)
{
va_list args;
int i;
unsigned char *cp = (unsigned char *)buf;
unsigned char **cpp = &cp;
va_start(args, fmt);
i = vtxprintf(str_tx_byte, cpp, fmt, args);
va_end(args);
return i;
}