27#ifdef LIBXML_ZLIB_ENABLED
30#ifdef LIBXML_LZMA_ENABLED
35#define WIN32_LEAN_AND_MEAN
43# define S_ISDIR(x) _S_ISDIR(x)
44# elif defined(S_IFDIR)
46# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
47# elif defined(_S_IFMT)
48# define S_ISDIR(m) (((m) & _S_IFMT) == S_IFDIR)
61#ifdef LIBXML_CATALOG_ENABLED
85#define MAX_INPUT_CALLBACK 15
91#ifdef LIBXML_OUTPUT_ENABLED
95typedef struct _xmlOutputCallback {
96 xmlOutputMatchCallback matchcallback;
97 xmlOutputOpenCallback opencallback;
98 xmlOutputWriteCallback writecallback;
99 xmlOutputCloseCallback closecallback;
102#define MAX_OUTPUT_CALLBACK 15
104static xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK];
105static int xmlOutputCallbackNr = 0;
106static int xmlOutputCallbackInitialized = 0;
118 "Resource temporarily unavailable",
119 "Bad file descriptor",
122 "Operation canceled",
123 "No child processes",
124 "Resource deadlock avoided",
129 "Operation in progress",
130 "Interrupted function call",
132 "Input/output error",
134 "Too many open files",
136 "Inappropriate message buffer length",
138 "Too many open files in system",
140 "No such file or directory",
142 "No locks available",
144 "No space left on device",
145 "Function not implemented",
147 "Directory not empty",
149 "Inappropriate I/O control operation",
150 "No such device or address",
151 "Operation not permitted",
154 "Read-only file system",
157 "Operation timed out",
159 "Attempt to load network entity %s",
168 "connection refused",
169 "unreachable network",
172 "unknown address family",
183__xmlIOWin32UTF8ToWChar(
const char *u8String)
185 wchar_t *wString =
NULL;
192 wString =
xmlMalloc(wLen *
sizeof(
wchar_t));
195 (
CP_UTF8, 0, u8String, -1, wString, wLen) == 0) {
207#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
215xmlIOErrMemory(
const char *
extra)
421 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)
ctx;
427 if ((ctxt !=
NULL) && (ctxt->disableSAX != 0) &&
430 if ((ctxt !=
NULL) && (ctxt->sax !=
NULL)) {
431 if (ctxt->validate) {
432 channel = ctxt->sax->error;
435 channel = ctxt->sax->warning;
439 schannel = ctxt->sax->serror;
440 data = ctxt->userData;
520#ifdef LIBXML_OUTPUT_ENABLED
528xmlCleanupOutputCallbacks(
void)
532 if (!xmlOutputCallbackInitialized)
535 for (
i = xmlOutputCallbackNr - 1;
i >= 0;
i--) {
536 xmlOutputCallbackTable[
i].matchcallback =
NULL;
537 xmlOutputCallbackTable[
i].opencallback =
NULL;
538 xmlOutputCallbackTable[
i].writecallback =
NULL;
539 xmlOutputCallbackTable[
i].closecallback =
NULL;
542 xmlOutputCallbackNr = 0;
543 xmlOutputCallbackInitialized = 0;
555xmlPopOutputCallbacks(
void)
557 if (!xmlOutputCallbackInitialized)
560 if (xmlOutputCallbackNr <= 0)
563 xmlOutputCallbackNr--;
564 xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback =
NULL;
565 xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback =
NULL;
566 xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback =
NULL;
567 xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback =
NULL;
569 return(xmlOutputCallbackNr);
591xmlWrapOpenUtf8(
const char *
path,
int mode)
596 wPath = __xmlIOWin32UTF8ToWChar(
path);
609#ifdef LIBXML_ZLIB_ENABLED
611xmlWrapGzOpenUtf8(
const char *
path,
const char *
mode)
620 wPath = __xmlIOWin32UTF8ToWChar(
path);
650 wPath = __xmlIOWin32UTF8ToWChar(
path);
682 struct _stat stat_buffer;
684 struct stat stat_buffer;
696 if ((
path[0] ==
'\\') && (
path[1] ==
'\\') && (
path[2] ==
'?') &&
700 if (xmlWrapStatUtf8(
path, &stat_buffer) == -1)
707 if (
S_ISDIR(stat_buffer.st_mode))
729 if (
ret < 0) xmlIOErr(0,
"read()");
733#ifdef LIBXML_OUTPUT_ENABLED
750 if (
ret < 0) xmlIOErr(0,
"write()");
768 if (
ret < 0) xmlIOErr(0,
"close()");
795xmlFileOpen_real (
const char *
filename) {
835 fd = xmlWrapOpenUtf8(
path, 0);
860 if (unescaped !=
NULL) {
861 retval = xmlFileOpen_real(unescaped);
869#ifdef LIBXML_OUTPUT_ENABLED
880xmlFileOpenW (
const char *
filename) {
908 fd = xmlWrapOpenUtf8(
path, 1);
936 if (
ret < 0) xmlIOErr(0,
"fread()");
940#ifdef LIBXML_OUTPUT_ENABLED
959 xmlIOErr(0,
"fwrite()");
985 xmlIOErr(0,
"fflush()");
992 xmlIOErr(0,
"fclose()");
1003xmlFileFlush (
void *
context) {
1010 xmlIOErr(0,
"fflush()");
1014#ifdef LIBXML_OUTPUT_ENABLED
1036#ifdef LIBXML_ZLIB_ENABLED
1065xmlGzfileOpen_real (
const char *
filename) {
1072 if (
fd ==
Z_NULL && duped_fd >= 0) {
1076 return((
void *)
fd);
1100 fd = xmlWrapGzOpenUtf8(
path,
"rb");
1104 return((
void *)
fd);
1115xmlGzfileOpen (
const char *
filename) {
1122 if (unescaped !=
NULL) {
1123 retval = xmlGzfileOpen_real(unescaped);
1130#ifdef LIBXML_OUTPUT_ENABLED
1151 if (
fd ==
Z_NULL && duped_fd >= 0) {
1155 return((
void *)
fd);
1181 return((
void *)
fd);
1200 if (
ret < 0) xmlIOErr(0,
"gzread()");
1204#ifdef LIBXML_OUTPUT_ENABLED
1220 if (
ret < 0) xmlIOErr(0,
"gzwrite()");
1232xmlGzfileClose (
void *
context) {
1236 if (
ret < 0) xmlIOErr(0,
"gzclose()");
1241#ifdef LIBXML_LZMA_ENABLED
1247#include "private/xzlib.h"
1271xmlXzfileOpen_real (
const char *
filename) {
1277 return((
void *)
fd);
1295 fd = __libxml2_xzopen(
path,
"rb");
1296 return((
void *)
fd);
1309xmlXzfileOpen (
const char *
filename) {
1316 if (unescaped !=
NULL) {
1317 retval = xmlXzfileOpen_real(unescaped);
1340 if (
ret < 0) xmlIOErr(0,
"xzread()");
1351xmlXzfileClose (
void *
context) {
1354 ret = (__libxml2_xzclose((xzFile)
context) == LZMA_OK ) ? 0 : -1;
1355 if (
ret < 0) xmlIOErr(0,
"xzclose()");
1360#ifdef LIBXML_HTTP_ENABLED
1367#ifdef LIBXML_OUTPUT_ENABLED
1368typedef struct xmlIOHTTPWriteCtxt_
1376} xmlIOHTTPWriteCtxt, *xmlIOHTTPWriteCtxtPtr;
1378#ifdef LIBXML_ZLIB_ENABLED
1380#define DFLT_WBITS ( -15 )
1381#define DFLT_MEM_LVL ( 8 )
1382#define GZ_MAGIC1 ( 0x1f )
1383#define GZ_MAGIC2 ( 0x8b )
1384#define LXML_ZLIB_OS_CODE ( 0x03 )
1385#define INIT_HTTP_BUFF_SIZE ( 32768 )
1386#define DFLT_ZLIB_RATIO ( 5 )
1393typedef struct xmlZMemBuff_
1398 unsigned char * zbuff;
1401} xmlZMemBuff, *xmlZMemBuffPtr;
1412append_reverse_ulong( xmlZMemBuff *
buff,
unsigned long data ) {
1427 *
buff->zctrl.next_out = (
data & 0xff );
1429 buff->zctrl.next_out++;
1443xmlFreeZMemBuff( xmlZMemBuffPtr
buff ) {
1479 xmlIOErrMemory(
"creating buffer context");
1484 buff->size = INIT_HTTP_BUFF_SIZE;
1487 xmlFreeZMemBuff(
buff );
1488 xmlIOErrMemory(
"creating buffer");
1494 if ( z_err !=
Z_OK ) {
1496 xmlFreeZMemBuff(
buff );
1499 "xmlCreateZMemBuff: %s %d\n",
1500 "Error initializing compression context. ZLIB error:",
1509 "%c%c%c%c%c%c%c%c%c%c",
1511 0, 0, 0, 0, 0, 0, LXML_ZLIB_OS_CODE );
1512 buff->zctrl.next_out =
buff->zbuff + hdr_lgth;
1513 buff->zctrl.avail_out =
buff->size - hdr_lgth;
1530xmlZMemBuffExtend( xmlZMemBuffPtr
buff,
size_t ext_amt ) {
1536 unsigned char * tmp_ptr =
NULL;
1541 else if ( ext_amt == 0 )
1544 cur_used =
buff->zctrl.next_out -
buff->zbuff;
1548 if ( tmp_ptr !=
NULL ) {
1551 buff->zbuff = tmp_ptr;
1552 buff->zctrl.next_out = tmp_ptr + cur_used;
1558 "xmlZMemBuffExtend: %s %lu bytes.\n",
1559 "Allocation failure extending output buffer to",
1579xmlZMemBuffAppend( xmlZMemBuffPtr
buff,
const char *
src,
int len ) {
1588 buff->zctrl.next_in = (
unsigned char *)
src;
1589 while (
buff->zctrl.avail_in > 0 ) {
1594 min_accept =
buff->zctrl.avail_in / DFLT_ZLIB_RATIO;
1595 if (
buff->zctrl.avail_out <= min_accept ) {
1596 if ( xmlZMemBuffExtend(
buff,
buff->size ) == -1 )
1601 if ( z_err !=
Z_OK ) {
1604 "xmlZMemBuffAppend: %s %d %s - %d",
1605 "Compression error while appending",
1606 len,
"bytes to buffer. ZLIB error", z_err );
1629xmlZMemBuffGetContent( xmlZMemBuffPtr
buff,
char ** data_ref ) {
1642 if ( z_err ==
Z_OK ) {
1645 if ( xmlZMemBuffExtend(
buff,
buff->size ) == -1 )
1649 while ( z_err ==
Z_OK );
1657 if (
buff->zctrl.avail_out < ( 2 *
sizeof(
unsigned long ) ) ) {
1658 if ( xmlZMemBuffExtend(
buff, (2 *
sizeof(
unsigned long))) == -1 )
1667 append_reverse_ulong(
buff,
buff->crc );
1668 append_reverse_ulong(
buff,
buff->zctrl.total_in );
1670 zlgth =
buff->zctrl.next_out -
buff->zbuff;
1671 *data_ref = (
char *)
buff->zbuff;
1677 "xmlZMemBuffGetContent: %s - %d\n",
1678 "Error flushing zlib buffers. Error code", z_err );
1687#ifdef LIBXML_OUTPUT_ENABLED
1697xmlFreeHTTPWriteCtxt( xmlIOHTTPWriteCtxtPtr ctxt )
1699 if ( ctxt->uri !=
NULL )
1702 if ( ctxt->doc_buff !=
NULL ) {
1704#ifdef LIBXML_ZLIB_ENABLED
1705 if ( ctxt->compression > 0 ) {
1706 xmlFreeZMemBuff( ctxt->doc_buff );
1711 xmlOutputBufferClose( ctxt->doc_buff );
1730xmlIOHTTPMatch (
const char *
filename) {
1745xmlIOHTTPOpen (
const char *
filename) {
1749#ifdef LIBXML_OUTPUT_ENABLED
1765 xmlIOHTTPWriteCtxtPtr ctxt =
NULL;
1767 if (post_uri ==
NULL)
1770 ctxt =
xmlMalloc(
sizeof(xmlIOHTTPWriteCtxt));
1772 xmlIOErrMemory(
"creating HTTP output context");
1776 (
void)
memset(ctxt, 0,
sizeof(xmlIOHTTPWriteCtxt));
1779 if (ctxt->uri ==
NULL) {
1780 xmlIOErrMemory(
"copying URI");
1781 xmlFreeHTTPWriteCtxt(ctxt);
1791#ifdef LIBXML_ZLIB_ENABLED
1801 ctxt->doc_buff = xmlAllocOutputBufferInternal(
NULL);
1804 if (ctxt->doc_buff ==
NULL) {
1805 xmlFreeHTTPWriteCtxt(ctxt);
1813#ifdef LIBXML_OUTPUT_ENABLED
1825xmlIOHTTPDfltOpenW(
const char * post_uri ) {
1826 return ( xmlIOHTTPOpenW( post_uri, 0 ) );
1846#ifdef LIBXML_OUTPUT_ENABLED
1862 xmlIOHTTPWriteCtxtPtr ctxt =
context;
1871#ifdef LIBXML_ZLIB_ENABLED
1872 if ( ctxt->compression > 0 )
1873 len = xmlZMemBuffAppend( ctxt->doc_buff,
buffer,
len );
1877 len = xmlOutputBufferWrite( ctxt->doc_buff,
len,
buffer );
1882 "xmlIOHTTPWrite: %s\n%s '%s'.\n",
1883 "Error appending to internal buffer.",
1884 "Error sending document to URI",
1904xmlIOHTTPClose (
void *
context) {
1909#ifdef LIBXML_OUTPUT_ENABLED
1918xmlIOHTTPCloseWrite(
void *
context,
const char * http_mthd ) {
1922 int content_lgth = 0;
1923 xmlIOHTTPWriteCtxtPtr ctxt =
context;
1925 char * http_content =
NULL;
1926 char * content_encoding =
NULL;
1928 void * http_ctxt =
NULL;
1930 if ( ( ctxt ==
NULL ) || ( http_mthd ==
NULL ) )
1935#ifdef LIBXML_ZLIB_ENABLED
1937 if ( ctxt->compression > 0 ) {
1938 content_lgth = xmlZMemBuffGetContent( ctxt->doc_buff, &http_content );
1939 content_encoding = (
char *)
"Content-Encoding: gzip";
1946 xmlOutputBufferPtr dctxt = ctxt->doc_buff;
1948 content_lgth =
xmlBufUse(dctxt->buffer);
1951 if ( http_content ==
NULL ) {
1954 "xmlIOHTTPCloseWrite: %s '%s' %s '%s'.\n",
1955 "Error retrieving content.\nUnable to",
1956 http_mthd,
"data to URI", ctxt->uri );
1962 http_ctxt = xmlNanoHTTPMethod( ctxt->uri, http_mthd, http_content,
1966 if ( http_ctxt !=
NULL ) {
1968 http_rtn = xmlNanoHTTPReturnCode( http_ctxt );
1969 if ( ( http_rtn >= 200 ) && ( http_rtn < 300 ) )
1974 "xmlIOHTTPCloseWrite: HTTP '%s' of %d %s\n'%s' %s %d\n",
1975 http_mthd, content_lgth,
1976 "bytes to URI", ctxt->uri,
1977 "failed. HTTP return code:", http_rtn );
1981 xmlNanoHTTPClose( http_ctxt );
1988 xmlFreeHTTPWriteCtxt( ctxt );
1990 return ( close_rc );
2002xmlIOHTTPClosePut(
void * ctxt ) {
2003 return ( xmlIOHTTPCloseWrite( ctxt,
"PUT" ) );
2016xmlIOHTTPClosePost(
void * ctxt ) {
2017 return ( xmlIOHTTPCloseWrite( ctxt,
"POST" ) );
2023#ifdef LIBXML_FTP_ENABLED
2038xmlIOFTPMatch (
const char *
filename) {
2053xmlIOFTPOpen (
const char *
filename) {
2082xmlIOFTPClose (
void *
context) {
2083 return ( xmlNanoFTPClose(
context) );
2114#ifdef LIBXML_OUTPUT_ENABLED
2127xmlRegisterOutputCallbacks(xmlOutputMatchCallback matchFunc,
2128 xmlOutputOpenCallback openFunc, xmlOutputWriteCallback writeFunc,
2129 xmlOutputCloseCallback closeFunc) {
2130 if (xmlOutputCallbackNr >= MAX_OUTPUT_CALLBACK) {
2133 xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback = matchFunc;
2134 xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback = openFunc;
2135 xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback = writeFunc;
2136 xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback = closeFunc;
2137 xmlOutputCallbackInitialized = 1;
2138 return(xmlOutputCallbackNr++);
2154#ifdef LIBXML_ZLIB_ENABLED
2156 xmlGzfileRead, xmlGzfileClose);
2158#ifdef LIBXML_LZMA_ENABLED
2160 xmlXzfileRead, xmlXzfileClose);
2163#ifdef LIBXML_HTTP_ENABLED
2165 xmlIOHTTPRead, xmlIOHTTPClose);
2168#ifdef LIBXML_FTP_ENABLED
2170 xmlIOFTPRead, xmlIOFTPClose);
2175#ifdef LIBXML_OUTPUT_ENABLED
2182xmlRegisterDefaultOutputCallbacks (
void) {
2183 if (xmlOutputCallbackInitialized)
2189#ifdef LIBXML_HTTP_ENABLED
2190 xmlRegisterOutputCallbacks(xmlIOHTTPMatch, xmlIOHTTPDfltOpenW,
2191 xmlIOHTTPWrite, xmlIOHTTPClosePut);
2210 xmlOutputCallbackInitialized = 1;
2213#ifdef LIBXML_HTTP_ENABLED
2223xmlRegisterHTTPPostCallbacks(
void ) {
2227 if ( xmlOutputCallbackInitialized == 0 )
2228 xmlRegisterDefaultOutputCallbacks( );
2230 xmlRegisterOutputCallbacks(xmlIOHTTPMatch, xmlIOHTTPDfltOpenW,
2231 xmlIOHTTPWrite, xmlIOHTTPClosePost);
2245xmlParserInputBufferPtr
2247 xmlParserInputBufferPtr
ret;
2249 ret = (xmlParserInputBufferPtr)
xmlMalloc(
sizeof(xmlParserInputBuffer));
2253 memset(
ret, 0,
sizeof(xmlParserInputBuffer));
2268 ret->compressed = -1;
2269 ret->rawconsumed = 0;
2274#ifdef LIBXML_OUTPUT_ENABLED
2285 xmlOutputBufferPtr
ret;
2287 ret = (xmlOutputBufferPtr)
xmlMalloc(
sizeof(xmlOutputBuffer));
2291 memset(
ret, 0,
sizeof(xmlOutputBuffer));
2332 xmlOutputBufferPtr
ret;
2334 ret = (xmlOutputBufferPtr)
xmlMalloc(
sizeof(xmlOutputBuffer));
2338 memset(
ret, 0,
sizeof(xmlOutputBuffer));
2390 if (
in->encoder !=
NULL) {
2393 if (
in->closecallback !=
NULL) {
2394 in->closecallback(
in->context);
2396 if (
in->buffer !=
NULL) {
2404#ifdef LIBXML_OUTPUT_ENABLED
2415xmlOutputBufferClose(xmlOutputBufferPtr
out)
2422 if (
out->writecallback !=
NULL)
2423 xmlOutputBufferFlush(
out);
2424 if (
out->closecallback !=
NULL) {
2425 err_rc =
out->closecallback(
out->context);
2427 written =
out->written;
2443 return ((err_rc == 0) ? written : err_rc);
2447xmlParserInputBufferPtr
2449 xmlParserInputBufferPtr
ret;
2485#ifdef LIBXML_ZLIB_ENABLED
2487 (
strcmp(URI,
"-") != 0)) {
2488#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230
2492 char *cptr, buff4[4];
2495 if (
strncmp(buff4, cptr, 4) == 0)
2496 ret->compressed = 0;
2498 ret->compressed = 1;
2505#ifdef LIBXML_LZMA_ENABLED
2507 (
strcmp(URI,
"-") != 0)) {
2508 ret->compressed = __libxml2_xzcompressed(
context);
2531xmlParserInputBufferPtr
2539#ifdef LIBXML_OUTPUT_ENABLED
2541__xmlOutputBufferCreateFilename(
const char *URI,
2544 xmlOutputBufferPtr
ret;
2548 char *unescaped =
NULL;
2549#ifdef LIBXML_ZLIB_ENABLED
2550 int is_file_uri = 1;
2553 if (xmlOutputCallbackInitialized == 0)
2554 xmlRegisterDefaultOutputCallbacks();
2560#ifdef LIBXML_ZLIB_ENABLED
2579 if (unescaped !=
NULL) {
2580#ifdef LIBXML_ZLIB_ENABLED
2587 ret->writecallback = xmlGzfileWrite;
2588 ret->closecallback = xmlGzfileClose;
2595 for (
i = xmlOutputCallbackNr - 1;
i >= 0;
i--) {
2596 if ((xmlOutputCallbackTable[
i].matchcallback !=
NULL) &&
2597 (xmlOutputCallbackTable[
i].matchcallback(unescaped) != 0)) {
2598#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_ZLIB_ENABLED)
2600 if (xmlOutputCallbackTable[
i].matchcallback == xmlIOHTTPMatch)
2604 context = xmlOutputCallbackTable[
i].opencallback(unescaped);
2617#ifdef LIBXML_ZLIB_ENABLED
2624 ret->writecallback = xmlGzfileWrite;
2625 ret->closecallback = xmlGzfileClose;
2633 for (
i = xmlOutputCallbackNr - 1;
i >= 0;
i--) {
2634 if ((xmlOutputCallbackTable[
i].matchcallback !=
NULL) &&
2635 (xmlOutputCallbackTable[
i].matchcallback(URI) != 0)) {
2636#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_ZLIB_ENABLED)
2638 if (xmlOutputCallbackTable[
i].matchcallback == xmlIOHTTPMatch)
2642 context = xmlOutputCallbackTable[
i].opencallback(URI);
2659 ret->writecallback = xmlOutputCallbackTable[
i].writecallback;
2660 ret->closecallback = xmlOutputCallbackTable[
i].closecallback;
2681xmlOutputBufferCreateFilename(
const char *URI,
2701xmlParserInputBufferPtr
2703 xmlParserInputBufferPtr
ret;
2714 ret->closecallback = xmlFileFlush;
2720#ifdef LIBXML_OUTPUT_ENABLED
2733 xmlOutputBufferPtr
ret;
2735 if (xmlOutputCallbackInitialized == 0)
2736 xmlRegisterDefaultOutputCallbacks();
2743 ret->writecallback = xmlFileWrite;
2744 ret->closecallback = xmlFileFlush;
2760xmlOutputBufferCreateBuffer(xmlBufferPtr
buffer,
2762 xmlOutputBufferPtr
ret;
2766 ret = xmlOutputBufferCreateIO(xmlBufferWrite,
NULL, (
void *)
buffer,
2781xmlOutputBufferGetContent(xmlOutputBufferPtr
out) {
2797xmlOutputBufferGetSize(xmlOutputBufferPtr
out) {
2817xmlParserInputBufferPtr
2819 xmlParserInputBufferPtr
ret;
2821 if (
fd < 0)
return(
NULL);
2826 ret->readcallback = xmlFdRead;
2827 ret->closecallback = xmlFdClose;
2840xmlMemRead(
void *vctxt,
char *
buf,
int size) {
2841 xmlMemIOCtxt *ctxt = vctxt;
2843 if ((
size_t)
size > ctxt->size)
2854xmlMemClose(
void *vctxt) {
2855 xmlMemIOCtxt *ctxt = vctxt;
2882xmlParserInputBufferPtr
2884 xmlParserInputBufferPtr
buf;
2901 ctxt =
buf->context;
2925xmlParserInputBufferPtr
2928 xmlParserInputBufferPtr
ret;
2947 ret->context = ctxt;
2948 ret->readcallback = xmlMemRead;
2949 ret->closecallback = xmlMemClose;
2959xmlStringRead(
void *vctxt,
char *
buf,
int size) {
2960 xmlStringIOCtxt *ctxt = vctxt;
2974xmlStringClose(
void *vctxt) {
2988xmlParserInputBufferPtr
2990 xmlParserInputBufferPtr
ret;
2991 xmlStringIOCtxt *ctxt;
3006 ret->context = ctxt;
3007 ret->readcallback = xmlStringRead;
3008 ret->closecallback = xmlStringClose;
3013#ifdef LIBXML_OUTPUT_ENABLED
3026 xmlOutputBufferPtr
ret;
3028 if (
fd < 0)
return(
NULL);
3033 ret->writecallback = xmlFdWrite;
3053xmlParserInputBufferPtr
3056 xmlParserInputBufferPtr
ret;
3062 ret->context = (
void *) ioctx;
3063 ret->readcallback = ioread;
3064 ret->closecallback = ioclose;
3070#ifdef LIBXML_OUTPUT_ENABLED
3084xmlOutputBufferCreateIO(xmlOutputWriteCallback iowrite,
3085 xmlOutputCloseCallback ioclose,
void *ioctx,
3087 xmlOutputBufferPtr
ret;
3093 ret->context = (
void *) ioctx;
3094 ret->writecallback = iowrite;
3095 ret->closecallback = ioclose;
3134#ifdef LIBXML_OUTPUT_ENABLED
3136 old = __xmlOutputBufferCreateFilename;
3158 int len,
const char *
buf) {
3162 if (
len < 0)
return(0);
3163 if ((
in ==
NULL) || (
in->error))
return(-1);
3164 if (
in->encoder !=
NULL) {
3231 if ((
in ==
NULL) || (
in->error))
return(-1);
3235 if (
in->encoder ==
NULL) {
3236 if (
in->readcallback ==
NULL)
3249 if (
in->readcallback !=
NULL) {
3257 in->readcallback = endOfInput;
3272 if (
in->compressed == -1) {
3273#ifdef LIBXML_LZMA_ENABLED
3274 if (
in->readcallback == xmlXzfileRead)
3275 in->compressed = __libxml2_xzcompressed(
in->context);
3279 if (
in->encoder !=
NULL) {
3304#ifdef LIBXML_OUTPUT_ENABLED
3320xmlOutputBufferWrite(xmlOutputBufferPtr
out,
int len,
const char *
buf) {
3326 if ((
out ==
NULL) || (
out->error))
return(-1);
3327 if (
len < 0)
return(0);
3328 if (
out->error)
return(-1);
3356 if ((
ret < 0) && (
ret != -3)) {
3361 if (
out->writecallback)
3364 nbchars =
ret >= 0 ?
ret : 0;
3369 if (
out->writecallback)
3377 if (
out->writecallback) {
3426xmlEscapeContent(
unsigned char*
out,
int *outlen,
3428 unsigned char* outstart =
out;
3429 const unsigned char*
base =
in;
3430 unsigned char* outend =
out + *outlen;
3431 const unsigned char* inend;
3433 inend =
in + (*inlen);
3435 while ((
in < inend) && (
out < outend)) {
3437 if (outend -
out < 4)
break;
3442 }
else if (*
in ==
'>') {
3443 if (outend -
out < 4)
break;
3448 }
else if (*
in ==
'&') {
3449 if (outend -
out < 5)
break;
3455 }
else if (*
in ==
'\r') {
3456 if (outend -
out < 5)
break;
3467 *outlen =
out - outstart;
3488xmlOutputBufferWriteEscape(xmlOutputBufferPtr
out,
const xmlChar *
str,
3502 if (
len < 0)
return(0);
3503 if (
out->error)
return(-1);
3504 if (escaping ==
NULL) escaping = xmlEscapeContent;
3507 oldwritten = written;
3549 if ((
ret < 0) && (
ret != -3)) {
3554 if (
out->writecallback)
3557 nbchars =
ret >= 0 ?
ret : 0;
3563 if (
out->writecallback)
3571 if (
out->writecallback) {
3602 }
while ((
len > 0) && (oldwritten != written));
3622xmlOutputBufferWriteString(xmlOutputBufferPtr
out,
const char *
str) {
3625 if ((
out ==
NULL) || (
out->error))
return(-1);
3631 return(xmlOutputBufferWrite(
out,
len,
str));
3644xmlOutputBufferFlush(xmlOutputBufferPtr
out) {
3645 int nbchars = 0,
ret = 0;
3647 if ((
out ==
NULL) || (
out->error))
return(-1);
3669 (
out->writecallback !=
NULL)) {
3675 }
else if (
out->writecallback !=
NULL) {
3716# define IS_XMLPGD_SEP(ch) ((ch=='/')||(ch=='\\'))
3718# define IS_XMLPGD_SEP(ch) (ch=='/')
3765#ifdef LIBXML_HTTP_ENABLED
3767 (
ret->buf->readcallback == xmlIOHTTPRead) &&
3768 (
ret->buf->context !=
NULL)) {
3769 const char *encoding;
3774 code = xmlNanoHTTPReturnCode(
ret->buf->context);
3779 (
const char *)
ret->filename);
3786 mime = xmlNanoHTTPMimeType(
ret->buf->context);
3789 encoding = xmlNanoHTTPEncoding(
ret->buf->context);
3790 if (encoding !=
NULL) {
3798 "Unknown encoding %s",
3806 redir = xmlNanoHTTPRedir(
ret->buf->context);
3807 if (redir !=
NULL) {
3823static int xmlNoNetExists(
const char *URL) {
3847#ifdef LIBXML_CATALOG_ENABLED
3862xmlResolveResourceFromCatalog(
const char *URL,
const char *
ID,
3863 xmlParserCtxtPtr ctxt) {
3865 xmlCatalogAllow pref;
3871 pref = xmlCatalogGetDefaults();
3873 if ((pref != XML_CATA_ALLOW_NONE) && (!xmlNoNetExists(URL))) {
3877 if ((ctxt !=
NULL) && (ctxt->catalogs !=
NULL) &&
3878 ((pref == XML_CATA_ALLOW_ALL) ||
3879 (pref == XML_CATA_ALLOW_DOCUMENT))) {
3880 resource = xmlCatalogLocalResolve(ctxt->catalogs,
3888 ((pref == XML_CATA_ALLOW_ALL) ||
3889 (pref == XML_CATA_ALLOW_GLOBAL))) {
3902 if ((ctxt !=
NULL) && (ctxt->catalogs !=
NULL) &&
3903 ((pref == XML_CATA_ALLOW_ALL) ||
3904 (pref == XML_CATA_ALLOW_DOCUMENT))) {
3905 tmp = xmlCatalogLocalResolveURI(ctxt->catalogs,
resource);
3907 if ((tmp ==
NULL) &&
3908 ((pref == XML_CATA_ALLOW_ALL) ||
3909 (pref == XML_CATA_ALLOW_GLOBAL))) {
3910 tmp = xmlCatalogResolveURI(
resource);
3935static xmlParserInputPtr
3936xmlDefaultExternalEntityLoader(
const char *URL,
const char *
ID,
3937 xmlParserCtxtPtr ctxt)
3950#ifdef LIBXML_CATALOG_ENABLED
3951 resource = xmlResolveResourceFromCatalog(URL,
ID, ctxt);
3970 xmlDefaultExternalEntityLoader;
3980 xmlCurrentExternalEntityLoader =
f;
3992 return(xmlCurrentExternalEntityLoader);
4008 xmlParserCtxtPtr ctxt) {
4009 if ((URL !=
NULL) && (xmlNoNetExists(URL) == 0)) {
4010 char *canonicFilename;
4011 xmlParserInputPtr
ret;
4014 if (canonicFilename ==
NULL) {
4019 ret = xmlCurrentExternalEntityLoader(canonicFilename,
ID, ctxt);
4023 return(xmlCurrentExternalEntityLoader(URL,
ID, ctxt));
4045 xmlParserCtxtPtr ctxt) {
4049#ifdef LIBXML_CATALOG_ENABLED
4050 resource = xmlResolveResourceFromCatalog(URL,
ID, ctxt);
4065 input = xmlDefaultExternalEntityLoader((
const char *)
resource,
ID, ctxt);
pair cons(caddr_t car, pair cdr)
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
_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)
xmlChar * xmlBufEnd(xmlBufPtr buf)
void xmlBufFree(xmlBufPtr buf)
xmlBufPtr xmlBufCreateSize(size_t size)
xmlBufPtr xmlBufCreate(void)
xmlChar * xmlBufContent(const xmlBuf *buf)
int xmlBufSetAllocationScheme(xmlBufPtr buf, xmlBufferAllocationScheme scheme)
size_t xmlBufUse(const xmlBufPtr buf)
int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len)
int xmlBufGrow(xmlBufPtr buf, int len)
size_t xmlBufShrink(xmlBufPtr buf, size_t len)
#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 *)
int WINAPIV _wopen(const wchar_t *path, int flags,...)
int CDECL fclose(FILE *file)
size_t CDECL fread(void *ptr, size_t size, size_t nmemb, FILE *file)
FILE *CDECL _wfopen(const wchar_t *path, const wchar_t *mode)
FILE *CDECL fopen(const char *path, const char *mode)
int CDECL fflush(FILE *file)
int CDECL ferror(FILE *file)
size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file)
static char * getcwd(char *buf, int size)
_ACRTIMP size_t __cdecl strlen(const char *)
_ACRTIMP char *__cdecl strstr(const char *, const char *)
_ACRTIMP int __cdecl strcmp(const char *, const char *)
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
XML_HIDDEN int xmlCharEncInput(xmlParserInputBufferPtr input)
XML_HIDDEN int xmlCharEncOutput(xmlOutputBufferPtr output, int init)
xmlCharEncodingHandlerPtr xmlGetCharEncodingHandler(xmlCharEncoding enc)
xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler(const char *name)
int(* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
XMLPUBFUN int xmlCharEncCloseFunc(xmlCharEncodingHandler *handler)
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
#define memcpy(s1, s2, n)
XMLPUBFUN xmlParserInputPtr xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename)
XML_DEPRECATED XMLPUBFUN int xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler)
XMLPUBFUN void xmlFreeInputStream(xmlParserInputPtr input)
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue
xmlReallocFunc xmlRealloc
xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue
xmlStrdupFunc xmlMemStrdup
XMLPUBFUN xmlParserInputPtr xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlExternalEntityLoader xmlGetExternalEntityLoader(void)
XMLPUBFUN void xmlSetExternalEntityLoader(xmlExternalEntityLoader f)
xmlParserInputPtr(* xmlExternalEntityLoader)(const char *URL, const char *ID, xmlParserCtxtPtr context)
XML_HIDDEN void XML_HIDDEN void __xmlSimpleError(int domain, int code, struct _xmlNode *node, const char *msg, const char *extra) LIBXML_ATTR_FORMAT(4
XML_HIDDEN void __xmlRaiseError(xmlStructuredErrorFunc schannel, xmlGenericErrorFunc channel, void *data, void *ctx, void *nod, int domain, int code, xmlErrorLevel level, const char *file, int line, const char *str1, const char *str2, const char *str3, int int1, int col, const char *msg,...) LIBXML_ATTR_FORMAT(16
XML_HIDDEN void __xmlIOErr(int domain, int code, const char *extra)
XML_HIDDEN void xmlParserInputBufferPtr xmlParserInputBufferCreateString(const xmlChar *str)
XML_HIDDEN void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2
XML_HIDDEN void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XML_HIDDEN void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar *str1, const xmlChar *str2) LIBXML_ATTR_FORMAT(3
XMLPUBFUN void xmlFreeURI(xmlURIPtr uri)
XMLPUBFUN char * xmlURIUnescapeString(const char *str, int len, char *target)
XMLPUBFUN xmlURIPtr xmlParseURI(const char *str)
XMLPUBFUN xmlChar * xmlCanonicPath(const xmlChar *path)
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
#define IS_XMLPGD_SEP(ch)
#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 xmlParserInputBufferPtr xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
XMLPUBFUN xmlChar * xmlNormalizeWindowsPath(const xmlChar *path)
XMLPUBFUN xmlParserInputBufferPtr xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc)
xmlParserInputBufferPtr(* xmlParserInputBufferCreateFilenameFunc)(const char *URI, xmlCharEncoding enc)
XMLPUBFUN xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
XMLPUBFUN int xmlPopInputCallbacks(void)
XMLPUBFUN void xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN void xmlRegisterDefaultInputCallbacks(void)
XMLPUBFUN xmlParserInputBufferPtr xmlAllocParserInputBuffer(xmlCharEncoding enc)
XMLPUBFUN char * xmlParserGetDirectory(const char *filename)
XMLPUBFUN int xmlFileClose(void *context)
XML_GLOBALS_IO XMLPUBFUN void xmlCleanupInputCallbacks(void)
xmlOutputBufferPtr(* xmlOutputBufferCreateFilenameFunc)(const char *URI, xmlCharEncodingHandlerPtr encoder, int compression)
xmlParserInputBufferPtr __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)
XMLPUBFUN xmlParserInputBufferPtr xmlParserInputBufferCreateStatic(const char *mem, int size, xmlCharEncoding enc)
int(* xmlInputMatchCallback)(char const *filename)
void *(* xmlInputOpenCallback)(char const *filename)
XMLPUBFUN xmlParserInputPtr xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret)
XMLPUBFUN int xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len)
int(* xmlInputReadCallback)(void *context, char *buffer, int len)
XMLPUBFUN xmlParserInputBufferPtr xmlParserInputBufferCreateFile(FILE *file, xmlCharEncoding enc)
int(* xmlInputCloseCallback)(void *context)
XMLPUBFUN xmlParserInputBufferPtr xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
XMLPUBFUN void * xmlFileOpen(const char *filename)
XMLPUBFUN xmlParserInputPtr xmlNoNetExternalEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlParserInputBufferPtr xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)
XMLPUBFUN int xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len)
XMLPUBFUN int xmlParserInputBufferPush(xmlParserInputBufferPtr in, int len, const char *buf)
XMLPUBFUN int xmlCheckFilename(const char *path)
XMLPUBFUN int xmlFileRead(void *context, char *buffer, int len)
XMLPUBFUN int xmlRegisterInputCallbacks(xmlInputMatchCallback matchFunc, xmlInputOpenCallback openFunc, xmlInputReadCallback readFunc, xmlInputCloseCallback closeFunc)
XMLPUBFUN int xmlFileMatch(const char *filename)
void(*) typedef void(* xmlStructuredErrorFunc)(void *userData, const xmlError *error)
void(* xmlGenericErrorFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
@ XML_ERR_UNKNOWN_ENCODING
XMLPUBFUN xmlChar * xmlStrndup(const xmlChar *cur, int len)
XMLPUBFUN int xmlStrPrintf(xmlChar *buf, int len, const char *msg,...) LIBXML_ATTR_FORMAT(3
XMLPUBFUN const xmlChar * xmlStrstr(const xmlChar *str, const xmlChar *val)
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
XMLPUBFUN int xmlStrncasecmp(const xmlChar *str1, const xmlChar *str2, int len)
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)