* xmlParserInputBufferPush: * @in: a buffered parser input * @len: the size in bytes of the array. * @buf: an char array * * Push the content of the arry in the input buffer * This routine handle the I18N transcoding to internal UTF-8 * This is used when operating the parser in progressive (push) mode. * * Returns the number of chars read and stored in the buffer, or -1 * in c
| 2272 | * in case of error. |
| 2273 | */ |
| 2274 | int |
| 2275 | xmlParserInputBufferPush(xmlParserInputBufferPtr in, |
| 2276 | int len, const char *buf) { |
| 2277 | int nbchars = 0; |
| 2278 | int ret; |
| 2279 | |
| 2280 | if (len < 0) return(0); |
| 2281 | if ((in == NULL) || (in->error)) return(-1); |
| 2282 | if (in->encoder != NULL) { |
| 2283 | /* |
| 2284 | * Store the data in the incoming raw buffer |
| 2285 | */ |
| 2286 | if (in->raw == NULL) { |
| 2287 | in->raw = xmlBufCreate(); |
| 2288 | if (in->raw == NULL) { |
| 2289 | in->error = XML_ERR_NO_MEMORY; |
| 2290 | return(-1); |
| 2291 | } |
| 2292 | } |
| 2293 | ret = xmlBufAdd(in->raw, (const xmlChar *) buf, len); |
| 2294 | if (ret != 0) { |
| 2295 | in->error = XML_ERR_NO_MEMORY; |
| 2296 | return(-1); |
| 2297 | } |
| 2298 | |
| 2299 | /* |
| 2300 | * convert as much as possible to the parser reading buffer. |
| 2301 | */ |
| 2302 | nbchars = xmlCharEncInput(in); |
| 2303 | if (nbchars < 0) |
| 2304 | return(-1); |
| 2305 | } else { |
| 2306 | nbchars = len; |
| 2307 | ret = xmlBufAdd(in->buffer, (xmlChar *) buf, nbchars); |
| 2308 | if (ret != 0) { |
| 2309 | in->error = XML_ERR_NO_MEMORY; |
| 2310 | return(-1); |
| 2311 | } |
| 2312 | } |
| 2313 | return(nbchars); |
| 2314 | } |
| 2315 | |
| 2316 | /** |
| 2317 | * endOfInput: |
no test coverage detected