aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxutil/iostream.c
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2004-06-29 19:45:18 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2004-06-29 19:45:18 +0000
commit0c73bd1bb647de6bd5a55cbddb683e2decae8a56 (patch)
treed0dc3b91c0fa176b1afe4bb22c8a37a34850f6c3 /tools/libxutil/iostream.c
parent0a61e6714d37bae173ce5d9910382f6275c6b13c (diff)
parent48e9a9c636cfbf00a1468f3a3dffe932e3e01a19 (diff)
downloadxen-0c73bd1bb647de6bd5a55cbddb683e2decae8a56.tar.gz
xen-0c73bd1bb647de6bd5a55cbddb683e2decae8a56.tar.bz2
xen-0c73bd1bb647de6bd5a55cbddb683e2decae8a56.zip
bitkeeper revision 1.1029 (40e1c6ce1NufVIrsLOg06kNbotFFZA)
Merge ssh://xenbk@gandalf.hpl.hp.com//var/bk/xeno-unstable.bk into scramble.cl.cam.ac.uk:/local/scratch/kaf24/hp.bk
Diffstat (limited to 'tools/libxutil/iostream.c')
-rw-r--r--tools/libxutil/iostream.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/libxutil/iostream.c b/tools/libxutil/iostream.c
new file mode 100644
index 0000000000..e9980838f7
--- /dev/null
+++ b/tools/libxutil/iostream.c
@@ -0,0 +1,37 @@
+#include "iostream.h"
+#include "sys_string.h"
+
+/** Print on a stream, like vfprintf().
+ *
+ * @param stream to print to
+ * @param format for the print (as fprintf())
+ * @param args arguments to print
+ * @return result code from the print
+ */
+int IOStream_vprint(IOStream *stream, const char *format, va_list args){
+ char buffer[1024];
+ int k = sizeof(buffer), n;
+
+ n = vsnprintf(buffer, k, (char*)format, args);
+ if(n < 0 || n > k ){
+ n = k;
+ }
+ n = IOStream_write(stream, buffer, n);
+ return n;
+}
+
+/** Print on a stream, like fprintf().
+ *
+ * @param stream to print to
+ * @param format for the print (as fprintf())
+ * @return result code from the print
+ */
+int IOStream_print(IOStream *stream, const char *format, ...){
+ va_list args;
+ int result = -1;
+
+ va_start(args, format);
+ result = IOStream_vprint(stream, format, args);
+ va_end(args);
+ return result;
+}