2003-04-22 21:02:15 +02:00
|
|
|
/*
|
|
|
|
* linux/lib/vsprintf.c
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
2004-05-28 17:07:03 +02:00
|
|
|
int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args);
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
int vsprintf(char * buf, const char *fmt, va_list args)
|
|
|
|
{
|
2009-05-26 16:31:37 +02:00
|
|
|
char *str_buf;
|
|
|
|
|
2009-07-26 17:05:40 +02:00
|
|
|
/* this function is only used by vsprintf.
|
2009-05-26 16:31:37 +02:00
|
|
|
To keep str_buf local (for reentrancy
|
|
|
|
and to avoid .bss use, nest it */
|
|
|
|
void str_tx_byte(unsigned char byte)
|
|
|
|
{
|
|
|
|
*str_buf = byte;
|
|
|
|
str_buf++;
|
|
|
|
}
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
int i;
|
|
|
|
str_buf = buf;
|
|
|
|
i = vtxprintf(str_tx_byte, fmt, args);
|
|
|
|
*str_buf = '\0';
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sprintf(char * buf, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
i=vsprintf(buf,fmt,args);
|
|
|
|
va_end(args);
|
|
|
|
return i;
|
|
|
|
}
|