18#ifdef HAVE_SYS_TYPES_H
30#ifdef LIBXML_ZLIB_ENABLED
33#ifdef LIBXML_LZMA_ENABLED
41#define WIN32_LEAN_AND_MEAN
50# define S_ISDIR(x) _S_ISDIR(x)
51# elif defined(S_IFDIR)
53# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
54# elif defined(_S_IFMT)
55# define S_ISDIR(m) (((m) & _S_IFMT) == S_IFDIR)
68#ifdef LIBXML_CATALOG_ENABLED
96#define MAX_INPUT_CALLBACK 15
102#ifdef LIBXML_OUTPUT_ENABLED
106typedef struct _xmlOutputCallback {
107 xmlOutputMatchCallback matchcallback;
108 xmlOutputOpenCallback opencallback;
109 xmlOutputWriteCallback writecallback;
110 xmlOutputCloseCallback closecallback;
113#define MAX_OUTPUT_CALLBACK 15
115static xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK];
116static int xmlOutputCallbackNr = 0;
117static int xmlOutputCallbackInitialized = 0;
132 "Resource temporarily unavailable",
133 "Bad file descriptor",
136 "Operation canceled",
137 "No child processes",
138 "Resource deadlock avoided",
143 "Operation in progress",
144 "Interrupted function call",
146 "Input/output error",
148 "Too many open files",
150 "Inappropriate message buffer length",
152 "Too many open files in system",
154 "No such file or directory",
156 "No locks available",
158 "No space left on device",
159 "Function not implemented",
161 "Directory not empty",
163 "Inappropriate I/O control operation",
164 "No such device or address",
165 "Operation not permitted",
168 "Read-only file system",
171 "Operation timed out",
173 "Attempt to load network entity %s",
182 "connection refused",
183 "unreachable network",
186 "unknown address family",
197__xmlIOWin32UTF8ToWChar(
const char *u8String)
199 wchar_t *wString =
NULL;
206 wString =
xmlMalloc(wLen *
sizeof(
wchar_t));
209 (
CP_UTF8, 0, u8String, -1, wString, wLen) == 0) {
444 channel = ctxt->
sax->error;
447 channel = ctxt->
sax->warning;
451 schannel = ctxt->
sax->serror;
532#ifdef LIBXML_OUTPUT_ENABLED
540xmlCleanupOutputCallbacks(
void)
544 if (!xmlOutputCallbackInitialized)
547 for (
i = xmlOutputCallbackNr - 1;
i >= 0;
i--) {
548 xmlOutputCallbackTable[
i].matchcallback =
NULL;
549 xmlOutputCallbackTable[
i].opencallback =
NULL;
550 xmlOutputCallbackTable[
i].writecallback =
NULL;
551 xmlOutputCallbackTable[
i].closecallback =
NULL;
554 xmlOutputCallbackNr = 0;
555 xmlOutputCallbackInitialized = 0;
567xmlPopOutputCallbacks(
void)
569 if (!xmlOutputCallbackInitialized)
572 if (xmlOutputCallbackNr <= 0)
575 xmlOutputCallbackNr--;
576 xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback =
NULL;
577 xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback =
NULL;
578 xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback =
NULL;
579 xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback =
NULL;
581 return(xmlOutputCallbackNr);
603xmlWrapOpenUtf8(
const char *
path,
int mode)
608 wPath = __xmlIOWin32UTF8ToWChar(
path);
621#ifdef LIBXML_ZLIB_ENABLED
623xmlWrapGzOpenUtf8(
const char *
path,
const char *
mode)
632 wPath = __xmlIOWin32UTF8ToWChar(
path);
662 wPath = __xmlIOWin32UTF8ToWChar(
path);
694 struct _stat stat_buffer;
696 struct stat stat_buffer;
708 if ((
path[0] ==
'\\') && (
path[1] ==
'\\') && (
path[2] ==
'?') &&
712 if (xmlWrapStatUtf8(
path, &stat_buffer) == -1)
719 if (
S_ISDIR(stat_buffer.st_mode))
755 if (
ret < 0) xmlIOErr(0,
"read()");
759#ifdef LIBXML_OUTPUT_ENABLED
776 if (
ret < 0) xmlIOErr(0,
"write()");
794 if (
ret < 0) xmlIOErr(0,
"close()");
821xmlFileOpen_real (
const char *
filename) {
861 fd = xmlWrapOpenUtf8(
path, 0);
883 retval = xmlFileOpen_real(
filename);
884 if (retval ==
NULL) {
886 if (unescaped !=
NULL) {
887 retval = xmlFileOpen_real(unescaped);
895#ifdef LIBXML_OUTPUT_ENABLED
906xmlFileOpenW (
const char *
filename) {
934 fd = xmlWrapOpenUtf8(
path, 1);
962 if (
ret < 0) xmlIOErr(0,
"fread()");
966#ifdef LIBXML_OUTPUT_ENABLED
985 xmlIOErr(0,
"fwrite()");
1011 xmlIOErr(0,
"fflush()");
1018 xmlIOErr(0,
"fclose()");
1029xmlFileFlush (
void *
context) {
1036 xmlIOErr(0,
"fflush()");
1040#ifdef LIBXML_OUTPUT_ENABLED
1062#ifdef LIBXML_ZLIB_ENABLED
1091xmlGzfileOpen_real (
const char *
filename) {
1098 if (
fd ==
Z_NULL && duped_fd >= 0) {
1102 return((
void *)
fd);
1126 fd = xmlWrapGzOpenUtf8(
path,
"rb");
1130 return((
void *)
fd);
1141xmlGzfileOpen (
const char *
filename) {
1145 retval = xmlGzfileOpen_real(
filename);
1146 if (retval ==
NULL) {
1148 if (unescaped !=
NULL) {
1149 retval = xmlGzfileOpen_real(unescaped);
1156#ifdef LIBXML_OUTPUT_ENABLED
1177 if (
fd ==
Z_NULL && duped_fd >= 0) {
1181 return((
void *)
fd);
1207 return((
void *)
fd);
1226 if (
ret < 0) xmlIOErr(0,
"gzread()");
1230#ifdef LIBXML_OUTPUT_ENABLED
1246 if (
ret < 0) xmlIOErr(0,
"gzwrite()");
1258xmlGzfileClose (
void *
context) {
1262 if (
ret < 0) xmlIOErr(0,
"gzclose()");
1267#ifdef LIBXML_LZMA_ENABLED
1297xmlXzfileOpen_real (
const char *
filename) {
1303 return((
void *)
fd);
1322 return((
void *)
fd);
1335xmlXzfileOpen (
const char *
filename) {
1339 retval = xmlXzfileOpen_real(
filename);
1340 if (retval ==
NULL) {
1342 if (unescaped !=
NULL) {
1343 retval = xmlXzfileOpen_real(unescaped);
1366 if (
ret < 0) xmlIOErr(0,
"xzread()");
1377xmlXzfileClose (
void *
context) {
1381 if (
ret < 0) xmlIOErr(0,
"xzclose()");
1386#ifdef LIBXML_HTTP_ENABLED
1393#ifdef LIBXML_OUTPUT_ENABLED
1394typedef struct xmlIOHTTPWriteCtxt_
1402} xmlIOHTTPWriteCtxt, *xmlIOHTTPWriteCtxtPtr;
1404#ifdef LIBXML_ZLIB_ENABLED
1406#define DFLT_WBITS ( -15 )
1407#define DFLT_MEM_LVL ( 8 )
1408#define GZ_MAGIC1 ( 0x1f )
1409#define GZ_MAGIC2 ( 0x8b )
1410#define LXML_ZLIB_OS_CODE ( 0x03 )
1411#define INIT_HTTP_BUFF_SIZE ( 32768 )
1412#define DFLT_ZLIB_RATIO ( 5 )
1419typedef struct xmlZMemBuff_
1424 unsigned char * zbuff;
1427} xmlZMemBuff, *xmlZMemBuffPtr;
1438append_reverse_ulong( xmlZMemBuff *
buff,
unsigned long data ) {
1453 *
buff->zctrl.next_out = (
data & 0xff );
1455 buff->zctrl.next_out++;
1469xmlFreeZMemBuff( xmlZMemBuffPtr
buff ) {
1481 if ( z_err !=
Z_OK )
1483 "xmlFreeZMemBuff: Error releasing zlib context: %d\n",
1522 buff->size = INIT_HTTP_BUFF_SIZE;
1525 xmlFreeZMemBuff(
buff );
1532 if ( z_err !=
Z_OK ) {
1534 xmlFreeZMemBuff(
buff );
1537 "xmlCreateZMemBuff: %s %d\n",
1538 "Error initializing compression context. ZLIB error:",
1547 "%c%c%c%c%c%c%c%c%c%c",
1549 0, 0, 0, 0, 0, 0, LXML_ZLIB_OS_CODE );
1550 buff->zctrl.next_out =
buff->zbuff + hdr_lgth;
1551 buff->zctrl.avail_out =
buff->size - hdr_lgth;
1568xmlZMemBuffExtend( xmlZMemBuffPtr
buff,
size_t ext_amt ) {
1574 unsigned char * tmp_ptr =
NULL;
1579 else if ( ext_amt == 0 )
1582 cur_used =
buff->zctrl.next_out -
buff->zbuff;
1583 new_size =
buff->size + ext_amt;
1586 if ( cur_used > new_size )
1588 "xmlZMemBuffExtend: %s\n%s %d bytes.\n",
1589 "Buffer overwrite detected during compressed memory",
1590 "buffer extension. Overflowed by",
1591 (cur_used - new_size ) );
1595 if ( tmp_ptr !=
NULL ) {
1597 buff->size = new_size;
1598 buff->zbuff = tmp_ptr;
1599 buff->zctrl.next_out = tmp_ptr + cur_used;
1600 buff->zctrl.avail_out = new_size - cur_used;
1605 "xmlZMemBuffExtend: %s %lu bytes.\n",
1606 "Allocation failure extending output buffer to",
1607 (
unsigned long) new_size );
1626xmlZMemBuffAppend( xmlZMemBuffPtr
buff,
const char *
src,
int len ) {
1635 buff->zctrl.next_in = (
unsigned char *)
src;
1636 while (
buff->zctrl.avail_in > 0 ) {
1641 min_accept =
buff->zctrl.avail_in / DFLT_ZLIB_RATIO;
1642 if (
buff->zctrl.avail_out <= min_accept ) {
1643 if ( xmlZMemBuffExtend(
buff,
buff->size ) == -1 )
1648 if ( z_err !=
Z_OK ) {
1651 "xmlZMemBuffAppend: %s %d %s - %d",
1652 "Compression error while appending",
1653 len,
"bytes to buffer. ZLIB error", z_err );
1676xmlZMemBuffGetContent( xmlZMemBuffPtr
buff,
char ** data_ref ) {
1689 if ( z_err ==
Z_OK ) {
1692 if ( xmlZMemBuffExtend(
buff,
buff->size ) == -1 )
1696 while ( z_err ==
Z_OK );
1704 if (
buff->zctrl.avail_out < ( 2 *
sizeof(
unsigned long ) ) ) {
1705 if ( xmlZMemBuffExtend(
buff, (2 *
sizeof(
unsigned long))) == -1 )
1714 append_reverse_ulong(
buff,
buff->crc );
1715 append_reverse_ulong(
buff,
buff->zctrl.total_in );
1717 zlgth =
buff->zctrl.next_out -
buff->zbuff;
1718 *data_ref = (
char *)
buff->zbuff;
1724 "xmlZMemBuffGetContent: %s - %d\n",
1725 "Error flushing zlib buffers. Error code", z_err );
1734#ifdef LIBXML_OUTPUT_ENABLED
1744xmlFreeHTTPWriteCtxt( xmlIOHTTPWriteCtxtPtr ctxt )
1746 if ( ctxt->uri !=
NULL )
1749 if ( ctxt->doc_buff !=
NULL ) {
1751#ifdef LIBXML_ZLIB_ENABLED
1752 if ( ctxt->compression > 0 ) {
1753 xmlFreeZMemBuff( ctxt->doc_buff );
1758 xmlOutputBufferClose( ctxt->doc_buff );
1777xmlIOHTTPMatch (
const char *
filename) {
1792xmlIOHTTPOpen (
const char *
filename) {
1796#ifdef LIBXML_OUTPUT_ENABLED
1812 xmlIOHTTPWriteCtxtPtr ctxt =
NULL;
1814 if (post_uri ==
NULL)
1817 ctxt =
xmlMalloc(
sizeof(xmlIOHTTPWriteCtxt));
1823 (
void)
memset(ctxt, 0,
sizeof(xmlIOHTTPWriteCtxt));
1826 if (ctxt->uri ==
NULL) {
1828 xmlFreeHTTPWriteCtxt(ctxt);
1838#ifdef LIBXML_ZLIB_ENABLED
1848 ctxt->doc_buff = xmlAllocOutputBufferInternal(
NULL);
1851 if (ctxt->doc_buff ==
NULL) {
1852 xmlFreeHTTPWriteCtxt(ctxt);
1860#ifdef LIBXML_OUTPUT_ENABLED
1872xmlIOHTTPDfltOpenW(
const char * post_uri ) {
1873 return ( xmlIOHTTPOpenW( post_uri, 0 ) );
1893#ifdef LIBXML_OUTPUT_ENABLED
1909 xmlIOHTTPWriteCtxtPtr ctxt =
context;
1918#ifdef LIBXML_ZLIB_ENABLED
1919 if ( ctxt->compression > 0 )
1920 len = xmlZMemBuffAppend( ctxt->doc_buff,
buffer,
len );
1924 len = xmlOutputBufferWrite( ctxt->doc_buff,
len,
buffer );
1929 "xmlIOHTTPWrite: %s\n%s '%s'.\n",
1930 "Error appending to internal buffer.",
1931 "Error sending document to URI",
1951xmlIOHTTPClose (
void *
context) {
1956#ifdef LIBXML_OUTPUT_ENABLED
1965xmlIOHTTPCloseWrite(
void *
context,
const char * http_mthd ) {
1969 int content_lgth = 0;
1970 xmlIOHTTPWriteCtxtPtr ctxt =
context;
1972 char * http_content =
NULL;
1973 char * content_encoding =
NULL;
1975 void * http_ctxt =
NULL;
1977 if ( ( ctxt ==
NULL ) || ( http_mthd ==
NULL ) )
1982#ifdef LIBXML_ZLIB_ENABLED
1984 if ( ctxt->compression > 0 ) {
1985 content_lgth = xmlZMemBuffGetContent( ctxt->doc_buff, &http_content );
1986 content_encoding = (
char *)
"Content-Encoding: gzip";
1995 content_lgth =
xmlBufUse(dctxt->buffer);
1998 if ( http_content ==
NULL ) {
2001 "xmlIOHTTPCloseWrite: %s '%s' %s '%s'.\n",
2002 "Error retrieving content.\nUnable to",
2003 http_mthd,
"data to URI", ctxt->uri );
2009 http_ctxt = xmlNanoHTTPMethod( ctxt->uri, http_mthd, http_content,
2013 if ( http_ctxt !=
NULL ) {
2019 char * dump_name =
NULL;
2023 "xmlNanoHTTPCloseWrite: HTTP %s to\n%s returned %d.\n",
2024 http_mthd, ctxt->uri,
2025 xmlNanoHTTPReturnCode( http_ctxt ) );
2034 if ( dump_name !=
NULL ) {
2038 if ( tst_file !=
NULL ) {
2040 "Transmitted content saved in file: %s\n",
buffer );
2042 fwrite( http_content,
sizeof(
char ),
2043 content_lgth, tst_file );
2049 if ( tst_file !=
NULL ) {
2051 "Reply content saved in file: %s\n",
buffer );
2054 while ( (
avail = xmlNanoHTTPRead( http_ctxt,
2067 http_rtn = xmlNanoHTTPReturnCode( http_ctxt );
2068 if ( ( http_rtn >= 200 ) && ( http_rtn < 300 ) )
2073 "xmlIOHTTPCloseWrite: HTTP '%s' of %d %s\n'%s' %s %d\n",
2074 http_mthd, content_lgth,
2075 "bytes to URI", ctxt->uri,
2076 "failed. HTTP return code:", http_rtn );
2080 xmlNanoHTTPClose( http_ctxt );
2087 xmlFreeHTTPWriteCtxt( ctxt );
2089 return ( close_rc );
2101xmlIOHTTPClosePut(
void * ctxt ) {
2102 return ( xmlIOHTTPCloseWrite( ctxt,
"PUT" ) );
2115xmlIOHTTPClosePost(
void * ctxt ) {
2116 return ( xmlIOHTTPCloseWrite( ctxt,
"POST" ) );
2122#ifdef LIBXML_FTP_ENABLED
2137xmlIOFTPMatch (
const char *
filename) {
2152xmlIOFTPOpen (
const char *
filename) {
2181xmlIOFTPClose (
void *
context) {
2182 return ( xmlNanoFTPClose(
context) );
2213#ifdef LIBXML_OUTPUT_ENABLED
2226xmlRegisterOutputCallbacks(xmlOutputMatchCallback matchFunc,
2227 xmlOutputOpenCallback openFunc, xmlOutputWriteCallback writeFunc,
2228 xmlOutputCloseCallback closeFunc) {
2229 if (xmlOutputCallbackNr >= MAX_OUTPUT_CALLBACK) {
2232 xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback = matchFunc;
2233 xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback = openFunc;
2234 xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback = writeFunc;
2235 xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback = closeFunc;
2236 xmlOutputCallbackInitialized = 1;
2237 return(xmlOutputCallbackNr++);
2253#ifdef LIBXML_ZLIB_ENABLED
2255 xmlGzfileRead, xmlGzfileClose);
2257#ifdef LIBXML_LZMA_ENABLED
2259 xmlXzfileRead, xmlXzfileClose);
2262#ifdef LIBXML_HTTP_ENABLED
2264 xmlIOHTTPRead, xmlIOHTTPClose);
2267#ifdef LIBXML_FTP_ENABLED
2269 xmlIOFTPRead, xmlIOFTPClose);
2274#ifdef LIBXML_OUTPUT_ENABLED
2281xmlRegisterDefaultOutputCallbacks (
void) {
2282 if (xmlOutputCallbackInitialized)
2288#ifdef LIBXML_HTTP_ENABLED
2289 xmlRegisterOutputCallbacks(xmlIOHTTPMatch, xmlIOHTTPDfltOpenW,
2290 xmlIOHTTPWrite, xmlIOHTTPClosePut);
2309 xmlOutputCallbackInitialized = 1;
2312#ifdef LIBXML_HTTP_ENABLED
2322xmlRegisterHTTPPostCallbacks(
void ) {
2326 if ( xmlOutputCallbackInitialized == 0 )
2327 xmlRegisterDefaultOutputCallbacks( );
2329 xmlRegisterOutputCallbacks(xmlIOHTTPMatch, xmlIOHTTPDfltOpenW,
2330 xmlIOHTTPWrite, xmlIOHTTPClosePost);
2368 ret->compressed = -1;
2369 ret->rawconsumed = 0;
2374#ifdef LIBXML_OUTPUT_ENABLED
2400 ret->encoder = encoder;
2401 if (encoder !=
NULL) {
2453 ret->encoder = encoder;
2454 if (encoder !=
NULL) {
2492 if (
in->encoder !=
NULL) {
2495 if (
in->closecallback !=
NULL) {
2496 in->closecallback(
in->context);
2498 if (
in->buffer !=
NULL) {
2506#ifdef LIBXML_OUTPUT_ENABLED
2524 if (
out->writecallback !=
NULL)
2525 xmlOutputBufferFlush(
out);
2526 if (
out->closecallback !=
NULL) {
2527 err_rc =
out->closecallback(
out->context);
2529 written =
out->written;
2545 return ((err_rc == 0) ? written : err_rc);
2587#ifdef LIBXML_ZLIB_ENABLED
2589 (
strcmp(URI,
"-") != 0)) {
2590#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230
2594 char *cptr, buff4[4];
2597 if (
strncmp(buff4, cptr, 4) == 0)
2598 ret->compressed = 0;
2600 ret->compressed = 1;
2607#ifdef LIBXML_LZMA_ENABLED
2609 (
strcmp(URI,
"-") != 0)) {
2641#ifdef LIBXML_OUTPUT_ENABLED
2643__xmlOutputBufferCreateFilename(
const char *URI,
2650 char *unescaped =
NULL;
2651#ifdef LIBXML_ZLIB_ENABLED
2652 int is_file_uri = 1;
2655 if (xmlOutputCallbackInitialized == 0)
2656 xmlRegisterDefaultOutputCallbacks();
2662#ifdef LIBXML_ZLIB_ENABLED
2681 if (unescaped !=
NULL) {
2682#ifdef LIBXML_ZLIB_ENABLED
2686 ret = xmlAllocOutputBufferInternal(encoder);
2689 ret->writecallback = xmlGzfileWrite;
2690 ret->closecallback = xmlGzfileClose;
2697 for (
i = xmlOutputCallbackNr - 1;
i >= 0;
i--) {
2698 if ((xmlOutputCallbackTable[
i].matchcallback !=
NULL) &&
2699 (xmlOutputCallbackTable[
i].matchcallback(unescaped) != 0)) {
2700#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_ZLIB_ENABLED)
2702 if (xmlOutputCallbackTable[
i].matchcallback == xmlIOHTTPMatch)
2706 context = xmlOutputCallbackTable[
i].opencallback(unescaped);
2719#ifdef LIBXML_ZLIB_ENABLED
2723 ret = xmlAllocOutputBufferInternal(encoder);
2726 ret->writecallback = xmlGzfileWrite;
2727 ret->closecallback = xmlGzfileClose;
2735 for (
i = xmlOutputCallbackNr - 1;
i >= 0;
i--) {
2736 if ((xmlOutputCallbackTable[
i].matchcallback !=
NULL) &&
2737 (xmlOutputCallbackTable[
i].matchcallback(URI) != 0)) {
2738#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_ZLIB_ENABLED)
2740 if (xmlOutputCallbackTable[
i].matchcallback == xmlIOHTTPMatch)
2744 context = xmlOutputCallbackTable[
i].opencallback(URI);
2758 ret = xmlAllocOutputBufferInternal(encoder);
2761 ret->writecallback = xmlOutputCallbackTable[
i].writecallback;
2762 ret->closecallback = xmlOutputCallbackTable[
i].closecallback;
2783xmlOutputBufferCreateFilename(
const char *URI,
2789 return __xmlOutputBufferCreateFilename(URI, encoder,
compression);
2816 ret->closecallback = xmlFileFlush;
2822#ifdef LIBXML_OUTPUT_ENABLED
2837 if (xmlOutputCallbackInitialized == 0)
2838 xmlRegisterDefaultOutputCallbacks();
2842 ret = xmlAllocOutputBufferInternal(encoder);
2845 ret->writecallback = xmlFileWrite;
2846 ret->closecallback = xmlFileFlush;
2868 ret = xmlOutputBufferCreateIO(xmlBufferWrite,
NULL, (
void *)
buffer,
2923 if (
fd < 0)
return(
NULL);
2928 ret->readcallback = xmlFdRead;
2929 ret->closecallback = xmlFdClose;
2956 ret->context = (
void *)
mem;
3006 ret->compressed = -1;
3007 ret->context = (
void *)
mem;
3014#ifdef LIBXML_OUTPUT_ENABLED
3029 if (
fd < 0)
return(
NULL);
3031 ret = xmlAllocOutputBufferInternal(encoder);
3034 ret->writecallback = xmlFdWrite;
3063 ret->context = (
void *) ioctx;
3064 ret->readcallback = ioread;
3065 ret->closecallback = ioclose;
3071#ifdef LIBXML_OUTPUT_ENABLED
3085xmlOutputBufferCreateIO(xmlOutputWriteCallback iowrite,
3086 xmlOutputCloseCallback ioclose,
void *ioctx,
3092 ret = xmlAllocOutputBufferInternal(encoder);
3094 ret->context = (
void *) ioctx;
3095 ret->writecallback = iowrite;
3096 ret->closecallback = ioclose;
3135#ifdef LIBXML_OUTPUT_ENABLED
3137 old = __xmlOutputBufferCreateFilename;
3159 int len,
const char *
buf) {
3163 if (
len < 0)
return(0);
3164 if ((
in ==
NULL) || (
in->error))
return(-1);
3165 if (
in->encoder !=
NULL) {
3197 "I/O: pushed %d chars, buffer %d/%d\n",
3237 if ((
in ==
NULL) || (
in->error))
return(-1);
3257 if (
in->readcallback !=
NULL) {
3260 in->readcallback = endOfInput;
3273 if (
in->compressed == -1) {
3274#ifdef LIBXML_LZMA_ENABLED
3275 if (
in->readcallback == xmlXzfileRead)
3281 if (
in->encoder !=
NULL) {
3311 "I/O: read %d chars, buffer %d\n",
3331 if ((
in ==
NULL) || (
in->error))
return(-1);
3332 if (
in->readcallback !=
NULL)
3340#ifdef LIBXML_OUTPUT_ENABLED
3362 if ((
out ==
NULL) || (
out->error))
return(-1);
3363 if (
len < 0)
return(0);
3364 if (
out->error)
return(-1);
3392 if ((
ret < 0) && (
ret != -3)) {
3397 if (
out->writecallback)
3400 nbchars =
ret >= 0 ?
ret : 0;
3405 if (
out->writecallback)
3413 if (
out->writecallback) {
3447 "I/O: wrote %d chars\n", written);
3466xmlEscapeContent(
unsigned char*
out,
int *outlen,
3468 unsigned char* outstart =
out;
3469 const unsigned char*
base =
in;
3470 unsigned char* outend =
out + *outlen;
3471 const unsigned char* inend;
3473 inend =
in + (*inlen);
3475 while ((
in < inend) && (
out < outend)) {
3477 if (outend -
out < 4)
break;
3482 }
else if (*
in ==
'>') {
3483 if (outend -
out < 4)
break;
3488 }
else if (*
in ==
'&') {
3489 if (outend -
out < 5)
break;
3495 }
else if (*
in ==
'\r') {
3496 if (outend -
out < 5)
break;
3507 *outlen =
out - outstart;
3543 if (
len < 0)
return(0);
3544 if (
out->error)
return(-1);
3545 if (escaping ==
NULL) escaping = xmlEscapeContent;
3548 oldwritten = written;
3590 if ((
ret < 0) && (
ret != -3)) {
3595 if (
out->writecallback)
3598 nbchars =
ret >= 0 ?
ret : 0;
3604 if (
out->writecallback)
3612 if (
out->writecallback) {
3643 }
while ((
len > 0) && (oldwritten != written));
3648 "I/O: wrote %d chars\n", written);
3670 if ((
out ==
NULL) || (
out->error))
return(-1);
3676 return(xmlOutputBufferWrite(
out,
len,
str));
3690 int nbchars = 0,
ret = 0;
3692 if ((
out ==
NULL) || (
out->error))
return(-1);
3714 (
out->writecallback !=
NULL)) {
3720 }
else if (
out->writecallback !=
NULL) {
3739 "I/O: flushed %d chars\n",
ret);
3765# define IS_XMLPGD_SEP(ch) ((ch=='/')||(ch=='\\'))
3767# define IS_XMLPGD_SEP(ch) (ch=='/')
3814#ifdef LIBXML_HTTP_ENABLED
3816 (
ret->buf->readcallback == xmlIOHTTPRead) &&
3817 (
ret->buf->context !=
NULL)) {
3823 code = xmlNanoHTTPReturnCode(
ret->buf->context);
3828 (
const char *)
ret->filename);
3835 mime = xmlNanoHTTPMimeType(
ret->buf->context);
3838 encoding = xmlNanoHTTPEncoding(
ret->buf->context);
3847 "Unknown encoding %s",
3857 redir = xmlNanoHTTPRedir(
ret->buf->context);
3858 if (redir !=
NULL) {
3874static int xmlNoNetExists(
const char *URL) {
3898#ifdef LIBXML_CATALOG_ENABLED
3913xmlResolveResourceFromCatalog(
const char *URL,
const char *
ID,
3916 xmlCatalogAllow pref;
3922 pref = xmlCatalogGetDefaults();
3924 if ((pref != XML_CATA_ALLOW_NONE) && (!xmlNoNetExists(URL))) {
3929 ((pref == XML_CATA_ALLOW_ALL) ||
3930 (pref == XML_CATA_ALLOW_DOCUMENT))) {
3939 ((pref == XML_CATA_ALLOW_ALL) ||
3940 (pref == XML_CATA_ALLOW_GLOBAL))) {
3954 ((pref == XML_CATA_ALLOW_ALL) ||
3955 (pref == XML_CATA_ALLOW_DOCUMENT))) {
3958 if ((tmp ==
NULL) &&
3959 ((pref == XML_CATA_ALLOW_ALL) ||
3960 (pref == XML_CATA_ALLOW_GLOBAL))) {
3961 tmp = xmlCatalogResolveURI(
resource);
3987xmlDefaultExternalEntityLoader(
const char *URL,
const char *
ID,
3993#ifdef DEBUG_EXTERNAL_ENTITIES
3995 "xmlDefaultExternalEntityLoader(%s, xxx)\n", URL);
4005#ifdef LIBXML_CATALOG_ENABLED
4006 resource = xmlResolveResourceFromCatalog(URL,
ID, ctxt);
4025 xmlDefaultExternalEntityLoader;
4035 xmlCurrentExternalEntityLoader =
f;
4047 return(xmlCurrentExternalEntityLoader);
4064 if ((URL !=
NULL) && (xmlNoNetExists(URL) == 0)) {
4065 char *canonicFilename;
4069 if (canonicFilename ==
NULL) {
4074 ret = xmlCurrentExternalEntityLoader(canonicFilename,
ID, ctxt);
4078 return(xmlCurrentExternalEntityLoader(URL,
ID, ctxt));
4104#ifdef LIBXML_CATALOG_ENABLED
4105 resource = xmlResolveResourceFromCatalog(URL,
ID, ctxt);
4120 input = xmlDefaultExternalEntityLoader((
const char *)
resource,
ID, ctxt);
int strcmp(const char *String1, const char *String2)
char * strstr(char *String1, char *String2)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
pair cons(caddr_t car, pair cdr)
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression
size_t xmlBufAvail(const xmlBufPtr buf)
int xmlBufAddLen(xmlBufPtr buf, size_t len)
int xmlBufGetAllocationScheme(xmlBufPtr buf)
size_t xmlBufLength(const xmlBufPtr buf)
void xmlBufFree(xmlBufPtr buf)
xmlBufPtr xmlBufCreateStatic(void *mem, size_t size)
xmlBufPtr xmlBufCreateSize(size_t size)
xmlBufPtr xmlBufCreate(void)
int xmlBufSetAllocationScheme(xmlBufPtr buf, xmlBufferAllocationScheme scheme)
int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len)
int xmlBufGrow(xmlBufPtr buf, int len)
_Check_return_ _Ret_opt_z_ _CRTIMP char *__cdecl getcwd(_Out_writes_opt_(_SizeInBytes) char *_DstBuf, _In_ int _SizeInBytes)
#define MultiByteToWideChar
#define crc32(crc, buf, len)
#define Z_DEFAULT_STRATEGY
int deflate(z_streamp strm, int flush) DECLSPEC_HIDDEN
int deflateEnd(z_streamp strm) DECLSPEC_HIDDEN
UINT(* handler)(MSIPACKAGE *)
__kernel_ptrdiff_t ptrdiff_t
int xmlCharEncOutput(xmlOutputBufferPtr output, int init)
int xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
XMLPUBFUN int XMLCALL xmlCharEncCloseFunc(xmlCharEncodingHandler *handler)
int(* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlGetCharEncodingHandler(xmlCharEncoding enc)
static unsigned char buff[32768]
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLenum GLenum input
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
int ZEXPORT gzclose(gzFile file)
int ZEXPORT gzrewind(gzFile file)
gzFile ZEXPORT gzopen(char *path, const char *mode) const
gzFile ZEXPORT gzdopen(int fd, const char *mode)
int ZEXPORT gzdirect(gzFile file)
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
#define MB_ERR_INVALID_CHARS
_CRTIMP char *__cdecl tempnam(_In_opt_z_ const char *_Directory, _In_opt_z_ const char *_FilePrefix)
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
_CRTIMP int __cdecl _wstat(_In_z_ const wchar_t *_Name, _Out_ struct _stat *_Stat)
int xmlInputReadCallbackNop(void *context, char *buffer, int len)
void __xmlIOErr(int domain, int code, const char *extra)
void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2
void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar *str1, const xmlChar *str2)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename)
XML_DEPRECATED XMLPUBFUN int XMLCALL xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler)
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
_CRTIMP int __cdecl _wopen(const wchar_t *_Filename, int _OpenFlag,...)
XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL xmlOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL xmlParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
xmlParserInputBufferPtr(* xmlParserInputBufferCreateFilenameFunc)(const char *URI, xmlCharEncoding enc)
XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue
XMLPUBVAR xmlStrdupFunc xmlMemStrdup
XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue
xmlOutputBufferPtr(* xmlOutputBufferCreateFilenameFunc)(const char *URI, xmlCharEncodingHandlerPtr encoder, int compression)
XMLPUBVAR xmlMallocFunc xmlMalloc
XMLPUBVAR int xmlDefaultBufferSize
XMLPUBVAR xmlFreeFunc xmlFree
XMLPUBVAR void * xmlGenericErrorContext
XMLPUBVAR xmlReallocFunc xmlRealloc
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
XMLPUBFUN xmlExternalEntityLoader XMLCALL xmlGetExternalEntityLoader(void)
XMLPUBFUN void XMLCALL xmlSetExternalEntityLoader(xmlExternalEntityLoader f)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
xmlParserInputPtr(* xmlExternalEntityLoader)(const char *URL, const char *ID, xmlParserCtxtPtr context)
XMLPUBFUN xmlChar *XMLCALL xmlBufEnd(xmlBufPtr buf)
XMLPUBFUN int XMLCALL xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len)
xmlOutputBuffer * xmlOutputBufferPtr
XMLPUBFUN size_t XMLCALL xmlBufUse(const xmlBufPtr buf)
struct _xmlOutputBuffer xmlOutputBuffer
XMLPUBFUN size_t XMLCALL xmlBufShrink(xmlBufPtr buf, size_t len)
@ XML_BUFFER_ALLOC_IMMUTABLE
@ XML_BUFFER_ALLOC_DOUBLEIT
xmlParserCtxt * xmlParserCtxtPtr
xmlParserInputBuffer * xmlParserInputBufferPtr
XMLPUBFUN xmlChar *XMLCALL xmlBufContent(const xmlBuf *buf)
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
struct _xmlSAXHandler * sax
xmlParserInputState instate
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
XMLPUBFUN char *XMLCALL xmlURIUnescapeString(const char *str, int len, char *target)
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
#define IS_XMLPGD_SEP(ch)
static void xmlIOErrMemory(const char *extra)
#define MAX_INPUT_CALLBACK
static const char *const IOerr[]
static xmlInputCallback xmlInputCallbackTable[MAX_INPUT_CALLBACK]
struct _xmlInputCallback xmlInputCallback
static int xmlInputCallbackInitialized
static int xmlInputCallbackNr
XMLPUBFUN void *XMLCALL xmlFileOpen(const char *filename)
XMLPUBFUN int XMLCALL xmlRegisterInputCallbacks(xmlInputMatchCallback matchFunc, xmlInputOpenCallback openFunc, xmlInputReadCallback readFunc, xmlInputCloseCallback closeFunc)
XMLPUBFUN int XMLCALL xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len)
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlAllocParserInputBuffer(xmlCharEncoding enc)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc)
XMLPUBFUN int XMLCALL xmlFileMatch(const char *filename)
int(XMLCALL * xmlInputMatchCallback)(char const *filename)
int(XMLCALL * xmlInputReadCallback)(void *context, char *buffer, int len)
XMLPUBFUN void XMLCALL xmlCleanupInputCallbacks(void)
xmlParserInputBufferPtr __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)
void *(XMLCALL * xmlInputOpenCallback)(char const *filename)
XMLPUBFUN int XMLCALL xmlPopInputCallbacks(void)
XMLPUBFUN void XMLCALL xmlRegisterDefaultInputCallbacks(void)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateStatic(const char *mem, int size, xmlCharEncoding enc)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
XMLPUBFUN int XMLCALL xmlCheckFilename(const char *path)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret)
XMLPUBFUN int XMLCALL xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len)
int(XMLCALL * xmlInputCloseCallback)(void *context)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNoNetExternalEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
XMLPUBFUN int XMLCALL xmlParserInputBufferPush(xmlParserInputBufferPtr in, int len, const char *buf)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
XMLPUBFUN xmlChar *XMLCALL xmlNormalizeWindowsPath(const xmlChar *path)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFile(FILE *file, xmlCharEncoding enc)
XMLPUBFUN int XMLCALL xmlFileClose(void *context)
XMLPUBFUN int XMLCALL xmlFileRead(void *context, char *buffer, int len)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)
void(XMLCDECL * xmlGenericErrorFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
void(XMLCDECL *) typedef void(XMLCALL * xmlStructuredErrorFunc)(void *userData, xmlErrorPtr error)
@ XML_ERR_UNKNOWN_ENCODING
XMLPUBFUN const xmlChar *XMLCALL xmlStrstr(const xmlChar *str, const xmlChar *val)
XMLPUBFUN int XMLCALL xmlStrPrintf(xmlChar *buf, int len, const char *msg,...) LIBXML_ATTR_FORMAT(3
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
XMLPUBFUN int XMLCALL xmlStrncasecmp(const xmlChar *str1, const xmlChar *str2, int len)
xzFile __libxml2_xzopen(const char *path, const char *mode)
xzFile __libxml2_xzdopen(int fd, const char *mode)
int __libxml2_xzclose(xzFile file)
int __libxml2_xzread(xzFile file, void *buf, unsigned len)
int __libxml2_xzcompressed(xzFile f)