update new sdk
This commit is contained in:
parent
f33907443a
commit
744c72c133
1643 changed files with 83006 additions and 28021 deletions
63
android/external/libxml2/nanohttp.c
vendored
63
android/external/libxml2/nanohttp.c
vendored
|
@ -11,7 +11,6 @@
|
|||
* daniel@veillard.com
|
||||
*/
|
||||
|
||||
#define NEED_SOCKETS
|
||||
#define IN_LIBXML
|
||||
#include "libxml.h"
|
||||
|
||||
|
@ -64,7 +63,7 @@
|
|||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#ifdef LIBXML_ZLIB_ENABLED
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
|
@ -74,14 +73,8 @@
|
|||
#define XML_SOCKLEN_T unsigned int
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) || defined(_WIN32_WCE)
|
||||
#ifndef _WINSOCKAPI_
|
||||
#define _WINSOCKAPI_
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include <wsockcompat.h>
|
||||
#include <winsock2.h>
|
||||
#undef XML_SOCKLEN_T
|
||||
#define XML_SOCKLEN_T unsigned int
|
||||
#endif
|
||||
|
||||
#include <libxml/globals.h>
|
||||
|
@ -152,7 +145,7 @@ typedef struct xmlNanoHTTPCtxt {
|
|||
char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */
|
||||
char *encoding; /* encoding extracted from the contentType */
|
||||
char *mimeType; /* Mime-Type extracted from the contentType */
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#ifdef LIBXML_ZLIB_ENABLED
|
||||
z_stream *strm; /* Zlib stream object */
|
||||
int usesGzip; /* "Content-Encoding: gzip" was detected */
|
||||
#endif
|
||||
|
@ -182,7 +175,21 @@ xmlHTTPErrMemory(const char *extra)
|
|||
*/
|
||||
static int socket_errno(void) {
|
||||
#ifdef _WINSOCKAPI_
|
||||
return(WSAGetLastError());
|
||||
int err = WSAGetLastError();
|
||||
switch(err) {
|
||||
case WSAECONNRESET:
|
||||
return(ECONNRESET);
|
||||
case WSAEINPROGRESS:
|
||||
return(EINPROGRESS);
|
||||
case WSAEINTR:
|
||||
return(EINTR);
|
||||
case WSAESHUTDOWN:
|
||||
return(ESHUTDOWN);
|
||||
case WSAEWOULDBLOCK:
|
||||
return(EWOULDBLOCK);
|
||||
default:
|
||||
return(err);
|
||||
}
|
||||
#else
|
||||
return(errno);
|
||||
#endif
|
||||
|
@ -427,7 +434,7 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
|
|||
if (ctxt->mimeType != NULL) xmlFree(ctxt->mimeType);
|
||||
if (ctxt->location != NULL) xmlFree(ctxt->location);
|
||||
if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader);
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#ifdef LIBXML_ZLIB_ENABLED
|
||||
if (ctxt->strm != NULL) {
|
||||
inflateEnd(ctxt->strm);
|
||||
xmlFree(ctxt->strm);
|
||||
|
@ -629,7 +636,7 @@ xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt)
|
|||
|
||||
if ((select(ctxt->fd + 1, &rfd, NULL, NULL, &tv) < 1)
|
||||
#if defined(EINTR)
|
||||
&& (errno != EINTR)
|
||||
&& (socket_errno() != EINTR)
|
||||
#endif
|
||||
)
|
||||
return (0);
|
||||
|
@ -810,7 +817,7 @@ xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) {
|
|||
if (ctxt->authHeader != NULL)
|
||||
xmlFree(ctxt->authHeader);
|
||||
ctxt->authHeader = xmlMemStrdup(cur);
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#ifdef LIBXML_ZLIB_ENABLED
|
||||
} else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Encoding:", 17) ) {
|
||||
cur += 17;
|
||||
while ((*cur == ' ') || (*cur == '\t')) cur++;
|
||||
|
@ -1038,16 +1045,13 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
|
|||
static SOCKET
|
||||
xmlNanoHTTPConnectHost(const char *host, int port)
|
||||
{
|
||||
struct hostent *h;
|
||||
struct sockaddr *addr = NULL;
|
||||
struct in_addr ia;
|
||||
struct sockaddr_in sockin;
|
||||
|
||||
#ifdef SUPPORT_IP6
|
||||
struct in6_addr ia6;
|
||||
struct sockaddr_in6 sockin6;
|
||||
#endif
|
||||
int i;
|
||||
SOCKET s;
|
||||
|
||||
memset (&sockin, 0, sizeof(sockin));
|
||||
|
@ -1084,7 +1088,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
|||
|
||||
for (res = result; res; res = res->ai_next) {
|
||||
if (res->ai_family == AF_INET) {
|
||||
if (res->ai_addrlen > sizeof(sockin)) {
|
||||
if ((size_t)res->ai_addrlen > sizeof(sockin)) {
|
||||
__xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
|
||||
freeaddrinfo (result);
|
||||
return INVALID_SOCKET;
|
||||
|
@ -1094,7 +1098,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
|||
addr = (struct sockaddr *)&sockin;
|
||||
#ifdef SUPPORT_IP6
|
||||
} else if (have_ipv6 () && (res->ai_family == AF_INET6)) {
|
||||
if (res->ai_addrlen > sizeof(sockin6)) {
|
||||
if ((size_t)res->ai_addrlen > sizeof(sockin6)) {
|
||||
__xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
|
||||
freeaddrinfo (result);
|
||||
return INVALID_SOCKET;
|
||||
|
@ -1122,6 +1126,10 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
|||
#endif
|
||||
#if !defined(HAVE_GETADDRINFO) || !defined(_WIN32)
|
||||
{
|
||||
struct hostent *h;
|
||||
struct in_addr ia;
|
||||
int i;
|
||||
|
||||
h = gethostbyname (GETHOSTBYNAME_ARG_CAST host);
|
||||
if (h == NULL) {
|
||||
|
||||
|
@ -1130,7 +1138,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
|||
* extraction code. it work on Linux, if it work on your platform
|
||||
* and one want to enable it, send me the defined(foobar) needed
|
||||
*/
|
||||
#if defined(HAVE_NETDB_H) && defined(HOST_NOT_FOUND) && defined(linux)
|
||||
#if defined(HAVE_NETDB_H) && defined(HOST_NOT_FOUND) && defined(__linux__)
|
||||
const char *h_err_txt = "";
|
||||
|
||||
switch (h_errno) {
|
||||
|
@ -1265,7 +1273,7 @@ xmlNanoHTTPOpenRedir(const char *URL, char **contentType, char **redir) {
|
|||
int
|
||||
xmlNanoHTTPRead(void *ctx, void *dest, int len) {
|
||||
xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx;
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#ifdef LIBXML_ZLIB_ENABLED
|
||||
int bytes_read = 0;
|
||||
int orig_avail_in;
|
||||
int z_ret;
|
||||
|
@ -1275,7 +1283,7 @@ xmlNanoHTTPRead(void *ctx, void *dest, int len) {
|
|||
if (dest == NULL) return(-1);
|
||||
if (len <= 0) return(0);
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#ifdef LIBXML_ZLIB_ENABLED
|
||||
if (ctxt->usesGzip == 1) {
|
||||
if (ctxt->strm == NULL) return(0);
|
||||
|
||||
|
@ -1416,16 +1424,16 @@ retry:
|
|||
/* 1 for '?' */
|
||||
blen += strlen(ctxt->query) + 1;
|
||||
blen += strlen(method) + strlen(ctxt->path) + 24;
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#ifdef LIBXML_ZLIB_ENABLED
|
||||
/* reserve for possible 'Accept-Encoding: gzip' string */
|
||||
blen += 23;
|
||||
#endif
|
||||
if (ctxt->port != 80) {
|
||||
/* reserve space for ':xxxxx', incl. potential proxy */
|
||||
if (proxy)
|
||||
blen += 12;
|
||||
blen += 17;
|
||||
else
|
||||
blen += 6;
|
||||
blen += 11;
|
||||
}
|
||||
bp = (char*)xmlMallocAtomic(blen);
|
||||
if ( bp == NULL ) {
|
||||
|
@ -1460,7 +1468,7 @@ retry:
|
|||
ctxt->hostname, ctxt->port);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#ifdef LIBXML_ZLIB_ENABLED
|
||||
p += snprintf(p, blen - (p - bp), "Accept-Encoding: gzip\r\n");
|
||||
#endif
|
||||
|
||||
|
@ -1534,7 +1542,8 @@ retry:
|
|||
xmlGenericError(xmlGenericErrorContext,
|
||||
"\nRedirect to: %s\n", ctxt->location);
|
||||
#endif
|
||||
while ( xmlNanoHTTPRecv(ctxt) > 0 ) ;
|
||||
while ( xmlNanoHTTPRecv(ctxt) > 0 )
|
||||
;
|
||||
if (nbRedirects < XML_NANO_HTTP_MAX_REDIR) {
|
||||
nbRedirects++;
|
||||
if (redirURL != NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue