summaryrefslogtreecommitdiffstats
path: root/src/core/xfer.c
diff options
context:
space:
mode:
authorMichael Brown2007-05-28 22:09:44 +0200
committerMichael Brown2007-05-28 22:09:44 +0200
commita6a18ae9af43f870c82836ec0c9b486db6e58b15 (patch)
tree0853493fb491b780fc59cd1d588411095f7ecd88 /src/core/xfer.c
parentMake URI structures reference-counted. (diff)
downloadipxe-a6a18ae9af43f870c82836ec0c9b486db6e58b15.tar.gz
ipxe-a6a18ae9af43f870c82836ec0c9b486db6e58b15.tar.xz
ipxe-a6a18ae9af43f870c82836ec0c9b486db6e58b15.zip
Add xfer_[v]printf() functions.
Diffstat (limited to 'src/core/xfer.c')
-rw-r--r--src/core/xfer.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/core/xfer.c b/src/core/xfer.c
index 54377c70..2250687e 100644
--- a/src/core/xfer.c
+++ b/src/core/xfer.c
@@ -17,6 +17,7 @@
*/
#include <string.h>
+#include <stdio.h>
#include <errno.h>
#include <gpxe/xfer.h>
@@ -221,6 +222,46 @@ int xfer_deliver_raw ( struct xfer_interface *xfer,
return rc;
}
+/**
+ * Deliver formatted string
+ *
+ * @v xfer Data transfer interface
+ * @v format Format string
+ * @v args Arguments corresponding to the format string
+ * @ret rc Return status code
+ */
+int xfer_vprintf ( struct xfer_interface *xfer, const char *format,
+ va_list args ) {
+ size_t len;
+ va_list args_tmp;
+
+ va_copy ( args_tmp, args );
+ len = vsnprintf ( NULL, 0, format, args );
+ {
+ char buf[len + 1];
+ vsnprintf ( buf, sizeof ( buf ), format, args_tmp );
+ return xfer_deliver_raw ( xfer, buf, len );
+ }
+}
+
+/**
+ * Deliver formatted string
+ *
+ * @v xfer Data transfer interface
+ * @v format Format string
+ * @v ... Arguments corresponding to the format string
+ * @ret rc Return status code
+ */
+int xfer_printf ( struct xfer_interface *xfer, const char *format, ... ) {
+ va_list args;
+ int rc;
+
+ va_start ( args, format );
+ rc = xfer_vprintf ( xfer, format, args );
+ va_end ( args );
+ return rc;
+}
+
/****************************************************************************
*
* Helper methods