changeset 2978:f01575de4e32

* include/diag.h: * src/diag.cxx: Add diag_vsnprintf().
author sergeig
date Sun, 21 Nov 2010 11:51:29 +0000
parents 0870333f7ba8
children 00ddfb443539
files packages/infra/current/ChangeLog packages/infra/current/include/diag.h packages/infra/current/src/diag.cxx
diffstat 3 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/packages/infra/current/ChangeLog
+++ b/packages/infra/current/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-13  Chris Holgate  <chris@zynaptic.com>
+
+	* include/diag.h:
+	* src/diag.cxx: Add diag_vsnprintf().
+
 2009-10-06  Uwe Kindler  <uwe_kindler@web.de>
 
 	* include/cyg_type.h: Changed definition of macro
--- a/packages/infra/current/include/diag.h
+++ b/packages/infra/current/include/diag.h
@@ -100,6 +100,8 @@ externC int  diag_snprintf(char *buf, si
      CYGBLD_ATTRIB_PRINTF_FORMAT(3,4);
 externC int  diag_vsprintf(char *buf, const char *fmt, va_list ap)
      CYGBLD_ATTRIB_PRINTF_FORMAT(2,0);
+externC int  diag_vsnprintf(char *buf, size_t len, const char *fmt, va_list ap)
+     CYGBLD_ATTRIB_PRINTF_FORMAT(3,0);
 externC int  diag_vprintf(const char *fmt, va_list ap)
      CYGBLD_ATTRIB_PRINTF_FORMAT(1,0);
 
--- a/packages/infra/current/src/diag.cxx
+++ b/packages/infra/current/src/diag.cxx
@@ -564,6 +564,19 @@ diag_vsprintf(char *buf, const char *fmt
     return (info.len);
 }
 
+int 
+diag_vsnprintf(char *buf, size_t len, const char *fmt, va_list ap)
+{
+    int ret;
+    struct _sputc_info info;
+
+    info.ptr = buf;
+    info.max = len-1;  
+    info.len = 0;
+    ret = _vprintf(_sputc, (void **)&info, fmt, ap);
+    return (info.len);
+}
+
 int
 diag_printf(const char *fmt, ...)
 {