return i;
}
+/**
+ * Version of vsnprintf() that accepts a signed buffer size
+ *
+ * @v buf Buffer into which to write the string
+ * @v size Size of buffer
+ * @v fmt Format string
+ * @v args Arguments corresponding to the format string
+ * @ret len Length of formatted string
+ */
+int vssnprintf ( char *buf, ssize_t ssize, const char *fmt, va_list args ) {
+
+ /* Treat negative buffer size as zero buffer size */
+ if ( ssize < 0 )
+ ssize = 0;
+
+ /* Hand off to vsnprintf */
+ return vsnprintf ( buf, ssize, fmt, args );
+}
+
+/**
+ * Version of vsnprintf() that accepts a signed buffer size
+ *
+ * @v buf Buffer into which to write the string
+ * @v size Size of buffer
+ * @v fmt Format string
+ * @v ... Arguments corresponding to the format string
+ * @ret len Length of formatted string
+ */
+int ssnprintf ( char *buf, ssize_t ssize, const char *fmt, ... ) {
+ va_list args;
+ int len;
+
+ /* Hand off to vssnprintf */
+ va_start ( args, fmt );
+ len = vssnprintf ( buf, ssize, fmt, args );
+ va_end ( args );
+ return len;
+}
+
/**
* Write character to console
*
extern size_t vcprintf ( struct printf_context *ctx, const char *fmt,
va_list args );
+extern int vssnprintf ( char *buf, ssize_t ssize, const char *fmt,
+ va_list args );
+extern int ssnprintf ( char *buf, ssize_t ssize, const char *fmt, ... );
+
#endif /* _GPXE_VSPRINTF_H */
#include <errno.h>
#include <assert.h>
#include <byteswap.h>
+#include <gpxe/vsprintf.h>
#include <gpxe/scsi.h>
#include <gpxe/process.h>
#include <gpxe/uaccess.h>
*
*/
-/**
- * Version of snprintf() that accepts a signed buffer size
- *
- * @v buf Buffer into which to write the string
- * @v size Size of buffer
- * @v fmt Format string
- * @v args Arguments corresponding to the format string
- * @ret len Length of formatted string
- *
- * This is a utility function for iscsi_build_login_request_strings().
- */
-static int ssnprintf ( char *buf, ssize_t ssize, const char *fmt, ... ) {
- va_list args;
- int len;
-
- /* Treat negative buffer size as zero buffer size */
- if ( ssize < 0 )
- ssize = 0;
-
- /* Hand off to vsnprintf */
- va_start ( args, fmt );
- len = vsnprintf ( buf, ssize, fmt, args );
- va_end ( args );
- return len;
-}
-
/**
* Build iSCSI login request strings
*