From b5a46da41dda383a419af6b42ea9190e40817f8a Mon Sep 17 00:00:00 2001 From: Aleksey Sanin Date: Wed, 29 Oct 2003 15:51:17 +0000 Subject: [PATCH] added xmlStrVPrintf function --- ChangeLog | 4 ++++ include/libxml/parser.h | 8 ++++++++ parser.c | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/ChangeLog b/ChangeLog index 942f4b31..611b017d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Oct 29 07:49:52 2003 Aleksey Sanin + + * include/libxml/parser.h parser.c: added xmlStrVPrintf function + Wed Oct 29 14:37:40 CET 2003 Daniel Veillard * nanoftp.c nanohttp.c testThreads.c threads.c: applied patch from diff --git a/include/libxml/parser.h b/include/libxml/parser.h index 1d8730d1..d7f8ce74 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -9,6 +9,8 @@ #ifndef __XML_PARSER_H__ #define __XML_PARSER_H__ +#include + #include #include #include @@ -864,6 +866,12 @@ XMLPUBFUN int XMLCALL const xmlChar *msg, ...); +XMLPUBFUN int XMLCALL + xmlStrVPrintf (xmlChar *buf, + int len, + const xmlChar *msg, + va_list ap); + /* * Basic parsing Interfaces */ diff --git a/parser.c b/parser.c index ce6272ce..7d151c30 100644 --- a/parser.c +++ b/parser.c @@ -2482,6 +2482,30 @@ xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) { return(ret); } +/** + * xmlStrVPrintf: + * @buf: the result buffer. + * @len: the result buffer length. + * @msg: the message with printf formatting. + * @ap: 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 +xmlStrVPrintf(xmlChar *buf, int len, const xmlChar *msg, va_list ap) { + int ret; + + if((buf == NULL) || (msg == NULL)) { + return(-1); + } + + ret = vsnprintf((char *) buf, len, (const char *) msg, ap); + buf[len - 1] = 0; /* be safe ! */ + + return(ret); +} /************************************************************************ * * * Commodity functions, cleanup needed ? *