diff --git a/ChangeLog b/ChangeLog index caafb303..73abf868 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Oct 2 13:01:13 2003 Aleksey Sanin + + * include/libxml/parser.h parser.c: introduced xmlStrPrintf + function (wrapper around snprintf) + Wed Oct 1 21:12:06 CEST 2003 Daniel Veillard * entities.c: Fix error on output of high codepoint charref like diff --git a/include/libxml/parser.h b/include/libxml/parser.h index 11bf6488..911c634a 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -851,6 +851,12 @@ XMLPUBFUN xmlChar * XMLCALL const xmlChar *add, int len); +XMLPUBFUN int XMLCALL + xmlStrPrintf (xmlChar *buf, + int len, + const xmlChar *msg, + ...); + /* * Basic parsing Interfaces */ diff --git a/parser.c b/parser.c index f3709971..0a9151a3 100644 --- a/parser.c +++ b/parser.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -2399,6 +2400,33 @@ xmlStrcat(xmlChar *cur, const xmlChar *add) { return(xmlStrncat(cur, add, p - add)); } +/** + * xmlStrPrintf: + * @buf: the result buffer. + * @len: the result buffer length. + * @msg: the message with printf formatting. + * @...: extra parameters for the message. + * + * Formats @msg and places result into @buf. + * + * Returns the number of characters written to @buf or -1 if an error occurs. + */ +int +xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) { + va_list args; + int ret; + + if((buf == NULL) || (msg == NULL)) { + return(-1); + } + + va_start(args, msg); + ret = vsnprintf(BAD_CAST buf, len, BAD_CAST msg, args); + va_end(args); + + return(ret); +} + /************************************************************************ * * * Commodity functions, cleanup needed ? *