|
@@ -338,6 +338,45 @@ int snprintf ( char *buf, size_t size, const char *fmt, ... ) {
|
338
|
338
|
return i;
|
339
|
339
|
}
|
340
|
340
|
|
|
341
|
+/**
|
|
342
|
+ * Version of vsnprintf() that accepts a signed buffer size
|
|
343
|
+ *
|
|
344
|
+ * @v buf Buffer into which to write the string
|
|
345
|
+ * @v size Size of buffer
|
|
346
|
+ * @v fmt Format string
|
|
347
|
+ * @v args Arguments corresponding to the format string
|
|
348
|
+ * @ret len Length of formatted string
|
|
349
|
+ */
|
|
350
|
+int vssnprintf ( char *buf, ssize_t ssize, const char *fmt, va_list args ) {
|
|
351
|
+
|
|
352
|
+ /* Treat negative buffer size as zero buffer size */
|
|
353
|
+ if ( ssize < 0 )
|
|
354
|
+ ssize = 0;
|
|
355
|
+
|
|
356
|
+ /* Hand off to vsnprintf */
|
|
357
|
+ return vsnprintf ( buf, ssize, fmt, args );
|
|
358
|
+}
|
|
359
|
+
|
|
360
|
+/**
|
|
361
|
+ * Version of vsnprintf() that accepts a signed buffer size
|
|
362
|
+ *
|
|
363
|
+ * @v buf Buffer into which to write the string
|
|
364
|
+ * @v size Size of buffer
|
|
365
|
+ * @v fmt Format string
|
|
366
|
+ * @v ... Arguments corresponding to the format string
|
|
367
|
+ * @ret len Length of formatted string
|
|
368
|
+ */
|
|
369
|
+int ssnprintf ( char *buf, ssize_t ssize, const char *fmt, ... ) {
|
|
370
|
+ va_list args;
|
|
371
|
+ int len;
|
|
372
|
+
|
|
373
|
+ /* Hand off to vssnprintf */
|
|
374
|
+ va_start ( args, fmt );
|
|
375
|
+ len = vssnprintf ( buf, ssize, fmt, args );
|
|
376
|
+ va_end ( args );
|
|
377
|
+ return len;
|
|
378
|
+}
|
|
379
|
+
|
341
|
380
|
/**
|
342
|
381
|
* Write character to console
|
343
|
382
|
*
|