* daniel@veillard.com
*/
-#define NEED_SOCKETS
#define IN_LIBXML
#include "libxml.h"
#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>
*/
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
if ((select(ctxt->fd + 1, &rfd, NULL, NULL, &tv) < 1)
#if defined(EINTR)
- && (errno != EINTR)
+ && (socket_errno() != EINTR)
#endif
)
return (0);
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));
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;
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;
#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) {
* 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) {
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 ) {
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)