Lines Matching +full:data +full:- +full:uri +full:- +full:to +full:- +full:buffer
41 #include <libxml/uri.h>
120 * Convert errno to xmlParserErrors.
298 * @u8String: uft-8 string
300 * Convert a string from utf-8 to wchar (WINDOWS ONLY!)
311 -1, NULL, 0); in __xmlIOWin32UTF8ToWChar()
316 (CP_UTF8, 0, u8String, -1, wString, wLen) == 0) { in __xmlIOWin32UTF8ToWChar()
323 * Convert to backward slash in __xmlIOWin32UTF8ToWChar()
353 * @path: the path to check
414 xmlConvertUriToPath(const char *uri, char **out) { in xmlConvertUriToPath() argument
420 if (!xmlStrncasecmp(BAD_CAST uri, BAD_CAST "file://localhost/", 17)) { in xmlConvertUriToPath()
421 escaped = &uri[16]; in xmlConvertUriToPath()
422 } else if (!xmlStrncasecmp(BAD_CAST uri, BAD_CAST "file:///", 8)) { in xmlConvertUriToPath()
423 escaped = &uri[7]; in xmlConvertUriToPath()
424 } else if (!xmlStrncasecmp(BAD_CAST uri, BAD_CAST "file:/", 6)) { in xmlConvertUriToPath()
425 /* lots of generators seems to lazy to read RFC 1738 */ in xmlConvertUriToPath()
426 escaped = &uri[5]; in xmlConvertUriToPath()
438 return(-1); in xmlConvertUriToPath()
446 * @filename: the URI for matching
447 * @out: pointer to resulting context
458 *out = -1; in xmlFdOpen()
514 * @buffer: where to drop data
515 * @len: number of bytes to read
517 * Read @len bytes to @buffer from the I/O channel.
522 xmlFdRead(void *context, char *buffer, int len) { in xmlFdRead() argument
528 bytes = read(fd, buffer, len); in xmlFdRead()
536 return(-xmlIOErr(errno)); in xmlFdRead()
541 buffer += bytes; in xmlFdRead()
542 len -= bytes; in xmlFdRead()
552 * @buffer: where to get data
553 * @len: number of bytes to write
555 * Write @len bytes from @buffer to the I/O channel.
560 xmlFdWrite(void *context, const char *buffer, int len) { in xmlFdWrite() argument
566 bytes = write(fd, buffer, len); in xmlFdWrite()
568 return(-xmlIOErr(errno)); in xmlFdWrite()
570 buffer += bytes; in xmlFdWrite()
571 len -= bytes; in xmlFdWrite()
599 * @filename: the URI for matching
612 * @filename: the URI for matching
613 * @out: pointer to resulting context
660 * This error won't be forwarded to the parser context in xmlFileOpenSafe()
674 * @filename: the URI for matching
691 * @buffer: where to drop data
692 * @len: number of bytes to write
699 xmlFileRead(void * context, char * buffer, int len) { in xmlFileRead() argument
703 if ((context == NULL) || (buffer == NULL)) in xmlFileRead()
704 return(-1); in xmlFileRead()
709 * Set errno to zero which will be reported as unknown error in xmlFileRead()
713 bytes = fread(buffer, 1, len, file); in xmlFileRead()
715 return(-xmlIOErr(errno)); in xmlFileRead()
724 * @buffer: where to drop data
725 * @len: number of bytes to write
727 * Write @len bytes from @buffer to the I/O channel.
732 xmlFileWrite(void *context, const char *buffer, int len) { in xmlFileWrite() argument
736 if ((context == NULL) || (buffer == NULL)) in xmlFileWrite()
737 return(-1); in xmlFileWrite()
740 bytes = fwrite(buffer, 1, len, file); in xmlFileWrite()
742 return(-xmlIOErr(errno)); in xmlFileWrite()
759 return(-1); in xmlFileFlush()
773 * Returns 0 or -1 an error code case of error
780 return(-1); in xmlFileClose()
797 * @buffer: the data to write
798 * @len: number of bytes to write
800 * Write @len bytes from @buffer to the xml buffer
806 xmlBufferWrite (void * context, const char * buffer, int len) { in xmlBufferWrite() argument
809 ret = xmlBufferAdd((xmlBufferPtr) context, (const xmlChar *) buffer, len); in xmlBufferWrite()
811 return(-XML_ERR_NO_MEMORY); in xmlBufferWrite()
826 * @buffer: where to drop data
827 * @len: number of bytes to write
829 * Read @len bytes to @buffer from the compressed I/O channel.
834 xmlGzfileRead (void * context, char * buffer, int len) { in xmlGzfileRead() argument
837 ret = gzread((gzFile) context, &buffer[0], len); in xmlGzfileRead()
839 return(-XML_IO_UNKNOWN); in xmlGzfileRead()
847 * @buffer: where to drop data
848 * @len: number of bytes to write
850 * Write @len bytes from @buffer to the compressed I/O channel.
855 xmlGzfileWrite (void * context, const char * buffer, int len) { in xmlGzfileWrite() argument
858 ret = gzwrite((gzFile) context, (char *) &buffer[0], len); in xmlGzfileWrite()
860 return(-XML_IO_UNKNOWN); in xmlGzfileWrite()
892 * @buffer: where to drop data
893 * @len: number of bytes to write
895 * Read @len bytes to @buffer from the compressed I/O channel.
900 xmlXzfileRead (void * context, char * buffer, int len) { in xmlXzfileRead() argument
903 ret = __libxml2_xzread((xzFile) context, &buffer[0], len); in xmlXzfileRead()
905 return(-XML_IO_UNKNOWN); in xmlXzfileRead()
932 * @filename: the URI for matching
936 * check if the URI matches an HTTP one
949 * @filename: the URI for matching
965 * @post_uri: The destination URI for the document
983 * @buffer: where to drop data
984 * @len: number of bytes to write
988 * Read @len bytes to @buffer from the I/O channel.
993 xmlIOHTTPRead(void * context, char * buffer, int len) { in xmlIOHTTPRead() argument
994 if ((buffer == NULL) || (len < 0)) return(-1); in xmlIOHTTPRead()
995 return(xmlNanoHTTPRead(context, &buffer[0], len)); in xmlIOHTTPRead()
1028 * @buf: input buffer to be filled
1029 * @filename: filename or URI
1048 buf->context = xmlIOHTTPOpen(filename); in xmlInputDefaultOpen()
1050 if (buf->context != NULL) { in xmlInputDefaultOpen()
1051 buf->readcallback = xmlIOHTTPRead; in xmlInputDefaultOpen()
1052 buf->closecallback = xmlIOHTTPClose; in xmlInputDefaultOpen()
1075 buf->context = xzStream; in xmlInputDefaultOpen()
1076 buf->readcallback = xmlXzfileRead; in xmlInputDefaultOpen()
1077 buf->closecallback = xmlXzfileClose; in xmlInputDefaultOpen()
1078 buf->compressed = 1; in xmlInputDefaultOpen()
1107 buf->context = gzStream; in xmlInputDefaultOpen()
1108 buf->readcallback = xmlGzfileRead; in xmlInputDefaultOpen()
1109 buf->closecallback = xmlGzfileClose; in xmlInputDefaultOpen()
1110 buf->compressed = 1; in xmlInputDefaultOpen()
1124 buf->context = (void *) (ptrdiff_t) fd; in xmlInputDefaultOpen()
1125 buf->readcallback = xmlFdRead; in xmlInputDefaultOpen()
1126 buf->closecallback = xmlFdClose; in xmlInputDefaultOpen()
1133 * @buf: input buffer to be filled
1134 * @filename: filename or URI
1136 * @is_file_uri: whether filename is a file URI
1147 if (!strcmp(filename, "-")) { in xmlOutputDefaultOpen()
1173 buf->context = gzStream; in xmlOutputDefaultOpen()
1174 buf->writecallback = xmlGzfileWrite; in xmlOutputDefaultOpen()
1175 buf->closecallback = xmlGzfileClose; in xmlOutputDefaultOpen()
1181 buf->context = (void *) (ptrdiff_t) fd; in xmlOutputDefaultOpen()
1182 buf->writecallback = xmlFdWrite; in xmlOutputDefaultOpen()
1183 buf->closecallback = xmlFdClose; in xmlOutputDefaultOpen()
1194 * The encoding argument is deprecated and should be set to
1209 ret->buffer = xmlBufCreateSize(2 * xmlDefaultBufferSize); in xmlAllocParserInputBuffer()
1210 if (ret->buffer == NULL) { in xmlAllocParserInputBuffer()
1214 xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT); in xmlAllocParserInputBuffer()
1216 if (xmlLookupCharEncodingHandler(enc, &ret->encoder) != 0) { in xmlAllocParserInputBuffer()
1222 if (ret->encoder != NULL) in xmlAllocParserInputBuffer()
1223 ret->raw = xmlBufCreateSize(2 * xmlDefaultBufferSize); in xmlAllocParserInputBuffer()
1225 ret->raw = NULL; in xmlAllocParserInputBuffer()
1226 ret->readcallback = NULL; in xmlAllocParserInputBuffer()
1227 ret->closecallback = NULL; in xmlAllocParserInputBuffer()
1228 ret->context = NULL; in xmlAllocParserInputBuffer()
1229 ret->compressed = -1; in xmlAllocParserInputBuffer()
1230 ret->rawconsumed = 0; in xmlAllocParserInputBuffer()
1253 ret->buffer = xmlBufCreate(); in xmlAllocOutputBuffer()
1254 if (ret->buffer == NULL) { in xmlAllocOutputBuffer()
1258 xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_IO); in xmlAllocOutputBuffer()
1260 ret->encoder = encoder; in xmlAllocOutputBuffer()
1262 ret->conv = xmlBufCreateSize(4000); in xmlAllocOutputBuffer()
1263 if (ret->conv == NULL) { in xmlAllocOutputBuffer()
1264 xmlBufFree(ret->buffer); in xmlAllocOutputBuffer()
1270 * This call is designed to initiate the encoder state in xmlAllocOutputBuffer()
1274 ret->conv = NULL; in xmlAllocOutputBuffer()
1275 ret->writecallback = NULL; in xmlAllocOutputBuffer()
1276 ret->closecallback = NULL; in xmlAllocOutputBuffer()
1277 ret->context = NULL; in xmlAllocOutputBuffer()
1278 ret->written = 0; in xmlAllocOutputBuffer()
1300 ret->buffer = xmlBufCreate(); in xmlAllocOutputBufferInternal()
1301 if (ret->buffer == NULL) { in xmlAllocOutputBufferInternal()
1310 xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_IO); in xmlAllocOutputBufferInternal()
1312 ret->encoder = encoder; in xmlAllocOutputBufferInternal()
1314 ret->conv = xmlBufCreateSize(4000); in xmlAllocOutputBufferInternal()
1315 if (ret->conv == NULL) { in xmlAllocOutputBufferInternal()
1316 xmlBufFree(ret->buffer); in xmlAllocOutputBufferInternal()
1322 * This call is designed to initiate the encoder state in xmlAllocOutputBufferInternal()
1326 ret->conv = NULL; in xmlAllocOutputBufferInternal()
1327 ret->writecallback = NULL; in xmlAllocOutputBufferInternal()
1328 ret->closecallback = NULL; in xmlAllocOutputBufferInternal()
1329 ret->context = NULL; in xmlAllocOutputBufferInternal()
1330 ret->written = 0; in xmlAllocOutputBufferInternal()
1347 if (in->raw) { in xmlFreeParserInputBuffer()
1348 xmlBufFree(in->raw); in xmlFreeParserInputBuffer()
1349 in->raw = NULL; in xmlFreeParserInputBuffer()
1351 if (in->encoder != NULL) { in xmlFreeParserInputBuffer()
1352 xmlCharEncCloseFunc(in->encoder); in xmlFreeParserInputBuffer()
1354 if (in->closecallback != NULL) { in xmlFreeParserInputBuffer()
1355 in->closecallback(in->context); in xmlFreeParserInputBuffer()
1357 if (in->buffer != NULL) { in xmlFreeParserInputBuffer()
1358 xmlBufFree(in->buffer); in xmlFreeParserInputBuffer()
1359 in->buffer = NULL; in xmlFreeParserInputBuffer()
1382 return (-1); in xmlOutputBufferClose()
1384 if (out->writecallback != NULL) in xmlOutputBufferClose()
1387 if (out->closecallback != NULL) { in xmlOutputBufferClose()
1388 int code = out->closecallback(out->context); in xmlOutputBufferClose()
1390 if ((code != XML_ERR_OK) && (out->error == XML_ERR_OK)) { in xmlOutputBufferClose()
1392 out->error = XML_IO_UNKNOWN; in xmlOutputBufferClose()
1394 out->error = code; in xmlOutputBufferClose()
1398 if (out->error != XML_ERR_OK) in xmlOutputBufferClose()
1399 ret = -out->error; in xmlOutputBufferClose()
1401 ret = out->written; in xmlOutputBufferClose()
1403 if (out->conv) { in xmlOutputBufferClose()
1404 xmlBufFree(out->conv); in xmlOutputBufferClose()
1405 out->conv = NULL; in xmlOutputBufferClose()
1407 if (out->encoder != NULL) { in xmlOutputBufferClose()
1408 xmlCharEncCloseFunc(out->encoder); in xmlOutputBufferClose()
1410 if (out->buffer != NULL) { in xmlOutputBufferClose()
1411 xmlBufFree(out->buffer); in xmlOutputBufferClose()
1412 out->buffer = NULL; in xmlOutputBufferClose()
1423 * @URI: the filename or URI
1426 * @out: pointer to resulting input buffer
1431 xmlParserInputBufferCreateUrl(const char *URI, xmlCharEncoding enc, in xmlParserInputBufferCreateUrl() argument
1438 if (URI == NULL) in xmlParserInputBufferCreateUrl()
1442 * Allocate the Input buffer front-end. in xmlParserInputBufferCreateUrl()
1449 * Try to find one of the input accept method accepting that scheme in xmlParserInputBufferCreateUrl()
1450 * Go in reverse to give precedence to user defined handlers. in xmlParserInputBufferCreateUrl()
1453 for (i = xmlInputCallbackNr - 1; i >= 0; i--) { in xmlParserInputBufferCreateUrl()
1456 if (cb->matchcallback == xmlIODefaultMatch) { in xmlParserInputBufferCreateUrl()
1457 ret = xmlInputDefaultOpen(buf, URI, flags); in xmlParserInputBufferCreateUrl()
1461 } else if ((cb->matchcallback != NULL) && in xmlParserInputBufferCreateUrl()
1462 (cb->matchcallback(URI) != 0)) { in xmlParserInputBufferCreateUrl()
1463 buf->context = cb->opencallback(URI); in xmlParserInputBufferCreateUrl()
1464 if (buf->context != NULL) { in xmlParserInputBufferCreateUrl()
1465 buf->readcallback = cb->readcallback; in xmlParserInputBufferCreateUrl()
1466 buf->closecallback = cb->closecallback; in xmlParserInputBufferCreateUrl()
1483 __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { in __xmlParserInputBufferCreateFilename() argument
1486 xmlParserInputBufferCreateUrl(URI, enc, 0, &ret); in __xmlParserInputBufferCreateFilename()
1492 * @URI: a C string containing the URI or filename
1497 * by default if found at compile-time.
1503 xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { in xmlParserInputBufferCreateFilename() argument
1507 return(xmlParserInputBufferCreateFilenameValue(URI, enc)); in xmlParserInputBufferCreateFilename()
1509 xmlParserInputBufferCreateUrl(URI, enc, 0, &ret); in xmlParserInputBufferCreateFilename()
1515 __xmlOutputBufferCreateFilename(const char *URI, in __xmlOutputBufferCreateFilename() argument
1523 if (URI == NULL) in __xmlOutputBufferCreateFilename()
1526 puri = xmlParseURI(URI); in __xmlOutputBufferCreateFilename()
1529 * try to limit the damages of the URI unescaping code. in __xmlOutputBufferCreateFilename()
1531 if (puri->scheme == NULL) { in __xmlOutputBufferCreateFilename()
1532 unescaped = xmlURIUnescapeString(URI, 0, NULL); in __xmlOutputBufferCreateFilename()
1537 URI = unescaped; in __xmlOutputBufferCreateFilename()
1543 * Allocate the Output buffer front-end. in __xmlOutputBufferCreateFilename()
1552 * Try to find one of the output accept method accepting that scheme in __xmlOutputBufferCreateFilename()
1553 * Go in reverse to give precedence to user defined handlers. in __xmlOutputBufferCreateFilename()
1555 for (i = xmlOutputCallbackNr - 1; i >= 0; i--) { in __xmlOutputBufferCreateFilename()
1559 if (cb->matchcallback == xmlIODefaultMatch) { in __xmlOutputBufferCreateFilename()
1560 code = xmlOutputDefaultOpen(ret, URI, compression); in __xmlOutputBufferCreateFilename()
1564 } else if ((cb->matchcallback != NULL) && in __xmlOutputBufferCreateFilename()
1565 (cb->matchcallback(URI) != 0)) { in __xmlOutputBufferCreateFilename()
1566 ret->context = cb->opencallback(URI); in __xmlOutputBufferCreateFilename()
1567 if (ret->context != NULL) { in __xmlOutputBufferCreateFilename()
1568 ret->writecallback = cb->writecallback; in __xmlOutputBufferCreateFilename()
1569 ret->closecallback = cb->closecallback; in __xmlOutputBufferCreateFilename()
1575 if (ret->context == NULL) { in __xmlOutputBufferCreateFilename()
1586 * @URI: a C string containing the URI or filename
1591 * If filename is "-' then we use stdout as the output.
1593 * by default if found at compile-time.
1595 * writing to a local file.
1600 xmlOutputBufferCreateFilename(const char *URI, in xmlOutputBufferCreateFilename() argument
1604 return xmlOutputBufferCreateFilenameValue(URI, encoder, compression); in xmlOutputBufferCreateFilename()
1606 return __xmlOutputBufferCreateFilename(URI, encoder, compression); in xmlOutputBufferCreateFilename()
1618 * The encoding argument is deprecated and should be set to
1632 ret->context = file; in xmlParserInputBufferCreateFile()
1633 ret->readcallback = xmlFileRead; in xmlParserInputBufferCreateFile()
1634 ret->closecallback = NULL; in xmlParserInputBufferCreateFile()
1646 * Create a buffered output for the progressive saving to a FILE *
1659 ret->context = file; in xmlOutputBufferCreateFile()
1660 ret->writecallback = xmlFileWrite; in xmlOutputBufferCreateFile()
1661 ret->closecallback = xmlFileFlush; in xmlOutputBufferCreateFile()
1669 * @buffer: a xmlBufferPtr
1672 * Create a buffered output for the progressive saving to a xmlBuffer
1677 xmlOutputBufferCreateBuffer(xmlBufferPtr buffer, in xmlOutputBufferCreateBuffer() argument
1681 if (buffer == NULL) return(NULL); in xmlOutputBufferCreateBuffer()
1683 ret = xmlOutputBufferCreateIO(xmlBufferWrite, NULL, (void *) buffer, in xmlOutputBufferCreateBuffer()
1693 * Gives a pointer to the data currently held in the output buffer
1695 * Returns a pointer to the data or NULL in case of error
1699 if ((out == NULL) || (out->buffer == NULL) || (out->error != 0)) in xmlOutputBufferGetContent()
1702 return(xmlBufContent(out->buffer)); in xmlOutputBufferGetContent()
1709 * Gives the length of the data currently held in the output buffer
1711 * Returns 0 in case or error or no data is held, the size otherwise
1715 if ((out == NULL) || (out->buffer == NULL) || (out->error != 0)) in xmlOutputBufferGetSize()
1718 return(xmlBufUse(out->buffer)); in xmlOutputBufferGetSize()
1732 * The encoding argument is deprecated and should be set to
1746 ret->context = (void *) (ptrdiff_t) fd; in xmlParserInputBufferCreateFd()
1747 ret->readcallback = xmlFdRead; in xmlParserInputBufferCreateFd()
1763 if ((size_t) size > ctxt->size) in xmlMemRead()
1764 size = ctxt->size; in xmlMemRead()
1766 memcpy(buf, ctxt->cur, size); in xmlMemRead()
1767 ctxt->cur += size; in xmlMemRead()
1768 ctxt->size -= size; in xmlMemRead()
1777 if (ctxt->mem != NULL) in xmlMemClose()
1778 xmlFree(ctxt->mem); in xmlMemClose()
1785 * @mem: memory buffer
1786 * @size: size of buffer
1790 * Create an input buffer for memory.
1792 * Returns the new input buffer or NULL.
1826 ctxt->mem = copy; in xmlNewInputBufferMemory()
1827 ctxt->cur = mem; in xmlNewInputBufferMemory()
1828 ctxt->size = size; in xmlNewInputBufferMemory()
1830 ret->context = ctxt; in xmlNewInputBufferMemory()
1831 ret->readcallback = xmlMemRead; in xmlNewInputBufferMemory()
1832 ret->closecallback = xmlMemClose; in xmlNewInputBufferMemory()
1843 * Create a parser input buffer for parsing from a memory area.
1845 * This function makes a copy of the whole input buffer. If you are sure
1846 * that the contents of the buffer will remain valid until the document
1850 * The encoding argument is deprecated and should be set to
1870 * Create a parser input buffer for parsing from a memory area.
1872 * This functions assumes that the contents of the input buffer remain
1876 * The encoding argument is deprecated and should be set to
1901 zero = memchr(ctxt->str, 0, size); in xmlStringRead()
1902 len = zero ? zero - ctxt->str : size; in xmlStringRead()
1904 memcpy(buf, ctxt->str, len); in xmlStringRead()
1905 ctxt->str += len; in xmlStringRead()
1921 * Create an input buffer for a null-teriminated C string.
1923 * Returns the new input buffer or NULL.
1944 ctxt->str = str; in xmlNewInputBufferString()
1946 ret->context = ctxt; in xmlNewInputBufferString()
1947 ret->readcallback = xmlStringRead; in xmlNewInputBufferString()
1948 ret->closecallback = xmlStringClose; in xmlNewInputBufferString()
1960 * to a file descriptor
1972 ret->context = (void *) (ptrdiff_t) fd; in xmlOutputBufferCreateFd()
1973 ret->writecallback = xmlFdWrite; in xmlOutputBufferCreateFd()
1974 ret->closecallback = NULL; in xmlOutputBufferCreateFd()
1991 * The encoding argument is deprecated and should be set to
2006 ret->context = (void *) ioctx; in xmlParserInputBufferCreateIO()
2007 ret->readcallback = ioread; in xmlParserInputBufferCreateIO()
2008 ret->closecallback = ioclose; in xmlParserInputBufferCreateIO()
2023 * to an I/O handler
2037 ret->context = (void *) ioctx; in xmlOutputBufferCreateIO()
2038 ret->writecallback = iowrite; in xmlOutputBufferCreateIO()
2039 ret->closecallback = ioclose; in xmlOutputBufferCreateIO()
2048 * @func: function pointer to the new ParserInputBufferCreateFilenameFunc
2052 * Registers a callback for URI input file handling
2074 * @func: function pointer to the new OutputBufferCreateFilenameFunc
2076 * Registers a callback for URI output file handling
2099 * Push the content of the arry in the input buffer
2100 * This routine handle the I18N transcoding to internal UTF-8
2103 * Returns the number of chars read and stored in the buffer, or -1
2113 if ((in == NULL) || (in->error)) return(-1); in xmlParserInputBufferPush()
2114 if (in->encoder != NULL) { in xmlParserInputBufferPush()
2116 * Store the data in the incoming raw buffer in xmlParserInputBufferPush()
2118 if (in->raw == NULL) { in xmlParserInputBufferPush()
2119 in->raw = xmlBufCreate(); in xmlParserInputBufferPush()
2120 if (in->raw == NULL) { in xmlParserInputBufferPush()
2121 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferPush()
2122 return(-1); in xmlParserInputBufferPush()
2125 ret = xmlBufAdd(in->raw, (const xmlChar *) buf, len); in xmlParserInputBufferPush()
2127 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferPush()
2128 return(-1); in xmlParserInputBufferPush()
2132 * convert as much as possible to the parser reading buffer. in xmlParserInputBufferPush()
2136 return(-1); in xmlParserInputBufferPush()
2139 ret = xmlBufAdd(in->buffer, (xmlChar *) buf, nbchars); in xmlParserInputBufferPush()
2141 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferPush()
2142 return(-1); in xmlParserInputBufferPush()
2156 char * buffer ATTRIBUTE_UNUSED, in endOfInput()
2164 * @len: indicative value of the amount of chars to read
2166 * Grow up the content of the input buffer, the old data are preserved
2167 * This routine handle the I18N transcoding to internal UTF-8
2170 * TODO: one should be able to remove one extra copy by copying directly
2171 * onto in->buffer or in->raw
2173 * Returns the number of chars read and stored in the buffer, or -1
2181 if ((in == NULL) || (in->error)) return(-1); in xmlParserInputBufferGrow()
2185 if (in->encoder == NULL) { in xmlParserInputBufferGrow()
2186 if (in->readcallback == NULL) in xmlParserInputBufferGrow()
2188 buf = in->buffer; in xmlParserInputBufferGrow()
2190 if (in->raw == NULL) { in xmlParserInputBufferGrow()
2191 in->raw = xmlBufCreate(); in xmlParserInputBufferGrow()
2193 buf = in->raw; in xmlParserInputBufferGrow()
2199 if (in->readcallback != NULL) { in xmlParserInputBufferGrow()
2201 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferGrow()
2202 return(-1); in xmlParserInputBufferGrow()
2205 res = in->readcallback(in->context, (char *)xmlBufEnd(buf), len); in xmlParserInputBufferGrow()
2207 in->readcallback = endOfInput; in xmlParserInputBufferGrow()
2209 if (res == -1) in xmlParserInputBufferGrow()
2210 in->error = XML_IO_UNKNOWN; in xmlParserInputBufferGrow()
2212 in->error = -res; in xmlParserInputBufferGrow()
2213 return(-1); in xmlParserInputBufferGrow()
2217 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferGrow()
2218 return(-1); in xmlParserInputBufferGrow()
2223 * try to establish compressed status of input if not done already in xmlParserInputBufferGrow()
2225 if (in->compressed == -1) { in xmlParserInputBufferGrow()
2227 if (in->readcallback == xmlXzfileRead) in xmlParserInputBufferGrow()
2228 in->compressed = __libxml2_xzcompressed(in->context); in xmlParserInputBufferGrow()
2232 if (in->encoder != NULL) { in xmlParserInputBufferGrow()
2235 return(-1); in xmlParserInputBufferGrow()
2243 * @len: indicative value of the amount of chars to read
2245 * Refresh the content of the input buffer, the old data are considered
2247 * This routine handle the I18N transcoding to internal UTF-8
2249 * Returns the number of chars read and stored in the buffer, or -1
2264 * Write the content of the array in the output I/O buffer
2265 * This routine handle the I18N transcoding from internal UTF-8
2266 * The buffer is lossless, i.e. will store in case of partial
2269 * Returns the number of chars immediately written, or -1
2274 int nbchars = 0; /* number of chars to output to I/O */ in xmlOutputBufferWrite()
2276 int written = 0; /* number of char written to I/O so far */ in xmlOutputBufferWrite()
2279 if ((out == NULL) || (out->error)) return(-1); in xmlOutputBufferWrite()
2281 if (out->error) return(-1); in xmlOutputBufferWrite()
2291 if (out->encoder != NULL) { in xmlOutputBufferWrite()
2293 * Store the data in the incoming raw buffer in xmlOutputBufferWrite()
2295 if (out->conv == NULL) { in xmlOutputBufferWrite()
2296 out->conv = xmlBufCreate(); in xmlOutputBufferWrite()
2297 if (out->conv == NULL) { in xmlOutputBufferWrite()
2298 out->error = XML_ERR_NO_MEMORY; in xmlOutputBufferWrite()
2299 return(-1); in xmlOutputBufferWrite()
2302 ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk); in xmlOutputBufferWrite()
2304 out->error = XML_ERR_NO_MEMORY; in xmlOutputBufferWrite()
2305 return(-1); in xmlOutputBufferWrite()
2308 if ((xmlBufUse(out->buffer) < MINLEN) && (chunk == len)) in xmlOutputBufferWrite()
2312 * convert as much as possible to the parser reading buffer. in xmlOutputBufferWrite()
2316 return(-1); in xmlOutputBufferWrite()
2317 if (out->writecallback) in xmlOutputBufferWrite()
2318 nbchars = xmlBufUse(out->conv); in xmlOutputBufferWrite()
2322 ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk); in xmlOutputBufferWrite()
2324 out->error = XML_ERR_NO_MEMORY; in xmlOutputBufferWrite()
2325 return(-1); in xmlOutputBufferWrite()
2327 if (out->writecallback) in xmlOutputBufferWrite()
2328 nbchars = xmlBufUse(out->buffer); in xmlOutputBufferWrite()
2333 len -= chunk; in xmlOutputBufferWrite()
2335 if (out->writecallback) { in xmlOutputBufferWrite()
2340 * second write the stuff to the I/O channel in xmlOutputBufferWrite()
2342 if (out->encoder != NULL) { in xmlOutputBufferWrite()
2343 ret = out->writecallback(out->context, in xmlOutputBufferWrite()
2344 (const char *)xmlBufContent(out->conv), nbchars); in xmlOutputBufferWrite()
2346 xmlBufShrink(out->conv, ret); in xmlOutputBufferWrite()
2348 ret = out->writecallback(out->context, in xmlOutputBufferWrite()
2349 (const char *)xmlBufContent(out->buffer), nbchars); in xmlOutputBufferWrite()
2351 xmlBufShrink(out->buffer, ret); in xmlOutputBufferWrite()
2354 out->error = (ret == -1) ? XML_IO_WRITE : -ret; in xmlOutputBufferWrite()
2357 if (out->written > INT_MAX - ret) in xmlOutputBufferWrite()
2358 out->written = INT_MAX; in xmlOutputBufferWrite()
2360 out->written += ret; in xmlOutputBufferWrite()
2371 * @out: a pointer to an array of bytes to store the result
2373 * @in: a pointer to an array of unescaped UTF-8 bytes
2376 * Take a block of UTF-8 chars in and escape them.
2377 * Returns 0 if success, or -1 otherwise
2394 if (outend - out < 4) break; in xmlEscapeContent()
2400 if (outend - out < 4) break; in xmlEscapeContent()
2406 if (outend - out < 5) break; in xmlEscapeContent()
2413 if (outend - out < 5) break; in xmlEscapeContent()
2424 *outlen = out - outstart; in xmlEscapeContent()
2425 *inlen = in - base; in xmlEscapeContent()
2432 * @str: a zero terminated UTF-8 string
2435 * Write the content of the string in the output I/O buffer
2437 * transcoding from internal UTF-8
2438 * The buffer is lossless, i.e. will store in case of partial
2441 * Returns the number of chars immediately written, or -1
2447 int nbchars = 0; /* number of chars to output to I/O */ in xmlOutputBufferWriteEscape()
2449 int written = 0; /* number of char written to I/O so far */ in xmlOutputBufferWriteEscape()
2455 if ((out == NULL) || (out->error) || (str == NULL) || in xmlOutputBufferWriteEscape()
2456 (out->buffer == NULL)) in xmlOutputBufferWriteEscape()
2457 return(-1); in xmlOutputBufferWriteEscape()
2460 if (out->error) return(-1); in xmlOutputBufferWriteEscape()
2467 * how many bytes to consume and how many bytes to store. in xmlOutputBufferWriteEscape()
2470 chunk = xmlBufAvail(out->buffer); in xmlOutputBufferWriteEscape()
2473 * make sure we have enough room to save first, if this is in xmlOutputBufferWriteEscape()
2477 if (xmlBufGrow(out->buffer, 100) < 0) { in xmlOutputBufferWriteEscape()
2478 out->error = XML_ERR_NO_MEMORY; in xmlOutputBufferWriteEscape()
2479 return(-1); in xmlOutputBufferWriteEscape()
2481 oldwritten = -1; in xmlOutputBufferWriteEscape()
2488 if (out->encoder != NULL) { in xmlOutputBufferWriteEscape()
2490 * Store the data in the incoming raw buffer in xmlOutputBufferWriteEscape()
2492 if (out->conv == NULL) { in xmlOutputBufferWriteEscape()
2493 out->conv = xmlBufCreate(); in xmlOutputBufferWriteEscape()
2494 if (out->conv == NULL) { in xmlOutputBufferWriteEscape()
2495 out->error = XML_ERR_NO_MEMORY; in xmlOutputBufferWriteEscape()
2496 return(-1); in xmlOutputBufferWriteEscape()
2499 ret = escaping(xmlBufEnd(out->buffer) , in xmlOutputBufferWriteEscape()
2502 out->error = XML_ERR_NO_MEMORY; in xmlOutputBufferWriteEscape()
2503 return(-1); in xmlOutputBufferWriteEscape()
2505 xmlBufAddLen(out->buffer, chunk); in xmlOutputBufferWriteEscape()
2507 if ((xmlBufUse(out->buffer) < MINLEN) && (cons == len)) in xmlOutputBufferWriteEscape()
2511 * convert as much as possible to the output buffer. in xmlOutputBufferWriteEscape()
2515 return(-1); in xmlOutputBufferWriteEscape()
2516 if (out->writecallback) in xmlOutputBufferWriteEscape()
2517 nbchars = xmlBufUse(out->conv); in xmlOutputBufferWriteEscape()
2521 ret = escaping(xmlBufEnd(out->buffer), &chunk, str, &cons); in xmlOutputBufferWriteEscape()
2523 out->error = XML_ERR_NO_MEMORY; in xmlOutputBufferWriteEscape()
2524 return(-1); in xmlOutputBufferWriteEscape()
2526 xmlBufAddLen(out->buffer, chunk); in xmlOutputBufferWriteEscape()
2527 if (out->writecallback) in xmlOutputBufferWriteEscape()
2528 nbchars = xmlBufUse(out->buffer); in xmlOutputBufferWriteEscape()
2533 len -= cons; in xmlOutputBufferWriteEscape()
2535 if (out->writecallback) { in xmlOutputBufferWriteEscape()
2540 * second write the stuff to the I/O channel in xmlOutputBufferWriteEscape()
2542 if (out->encoder != NULL) { in xmlOutputBufferWriteEscape()
2543 ret = out->writecallback(out->context, in xmlOutputBufferWriteEscape()
2544 (const char *)xmlBufContent(out->conv), nbchars); in xmlOutputBufferWriteEscape()
2546 xmlBufShrink(out->conv, ret); in xmlOutputBufferWriteEscape()
2548 ret = out->writecallback(out->context, in xmlOutputBufferWriteEscape()
2549 (const char *)xmlBufContent(out->buffer), nbchars); in xmlOutputBufferWriteEscape()
2551 xmlBufShrink(out->buffer, ret); in xmlOutputBufferWriteEscape()
2554 out->error = (ret == -1) ? XML_IO_WRITE : -ret; in xmlOutputBufferWriteEscape()
2555 return(-1); in xmlOutputBufferWriteEscape()
2557 if (out->written > INT_MAX - ret) in xmlOutputBufferWriteEscape()
2558 out->written = INT_MAX; in xmlOutputBufferWriteEscape()
2560 out->written += ret; in xmlOutputBufferWriteEscape()
2561 } else if (xmlBufAvail(out->buffer) < MINLEN) { in xmlOutputBufferWriteEscape()
2562 if (xmlBufGrow(out->buffer, MINLEN) < 0) { in xmlOutputBufferWriteEscape()
2563 out->error = XML_ERR_NO_MEMORY; in xmlOutputBufferWriteEscape()
2564 return(-1); in xmlOutputBufferWriteEscape()
2579 * Write the content of the string in the output I/O buffer
2580 * This routine handle the I18N transcoding from internal UTF-8
2581 * The buffer is lossless, i.e. will store in case of partial
2584 * Returns the number of chars immediately written, or -1
2591 if ((out == NULL) || (out->error)) return(-1); in xmlOutputBufferWriteString()
2593 return(-1); in xmlOutputBufferWriteString()
2603 * @buf: output buffer
2604 * @string: the string to add
2606 * routine which manage and grows an output buffer. This one writes
2608 * quote or double-quotes internally
2615 if ((buf == NULL) || (buf->error)) in xmlOutputBufferWriteQuotedString()
2625 xmlOutputBufferWrite(buf, cur - base, in xmlOutputBufferWriteQuotedString()
2636 xmlOutputBufferWrite(buf, cur - base, (const char *) base); in xmlOutputBufferWriteQuotedString()
2657 * Returns the number of byte written or -1 in case of error.
2663 if ((out == NULL) || (out->error)) return(-1); in xmlOutputBufferFlush()
2667 if ((out->conv != NULL) && (out->encoder != NULL)) { in xmlOutputBufferFlush()
2669 * convert as much as possible to the parser output buffer. in xmlOutputBufferFlush()
2674 return(-1); in xmlOutputBufferFlush()
2679 * second flush the stuff to the I/O channel in xmlOutputBufferFlush()
2681 if ((out->conv != NULL) && (out->encoder != NULL) && in xmlOutputBufferFlush()
2682 (out->writecallback != NULL)) { in xmlOutputBufferFlush()
2683 ret = out->writecallback(out->context, in xmlOutputBufferFlush()
2684 (const char *)xmlBufContent(out->conv), in xmlOutputBufferFlush()
2685 xmlBufUse(out->conv)); in xmlOutputBufferFlush()
2687 xmlBufShrink(out->conv, ret); in xmlOutputBufferFlush()
2688 } else if (out->writecallback != NULL) { in xmlOutputBufferFlush()
2689 ret = out->writecallback(out->context, in xmlOutputBufferFlush()
2690 (const char *)xmlBufContent(out->buffer), in xmlOutputBufferFlush()
2691 xmlBufUse(out->buffer)); in xmlOutputBufferFlush()
2693 xmlBufShrink(out->buffer, ret); in xmlOutputBufferFlush()
2696 out->error = (ret == -1) ? XML_IO_WRITE : -ret; in xmlOutputBufferFlush()
2699 if (out->written > INT_MAX - ret) in xmlOutputBufferFlush()
2700 out->written = INT_MAX; in xmlOutputBufferFlush()
2702 out->written += ret; in xmlOutputBufferFlush()
2710 * @filename: the path to a file
2735 cur --; in xmlParserGetDirectory()
2753 * @filename: the path to check
2815 * Returns the registered handler number or -1 in case of error
2822 return(-1); in xmlRegisterInputCallbacks()
2834 * Registers the default compiled-in I/O handlers.
2845 * compiled-in I/O.
2847 * Returns the number of input callback registered or -1 in case of error.
2853 return(-1); in xmlPopInputCallbacks()
2855 xmlInputCallbackNr--; in xmlPopInputCallbacks()
2864 * compiled-in I/O.
2882 * Returns the registered handler number or -1 in case of error
2889 return(-1); in xmlRegisterOutputCallbacks()
2901 * Registers the default compiled-in I/O handlers.
2912 * compiled-in I/O.
2914 * Returns the number of output callback registered or -1 in case of error.
2920 return(-1); in xmlPopOutputCallbacks()
2922 xmlOutputCallbackNr--; in xmlPopOutputCallbacks()
2931 * compiled-in I/O callbacks.