update for HEAD-2003091401
[reactos.git] / lib / msvcrt / stdio / fprintf.c
1 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
2 #include <msvcrt/stdio.h>
3 #include <msvcrt/wchar.h>
4 #include <msvcrt/internal/file.h>
5
6 /*
7  * @implemented
8  */
9 int
10 fprintf(register FILE *iop, const char *fmt, ...)
11 {
12   int len;
13   char localbuf[BUFSIZ];
14   va_list a=0;
15   
16
17   va_start( a, fmt ); 
18   if (iop->_flag & _IONBF)
19   {
20     iop->_flag &= ~_IONBF;
21     iop->_ptr = iop->_base = localbuf;
22     iop->_bufsiz = BUFSIZ;
23     len = vfprintf(iop,fmt,a);
24     fflush(iop);
25     iop->_flag |= _IONBF;
26     iop->_base = NULL;
27     iop->_bufsiz = 0;
28     iop->_cnt = 0;
29   }
30   else
31     len = vfprintf(iop, fmt, a);
32   return ferror(iop) ? EOF : len;
33 }
34
35 /*
36  * @implemented
37  */
38 int
39 fwprintf(register FILE *iop, const wchar_t *fmt, ...)
40 {
41   int len;
42   wchar_t localbuf[BUFSIZ];
43   va_list a=0;
44   
45
46   va_start( a, fmt ); 
47   if (iop->_flag & _IONBF)
48   {
49     iop->_flag &= ~_IONBF;
50     iop->_ptr = iop->_base = (char *)localbuf;
51     iop->_bufsiz = BUFSIZ;
52     len = vfwprintf(iop,fmt,a);
53     fflush(iop);
54     iop->_flag |= _IONBF;
55     iop->_base = NULL;
56     iop->_bufsiz = 0;
57     iop->_cnt = 0;
58   }
59   else
60     len = vfwprintf(iop, fmt, a);
61   return ferror(iop) ? EOF : len;
62 }