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:
28
parser.c
28
parser.c
@ -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 ? *
|
||||
|
Reference in New Issue
Block a user