* htmlCreateMemoryParserCtxt: * @buffer: a pointer to a char array * @size: the size of the array * * Create a parser context for an HTML in-memory document. * * Returns the new parser context or NULL */
| 4360 | * Returns the new parser context or NULL |
| 4361 | */ |
| 4362 | htmlParserCtxtPtr |
| 4363 | htmlCreateMemoryParserCtxt(const char *buffer, int size) { |
| 4364 | xmlParserCtxtPtr ctxt; |
| 4365 | xmlParserInputPtr input; |
| 4366 | xmlParserInputBufferPtr buf; |
| 4367 | |
| 4368 | if (buffer == NULL) |
| 4369 | return(NULL); |
| 4370 | if (size <= 0) |
| 4371 | return(NULL); |
| 4372 | |
| 4373 | ctxt = htmlNewParserCtxt(); |
| 4374 | if (ctxt == NULL) |
| 4375 | return(NULL); |
| 4376 | |
| 4377 | buf = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE); |
| 4378 | if (buf == NULL) return(NULL); |
| 4379 | |
| 4380 | input = xmlNewInputStream(ctxt); |
| 4381 | if (input == NULL) { |
| 4382 | xmlFreeParserCtxt(ctxt); |
| 4383 | return(NULL); |
| 4384 | } |
| 4385 | |
| 4386 | input->filename = NULL; |
| 4387 | input->buf = buf; |
| 4388 | input->base = input->buf->buffer->content; |
| 4389 | input->cur = input->buf->buffer->content; |
| 4390 | input->end = &input->buf->buffer->content[input->buf->buffer->use]; |
| 4391 | |
| 4392 | inputPush(ctxt, input); |
| 4393 | return(ctxt); |
| 4394 | } |
| 4395 | |
| 4396 | /** |
| 4397 | * htmlCreateDocParserCtxt: |