forked from KolibriOS/kolibrios
libc testsuite + fixes
git-svn-id: svn://kolibrios.org@6433 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -1,23 +1,44 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
int fprintf(FILE* file, const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
char *buf;
|
||||
int printed;
|
||||
//int data[4];
|
||||
|
||||
va_start (arg, format);
|
||||
buf=malloc(4096*2); //8kb max
|
||||
//data[0]=(int)&arg-(int)&format;
|
||||
va_list arg;
|
||||
va_start (arg, format);
|
||||
|
||||
return vfprintf(file, format, arg);
|
||||
|
||||
}
|
||||
|
||||
int vfprintf ( FILE * file, const char * format, va_list arg )
|
||||
{
|
||||
char *buf;
|
||||
int printed, rc = 0;
|
||||
|
||||
if(!file || !format)
|
||||
{
|
||||
errno = E_INVALIDPTR;
|
||||
return errno;
|
||||
}
|
||||
|
||||
buf=malloc(4096*2); //8kb max
|
||||
if(!buf)
|
||||
{
|
||||
errno = E_NOMEM;
|
||||
return errno;
|
||||
}
|
||||
|
||||
printed=format_print(buf,8191, format,arg);
|
||||
if (file == stderr)
|
||||
debug_out_str(buf);
|
||||
else
|
||||
fwrite(buf,printed,1,file);
|
||||
rc = fwrite(buf,printed,1,file);
|
||||
free(buf);
|
||||
|
||||
return(printed);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
else
|
||||
return(printed);
|
||||
}
|
||||
|
Reference in New Issue
Block a user