ia64/xen-unstable

view tools/libxutil/iostream.c @ 2621:9402048e2325

bitkeeper revision 1.1159.1.218 (416a8128OiHXHyk_Sy8FsA0YUQcEnA)

Merge freefall.cl.cam.ac.uk:/auto/groups/xeno/users/cl349/BK/xeno.bk-26dom0
into freefall.cl.cam.ac.uk:/local/scratch/cl349/xeno.bk-26dom0
author cl349@freefall.cl.cam.ac.uk
date Mon Oct 11 12:48:40 2004 +0000 (2004-10-11)
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 }