ia64/xen-unstable

view tools/libxutil/iostream.c @ 2422:2274a0386cc9

bitkeeper revision 1.1159.69.5 (4138e882jA1YaR_OfTfNHe_uT4PDIg)

trivial
author iap10@labyrinth.cl.cam.ac.uk
date Fri Sep 03 21:56:18 2004 +0000 (2004-09-03)
parents 236a9f2698a3
children beb02da3f69f 42bdac6c8985 0a4b76b6b5a0
line source
1 #include "iostream.h"
2 #include "sys_string.h"
4 /** Print on a stream, like vfprintf().
5 *
6 * @param stream to print to
7 * @param format for the print (as fprintf())
8 * @param args arguments to print
9 * @return result code from the print
10 */
11 int IOStream_vprint(IOStream *stream, const char *format, va_list args){
12 char buffer[1024];
13 int k = sizeof(buffer), n;
15 n = vsnprintf(buffer, k, (char*)format, args);
16 if(n < 0 || n > k ){
17 n = k;
18 }
19 n = IOStream_write(stream, buffer, n);
20 return n;
21 }
23 /** Print on a stream, like fprintf().
24 *
25 * @param stream to print to
26 * @param format for the print (as fprintf())
27 * @return result code from the print
28 */
29 int IOStream_print(IOStream *stream, const char *format, ...){
30 va_list args;
31 int result = -1;
33 va_start(args, format);
34 result = IOStream_vprint(stream, format, args);
35 va_end(args);
36 return result;
37 }