version 1.1.1.1, 2012/02/21 23:37:57
|
version 1.1.1.2, 2013/07/22 01:22:19
|
Line 64
|
Line 64
|
#ifdef HAVE_STRINGS_H |
#ifdef HAVE_STRINGS_H |
#include <strings.h> |
#include <strings.h> |
#endif |
#endif |
#ifdef SUPPORT_IP6 |
|
#include <resolv.h> |
|
#endif |
|
#ifdef HAVE_ZLIB_H |
#ifdef HAVE_ZLIB_H |
#include <zlib.h> |
#include <zlib.h> |
#endif |
#endif |
Line 1140 xmlNanoHTTPConnectHost(const char *host, int port)
|
Line 1137 xmlNanoHTTPConnectHost(const char *host, int port)
|
"Non-recoverable errors: FORMERR, REFUSED, or NOTIMP."; |
"Non-recoverable errors: FORMERR, REFUSED, or NOTIMP."; |
break; |
break; |
|
|
|
#ifdef NO_ADDRESS |
case NO_ADDRESS: |
case NO_ADDRESS: |
h_err_txt = |
h_err_txt = |
"Valid name, no data record of requested type."; |
"Valid name, no data record of requested type."; |
break; |
break; |
|
#endif |
|
|
default: |
default: |
h_err_txt = "No error text defined."; |
h_err_txt = "No error text defined."; |
Line 1166 xmlNanoHTTPConnectHost(const char *host, int port)
|
Line 1165 xmlNanoHTTPConnectHost(const char *host, int port)
|
memcpy (&ia, h->h_addr_list[i], h->h_length); |
memcpy (&ia, h->h_addr_list[i], h->h_length); |
sockin.sin_family = h->h_addrtype; |
sockin.sin_family = h->h_addrtype; |
sockin.sin_addr = ia; |
sockin.sin_addr = ia; |
sockin.sin_port = (u_short)htons ((unsigned short)port); | sockin.sin_port = (unsigned short)htons ((unsigned short)port); |
addr = (struct sockaddr *) &sockin; |
addr = (struct sockaddr *) &sockin; |
#ifdef SUPPORT_IP6 |
#ifdef SUPPORT_IP6 |
} else if (have_ipv6 () && (h->h_addrtype == AF_INET6)) { |
} else if (have_ipv6 () && (h->h_addrtype == AF_INET6)) { |
Line 1615 xmlNanoHTTPFetch(const char *URL, const char *filename
|
Line 1614 xmlNanoHTTPFetch(const char *URL, const char *filename
|
char *buf = NULL; |
char *buf = NULL; |
int fd; |
int fd; |
int len; |
int len; |
| int ret = 0; |
| |
if (filename == NULL) return(-1); |
if (filename == NULL) return(-1); |
ctxt = xmlNanoHTTPOpen(URL, contentType); |
ctxt = xmlNanoHTTPOpen(URL, contentType); |
if (ctxt == NULL) return(-1); |
if (ctxt == NULL) return(-1); |
Line 1636 xmlNanoHTTPFetch(const char *URL, const char *filename
|
Line 1636 xmlNanoHTTPFetch(const char *URL, const char *filename
|
|
|
xmlNanoHTTPFetchContent( ctxt, &buf, &len ); |
xmlNanoHTTPFetchContent( ctxt, &buf, &len ); |
if ( len > 0 ) { |
if ( len > 0 ) { |
write(fd, buf, len); | if (write(fd, buf, len) == -1) { |
| ret = -1; |
| } |
} |
} |
|
|
xmlNanoHTTPClose(ctxt); |
xmlNanoHTTPClose(ctxt); |
close(fd); |
close(fd); |
return(0); | return(ret); |
} |
} |
|
|
#ifdef LIBXML_OUTPUT_ENABLED |
#ifdef LIBXML_OUTPUT_ENABLED |
Line 1660 xmlNanoHTTPSave(void *ctxt, const char *filename) {
|
Line 1662 xmlNanoHTTPSave(void *ctxt, const char *filename) {
|
char *buf = NULL; |
char *buf = NULL; |
int fd; |
int fd; |
int len; |
int len; |
| int ret = 0; |
| |
if ((ctxt == NULL) || (filename == NULL)) return(-1); |
if ((ctxt == NULL) || (filename == NULL)) return(-1); |
|
|
if (!strcmp(filename, "-")) |
if (!strcmp(filename, "-")) |
Line 1675 xmlNanoHTTPSave(void *ctxt, const char *filename) {
|
Line 1678 xmlNanoHTTPSave(void *ctxt, const char *filename) {
|
|
|
xmlNanoHTTPFetchContent( ctxt, &buf, &len ); |
xmlNanoHTTPFetchContent( ctxt, &buf, &len ); |
if ( len > 0 ) { |
if ( len > 0 ) { |
write(fd, buf, len); | if (write(fd, buf, len) == -1) { |
| ret = -1; |
| } |
} |
} |
|
|
xmlNanoHTTPClose(ctxt); |
xmlNanoHTTPClose(ctxt); |
close(fd); |
close(fd); |
return(0); | return(ret); |
} |
} |
#endif /* LIBXML_OUTPUT_ENABLED */ |
#endif /* LIBXML_OUTPUT_ENABLED */ |
|
|