*
* This module provides various utility functions for manipulating
* the xmlChar* type. All functions named xmlStr* have been moved here
- * from the parser.c file (their original home).
+ * from the parser.c file (their original home).
*
* See Copyright for the status of this software.
*
xmlChar *
xmlStrndup(const xmlChar *cur, int len) {
xmlChar *ret;
-
+
if ((cur == NULL) || (len < 0)) return(NULL);
ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar));
if (ret == NULL) {
xmlCharStrndup(const char *cur, int len) {
int i;
xmlChar *ret;
-
+
if ((cur == NULL) || (len < 0)) return(NULL);
ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar));
if (ret == NULL) {
* @name: the localname of the QName
* @str: the second xmlChar *
*
- * Check if a QName is Equal to a given string
+ * Check if a QName is Equal to a given string
*
* Returns 1 if they are equal, 0 if they are different
*/
const xmlChar *
xmlStrstr(const xmlChar *str, const xmlChar *val) {
int n;
-
+
if (str == NULL) return(NULL);
if (val == NULL) return(NULL);
n = xmlStrlen(val);
const xmlChar *
xmlStrcasestr(const xmlChar *str, const xmlChar *val) {
int n;
-
+
if (str == NULL) return(NULL);
if (val == NULL) return(NULL);
n = xmlStrlen(val);
xmlChar *
xmlStrsub(const xmlChar *str, int start, int len) {
int i;
-
+
if (str == NULL) return(NULL);
if (start < 0) return(NULL);
if (len < 0) return(NULL);
const xmlChar *p = add;
if (add == NULL) return(cur);
- if (cur == NULL)
+ if (cur == NULL)
return(xmlStrdup(add));
while (*p != 0) p++; /* non input consuming */
*
* Returns the number of characters written to @buf or -1 if an error occurs.
*/
-int XMLCDECL
+int XMLCDECL
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((char *) buf, len, (const char *) msg, args);
va_end(args);
buf[len - 1] = 0; /* be safe ! */
-
+
return(ret);
}
*
* Returns the number of characters written to @buf or -1 if an error occurs.
*/
-int
+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);
}
xmlUTF8Strndup(const xmlChar *utf, int len) {
xmlChar *ret;
int i;
-
+
if ((utf == NULL) || (len < 0)) return(NULL);
i = xmlUTF8Strsize(utf, len);
ret = (xmlChar *) xmlMallocAtomic((i + 1) * sizeof(xmlChar));