summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2017-10-05 13:47:36 +0300
committerTimo Teräs <timo.teras@iki.fi>2017-10-05 16:59:14 +0300
commit531fea4c9082d6542c776dcb6d4ca0a3949ecdd0 (patch)
tree5d7d5ccb6d78c415cc4422569d9f88f0b1cf8bd1
parentf6860e0e110a82fe61ce46de4fb5a05794e456ab (diff)
downloadapk-tools-531fea4c9082d6542c776dcb6d4ca0a3949ecdd0.tar.gz
apk-tools-531fea4c9082d6542c776dcb6d4ca0a3949ecdd0.tar.bz2
apk-tools-531fea4c9082d6542c776dcb6d4ca0a3949ecdd0.tar.xz
apk-tools-531fea4c9082d6542c776dcb6d4ca0a3949ecdd0.zip
libfetch: remove unwanted code conditionals
-rw-r--r--libfetch/Makefile1
-rw-r--r--libfetch/common.c48
-rw-r--r--libfetch/common.h10
-rw-r--r--libfetch/fetch.c9
-rw-r--r--libfetch/file.c5
-rw-r--r--libfetch/ftp.c12
-rw-r--r--libfetch/http.c16
7 files changed, 7 insertions, 94 deletions
diff --git a/libfetch/Makefile b/libfetch/Makefile
index 6b183cb..05f045e 100644
--- a/libfetch/Makefile
+++ b/libfetch/Makefile
@@ -1,4 +1,3 @@
-CFLAGS_ALL += -DINET6 -DWITH_SSL -DFTP_COMBINE_CWDS
libs-y += libfetch.a
libfetch.a-objs := common.o fetch.o file.o ftp.o http.o
generate-y += ftperr.h httperr.h
diff --git a/libfetch/common.c b/libfetch/common.c
index 3538cc4..729c885 100644
--- a/libfetch/common.c
+++ b/libfetch/common.c
@@ -30,10 +30,6 @@
* $FreeBSD: common.c,v 1.53 2007/12/19 00:26:36 des Exp $
*/
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <poll.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -53,10 +49,6 @@
#include <string.h>
#include <unistd.h>
-#ifndef MSG_NOSIGNAL
-#include <signal.h>
-#endif
-
#include "fetch.h"
#include "common.h"
@@ -66,9 +58,7 @@
* Error messages for resolver errors
*/
static struct fetcherr netdb_errlist[] = {
-#ifdef EAI_NODATA
{ EAI_NODATA, FETCH_RESOLV, "Host not found" },
-#endif
{ EAI_AGAIN, FETCH_TEMP, "Transient resolver failure" },
{ EAI_FAIL, FETCH_RESOLV, "Non-recoverable resolver failure" },
{ EAI_NONAME, FETCH_RESOLV, "No address record" },
@@ -156,7 +146,7 @@ fetch_syserr(void)
case EHOSTDOWN:
fetchLastErrCode = FETCH_DOWN;
break;
-default:
+ default:
fetchLastErrCode = FETCH_UNKNOWN;
}
snprintf(fetchLastErrString, MAXERRSTRING, "%s", strerror(errno));
@@ -425,8 +415,6 @@ fetch_cache_put(conn_t *conn, int (*closecb)(conn_t *))
int
fetch_ssl(conn_t *conn, const struct url *URL, int verbose)
{
-
-#ifdef WITH_SSL
/* Init the SSL library and context */
if (!SSL_library_init()){
fprintf(stderr, "SSL library init failed\n");
@@ -446,14 +434,13 @@ fetch_ssl(conn_t *conn, const struct url *URL, int verbose)
}
conn->buf_events = 0;
SSL_set_fd(conn->ssl, conn->sd);
-#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
if (!SSL_set_tlsext_host_name(conn->ssl, (char *)(uintptr_t)URL->host)) {
fprintf(stderr,
"TLS server name indication extension failed for host %s\n",
URL->host);
return (-1);
}
-#endif
+
if (SSL_connect(conn->ssl) == -1){
ERR_print_errors_fp(stderr);
return (-1);
@@ -477,12 +464,6 @@ fetch_ssl(conn_t *conn, const struct url *URL, int verbose)
}
return (0);
-#else
- (void)conn;
- (void)verbose;
- fprintf(stderr, "SSL support disabled\n");
- return (-1);
-#endif
}
static int
@@ -546,7 +527,7 @@ fetch_read(conn_t *conn, char *buf, size_t len)
}
} while (pfd.revents == 0);
}
-#ifdef WITH_SSL
+
if (conn->ssl != NULL) {
rlen = SSL_read(conn->ssl, buf, len);
if (rlen == -1) {
@@ -566,9 +547,9 @@ fetch_read(conn_t *conn, char *buf, size_t len)
/* Assume buffering on the SSL layer. */
conn->buf_events = 0;
}
- } else
-#endif
+ } else {
rlen = read(conn->sd, buf, len);
+ }
if (rlen >= 0)
break;
@@ -655,17 +636,6 @@ fetch_write(conn_t *conn, const void *buf, size_t len)
fd_set writefds;
ssize_t wlen, total;
int r;
-#ifndef MSG_NOSIGNAL
- static int killed_sigpipe;
-#endif
-
-#ifndef MSG_NOSIGNAL
- if (!killed_sigpipe) {
- signal(SIGPIPE, SIG_IGN);
- killed_sigpipe = 1;
- }
-#endif
-
if (fetchTimeout) {
FD_ZERO(&writefds);
@@ -698,16 +668,10 @@ fetch_write(conn_t *conn, const void *buf, size_t len)
}
}
errno = 0;
-#ifdef WITH_SSL
if (conn->ssl != NULL)
wlen = SSL_write(conn->ssl, buf, len);
else
-#endif
-#ifndef MSG_NOSIGNAL
- wlen = send(conn->sd, buf, len, 0);
-#else
wlen = send(conn->sd, buf, len, MSG_NOSIGNAL);
-#endif
if (wlen == 0) {
/* we consider a short write a failure */
errno = EPIPE;
@@ -735,7 +699,6 @@ fetch_close(conn_t *conn)
{
int ret;
-#ifdef WITH_SSL
if (conn->ssl) {
SSL_shutdown(conn->ssl);
SSL_set_connect_state(conn->ssl);
@@ -747,7 +710,6 @@ fetch_close(conn_t *conn)
if (conn->ssl_cert) {
X509_free(conn->ssl_cert);
}
-#endif
ret = close(conn->sd);
if (conn->cache_url)
diff --git a/libfetch/common.h b/libfetch/common.h
index 9a07e35..e36027c 100644
--- a/libfetch/common.h
+++ b/libfetch/common.h
@@ -37,13 +37,11 @@
#define FTP_DEFAULT_PROXY_PORT 21
#define HTTP_DEFAULT_PROXY_PORT 3128
-#ifdef WITH_SSL
#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
-#endif
#if defined(__GNUC__) && __GNUC__ >= 3
#define LIBFETCH_PRINTFLIKE(fmtarg, firstvararg) \
@@ -70,19 +68,11 @@ struct fetchconn {
char *next_buf; /* pending buffer, e.g. after getln */
size_t next_len; /* size of pending buffer */
int err; /* last protocol reply code */
-#ifdef WITH_SSL
SSL *ssl; /* SSL handle */
SSL_CTX *ssl_ctx; /* SSL context */
X509 *ssl_cert; /* server certificate */
-# if OPENSSL_VERSION_NUMBER < 0x00909000L
- SSL_METHOD *ssl_meth; /* SSL method */
-# else
const SSL_METHOD *ssl_meth; /* SSL method */
-# endif
-#endif
-
char *ftp_home;
-
struct url *cache_url;
int cache_af;
int (*cache_close)(conn_t *);
diff --git a/libfetch/fetch.c b/libfetch/fetch.c
index 78cec71..4abf56f 100644
--- a/libfetch/fetch.c
+++ b/libfetch/fetch.c
@@ -30,10 +30,6 @@
* $FreeBSD: fetch.c,v 1.41 2007/12/19 00:26:36 des Exp $
*/
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
@@ -446,18 +442,17 @@ find_user:
}
/* hostname */
-#ifdef INET6
if (*p == '[' && (q = strchr(p + 1, ']')) != NULL &&
(*++q == '\0' || *q == '/' || *q == ':')) {
if ((i = q - p - 2) > URL_HOSTLEN)
i = URL_HOSTLEN;
strncpy(u->host, ++p, i);
p = q;
- } else
-#endif
+ } else {
for (i = 0; *p && (*p != '/') && (*p != ':'); p++)
if (i < URL_HOSTLEN)
u->host[i++] = *p;
+ }
/* port */
if (*p == ':') {
diff --git a/libfetch/file.c b/libfetch/file.c
index a18d94c..e78a96d 100644
--- a/libfetch/file.c
+++ b/libfetch/file.c
@@ -30,12 +30,7 @@
* $FreeBSD: file.c,v 1.18 2007/12/14 10:26:58 des Exp $
*/
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <sys/stat.h>
-
#include <dirent.h>
#include <fcntl.h>
#include <fnmatch.h>
diff --git a/libfetch/ftp.c b/libfetch/ftp.c
index af6a964..6caadf2 100644
--- a/libfetch/ftp.c
+++ b/libfetch/ftp.c
@@ -57,16 +57,10 @@
*
*/
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <sys/types.h>
#include <sys/socket.h>
-
#include <netinet/in.h>
#include <arpa/inet.h>
-
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@@ -353,7 +347,6 @@ ftp_cwd(conn_t *conn, const char *path, int subdir)
}
free(pwd);
-#ifdef FTP_COMBINE_CWDS
/* Skip leading slashes, even "////". */
for (beg = dst + i; beg < end && *beg == '/'; ++beg, ++i)
/* nothing */ ;
@@ -370,7 +363,6 @@ ftp_cwd(conn_t *conn, const char *path, int subdir)
free(dst);
return (0);
}
-#endif /* FTP_COMBINE_CWDS */
/* That didn't work so go back to legacy behavior (multiple CWDs). */
for (beg = dst + i; beg < end; beg = dst + i + 1) {
@@ -1019,11 +1011,7 @@ ftp_connect(struct url *url, struct url *purl, const char *flags)
{
conn_t *conn;
int e, direct, verbose;
-#ifdef INET6
int af = AF_UNSPEC;
-#else
- int af = AF_INET;
-#endif
direct = CHECK_FLAG('d');
verbose = CHECK_FLAG('v');
diff --git a/libfetch/http.c b/libfetch/http.c
index 6cf5aac..7b33e3c 100644
--- a/libfetch/http.c
+++ b/libfetch/http.c
@@ -63,16 +63,8 @@
* SUCH DAMAGE.
*/
-/* Needed for gmtime_r on Interix */
-#define _REENTRANT
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <sys/types.h>
#include <sys/socket.h>
-
#include <ctype.h>
#include <errno.h>
#include <locale.h>
@@ -702,19 +694,13 @@ http_connect(struct url *URL, struct url *purl, const char *flags, int *cached)
*cached = 0;
-#ifdef INET6
af = AF_UNSPEC;
-#else
- af = AF_INET;
-#endif
verbose = CHECK_FLAG('v');
if (CHECK_FLAG('4'))
af = AF_INET;
-#ifdef INET6
else if (CHECK_FLAG('6'))
af = AF_INET6;
-#endif
curl = (purl != NULL) ? purl : URL;
@@ -887,12 +873,10 @@ http_request(struct url *URL, const char *op, struct url_stat *us,
goto ouch;
host = url->host;
-#ifdef INET6
if (strchr(url->host, ':')) {
snprintf(hbuf, sizeof(hbuf), "[%s]", url->host);
host = hbuf;
}
-#endif
if (url->port != fetch_default_port(url->scheme)) {
if (host != hbuf) {
strcpy(hbuf, host);