summaryrefslogtreecommitdiff
path: root/nanohttp.c
diff options
context:
space:
mode:
authorAron Xu <aron@debian.org>2012-05-25 04:03:35 +0000
committerAron Xu <aron@debian.org>2012-05-25 04:03:35 +0000
commitd7372d053bbd1d58216fbb04d1771ffa4cc3e624 (patch)
tree62b661911406394bbeaca8951d660bb6d8aac0de /nanohttp.c
parent2d1849b271fa8697b88d07ba7d78dc83591e1363 (diff)
downloadlibxml2-d7372d053bbd1d58216fbb04d1771ffa4cc3e624.tar.gz
Imported Upstream version 2.8.0+dfsg1upstream/2.8.0+dfsg1
Diffstat (limited to 'nanohttp.c')
-rw-r--r--nanohttp.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/nanohttp.c b/nanohttp.c
index f669457..2437fed 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -64,9 +64,6 @@
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
-#ifdef SUPPORT_IP6
-#include <resolv.h>
-#endif
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
@@ -1140,10 +1137,12 @@ xmlNanoHTTPConnectHost(const char *host, int port)
"Non-recoverable errors: FORMERR, REFUSED, or NOTIMP.";
break;
+#ifdef NO_ADDRESS
case NO_ADDRESS:
h_err_txt =
"Valid name, no data record of requested type.";
break;
+#endif
default:
h_err_txt = "No error text defined.";
@@ -1166,7 +1165,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
memcpy (&ia, h->h_addr_list[i], h->h_length);
sockin.sin_family = h->h_addrtype;
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;
#ifdef SUPPORT_IP6
} else if (have_ipv6 () && (h->h_addrtype == AF_INET6)) {
@@ -1615,7 +1614,8 @@ xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) {
char *buf = NULL;
int fd;
int len;
-
+ int ret = 0;
+
if (filename == NULL) return(-1);
ctxt = xmlNanoHTTPOpen(URL, contentType);
if (ctxt == NULL) return(-1);
@@ -1636,12 +1636,14 @@ xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) {
xmlNanoHTTPFetchContent( ctxt, &buf, &len );
if ( len > 0 ) {
- write(fd, buf, len);
+ if (write(fd, buf, len) == -1) {
+ ret = -1;
+ }
}
xmlNanoHTTPClose(ctxt);
close(fd);
- return(0);
+ return(ret);
}
#ifdef LIBXML_OUTPUT_ENABLED
@@ -1660,7 +1662,8 @@ xmlNanoHTTPSave(void *ctxt, const char *filename) {
char *buf = NULL;
int fd;
int len;
-
+ int ret = 0;
+
if ((ctxt == NULL) || (filename == NULL)) return(-1);
if (!strcmp(filename, "-"))
@@ -1675,12 +1678,14 @@ xmlNanoHTTPSave(void *ctxt, const char *filename) {
xmlNanoHTTPFetchContent( ctxt, &buf, &len );
if ( len > 0 ) {
- write(fd, buf, len);
+ if (write(fd, buf, len) == -1) {
+ ret = -1;
+ }
}
xmlNanoHTTPClose(ctxt);
close(fd);
- return(0);
+ return(ret);
}
#endif /* LIBXML_OUTPUT_ENABLED */