core/sm_stringutil.cpp
changeset 274 959c85596341
parent 236 123045747879
child 276 065d151c41b2
     1.1 --- a/core/sm_stringutil.cpp	Sat Jan 06 19:35:25 2007 +0000
     1.2 +++ b/core/sm_stringutil.cpp	Sun Jan 07 01:30:28 2007 +0000
     1.3 @@ -1,5 +1,6 @@
     1.4  #include <stdlib.h>
     1.5  #include <ctype.h>
     1.6 +#include <stdarg.h>
     1.7  #include "sm_stringutil.h"
     1.8  
     1.9  #define ALT				0x00000001		/* alternate form */
    1.10 @@ -471,3 +472,13 @@
    1.11  
    1.12  	return (dest - start);
    1.13  }
    1.14 +
    1.15 +size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
    1.16 +{
    1.17 +	va_list ap;
    1.18 +	va_start(ap, fmt);
    1.19 +	size_t len = vsnprintf(buffer, maxlength, fmt, ap);
    1.20 +	va_end(ap);
    1.21 +
    1.22 +	return (len >= maxlength) ? (maxlength - 1) : len;
    1.23 +}
    1.24 \ No newline at end of file