* xmlNewInputBufferString: * @str: C string * @flags: flags * * Create an input buffer for a null-teriminated C string. * * Returns the new input buffer or NULL. */
| 2093 | * Returns the new input buffer or NULL. |
| 2094 | */ |
| 2095 | xmlParserInputBufferPtr |
| 2096 | xmlNewInputBufferString(const char *str, int flags) { |
| 2097 | xmlParserInputBufferPtr ret; |
| 2098 | xmlStringIOCtxt *ctxt; |
| 2099 | |
| 2100 | if ((flags & XML_INPUT_BUF_STATIC) == 0) |
| 2101 | return(xmlNewInputBufferMemory(str, strlen(str), flags, |
| 2102 | XML_CHAR_ENCODING_NONE)); |
| 2103 | |
| 2104 | ret = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE); |
| 2105 | if (ret == NULL) |
| 2106 | return(NULL); |
| 2107 | |
| 2108 | ctxt = xmlMalloc(sizeof(*ctxt)); |
| 2109 | if (ctxt == NULL) { |
| 2110 | xmlFreeParserInputBuffer(ret); |
| 2111 | return(NULL); |
| 2112 | } |
| 2113 | |
| 2114 | ctxt->str = str; |
| 2115 | |
| 2116 | ret->context = ctxt; |
| 2117 | ret->readcallback = xmlStringRead; |
| 2118 | ret->closecallback = xmlStringClose; |
| 2119 | |
| 2120 | return(ret); |
| 2121 | } |
| 2122 | |
| 2123 | #ifdef LIBXML_OUTPUT_ENABLED |
| 2124 | /** |
no test coverage detected