|
@@ -17,6 +17,7 @@
|
17
|
17
|
*/
|
18
|
18
|
|
19
|
19
|
#include <string.h>
|
|
20
|
+#include <stdio.h>
|
20
|
21
|
#include <errno.h>
|
21
|
22
|
#include <gpxe/xfer.h>
|
22
|
23
|
|
|
@@ -221,6 +222,46 @@ int xfer_deliver_raw ( struct xfer_interface *xfer,
|
221
|
222
|
return rc;
|
222
|
223
|
}
|
223
|
224
|
|
|
225
|
+/**
|
|
226
|
+ * Deliver formatted string
|
|
227
|
+ *
|
|
228
|
+ * @v xfer Data transfer interface
|
|
229
|
+ * @v format Format string
|
|
230
|
+ * @v args Arguments corresponding to the format string
|
|
231
|
+ * @ret rc Return status code
|
|
232
|
+ */
|
|
233
|
+int xfer_vprintf ( struct xfer_interface *xfer, const char *format,
|
|
234
|
+ va_list args ) {
|
|
235
|
+ size_t len;
|
|
236
|
+ va_list args_tmp;
|
|
237
|
+
|
|
238
|
+ va_copy ( args_tmp, args );
|
|
239
|
+ len = vsnprintf ( NULL, 0, format, args );
|
|
240
|
+ {
|
|
241
|
+ char buf[len + 1];
|
|
242
|
+ vsnprintf ( buf, sizeof ( buf ), format, args_tmp );
|
|
243
|
+ return xfer_deliver_raw ( xfer, buf, len );
|
|
244
|
+ }
|
|
245
|
+}
|
|
246
|
+
|
|
247
|
+/**
|
|
248
|
+ * Deliver formatted string
|
|
249
|
+ *
|
|
250
|
+ * @v xfer Data transfer interface
|
|
251
|
+ * @v format Format string
|
|
252
|
+ * @v ... Arguments corresponding to the format string
|
|
253
|
+ * @ret rc Return status code
|
|
254
|
+ */
|
|
255
|
+int xfer_printf ( struct xfer_interface *xfer, const char *format, ... ) {
|
|
256
|
+ va_list args;
|
|
257
|
+ int rc;
|
|
258
|
+
|
|
259
|
+ va_start ( args, format );
|
|
260
|
+ rc = xfer_vprintf ( xfer, format, args );
|
|
261
|
+ va_end ( args );
|
|
262
|
+ return rc;
|
|
263
|
+}
|
|
264
|
+
|
224
|
265
|
/****************************************************************************
|
225
|
266
|
*
|
226
|
267
|
* Helper methods
|