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