1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

introduced xmlStrPrintf function - wrapper for snprintf

This commit is contained in:
Aleksey Sanin
2003-10-02 20:05:27 +00:00
parent b2517d850d
commit e7acf431b8
3 changed files with 39 additions and 0 deletions

View File

@ -1,3 +1,8 @@
Thu Oct 2 13:01:13 2003 Aleksey Sanin <aleksey@aleksey.com>
* include/libxml/parser.h parser.c: introduced xmlStrPrintf
function (wrapper around snprintf)
Wed Oct 1 21:12:06 CEST 2003 Daniel Veillard <daniel@veillard.com> Wed Oct 1 21:12:06 CEST 2003 Daniel Veillard <daniel@veillard.com>
* entities.c: Fix error on output of high codepoint charref like * entities.c: Fix error on output of high codepoint charref like

View File

@ -851,6 +851,12 @@ XMLPUBFUN xmlChar * XMLCALL
const xmlChar *add, const xmlChar *add,
int len); int len);
XMLPUBFUN int XMLCALL
xmlStrPrintf (xmlChar *buf,
int len,
const xmlChar *msg,
...);
/* /*
* Basic parsing Interfaces * Basic parsing Interfaces
*/ */

View File

@ -41,6 +41,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>
#include <libxml/threads.h> #include <libxml/threads.h>
#include <libxml/globals.h> #include <libxml/globals.h>
@ -2399,6 +2400,33 @@ xmlStrcat(xmlChar *cur, const xmlChar *add) {
return(xmlStrncat(cur, add, p - 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 ? * * Commodity functions, cleanup needed ? *