Lines Matching +full:out +full:- +full:null
8 * 14 Nov 2000 ht - for VMS, truncated name of long functions to under 32 char
154 "Read-only file system", /* EROFS */
157 "Operation timed out", /* ETIMEDOUT */
178 * @u8String: uft-8 string
180 * Convert a string from utf-8 to wchar (WINDOWS ONLY!)
185 wchar_t *wString = NULL; in __xmlIOWin32UTF8ToWChar()
190 -1, NULL, 0); in __xmlIOWin32UTF8ToWChar()
195 (CP_UTF8, 0, u8String, -1, wString, wLen) == 0) { in __xmlIOWin32UTF8ToWChar()
197 wString = NULL; in __xmlIOWin32UTF8ToWChar()
212 * Handle an out of memory condition
217 __xmlSimpleError(XML_FROM_IO, XML_ERR_NO_MEMORY, NULL, NULL, extra); in xmlIOErrMemory()
392 if (code >= XML_IO_UNKNOWN) idx = code - XML_IO_UNKNOWN; in __xmlIOErr()
395 __xmlSimpleError(domain, code, NULL, IOerr[idx], extra); in __xmlIOErr()
422 xmlStructuredErrorFunc schannel = NULL; in __xmlLoaderErr()
423 xmlGenericErrorFunc channel = NULL; in __xmlLoaderErr()
424 void *data = NULL; in __xmlLoaderErr()
427 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && in __xmlLoaderErr()
428 (ctxt->instate == XML_PARSER_EOF)) in __xmlLoaderErr()
430 if ((ctxt != NULL) && (ctxt->sax != NULL)) { in __xmlLoaderErr()
431 if (ctxt->validate) { in __xmlLoaderErr()
432 channel = ctxt->sax->error; in __xmlLoaderErr()
435 channel = ctxt->sax->warning; in __xmlLoaderErr()
438 if (ctxt->sax->initialized == XML_SAX2_MAGIC) in __xmlLoaderErr()
439 schannel = ctxt->sax->serror; in __xmlLoaderErr()
440 data = ctxt->userData; in __xmlLoaderErr()
442 __xmlRaiseError(schannel, channel, data, ctxt, NULL, XML_FROM_IO, in __xmlLoaderErr()
443 XML_IO_LOAD_ERROR, level, NULL, 0, in __xmlLoaderErr()
444 filename, NULL, NULL, 0, 0, in __xmlLoaderErr()
473 * compiled-in I/O.
483 for (i = xmlInputCallbackNr - 1; i >= 0; i--) { in xmlCleanupInputCallbacks()
484 xmlInputCallbackTable[i].matchcallback = NULL; in xmlCleanupInputCallbacks()
485 xmlInputCallbackTable[i].opencallback = NULL; in xmlCleanupInputCallbacks()
486 xmlInputCallbackTable[i].readcallback = NULL; in xmlCleanupInputCallbacks()
487 xmlInputCallbackTable[i].closecallback = NULL; in xmlCleanupInputCallbacks()
498 * compiled-in I/O.
500 * Returns the number of input callback registered or -1 in case of error.
506 return(-1); in xmlPopInputCallbacks()
509 return(-1); in xmlPopInputCallbacks()
511 xmlInputCallbackNr--; in xmlPopInputCallbacks()
512 xmlInputCallbackTable[xmlInputCallbackNr].matchcallback = NULL; in xmlPopInputCallbacks()
513 xmlInputCallbackTable[xmlInputCallbackNr].opencallback = NULL; in xmlPopInputCallbacks()
514 xmlInputCallbackTable[xmlInputCallbackNr].readcallback = NULL; in xmlPopInputCallbacks()
515 xmlInputCallbackTable[xmlInputCallbackNr].closecallback = NULL; in xmlPopInputCallbacks()
525 * compiled-in I/O callbacks.
535 for (i = xmlOutputCallbackNr - 1; i >= 0; i--) { in xmlCleanupOutputCallbacks()
536 xmlOutputCallbackTable[i].matchcallback = NULL; in xmlCleanupOutputCallbacks()
537 xmlOutputCallbackTable[i].opencallback = NULL; in xmlCleanupOutputCallbacks()
538 xmlOutputCallbackTable[i].writecallback = NULL; in xmlCleanupOutputCallbacks()
539 xmlOutputCallbackTable[i].closecallback = NULL; in xmlCleanupOutputCallbacks()
550 * compiled-in I/O.
552 * Returns the number of output callback registered or -1 in case of error.
558 return(-1); in xmlPopOutputCallbacks()
561 return(-1); in xmlPopOutputCallbacks()
563 xmlOutputCallbackNr--; in xmlPopOutputCallbacks()
564 xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback = NULL; in xmlPopOutputCallbacks()
565 xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback = NULL; in xmlPopOutputCallbacks()
566 xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback = NULL; in xmlPopOutputCallbacks()
567 xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback = NULL; in xmlPopOutputCallbacks()
584 * @path: the path in utf-8 encoding
585 * @mode: type of access (0 - read, 1 - write)
593 FILE *fd = NULL; in xmlWrapOpenUtf8()
603 if(fd == NULL) in xmlWrapOpenUtf8()
639 * @path: the path in utf-8 encoding
647 int retval = -1; in xmlWrapStatUtf8()
687 if (path == NULL) in xmlCheckFilename()
700 if (xmlWrapStatUtf8(path, &stat_buffer) == -1) in xmlCheckFilename()
703 if (stat(path, &stat_buffer) == -1) in xmlCheckFilename()
792 * Returns an I/O context or NULL in case of error
799 if (filename == NULL) in xmlFileOpen_real()
800 return(NULL); in xmlFileOpen_real()
802 if (!strcmp(filename, "-")) { in xmlFileOpen_real()
831 return(NULL); in xmlFileOpen_real()
839 if (fd == NULL) xmlIOErr(0, path); in xmlFileOpen_real()
850 * Returns a handler or NULL in case or failure
858 if (retval == NULL) { in xmlFileOpen()
859 unescaped = xmlURIUnescapeString(filename, 0, NULL); in xmlFileOpen()
860 if (unescaped != NULL) { in xmlFileOpen()
875 * if @filename is "-" then the standard output is used
877 * Returns an I/O context or NULL in case of error
881 const char *path = NULL; in xmlFileOpenW()
884 if (!strcmp(filename, "-")) { in xmlFileOpenW()
904 if (path == NULL) in xmlFileOpenW()
905 return(NULL); in xmlFileOpenW()
915 if (fd == NULL) xmlIOErr(0, path); in xmlFileOpenW()
933 if ((context == NULL) || (buffer == NULL)) in xmlFileRead()
934 return(-1); in xmlFileRead()
955 if ((context == NULL) || (buffer == NULL)) in xmlFileWrite()
956 return(-1); in xmlFileWrite()
960 return(-1); in xmlFileWrite()
972 * Returns 0 or -1 in case of error
979 if (context == NULL) in xmlFileClose()
980 return(-1); in xmlFileClose()
990 ret = ( fclose((FILE *) context) == EOF ) ? -1 : 0; in xmlFileClose()
1006 if (context == NULL) in xmlFileFlush()
1007 return(-1); in xmlFileFlush()
1008 ret = ( fflush((FILE *) context) == EOF ) ? -1 : 0; in xmlFileFlush()
1031 return(-1); in xmlBufferWrite()
1062 * Returns an I/O context or NULL in case of error
1066 const char *path = NULL; in xmlGzfileOpen_real()
1069 if (!strcmp(filename, "-")) { in xmlGzfileOpen_real()
1094 if (path == NULL) in xmlGzfileOpen_real()
1095 return(NULL); in xmlGzfileOpen_real()
1097 return(NULL); in xmlGzfileOpen_real()
1120 if (retval == NULL) { in xmlGzfileOpen()
1121 unescaped = xmlURIUnescapeString(filename, 0, NULL); in xmlGzfileOpen()
1122 if (unescaped != NULL) { in xmlGzfileOpen()
1134 * @compression: the compression factor (0 - 9 included)
1139 * Returns an I/O context or NULL in case of error
1143 const char *path = NULL; in xmlGzfileOpenW()
1148 if (!strcmp(filename, "-")) { in xmlGzfileOpenW()
1173 if (path == NULL) in xmlGzfileOpenW()
1174 return(NULL); in xmlGzfileOpenW()
1235 ret = (gzclose((gzFile) context) == Z_OK ) ? 0 : -1; in xmlGzfileClose()
1268 * Returns an I/O context or NULL in case of error
1272 const char *path = NULL; in xmlXzfileOpen_real()
1275 if (!strcmp(filename, "-")) { in xmlXzfileOpen_real()
1290 if (path == NULL) in xmlXzfileOpen_real()
1291 return(NULL); in xmlXzfileOpen_real()
1293 return(NULL); in xmlXzfileOpen_real()
1306 * Returns a handler or NULL in case or failure
1314 if (retval == NULL) { in xmlXzfileOpen()
1315 unescaped = xmlURIUnescapeString(filename, 0, NULL); in xmlXzfileOpen()
1316 if (unescaped != NULL) { in xmlXzfileOpen()
1354 ret = (__libxml2_xzclose((xzFile) context) == LZMA_OK ) ? 0 : -1; in xmlXzfileClose()
1380 #define DFLT_WBITS ( -15 )
1416 if ( buff == NULL ) in append_reverse_ulong()
1427 *buff->zctrl.next_out = ( data & 0xff ); in append_reverse_ulong()
1429 buff->zctrl.next_out++; in append_reverse_ulong()
1445 if ( buff == NULL ) in xmlFreeZMemBuff()
1448 xmlFree( buff->zbuff ); in xmlFreeZMemBuff()
1449 deflateEnd( &buff->zctrl ); in xmlFreeZMemBuff()
1470 xmlZMemBuffPtr buff = NULL; in xmlCreateZMemBuff()
1473 return ( NULL ); in xmlCreateZMemBuff()
1478 if ( buff == NULL ) { in xmlCreateZMemBuff()
1480 return ( NULL ); in xmlCreateZMemBuff()
1484 buff->size = INIT_HTTP_BUFF_SIZE; in xmlCreateZMemBuff()
1485 buff->zbuff = xmlMalloc( buff->size ); in xmlCreateZMemBuff()
1486 if ( buff->zbuff == NULL ) { in xmlCreateZMemBuff()
1489 return ( NULL ); in xmlCreateZMemBuff()
1492 z_err = deflateInit2( &buff->zctrl, compression, Z_DEFLATED, in xmlCreateZMemBuff()
1497 buff = NULL; in xmlCreateZMemBuff()
1503 return ( NULL ); in xmlCreateZMemBuff()
1507 buff->crc = crc32( 0L, NULL, 0 ); in xmlCreateZMemBuff()
1508 hdr_lgth = snprintf( (char *)buff->zbuff, buff->size, in xmlCreateZMemBuff()
1512 buff->zctrl.next_out = buff->zbuff + hdr_lgth; in xmlCreateZMemBuff()
1513 buff->zctrl.avail_out = buff->size - hdr_lgth; in xmlCreateZMemBuff()
1526 * Returns 0 on success or -1 on failure to extend the buffer. On failure
1532 int rc = -1; in xmlZMemBuffExtend()
1536 unsigned char * tmp_ptr = NULL; in xmlZMemBuffExtend()
1538 if ( buff == NULL ) in xmlZMemBuffExtend()
1539 return ( -1 ); in xmlZMemBuffExtend()
1544 cur_used = buff->zctrl.next_out - buff->zbuff; in xmlZMemBuffExtend()
1545 new_size = buff->size + ext_amt; in xmlZMemBuffExtend()
1547 tmp_ptr = xmlRealloc( buff->zbuff, new_size ); in xmlZMemBuffExtend()
1548 if ( tmp_ptr != NULL ) { in xmlZMemBuffExtend()
1550 buff->size = new_size; in xmlZMemBuffExtend()
1551 buff->zbuff = tmp_ptr; in xmlZMemBuffExtend()
1552 buff->zctrl.next_out = tmp_ptr + cur_used; in xmlZMemBuffExtend()
1553 buff->zctrl.avail_out = new_size - cur_used; in xmlZMemBuffExtend()
1576 * Returns the number of bytes appended to the buffer or -1 on error.
1584 if ( ( buff == NULL ) || ( src == NULL ) ) in xmlZMemBuffAppend()
1585 return ( -1 ); in xmlZMemBuffAppend()
1587 buff->zctrl.avail_in = len; in xmlZMemBuffAppend()
1588 buff->zctrl.next_in = (unsigned char *)src; in xmlZMemBuffAppend()
1589 while ( buff->zctrl.avail_in > 0 ) { in xmlZMemBuffAppend()
1594 min_accept = buff->zctrl.avail_in / DFLT_ZLIB_RATIO; in xmlZMemBuffAppend()
1595 if ( buff->zctrl.avail_out <= min_accept ) { in xmlZMemBuffAppend()
1596 if ( xmlZMemBuffExtend( buff, buff->size ) == -1 ) in xmlZMemBuffAppend()
1597 return ( -1 ); in xmlZMemBuffAppend()
1600 z_err = deflate( &buff->zctrl, Z_NO_FLUSH ); in xmlZMemBuffAppend()
1604 "xmlZMemBuffAppend: %s %d %s - %d", in xmlZMemBuffAppend()
1608 return ( -1 ); in xmlZMemBuffAppend()
1612 buff->crc = crc32( buff->crc, (unsigned char *)src, len ); in xmlZMemBuffAppend()
1626 * Returns the length of the compressed data or -1 on error.
1631 int zlgth = -1; in xmlZMemBuffGetContent()
1634 if ( ( buff == NULL ) || ( data_ref == NULL ) ) in xmlZMemBuffGetContent()
1635 return ( -1 ); in xmlZMemBuffGetContent()
1641 z_err = deflate( &buff->zctrl, Z_FINISH ); in xmlZMemBuffGetContent()
1645 if ( xmlZMemBuffExtend( buff, buff->size ) == -1 ) in xmlZMemBuffGetContent()
1646 return ( -1 ); in xmlZMemBuffGetContent()
1657 if ( buff->zctrl.avail_out < ( 2 * sizeof( unsigned long ) ) ) { in xmlZMemBuffGetContent()
1658 if ( xmlZMemBuffExtend(buff, (2 * sizeof(unsigned long))) == -1 ) in xmlZMemBuffGetContent()
1659 return ( -1 ); in xmlZMemBuffGetContent()
1663 ** For whatever reason, the CRC and length data are pushed out in xmlZMemBuffGetContent()
1667 append_reverse_ulong( buff, buff->crc ); in xmlZMemBuffGetContent()
1668 append_reverse_ulong( buff, buff->zctrl.total_in ); in xmlZMemBuffGetContent()
1670 zlgth = buff->zctrl.next_out - buff->zbuff; in xmlZMemBuffGetContent()
1671 *data_ref = (char *)buff->zbuff; in xmlZMemBuffGetContent()
1677 "xmlZMemBuffGetContent: %s - %d\n", in xmlZMemBuffGetContent()
1699 if ( ctxt->uri != NULL ) in xmlFreeHTTPWriteCtxt()
1700 xmlFree( ctxt->uri ); in xmlFreeHTTPWriteCtxt()
1702 if ( ctxt->doc_buff != NULL ) { in xmlFreeHTTPWriteCtxt()
1705 if ( ctxt->compression > 0 ) { in xmlFreeHTTPWriteCtxt()
1706 xmlFreeZMemBuff( ctxt->doc_buff ); in xmlFreeHTTPWriteCtxt()
1711 xmlOutputBufferClose( ctxt->doc_buff ); in xmlFreeHTTPWriteCtxt()
1742 * Returns an I/O context or NULL in case of error
1746 return(xmlNanoHTTPOpen(filename, NULL)); in xmlIOHTTPOpen()
1756 * request. Non-static as is called from the output buffer creation routine.
1758 * Returns an I/O context or NULL in case of error.
1765 xmlIOHTTPWriteCtxtPtr ctxt = NULL; in xmlIOHTTPOpenW()
1767 if (post_uri == NULL) in xmlIOHTTPOpenW()
1768 return (NULL); in xmlIOHTTPOpenW()
1771 if (ctxt == NULL) { in xmlIOHTTPOpenW()
1773 return (NULL); in xmlIOHTTPOpenW()
1778 ctxt->uri = (char *) xmlStrdup((const xmlChar *)post_uri); in xmlIOHTTPOpenW()
1779 if (ctxt->uri == NULL) { in xmlIOHTTPOpenW()
1782 return (NULL); in xmlIOHTTPOpenW()
1794 ctxt->compression = compression; in xmlIOHTTPOpenW()
1795 ctxt->doc_buff = xmlCreateZMemBuff(compression); in xmlIOHTTPOpenW()
1801 ctxt->doc_buff = xmlAllocOutputBufferInternal(NULL); in xmlIOHTTPOpenW()
1804 if (ctxt->doc_buff == NULL) { in xmlIOHTTPOpenW()
1806 ctxt = NULL; in xmlIOHTTPOpenW()
1842 if ((buffer == NULL) || (len < 0)) return(-1); in xmlIOHTTPRead()
1864 if ( ( ctxt == NULL ) || ( ctxt->doc_buff == NULL ) || ( buffer == NULL ) ) in xmlIOHTTPWrite()
1865 return ( -1 ); in xmlIOHTTPWrite()
1872 if ( ctxt->compression > 0 ) in xmlIOHTTPWrite()
1873 len = xmlZMemBuffAppend( ctxt->doc_buff, buffer, len ); in xmlIOHTTPWrite()
1877 len = xmlOutputBufferWrite( ctxt->doc_buff, len, buffer ); in xmlIOHTTPWrite()
1885 ctxt->uri ); in xmlIOHTTPWrite()
1920 int close_rc = -1; in xmlIOHTTPCloseWrite()
1925 char * http_content = NULL; in xmlIOHTTPCloseWrite()
1926 char * content_encoding = NULL; in xmlIOHTTPCloseWrite()
1928 void * http_ctxt = NULL; in xmlIOHTTPCloseWrite()
1930 if ( ( ctxt == NULL ) || ( http_mthd == NULL ) ) in xmlIOHTTPCloseWrite()
1931 return ( -1 ); in xmlIOHTTPCloseWrite()
1937 if ( ctxt->compression > 0 ) { in xmlIOHTTPCloseWrite()
1938 content_lgth = xmlZMemBuffGetContent( ctxt->doc_buff, &http_content ); in xmlIOHTTPCloseWrite()
1939 content_encoding = (char *) "Content-Encoding: gzip"; in xmlIOHTTPCloseWrite()
1944 /* Pull the data out of the memory output buffer */ in xmlIOHTTPCloseWrite()
1946 xmlOutputBufferPtr dctxt = ctxt->doc_buff; in xmlIOHTTPCloseWrite()
1947 http_content = (char *) xmlBufContent(dctxt->buffer); in xmlIOHTTPCloseWrite()
1948 content_lgth = xmlBufUse(dctxt->buffer); in xmlIOHTTPCloseWrite()
1951 if ( http_content == NULL ) { in xmlIOHTTPCloseWrite()
1956 http_mthd, "data to URI", ctxt->uri ); in xmlIOHTTPCloseWrite()
1962 http_ctxt = xmlNanoHTTPMethod( ctxt->uri, http_mthd, http_content, in xmlIOHTTPCloseWrite()
1966 if ( http_ctxt != NULL ) { in xmlIOHTTPCloseWrite()
1976 "bytes to URI", ctxt->uri, in xmlIOHTTPCloseWrite()
2050 * Returns an I/O context or NULL in case of error
2069 if ((buffer == NULL) || (len < 0)) return(-1); in xmlIOFTPRead()
2097 * Returns the registered handler number or -1 in case of error
2104 return(-1); in xmlRegisterInputCallbacks()
2124 * Returns the registered handler number or -1 in case of error
2131 return(-1); in xmlRegisterOutputCallbacks()
2145 * Registers the default compiled-in I/O handlers.
2179 * Registers the default compiled-in I/O handlers.
2195 No way a-priori to distinguish between gzipped files from in xmlRegisterDefaultOutputCallbacks()
2243 * Returns the new parser input or NULL
2250 if (ret == NULL) { in xmlAllocParserInputBuffer()
2251 return(NULL); in xmlAllocParserInputBuffer()
2254 ret->buffer = xmlBufCreateSize(2 * xmlDefaultBufferSize); in xmlAllocParserInputBuffer()
2255 if (ret->buffer == NULL) { in xmlAllocParserInputBuffer()
2257 return(NULL); in xmlAllocParserInputBuffer()
2259 xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT); in xmlAllocParserInputBuffer()
2260 ret->encoder = xmlGetCharEncodingHandler(enc); in xmlAllocParserInputBuffer()
2261 if (ret->encoder != NULL) in xmlAllocParserInputBuffer()
2262 ret->raw = xmlBufCreateSize(2 * xmlDefaultBufferSize); in xmlAllocParserInputBuffer()
2264 ret->raw = NULL; in xmlAllocParserInputBuffer()
2265 ret->readcallback = NULL; in xmlAllocParserInputBuffer()
2266 ret->closecallback = NULL; in xmlAllocParserInputBuffer()
2267 ret->context = NULL; in xmlAllocParserInputBuffer()
2268 ret->compressed = -1; in xmlAllocParserInputBuffer()
2269 ret->rawconsumed = 0; in xmlAllocParserInputBuffer()
2277 * @encoder: the encoding converter or NULL
2281 * Returns the new parser output or NULL
2288 if (ret == NULL) { in xmlAllocOutputBuffer()
2289 return(NULL); in xmlAllocOutputBuffer()
2292 ret->buffer = xmlBufCreate(); in xmlAllocOutputBuffer()
2293 if (ret->buffer == NULL) { in xmlAllocOutputBuffer()
2295 return(NULL); in xmlAllocOutputBuffer()
2297 xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT); in xmlAllocOutputBuffer()
2299 ret->encoder = encoder; in xmlAllocOutputBuffer()
2300 if (encoder != NULL) { in xmlAllocOutputBuffer()
2301 ret->conv = xmlBufCreateSize(4000); in xmlAllocOutputBuffer()
2302 if (ret->conv == NULL) { in xmlAllocOutputBuffer()
2303 xmlBufFree(ret->buffer); in xmlAllocOutputBuffer()
2305 return(NULL); in xmlAllocOutputBuffer()
2313 ret->conv = NULL; in xmlAllocOutputBuffer()
2314 ret->writecallback = NULL; in xmlAllocOutputBuffer()
2315 ret->closecallback = NULL; in xmlAllocOutputBuffer()
2316 ret->context = NULL; in xmlAllocOutputBuffer()
2317 ret->written = 0; in xmlAllocOutputBuffer()
2324 * @encoder: the encoding converter or NULL
2328 * Returns the new parser output or NULL
2335 if (ret == NULL) { in xmlAllocOutputBufferInternal()
2336 return(NULL); in xmlAllocOutputBufferInternal()
2339 ret->buffer = xmlBufCreate(); in xmlAllocOutputBufferInternal()
2340 if (ret->buffer == NULL) { in xmlAllocOutputBufferInternal()
2342 return(NULL); in xmlAllocOutputBufferInternal()
2349 xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_IO); in xmlAllocOutputBufferInternal()
2351 ret->encoder = encoder; in xmlAllocOutputBufferInternal()
2352 if (encoder != NULL) { in xmlAllocOutputBufferInternal()
2353 ret->conv = xmlBufCreateSize(4000); in xmlAllocOutputBufferInternal()
2354 if (ret->conv == NULL) { in xmlAllocOutputBufferInternal()
2355 xmlBufFree(ret->buffer); in xmlAllocOutputBufferInternal()
2357 return(NULL); in xmlAllocOutputBufferInternal()
2365 ret->conv = NULL; in xmlAllocOutputBufferInternal()
2366 ret->writecallback = NULL; in xmlAllocOutputBufferInternal()
2367 ret->closecallback = NULL; in xmlAllocOutputBufferInternal()
2368 ret->context = NULL; in xmlAllocOutputBufferInternal()
2369 ret->written = 0; in xmlAllocOutputBufferInternal()
2384 if (in == NULL) return; in xmlFreeParserInputBuffer()
2386 if (in->raw) { in xmlFreeParserInputBuffer()
2387 xmlBufFree(in->raw); in xmlFreeParserInputBuffer()
2388 in->raw = NULL; in xmlFreeParserInputBuffer()
2390 if (in->encoder != NULL) { in xmlFreeParserInputBuffer()
2391 xmlCharEncCloseFunc(in->encoder); in xmlFreeParserInputBuffer()
2393 if (in->closecallback != NULL) { in xmlFreeParserInputBuffer()
2394 in->closecallback(in->context); in xmlFreeParserInputBuffer()
2396 if (in->buffer != NULL) { in xmlFreeParserInputBuffer()
2397 xmlBufFree(in->buffer); in xmlFreeParserInputBuffer()
2398 in->buffer = NULL; in xmlFreeParserInputBuffer()
2407 * @out: a buffered output
2412 * Returns the number of byte written or -1 in case of error.
2415 xmlOutputBufferClose(xmlOutputBufferPtr out) in xmlOutputBufferClose() argument
2420 if (out == NULL) in xmlOutputBufferClose()
2421 return (-1); in xmlOutputBufferClose()
2422 if (out->writecallback != NULL) in xmlOutputBufferClose()
2423 xmlOutputBufferFlush(out); in xmlOutputBufferClose()
2424 if (out->closecallback != NULL) { in xmlOutputBufferClose()
2425 err_rc = out->closecallback(out->context); in xmlOutputBufferClose()
2427 written = out->written; in xmlOutputBufferClose()
2428 if (out->conv) { in xmlOutputBufferClose()
2429 xmlBufFree(out->conv); in xmlOutputBufferClose()
2430 out->conv = NULL; in xmlOutputBufferClose()
2432 if (out->encoder != NULL) { in xmlOutputBufferClose()
2433 xmlCharEncCloseFunc(out->encoder); in xmlOutputBufferClose()
2435 if (out->buffer != NULL) { in xmlOutputBufferClose()
2436 xmlBufFree(out->buffer); in xmlOutputBufferClose()
2437 out->buffer = NULL; in xmlOutputBufferClose()
2440 if (out->error) in xmlOutputBufferClose()
2441 err_rc = -1; in xmlOutputBufferClose()
2442 xmlFree(out); in xmlOutputBufferClose()
2451 void *context = NULL; in __xmlParserInputBufferCreateFilename()
2456 if (URI == NULL) return(NULL); in __xmlParserInputBufferCreateFilename()
2462 if (context == NULL) { in __xmlParserInputBufferCreateFilename()
2463 for (i = xmlInputCallbackNr - 1;i >= 0;i--) { in __xmlParserInputBufferCreateFilename()
2464 if ((xmlInputCallbackTable[i].matchcallback != NULL) && in __xmlParserInputBufferCreateFilename()
2467 if (context != NULL) { in __xmlParserInputBufferCreateFilename()
2473 if (context == NULL) { in __xmlParserInputBufferCreateFilename()
2474 return(NULL); in __xmlParserInputBufferCreateFilename()
2478 * Allocate the Input buffer front-end. in __xmlParserInputBufferCreateFilename()
2481 if (ret != NULL) { in __xmlParserInputBufferCreateFilename()
2482 ret->context = context; in __xmlParserInputBufferCreateFilename()
2483 ret->readcallback = xmlInputCallbackTable[i].readcallback; in __xmlParserInputBufferCreateFilename()
2484 ret->closecallback = xmlInputCallbackTable[i].closecallback; in __xmlParserInputBufferCreateFilename()
2487 (strcmp(URI, "-") != 0)) { in __xmlParserInputBufferCreateFilename()
2489 ret->compressed = !gzdirect(context); in __xmlParserInputBufferCreateFilename()
2491 if (((z_stream *)context)->avail_in > 4) { in __xmlParserInputBufferCreateFilename()
2493 cptr = (char *) ((z_stream *)context)->next_in; in __xmlParserInputBufferCreateFilename()
2496 ret->compressed = 0; in __xmlParserInputBufferCreateFilename()
2498 ret->compressed = 1; in __xmlParserInputBufferCreateFilename()
2507 (strcmp(URI, "-") != 0)) { in __xmlParserInputBufferCreateFilename()
2508 ret->compressed = __libxml2_xzcompressed(context); in __xmlParserInputBufferCreateFilename()
2524 * If filename is "-' then we use stdin as the input.
2526 * by default if found at compile-time.
2529 * Returns the new parser input or NULL
2547 void *context = NULL; in __xmlOutputBufferCreateFilename()
2548 char *unescaped = NULL; in __xmlOutputBufferCreateFilename()
2556 if (URI == NULL) return(NULL); in __xmlOutputBufferCreateFilename()
2559 if (puri != NULL) { in __xmlOutputBufferCreateFilename()
2561 if ((puri->scheme != NULL) && in __xmlOutputBufferCreateFilename()
2562 (!xmlStrEqual(BAD_CAST puri->scheme, BAD_CAST "file"))) in __xmlOutputBufferCreateFilename()
2568 if ((puri->scheme == NULL) || in __xmlOutputBufferCreateFilename()
2569 (xmlStrEqual(BAD_CAST puri->scheme, BAD_CAST "file"))) in __xmlOutputBufferCreateFilename()
2570 unescaped = xmlURIUnescapeString(URI, 0, NULL); in __xmlOutputBufferCreateFilename()
2579 if (unescaped != NULL) { in __xmlOutputBufferCreateFilename()
2583 if (context != NULL) { in __xmlOutputBufferCreateFilename()
2585 if (ret != NULL) { in __xmlOutputBufferCreateFilename()
2586 ret->context = context; in __xmlOutputBufferCreateFilename()
2587 ret->writecallback = xmlGzfileWrite; in __xmlOutputBufferCreateFilename()
2588 ret->closecallback = xmlGzfileClose; in __xmlOutputBufferCreateFilename()
2595 for (i = xmlOutputCallbackNr - 1;i >= 0;i--) { in __xmlOutputBufferCreateFilename()
2596 if ((xmlOutputCallbackTable[i].matchcallback != NULL) && in __xmlOutputBufferCreateFilename()
2605 if (context != NULL) in __xmlOutputBufferCreateFilename()
2613 * If this failed try with a non-escaped URI this may be a strange in __xmlOutputBufferCreateFilename()
2616 if (context == NULL) { in __xmlOutputBufferCreateFilename()
2620 if (context != NULL) { in __xmlOutputBufferCreateFilename()
2622 if (ret != NULL) { in __xmlOutputBufferCreateFilename()
2623 ret->context = context; in __xmlOutputBufferCreateFilename()
2624 ret->writecallback = xmlGzfileWrite; in __xmlOutputBufferCreateFilename()
2625 ret->closecallback = xmlGzfileClose; in __xmlOutputBufferCreateFilename()
2633 for (i = xmlOutputCallbackNr - 1;i >= 0;i--) { in __xmlOutputBufferCreateFilename()
2634 if ((xmlOutputCallbackTable[i].matchcallback != NULL) && in __xmlOutputBufferCreateFilename()
2643 if (context != NULL) in __xmlOutputBufferCreateFilename()
2649 if (context == NULL) { in __xmlOutputBufferCreateFilename()
2650 return(NULL); in __xmlOutputBufferCreateFilename()
2654 * Allocate the Output buffer front-end. in __xmlOutputBufferCreateFilename()
2657 if (ret != NULL) { in __xmlOutputBufferCreateFilename()
2658 ret->context = context; in __xmlOutputBufferCreateFilename()
2659 ret->writecallback = xmlOutputCallbackTable[i].writecallback; in __xmlOutputBufferCreateFilename()
2660 ret->closecallback = xmlOutputCallbackTable[i].closecallback; in __xmlOutputBufferCreateFilename()
2668 * @encoder: the encoding converter or NULL
2672 * If filename is "-' then we use stdout as the output.
2674 * by default if found at compile-time.
2678 * Returns the new output or NULL
2699 * Returns the new parser input or NULL
2708 if (file == NULL) return(NULL); in xmlParserInputBufferCreateFile()
2711 if (ret != NULL) { in xmlParserInputBufferCreateFile()
2712 ret->context = file; in xmlParserInputBufferCreateFile()
2713 ret->readcallback = xmlFileRead; in xmlParserInputBufferCreateFile()
2714 ret->closecallback = xmlFileFlush; in xmlParserInputBufferCreateFile()
2724 * @encoder: the encoding converter or NULL
2729 * Returns the new parser output or NULL
2738 if (file == NULL) return(NULL); in xmlOutputBufferCreateFile()
2741 if (ret != NULL) { in xmlOutputBufferCreateFile()
2742 ret->context = file; in xmlOutputBufferCreateFile()
2743 ret->writecallback = xmlFileWrite; in xmlOutputBufferCreateFile()
2744 ret->closecallback = xmlFileFlush; in xmlOutputBufferCreateFile()
2753 * @encoder: the encoding converter or NULL
2757 * Returns the new parser output or NULL
2764 if (buffer == NULL) return(NULL); in xmlOutputBufferCreateBuffer()
2766 ret = xmlOutputBufferCreateIO(xmlBufferWrite, NULL, (void *) buffer, in xmlOutputBufferCreateBuffer()
2774 * @out: an xmlOutputBufferPtr
2778 * Returns a pointer to the data or NULL in case of error
2781 xmlOutputBufferGetContent(xmlOutputBufferPtr out) { in xmlOutputBufferGetContent() argument
2782 if ((out == NULL) || (out->buffer == NULL)) in xmlOutputBufferGetContent()
2783 return(NULL); in xmlOutputBufferGetContent()
2785 return(xmlBufContent(out->buffer)); in xmlOutputBufferGetContent()
2790 * @out: an xmlOutputBufferPtr
2797 xmlOutputBufferGetSize(xmlOutputBufferPtr out) { in xmlOutputBufferGetSize() argument
2798 if ((out == NULL) || (out->buffer == NULL)) in xmlOutputBufferGetSize()
2801 return(xmlBufUse(out->buffer)); in xmlOutputBufferGetSize()
2815 * Returns the new parser input or NULL
2821 if (fd < 0) return(NULL); in xmlParserInputBufferCreateFd()
2824 if (ret != NULL) { in xmlParserInputBufferCreateFd()
2825 ret->context = (void *) (ptrdiff_t) fd; in xmlParserInputBufferCreateFd()
2826 ret->readcallback = xmlFdRead; in xmlParserInputBufferCreateFd()
2827 ret->closecallback = xmlFdClose; in xmlParserInputBufferCreateFd()
2842 if ((size_t) size > ctxt->size) in xmlMemRead()
2843 size = ctxt->size; in xmlMemRead()
2845 memcpy(buf, ctxt->mem, size); in xmlMemRead()
2846 ctxt->mem += size; in xmlMemRead()
2847 ctxt->size -= size; in xmlMemRead()
2867 * Returns the new parser input or NULL
2874 if (size < 0) return(NULL); in xmlParserInputBufferCreateMem()
2875 if (mem == NULL) return(NULL); in xmlParserInputBufferCreateMem()
2878 if (ret == NULL) in xmlParserInputBufferCreateMem()
2879 return(NULL); in xmlParserInputBufferCreateMem()
2882 if (ctxt == NULL) { in xmlParserInputBufferCreateMem()
2884 return(NULL); in xmlParserInputBufferCreateMem()
2886 ctxt->mem = mem; in xmlParserInputBufferCreateMem()
2887 ctxt->size = size; in xmlParserInputBufferCreateMem()
2889 ret->context = ctxt; in xmlParserInputBufferCreateMem()
2890 ret->readcallback = xmlMemRead; in xmlParserInputBufferCreateMem()
2891 ret->closecallback = xmlMemClose; in xmlParserInputBufferCreateMem()
2904 * Returns the new parser input or NULL
2922 zero = memchr(ctxt->str, 0, size); in xmlStringRead()
2923 len = zero ? zero - ctxt->str : size; in xmlStringRead()
2925 memcpy(buf, ctxt->str, len); in xmlStringRead()
2926 ctxt->str += len; in xmlStringRead()
2939 * @str: a null-terminated string
2942 * from a null-terminated C string.
2944 * Returns the new parser input or NULL
2951 if (str == NULL) return(NULL); in xmlParserInputBufferCreateString()
2954 if (ret == NULL) in xmlParserInputBufferCreateString()
2955 return(NULL); in xmlParserInputBufferCreateString()
2958 if (ctxt == NULL) { in xmlParserInputBufferCreateString()
2960 return(NULL); in xmlParserInputBufferCreateString()
2962 ctxt->str = str; in xmlParserInputBufferCreateString()
2964 ret->context = ctxt; in xmlParserInputBufferCreateString()
2965 ret->readcallback = xmlStringRead; in xmlParserInputBufferCreateString()
2966 ret->closecallback = xmlStringClose; in xmlParserInputBufferCreateString()
2975 * @encoder: the encoding converter or NULL
2980 * Returns the new parser output or NULL
2986 if (fd < 0) return(NULL); in xmlOutputBufferCreateFd()
2989 if (ret != NULL) { in xmlOutputBufferCreateFd()
2990 ret->context = (void *) (ptrdiff_t) fd; in xmlOutputBufferCreateFd()
2991 ret->writecallback = xmlFdWrite; in xmlOutputBufferCreateFd()
2992 ret->closecallback = NULL; in xmlOutputBufferCreateFd()
3009 * Returns the new parser input or NULL
3016 if (ioread == NULL) return(NULL); in xmlParserInputBufferCreateIO()
3019 if (ret != NULL) { in xmlParserInputBufferCreateIO()
3020 ret->context = (void *) ioctx; in xmlParserInputBufferCreateIO()
3021 ret->readcallback = ioread; in xmlParserInputBufferCreateIO()
3022 ret->closecallback = ioclose; in xmlParserInputBufferCreateIO()
3039 * Returns the new parser output or NULL
3047 if (iowrite == NULL) return(NULL); in xmlOutputBufferCreateIO()
3050 if (ret != NULL) { in xmlOutputBufferCreateIO()
3051 ret->context = (void *) ioctx; in xmlOutputBufferCreateIO()
3052 ret->writecallback = iowrite; in xmlOutputBufferCreateIO()
3053 ret->closecallback = ioclose; in xmlOutputBufferCreateIO()
3072 if (old == NULL) { in xmlParserInputBufferCreateFilenameDefault()
3093 if (old == NULL) { in xmlOutputBufferCreateFilenameDefault()
3108 * This routine handle the I18N transcoding to internal UTF-8
3111 * Returns the number of chars read and stored in the buffer, or -1
3121 if ((in == NULL) || (in->error)) return(-1); in xmlParserInputBufferPush()
3122 if (in->encoder != NULL) { in xmlParserInputBufferPush()
3126 if (in->raw == NULL) { in xmlParserInputBufferPush()
3127 in->raw = xmlBufCreate(); in xmlParserInputBufferPush()
3128 if (in->raw == NULL) { in xmlParserInputBufferPush()
3129 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferPush()
3130 return(-1); in xmlParserInputBufferPush()
3133 ret = xmlBufAdd(in->raw, (const xmlChar *) buf, len); in xmlParserInputBufferPush()
3135 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferPush()
3136 return(-1); in xmlParserInputBufferPush()
3144 return(-1); in xmlParserInputBufferPush()
3147 ret = xmlBufAdd(in->buffer, (xmlChar *) buf, nbchars); in xmlParserInputBufferPush()
3149 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferPush()
3150 return(-1); in xmlParserInputBufferPush()
3175 * This routine handle the I18N transcoding to internal UTF-8
3179 * onto in->buffer or in->raw
3181 * Returns the number of chars read and stored in the buffer, or -1
3189 if ((in == NULL) || (in->error)) return(-1); in xmlParserInputBufferGrow()
3193 if (in->encoder == NULL) { in xmlParserInputBufferGrow()
3194 if (in->readcallback == NULL) in xmlParserInputBufferGrow()
3196 buf = in->buffer; in xmlParserInputBufferGrow()
3198 if (in->raw == NULL) { in xmlParserInputBufferGrow()
3199 in->raw = xmlBufCreate(); in xmlParserInputBufferGrow()
3201 buf = in->raw; in xmlParserInputBufferGrow()
3207 if (in->readcallback != NULL) { in xmlParserInputBufferGrow()
3209 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferGrow()
3210 return(-1); in xmlParserInputBufferGrow()
3213 res = in->readcallback(in->context, (char *)xmlBufEnd(buf), len); in xmlParserInputBufferGrow()
3215 in->readcallback = endOfInput; in xmlParserInputBufferGrow()
3217 in->error = XML_IO_UNKNOWN; in xmlParserInputBufferGrow()
3218 return(-1); in xmlParserInputBufferGrow()
3222 in->error = XML_ERR_NO_MEMORY; in xmlParserInputBufferGrow()
3223 return(-1); in xmlParserInputBufferGrow()
3230 if (in->compressed == -1) { in xmlParserInputBufferGrow()
3232 if (in->readcallback == xmlXzfileRead) in xmlParserInputBufferGrow()
3233 in->compressed = __libxml2_xzcompressed(in->context); in xmlParserInputBufferGrow()
3237 if (in->encoder != NULL) { in xmlParserInputBufferGrow()
3240 return(-1); in xmlParserInputBufferGrow()
3252 * This routine handle the I18N transcoding to internal UTF-8
3254 * Returns the number of chars read and stored in the buffer, or -1
3265 * @out: a buffered parser output
3270 * This routine handle the I18N transcoding from internal UTF-8
3274 * Returns the number of chars immediately written, or -1
3278 xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) { in xmlOutputBufferWrite() argument
3284 if ((out == NULL) || (out->error)) return(-1); in xmlOutputBufferWrite()
3286 if (out->error) return(-1); in xmlOutputBufferWrite()
3296 if (out->encoder != NULL) { in xmlOutputBufferWrite()
3300 if (out->conv == NULL) { in xmlOutputBufferWrite()
3301 out->conv = xmlBufCreate(); in xmlOutputBufferWrite()
3303 ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk); in xmlOutputBufferWrite()
3305 return(-1); in xmlOutputBufferWrite()
3307 if ((xmlBufUse(out->buffer) < MINLEN) && (chunk == len)) in xmlOutputBufferWrite()
3313 ret = xmlCharEncOutput(out, 0); in xmlOutputBufferWrite()
3314 if ((ret < 0) && (ret != -3)) { in xmlOutputBufferWrite()
3315 xmlIOErr(XML_IO_ENCODER, NULL); in xmlOutputBufferWrite()
3316 out->error = XML_IO_ENCODER; in xmlOutputBufferWrite()
3317 return(-1); in xmlOutputBufferWrite()
3319 if (out->writecallback) in xmlOutputBufferWrite()
3320 nbchars = xmlBufUse(out->conv); in xmlOutputBufferWrite()
3324 ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk); in xmlOutputBufferWrite()
3326 return(-1); in xmlOutputBufferWrite()
3327 if (out->writecallback) in xmlOutputBufferWrite()
3328 nbchars = xmlBufUse(out->buffer); in xmlOutputBufferWrite()
3333 len -= chunk; in xmlOutputBufferWrite()
3335 if (out->writecallback) { in xmlOutputBufferWrite()
3342 if (out->encoder != NULL) { in xmlOutputBufferWrite()
3343 ret = out->writecallback(out->context, in xmlOutputBufferWrite()
3344 (const char *)xmlBufContent(out->conv), nbchars); in xmlOutputBufferWrite()
3346 xmlBufShrink(out->conv, ret); in xmlOutputBufferWrite()
3348 ret = out->writecallback(out->context, in xmlOutputBufferWrite()
3349 (const char *)xmlBufContent(out->buffer), nbchars); in xmlOutputBufferWrite()
3351 xmlBufShrink(out->buffer, ret); in xmlOutputBufferWrite()
3354 xmlIOErr(XML_IO_WRITE, NULL); in xmlOutputBufferWrite()
3355 out->error = XML_IO_WRITE; in xmlOutputBufferWrite()
3358 if (out->written > INT_MAX - ret) in xmlOutputBufferWrite()
3359 out->written = INT_MAX; in xmlOutputBufferWrite()
3361 out->written += ret; in xmlOutputBufferWrite()
3372 * @out: a pointer to an array of bytes to store the result
3373 * @outlen: the length of @out
3374 * @in: a pointer to an array of unescaped UTF-8 bytes
3377 * Take a block of UTF-8 chars in and escape them.
3378 * Returns 0 if success, or -1 otherwise
3384 xmlEscapeContent(unsigned char* out, int *outlen, in xmlEscapeContent() argument
3386 unsigned char* outstart = out; in xmlEscapeContent()
3388 unsigned char* outend = out + *outlen; in xmlEscapeContent()
3393 while ((in < inend) && (out < outend)) { in xmlEscapeContent()
3395 if (outend - out < 4) break; in xmlEscapeContent()
3396 *out++ = '&'; in xmlEscapeContent()
3397 *out++ = 'l'; in xmlEscapeContent()
3398 *out++ = 't'; in xmlEscapeContent()
3399 *out++ = ';'; in xmlEscapeContent()
3401 if (outend - out < 4) break; in xmlEscapeContent()
3402 *out++ = '&'; in xmlEscapeContent()
3403 *out++ = 'g'; in xmlEscapeContent()
3404 *out++ = 't'; in xmlEscapeContent()
3405 *out++ = ';'; in xmlEscapeContent()
3407 if (outend - out < 5) break; in xmlEscapeContent()
3408 *out++ = '&'; in xmlEscapeContent()
3409 *out++ = 'a'; in xmlEscapeContent()
3410 *out++ = 'm'; in xmlEscapeContent()
3411 *out++ = 'p'; in xmlEscapeContent()
3412 *out++ = ';'; in xmlEscapeContent()
3414 if (outend - out < 5) break; in xmlEscapeContent()
3415 *out++ = '&'; in xmlEscapeContent()
3416 *out++ = '#'; in xmlEscapeContent()
3417 *out++ = '1'; in xmlEscapeContent()
3418 *out++ = '3'; in xmlEscapeContent()
3419 *out++ = ';'; in xmlEscapeContent()
3421 *out++ = *in; in xmlEscapeContent()
3425 *outlen = out - outstart; in xmlEscapeContent()
3426 *inlen = in - base; in xmlEscapeContent()
3432 * @out: a buffered parser output
3433 * @str: a zero terminated UTF-8 string
3434 * @escaping: an optional escaping function (or NULL)
3438 * transcoding from internal UTF-8
3442 * Returns the number of chars immediately written, or -1
3446 xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str, in xmlOutputBufferWriteEscape() argument
3456 if ((out == NULL) || (out->error) || (str == NULL) || in xmlOutputBufferWriteEscape()
3457 (out->buffer == NULL)) in xmlOutputBufferWriteEscape()
3458 return(-1); in xmlOutputBufferWriteEscape()
3461 if (out->error) return(-1); in xmlOutputBufferWriteEscape()
3462 if (escaping == NULL) escaping = xmlEscapeContent; in xmlOutputBufferWriteEscape()
3471 chunk = xmlBufAvail(out->buffer); in xmlOutputBufferWriteEscape()
3478 if (xmlBufGrow(out->buffer, 100) < 0) in xmlOutputBufferWriteEscape()
3479 return(-1); in xmlOutputBufferWriteEscape()
3480 oldwritten = -1; in xmlOutputBufferWriteEscape()
3487 if (out->encoder != NULL) { in xmlOutputBufferWriteEscape()
3491 if (out->conv == NULL) { in xmlOutputBufferWriteEscape()
3492 out->conv = xmlBufCreate(); in xmlOutputBufferWriteEscape()
3494 ret = escaping(xmlBufEnd(out->buffer) , in xmlOutputBufferWriteEscape()
3497 return(-1); in xmlOutputBufferWriteEscape()
3498 xmlBufAddLen(out->buffer, chunk); in xmlOutputBufferWriteEscape()
3500 if ((xmlBufUse(out->buffer) < MINLEN) && (cons == len)) in xmlOutputBufferWriteEscape()
3506 ret = xmlCharEncOutput(out, 0); in xmlOutputBufferWriteEscape()
3507 if ((ret < 0) && (ret != -3)) { in xmlOutputBufferWriteEscape()
3508 xmlIOErr(XML_IO_ENCODER, NULL); in xmlOutputBufferWriteEscape()
3509 out->error = XML_IO_ENCODER; in xmlOutputBufferWriteEscape()
3510 return(-1); in xmlOutputBufferWriteEscape()
3512 if (out->writecallback) in xmlOutputBufferWriteEscape()
3513 nbchars = xmlBufUse(out->conv); in xmlOutputBufferWriteEscape()
3517 ret = escaping(xmlBufEnd(out->buffer), &chunk, str, &cons); in xmlOutputBufferWriteEscape()
3519 return(-1); in xmlOutputBufferWriteEscape()
3520 xmlBufAddLen(out->buffer, chunk); in xmlOutputBufferWriteEscape()
3521 if (out->writecallback) in xmlOutputBufferWriteEscape()
3522 nbchars = xmlBufUse(out->buffer); in xmlOutputBufferWriteEscape()
3527 len -= cons; in xmlOutputBufferWriteEscape()
3529 if (out->writecallback) { in xmlOutputBufferWriteEscape()
3536 if (out->encoder != NULL) { in xmlOutputBufferWriteEscape()
3537 ret = out->writecallback(out->context, in xmlOutputBufferWriteEscape()
3538 (const char *)xmlBufContent(out->conv), nbchars); in xmlOutputBufferWriteEscape()
3540 xmlBufShrink(out->conv, ret); in xmlOutputBufferWriteEscape()
3542 ret = out->writecallback(out->context, in xmlOutputBufferWriteEscape()
3543 (const char *)xmlBufContent(out->buffer), nbchars); in xmlOutputBufferWriteEscape()
3545 xmlBufShrink(out->buffer, ret); in xmlOutputBufferWriteEscape()
3548 xmlIOErr(XML_IO_WRITE, NULL); in xmlOutputBufferWriteEscape()
3549 out->error = XML_IO_WRITE; in xmlOutputBufferWriteEscape()
3552 if (out->written > INT_MAX - ret) in xmlOutputBufferWriteEscape()
3553 out->written = INT_MAX; in xmlOutputBufferWriteEscape()
3555 out->written += ret; in xmlOutputBufferWriteEscape()
3556 } else if (xmlBufAvail(out->buffer) < MINLEN) { in xmlOutputBufferWriteEscape()
3557 xmlBufGrow(out->buffer, MINLEN); in xmlOutputBufferWriteEscape()
3568 * @out: a buffered parser output
3572 * This routine handle the I18N transcoding from internal UTF-8
3576 * Returns the number of chars immediately written, or -1
3580 xmlOutputBufferWriteString(xmlOutputBufferPtr out, const char *str) { in xmlOutputBufferWriteString() argument
3583 if ((out == NULL) || (out->error)) return(-1); in xmlOutputBufferWriteString()
3584 if (str == NULL) in xmlOutputBufferWriteString()
3585 return(-1); in xmlOutputBufferWriteString()
3589 return(xmlOutputBufferWrite(out, len, str)); in xmlOutputBufferWriteString()
3595 * @out: a buffered output
3599 * Returns the number of byte written or -1 in case of error.
3602 xmlOutputBufferFlush(xmlOutputBufferPtr out) { in xmlOutputBufferFlush() argument
3605 if ((out == NULL) || (out->error)) return(-1); in xmlOutputBufferFlush()
3609 if ((out->conv != NULL) && (out->encoder != NULL)) { in xmlOutputBufferFlush()
3614 nbchars = xmlCharEncOutput(out, 0); in xmlOutputBufferFlush()
3616 xmlIOErr(XML_IO_ENCODER, NULL); in xmlOutputBufferFlush()
3617 out->error = XML_IO_ENCODER; in xmlOutputBufferFlush()
3618 return(-1); in xmlOutputBufferFlush()
3626 if ((out->conv != NULL) && (out->encoder != NULL) && in xmlOutputBufferFlush()
3627 (out->writecallback != NULL)) { in xmlOutputBufferFlush()
3628 ret = out->writecallback(out->context, in xmlOutputBufferFlush()
3629 (const char *)xmlBufContent(out->conv), in xmlOutputBufferFlush()
3630 xmlBufUse(out->conv)); in xmlOutputBufferFlush()
3632 xmlBufShrink(out->conv, ret); in xmlOutputBufferFlush()
3633 } else if (out->writecallback != NULL) { in xmlOutputBufferFlush()
3634 ret = out->writecallback(out->context, in xmlOutputBufferFlush()
3635 (const char *)xmlBufContent(out->buffer), in xmlOutputBufferFlush()
3636 xmlBufUse(out->buffer)); in xmlOutputBufferFlush()
3638 xmlBufShrink(out->buffer, ret); in xmlOutputBufferFlush()
3641 xmlIOErr(XML_IO_FLUSH, NULL); in xmlOutputBufferFlush()
3642 out->error = XML_IO_FLUSH; in xmlOutputBufferFlush()
3645 if (out->written > INT_MAX - ret) in xmlOutputBufferFlush()
3646 out->written = INT_MAX; in xmlOutputBufferFlush()
3648 out->written += ret; in xmlOutputBufferFlush()
3660 * Returns a new allocated string containing the directory, or NULL.
3664 char *ret = NULL; in xmlParserGetDirectory()
3671 if (filename == NULL) return(NULL); in xmlParserGetDirectory()
3684 cur --; in xmlParserGetDirectory()
3691 if (getcwd(dir, 1024) != NULL) { in xmlParserGetDirectory()
3716 * Returns the input or NULL in case of HTTP error.
3724 if ((ret != NULL) && (ret->buf != NULL) && in xmlCheckHTTPInput()
3725 (ret->buf->readcallback == xmlIOHTTPRead) && in xmlCheckHTTPInput()
3726 (ret->buf->context != NULL)) { in xmlCheckHTTPInput()
3732 code = xmlNanoHTTPReturnCode(ret->buf->context); in xmlCheckHTTPInput()
3735 if (ret->filename != NULL) in xmlCheckHTTPInput()
3737 (const char *) ret->filename); in xmlCheckHTTPInput()
3739 __xmlLoaderErr(ctxt, "failed to load HTTP resource\n", NULL); in xmlCheckHTTPInput()
3741 ret = NULL; in xmlCheckHTTPInput()
3744 mime = xmlNanoHTTPMimeType(ret->buf->context); in xmlCheckHTTPInput()
3747 encoding = xmlNanoHTTPEncoding(ret->buf->context); in xmlCheckHTTPInput()
3748 if (encoding != NULL) { in xmlCheckHTTPInput()
3752 if (handler != NULL) { in xmlCheckHTTPInput()
3757 BAD_CAST encoding, NULL); in xmlCheckHTTPInput()
3764 redir = xmlNanoHTTPRedir(ret->buf->context); in xmlCheckHTTPInput()
3765 if (redir != NULL) { in xmlCheckHTTPInput()
3766 if (ret->filename != NULL) in xmlCheckHTTPInput()
3767 xmlFree((xmlChar *) ret->filename); in xmlCheckHTTPInput()
3768 if (ret->directory != NULL) { in xmlCheckHTTPInput()
3769 xmlFree((xmlChar *) ret->directory); in xmlCheckHTTPInput()
3770 ret->directory = NULL; in xmlCheckHTTPInput()
3772 ret->filename = in xmlCheckHTTPInput()
3784 if (URL == NULL) in xmlNoNetExists()
3811 * @ctxt: the context in which the entity is called or NULL
3817 * Returns a new allocated URL, or NULL.
3822 xmlChar *resource = NULL; in xmlResolveResourceFromCatalog()
3835 if ((ctxt != NULL) && (ctxt->catalogs != NULL) && in xmlResolveResourceFromCatalog()
3838 resource = xmlCatalogLocalResolve(ctxt->catalogs, in xmlResolveResourceFromCatalog()
3845 if ((resource == NULL) && in xmlResolveResourceFromCatalog()
3851 if ((resource == NULL) && (URL != NULL)) in xmlResolveResourceFromCatalog()
3857 if ((resource != NULL) && (!xmlNoNetExists((const char *)resource))) { in xmlResolveResourceFromCatalog()
3858 xmlChar *tmp = NULL; in xmlResolveResourceFromCatalog()
3860 if ((ctxt != NULL) && (ctxt->catalogs != NULL) && in xmlResolveResourceFromCatalog()
3863 tmp = xmlCatalogLocalResolveURI(ctxt->catalogs, resource); in xmlResolveResourceFromCatalog()
3865 if ((tmp == NULL) && in xmlResolveResourceFromCatalog()
3871 if (tmp != NULL) { in xmlResolveResourceFromCatalog()
3887 * @ctxt: the context in which the entity is called or NULL
3891 * Returns a new allocated xmlParserInputPtr, or NULL.
3897 xmlParserInputPtr ret = NULL; in xmlDefaultExternalEntityLoader()
3898 xmlChar *resource = NULL; in xmlDefaultExternalEntityLoader()
3900 if ((ctxt != NULL) && (ctxt->options & XML_PARSE_NONET)) { in xmlDefaultExternalEntityLoader()
3901 int options = ctxt->options; in xmlDefaultExternalEntityLoader()
3903 ctxt->options -= XML_PARSE_NONET; in xmlDefaultExternalEntityLoader()
3905 ctxt->options = options; in xmlDefaultExternalEntityLoader()
3912 if (resource == NULL) in xmlDefaultExternalEntityLoader()
3915 if (resource == NULL) { in xmlDefaultExternalEntityLoader()
3916 if (ID == NULL) in xmlDefaultExternalEntityLoader()
3917 ID = "NULL"; in xmlDefaultExternalEntityLoader()
3919 return (NULL); in xmlDefaultExternalEntityLoader()
3922 if ((resource != NULL) && (resource != (xmlChar *) URL)) in xmlDefaultExternalEntityLoader()
3957 * @ctxt: the context in which the entity is called or NULL
3962 * Returns the xmlParserInputPtr or NULL
3967 if ((URL != NULL) && (xmlNoNetExists(URL) == 0)) { in xmlLoadExternalEntity()
3972 if (canonicFilename == NULL) { in xmlLoadExternalEntity()
3974 return(NULL); in xmlLoadExternalEntity()
3994 * @ctxt: the context in which the entity is called or NULL
3999 * Returns a new allocated xmlParserInputPtr, or NULL.
4004 xmlParserInputPtr input = NULL; in xmlNoNetExternalEntityLoader()
4005 xmlChar *resource = NULL; in xmlNoNetExternalEntityLoader()
4011 if (resource == NULL) in xmlNoNetExternalEntityLoader()
4014 if (resource != NULL) { in xmlNoNetExternalEntityLoader()
4020 return(NULL); in xmlNoNetExternalEntityLoader()