1 /* libxml2 - Library for parsing XML documents 2 * Copyright (C) 2006-2019 Free Software Foundation, Inc. 3 * 4 * This file is not part of the GNU gettext program, but is used with 5 * GNU gettext. 6 * 7 * The original copyright notice is as follows: 8 */ 9 10 /* 11 * Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved. 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining a copy 14 * of this software and associated documentation files (the "Software"), to deal 15 * in the Software without restriction, including without limitation the rights 16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 * copies of the Software, and to permit persons to whom the Software is fur- 18 * nished to do so, subject to the following conditions: 19 * 20 * The above copyright notice and this permission notice shall be included in 21 * all copies or substantial portions of the Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 25 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 * THE SOFTWARE. 30 * 31 * Author: Daniel Veillard 32 */ 33 34 /* 35 * Summary: set of routines to process strings 36 * Description: type and interfaces needed for the internal string handling 37 * of the library, especially UTF8 processing. 38 */ 39 40 #ifndef __XML_STRING_H__ 41 #define __XML_STRING_H__ 42 43 #include <stdarg.h> 44 #include <libxml/xmlversion.h> 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * xmlChar: 52 * 53 * This is a basic byte in an UTF-8 encoded string. 54 * It's unsigned allowing to pinpoint case where char * are assigned 55 * to xmlChar * (possibly making serialization back impossible). 56 */ 57 typedef unsigned char xmlChar; 58 59 /** 60 * BAD_CAST: 61 * 62 * Macro to cast a string to an xmlChar * when one know its safe. 63 */ 64 #define BAD_CAST (xmlChar *) 65 66 /* 67 * xmlChar handling 68 */ 69 XMLPUBFUN xmlChar * XMLCALL 70 xmlStrdup (const xmlChar *cur); 71 XMLPUBFUN xmlChar * XMLCALL 72 xmlStrndup (const xmlChar *cur, 73 int len); 74 XMLPUBFUN xmlChar * XMLCALL 75 xmlCharStrndup (const char *cur, 76 int len); 77 XMLPUBFUN xmlChar * XMLCALL 78 xmlCharStrdup (const char *cur); 79 XMLPUBFUN xmlChar * XMLCALL 80 xmlStrsub (const xmlChar *str, 81 int start, 82 int len); 83 XMLPUBFUN const xmlChar * XMLCALL 84 xmlStrchr (const xmlChar *str, 85 xmlChar val); 86 XMLPUBFUN const xmlChar * XMLCALL 87 xmlStrstr (const xmlChar *str, 88 const xmlChar *val); 89 XMLPUBFUN const xmlChar * XMLCALL 90 xmlStrcasestr (const xmlChar *str, 91 const xmlChar *val); 92 XMLPUBFUN int XMLCALL 93 xmlStrcmp (const xmlChar *str1, 94 const xmlChar *str2); 95 XMLPUBFUN int XMLCALL 96 xmlStrncmp (const xmlChar *str1, 97 const xmlChar *str2, 98 int len); 99 XMLPUBFUN int XMLCALL 100 xmlStrcasecmp (const xmlChar *str1, 101 const xmlChar *str2); 102 XMLPUBFUN int XMLCALL 103 xmlStrncasecmp (const xmlChar *str1, 104 const xmlChar *str2, 105 int len); 106 XMLPUBFUN int XMLCALL 107 xmlStrEqual (const xmlChar *str1, 108 const xmlChar *str2); 109 XMLPUBFUN int XMLCALL 110 xmlStrQEqual (const xmlChar *pref, 111 const xmlChar *name, 112 const xmlChar *str); 113 XMLPUBFUN int XMLCALL 114 xmlStrlen (const xmlChar *str); 115 XMLPUBFUN xmlChar * XMLCALL 116 xmlStrcat (xmlChar *cur, 117 const xmlChar *add); 118 XMLPUBFUN xmlChar * XMLCALL 119 xmlStrncat (xmlChar *cur, 120 const xmlChar *add, 121 int len); 122 XMLPUBFUN xmlChar * XMLCALL 123 xmlStrncatNew (const xmlChar *str1, 124 const xmlChar *str2, 125 int len); 126 XMLPUBFUN int XMLCALL 127 xmlStrPrintf (xmlChar *buf, 128 int len, 129 const char *msg, 130 ...) LIBXML_ATTR_FORMAT(3,4); 131 XMLPUBFUN int XMLCALL 132 xmlStrVPrintf (xmlChar *buf, 133 int len, 134 const char *msg, 135 va_list ap) LIBXML_ATTR_FORMAT(3,0); 136 137 XMLPUBFUN int XMLCALL 138 xmlGetUTF8Char (const unsigned char *utf, 139 int *len); 140 XMLPUBFUN int XMLCALL 141 xmlCheckUTF8 (const unsigned char *utf); 142 XMLPUBFUN int XMLCALL 143 xmlUTF8Strsize (const xmlChar *utf, 144 int len); 145 XMLPUBFUN xmlChar * XMLCALL 146 xmlUTF8Strndup (const xmlChar *utf, 147 int len); 148 XMLPUBFUN const xmlChar * XMLCALL 149 xmlUTF8Strpos (const xmlChar *utf, 150 int pos); 151 XMLPUBFUN int XMLCALL 152 xmlUTF8Strloc (const xmlChar *utf, 153 const xmlChar *utfchar); 154 XMLPUBFUN xmlChar * XMLCALL 155 xmlUTF8Strsub (const xmlChar *utf, 156 int start, 157 int len); 158 XMLPUBFUN int XMLCALL 159 xmlUTF8Strlen (const xmlChar *utf); 160 XMLPUBFUN int XMLCALL 161 xmlUTF8Size (const xmlChar *utf); 162 XMLPUBFUN int XMLCALL 163 xmlUTF8Charcmp (const xmlChar *utf1, 164 const xmlChar *utf2); 165 166 #ifdef __cplusplus 167 } 168 #endif 169 #endif /* __XML_STRING_H__ */ 170