fixed function prototype for die()
[coreboot.git] / src / console / vsprintf.c
1 /*
2  *  linux/lib/vsprintf.c
3  *
4  *  Copyright (C) 1991, 1992  Linus Torvalds
5  */
6
7 /* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
8 /*
9  * Wirzenius wrote this portably, Torvalds fucked it up :-)
10  */
11 #include <stdarg.h>
12 #include <string.h>
13
14 int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args);
15
16 /* FIXME this global makes vsprintf non-reentrant */
17
18 static char *str_buf;
19 static void str_tx_byte(unsigned char byte)
20 {
21         *str_buf = byte;
22         str_buf++;
23 }
24
25 int vsprintf(char * buf, const char *fmt, va_list args)
26 {
27         int i;
28         str_buf = buf;
29         i = vtxprintf(str_tx_byte, fmt, args);
30         /* maeder/Ispiri -- The null termination was missing a deference */
31         /*                  and was just zeroing out the pointer instead */
32         *str_buf = '\0';
33         return i;
34 }
35
36 int sprintf(char * buf, const char *fmt, ...)
37 {
38         va_list args;
39         int i;
40
41         va_start(args, fmt);
42         i=vsprintf(buf,fmt,args);
43         va_end(args);
44         return i;
45 }