1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-28 00:21:53 +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

@ -41,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <libxml/xmlmemory.h>
#include <libxml/threads.h>
#include <libxml/globals.h>
@ -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 ? *