Commit: eda382c99b8a36611504ebc1a4b39ca64f9901e7
Parent: fb0a4ebb4abbb6ddb7cfff410370e8b2afd62847
Author: opask
Date: Wed, 11 Jul 2018 00:23:35 -0600
remove unused code, cleanup #defines in config.h, update TODO
Diffstat:
M | TODO | | | 4 | ++++ |
D | bits.h | | | 50 | -------------------------------------------------- |
M | cache.c | | | 28 | ---------------------------- |
M | cfg.h | | | 14 | ++------------ |
M | compress.c | | | 19 | ++----------------- |
M | config.h | | | 402 | +------------------------------------------------------------------------------ |
M | connect.c | | | 24 | ++++-------------------- |
M | default.c | | | 24 | +----------------------- |
M | dip.c | | | 76 | ---------------------------------------------------------------------------- |
M | dither.c | | | 13 | +------------ |
M | dns.c | | | 99 | ------------------------------------------------------------------------------- |
M | fbcommon.inc | | | 69 | ++++++++++----------------------------------------------------------- |
M | http.c | | | 31 | ++++++------------------------- |
M | https.c | | | 160 | ------------------------------------------------------------------------------- |
M | kbd.c | | | 43 | ------------------------------------------- |
M | links.h | | | 121 | ++++--------------------------------------------------------------------------- |
M | main.c | | | 8 | +++----- |
M | memory.c | | | 2 | -- |
M | menu.c | | | 20 | +------------------- |
M | os_dep.c | | | 2 | -- |
M | os_dep.h | | | 11 | ----------- |
M | os_depx.h | | | 15 | --------------- |
M | png.c | | | 18 | ------------------ |
M | sched.c | | | 16 | ---------------- |
M | select.c | | | 75 | ++------------------------------------------------------------------------- |
M | session.c | | | 18 | ------------------ |
M | setup.h | | | 4 | +--- |
M | terminal.c | | | 2 | +- |
M | view.c | | | 2 | -- |
M | x.c | | | 76 | ++++++++++------------------------------------------------------------------ |
30 files changed, 54 insertions(+), 1392 deletions(-)
diff --git a/TODO b/TODO
@@ -1,3 +1,7 @@
+- target OpenBSD and musl/linux remove workarounds for everything else
+
+- KNF see style(9) on OpenBSD
+
- xembed support
- pledge(2) for OpenBSD
diff --git a/bits.h b/bits.h
@@ -1,50 +0,0 @@
-/* bits.h
- * (c) 2002 Karel 'Clock' Kulhavy
- * This file is a part of the Links program, released under GPL.
- */
-
-/* t2c
- * Type that has exactly 2 chars.
- * If there is none, t2c is not defined
- * The type may be signed or unsigned, it doesn't matter
- */
-#if SIZEOF_UNSIGNED_SHORT == 2
-#define t2c unsigned short
-#elif SIZEOF_UNSIGNED == 2
-#define t2c unsigned
-#elif SIZEOF_UNSIGNED_LONG == 2
-#define t2c unsigned long
-#elif defined(SIZEOF_UNSIGNED_LONG_LONG) && SIZEOF_UNSIGNED_LONG_LONG == 2
-#define t2c unsigned long long
-#endif /* #if sizeof(short) */
-
-/* t4c
- * Type that has exactly 4 chars.
- * If there is none, t4c is not defined
- * The type may be signed or unsigned, it doesn't matter
- */
-#if SIZEOF_UNSIGNED_SHORT == 4
-#define t4c unsigned short
-#elif SIZEOF_UNSIGNED == 4
-#define t4c unsigned
-#elif SIZEOF_UNSIGNED_LONG == 4
-#define t4c unsigned long
-#elif defined(SIZEOF_UNSIGNED_LONG_LONG) && SIZEOF_UNSIGNED_LONG_LONG == 4
-#define t4c unsigned long long
-#endif /* #if sizeof(short) */
-
-/* t8c
- * Type that has exactly 8 chars.
- * If there is none, t8c is not defined
- * The type may be signed or unsigned, it doesn't matter
- */
-#if SIZEOF_UNSIGNED_SHORT == 8
-#define t8c unsigned short
-#elif SIZEOF_UNSIGNED == 8
-#define t8c unsigned
-#elif SIZEOF_UNSIGNED_LONG == 8
-#define t8c unsigned long
-#elif defined(SIZEOF_UNSIGNED_LONG_LONG) && SIZEOF_UNSIGNED_LONG_LONG == 8
-#define t8c unsigned long long
-#endif /* #if sizeof(short) */
-
diff --git a/cache.c b/cache.c
@@ -5,10 +5,6 @@
#include "links.h"
-#if defined(HAVE_SEARCH_H) && defined(HAVE_TDELETE) && defined(HAVE_TFIND) && defined(HAVE_TSEARCH)
-#define USE_TREE
-#endif
-
static struct list_head cache = {&cache, &cache};
static my_uintptr_t cache_size = 0;
@@ -16,8 +12,6 @@ static my_uintptr_t cache_size = 0;
static tcount cache_count = 1;
-#ifdef USE_TREE
-
static void *cache_root = NULL;
static int ce_compare(const void *p1, const void *p2)
@@ -82,24 +76,6 @@ static struct cache_entry *cache_search_tree(unsigned char *url)
return get_struct(*p, struct cache_entry, url);
}
-#else
-
-static void cache_add_to_tree(struct cache_entry *e) { }
-static void cache_delete_from_tree(struct cache_entry *e) { }
-
-static struct cache_entry *cache_search_tree(unsigned char *url)
-{
- struct cache_entry *e;
- struct list_head *le;
- foreach(struct cache_entry, e, le, cache)
- if (!strcmp(cast_const_char e->url, cast_const_char url))
- return e;
- return NULL;
-}
-
-#endif
-
-
my_uintptr_t cache_info(int type)
{
my_uintptr_t i = 0;
@@ -473,9 +449,7 @@ void delete_cache_entry(struct cache_entry *e)
if (e->head) mem_free(e->head);
if (e->redirect) mem_free(e->redirect);
if (e->ip_address) mem_free(e->ip_address);
-#ifdef HAVE_SSL
if (e->ssl_info) mem_free(e->ssl_info);
-#endif
mem_free(e);
}
@@ -547,10 +521,8 @@ ret:
void init_cache(void)
{
-#ifdef HAVE_GETPAGESIZE
int getpg;
EINTRLOOP(getpg, getpagesize());
if (getpg > 0 && getpg < 0x10000 && !(getpg & (getpg - 1))) page_size = getpg;
-#endif
register_cache_upcall(shrink_file_cache, 0, cast_uchar "file");
}
diff --git a/cfg.h b/cfg.h
@@ -12,21 +12,11 @@
#include "config2.h"
#endif
-#if !defined(G) && DEBUGLEVEL >= 0 && defined(HAVE_SETJMP_H)
-#undef HAVE_SETJMP_H
+#if defined(G)
+#define HAVE_SETJMP_H 1
#endif
-#ifndef HAVE_VOLATILE
-#define volatile
-#endif
-
-#if defined(HAVE_RESTRICT)
-#define my_restrict restrict
-#elif defined(HAVE___RESTRICT)
#define my_restrict __restrict
-#else
-#define my_restrict
-#endif
typedef int cfg_h_no_empty_unit;
diff --git a/compress.c b/compress.c
@@ -1,5 +1,7 @@
#include "links.h"
+#include <zlib.h>
+
#ifdef write
#undef write
#endif
@@ -14,8 +16,6 @@ static int display_error(struct terminal *term, unsigned char *msg, int *errp)
return 1;
}
-#ifdef HAVE_ANY_COMPRESSION
-
static void decoder_memory_init(unsigned char **p, size_t *size, off_t init_length)
{
if (init_length > 0 && init_length < MAXINT) *size = (int)init_length;
@@ -56,10 +56,6 @@ static void decompress_error(struct terminal *term, struct cache_entry *ce, unsi
msg_box(term, getml(u, NULL), TEXT_(T_DECOMPRESSION_ERROR), AL_CENTER, TEXT_(T_ERROR_DECOMPRESSING_), u, TEXT_(T__wITH_), lib, cast_uchar ": ", msg, MSG_BOX_END, NULL, 1, TEXT_(T_CANCEL), msg_box_null, B_ENTER | B_ESC);
}
-#endif
-
-#ifdef HAVE_ZLIB
-#include <zlib.h>
static int decode_gzip(struct terminal *term, struct cache_entry *ce, int defl, int *errp)
{
unsigned char err;
@@ -255,7 +251,6 @@ static int decode_gzip(struct terminal *term, struct cache_entry *ce, int defl,
ce->decompressed = mem_realloc(ce->decompressed, ce->decompressed_len);
return 0;
}
-#endif
int get_file_by_term(struct terminal *term, struct cache_entry *ce, unsigned char **start, unsigned char **end, int *errp)
{
@@ -266,23 +261,19 @@ int get_file_by_term(struct terminal *term, struct cache_entry *ce, unsigned cha
*start = *end = NULL;
if (!ce) return 1;
if (ce->decompressed) {
-#if defined(HAVE_ANY_COMPRESSION)
return_decompressed:
-#endif
*start = ce->decompressed;
*end = ce->decompressed + ce->decompressed_len;
return 0;
}
enc = get_content_encoding(ce->head, ce->url, 0);
if (enc) {
-#ifdef HAVE_ZLIB
if (!casestrcmp(enc, cast_uchar "gzip") || !casestrcmp(enc, cast_uchar "x-gzip") || !casestrcmp(enc, cast_uchar "deflate")) {
int defl = !casestrcmp(enc, cast_uchar "deflate");
mem_free(enc);
if (decode_gzip(term, ce, defl, errp)) goto uncompressed;
goto return_decompressed;
}
-#endif
mem_free(enc);
goto uncompressed;
}
@@ -322,12 +313,9 @@ void free_decompressed_data(struct cache_entry *e)
}
}
-#ifdef HAVE_ANY_COMPRESSION
-
void add_compress_methods(unsigned char **s, int *l)
{
int cl = 0;
-#ifdef HAVE_ZLIB
{
if (!cl) cl = 1; else add_to_str(s, l, cast_uchar ", ");
add_to_str(s, l, cast_uchar "ZLIB");
@@ -337,7 +325,4 @@ void add_compress_methods(unsigned char **s, int *l)
add_to_str(s, l, cast_uchar ")");
#endif
}
-#endif
}
-
-#endif
diff --git a/config.h b/config.h
@@ -1,435 +1,35 @@
-/* The number of bytes in a unsigned. */
-#define SIZEOF_UNSIGNED 4
-
-/* The number of bytes in a unsigned long. */
-#define SIZEOF_UNSIGNED_LONG 8
-
-/* The number of bytes in a unsigned long long. */
-#define SIZEOF_UNSIGNED_LONG_LONG 8
-
-/* The number of bytes in a unsigned short. */
-#define SIZEOF_UNSIGNED_SHORT 2
-
-/* Define if you have the ASN1_STRING_get0_data function. */
-/* #define HAVE_ASN1_STRING_GET0_DATA 1 */
-
-/* Define if you have the ASN1_STRING_to_UTF8 function. */
-#define HAVE_ASN1_STRING_TO_UTF8 1
-
-/* Define if you have the OPENSSL_init_ssl function. */
-/* #define HAVE_OPENSSL_INIT_SSL 1 */
-
-/* Define if you have the SSL_get1_session function. */
-#define HAVE_SSL_GET1_SESSION 1
-
-/* Define if you have the SSL_load_error_strings function. */
-#define HAVE_SSL_LOAD_ERROR_STRINGS 1
-
-/* Define if you have the X509_check_host function. */
-#define HAVE_X509_CHECK_HOST 1
-
-/* Define if you have the X509_check_ip function. */
-#define HAVE_X509_CHECK_IP 1
-
-/* Define if you have the XCloseIM function. */
-#define HAVE_XCLOSEIM 1
-
-/* Define if you have the XCreateIC function. */
-#define HAVE_XCREATEIC 1
-
-/* Define if you have the XDestroyIC function. */
-#define HAVE_XDESTROYIC 1
-
-/* Define if you have the XOpenDisplay function. */
-#define HAVE_XOPENDISPLAY 1
-
-/* Define if you have the XOpenIM function. */
-#define HAVE_XOPENIM 1
-
-/* Define if you have the XSupportsLocale function. */
-#define HAVE_XSUPPORTSLOCALE 1
-
-/* Define if you have the XmbTextListToTextProperty function. */
-#define HAVE_XMBTEXTLISTTOTEXTPROPERTY 1
-
-/* Define if you have the Xutf8LookupString function. */
-#define HAVE_XUTF8LOOKUPSTRING 1
-
-/* Define if you have the XwcLookupString function. */
-#define HAVE_XWCLOOKUPSTRING 1
-
-/* Define if you have the event_base_free function. */
-#define HAVE_EVENT_BASE_FREE 1
-
-/* Define if you have the event_base_get_method function. */
-#define HAVE_EVENT_BASE_GET_METHOD 1
-
-/* Define if you have the event_base_new function. */
-#define HAVE_EVENT_BASE_NEW 1
-
-/* Define if you have the event_base_set function. */
-#define HAVE_EVENT_BASE_SET 1
-
-/* Define if you have the event_get_method function. */
-#define HAVE_EVENT_GET_METHOD 1
-
-/* Define if you have the event_get_version function. */
-#define HAVE_EVENT_GET_VERSION 1
-
-/* Define if you have the event_reinit function. */
-#define HAVE_EVENT_REINIT 1
-
-/* Define if you have the freeaddrinfo function. */
-#define HAVE_FREEADDRINFO 1
-
-/* Define if you have the getaddrinfo function. */
-#define HAVE_GETADDRINFO 1
-
-/* Define if you have the getgrgid function. */
-#define HAVE_GETGRGID 1
-
-/* Define if you have the getpagesize function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define if you have the getpid function. */
-#define HAVE_GETPID 1
-
-/* Define if you have the getpwuid function. */
-#define HAVE_GETPWUID 1
-
-/* Define if you have the getrlimit function. */
-#define HAVE_GETRLIMIT 1
-
-/* Define if you have the herror function. */
-#define HAVE_HERROR 1
-
-/* Define if you have the inet_ntop function. */
-#define HAVE_INET_NTOP 1
-
-/* Define if you have the inet_pton function. */
-#define HAVE_INET_PTON 1
-
-/* Define if you have the kqueue function. */
-#define HAVE_KQUEUE 1
-
-/* Define if you have the mktime function. */
-#define HAVE_MKTIME 1
-
-/* Define if you have the nl_langinfo function. */
-#define HAVE_NL_LANGINFO 1
-
-/* Define if you have the png_create_info_struct function. */
-#define HAVE_PNG_CREATE_INFO_STRUCT 1
-
-/* Define if you have the png_get_bit_depth function. */
-#define HAVE_PNG_GET_BIT_DEPTH 1
-
-/* Define if you have the png_get_color_type function. */
-#define HAVE_PNG_GET_COLOR_TYPE 1
-
-/* Define if you have the png_get_gAMA function. */
-#define HAVE_PNG_GET_GAMA 1
-
-/* Define if you have the png_get_image_height function. */
-#define HAVE_PNG_GET_IMAGE_HEIGHT 1
-
-/* Define if you have the png_get_image_width function. */
-#define HAVE_PNG_GET_IMAGE_WIDTH 1
-
-/* Define if you have the png_get_libpng_ver function. */
-#define HAVE_PNG_GET_LIBPNG_VER 1
-
-/* Define if you have the png_get_sRGB function. */
-#define HAVE_PNG_GET_SRGB 1
-
-/* Define if you have the png_get_valid function. */
-#define HAVE_PNG_GET_VALID 1
-
-/* Define if you have the png_set_rgb_to_gray function. */
-#define HAVE_PNG_SET_RGB_TO_GRAY 1
-
-/* Define if you have the png_set_strip_alpha function. */
-#define HAVE_PNG_SET_STRIP_ALPHA 1
-
-/* Define if you have the poll function. */
-#define HAVE_POLL 1
-
-/* Define if you have the popen function. */
-#define HAVE_POPEN 1
-
/* Define if you have the pthread_sigmask function. */
#define HAVE_PTHREAD_SIGMASK 1
-/* Define if you have the select function. */
-#define HAVE_SELECT 1
-
-/* Define if you have the setlocale function. */
-#define HAVE_SETLOCALE 1
-
-/* Define if you have the setpgid function. */
-#define HAVE_SETPGID 1
-
-/* Define if you have the setrlimit function. */
-#define HAVE_SETRLIMIT 1
-
-/* Define if you have the setsid function. */
-#define HAVE_SETSID 1
-
-/* Define if you have the sigaction function. */
-#define HAVE_SIGACTION 1
-
-/* Define if you have the sigblock function. */
-#define HAVE_SIGBLOCK 1
-
-/* Define if you have the sigdelset function. */
-#define HAVE_SIGDELSET 1
-
-/* Define if you have the sigprocmask function. */
-#define HAVE_SIGPROCMASK 1
-
-/* Define if you have the sigsetmask function. */
-#define HAVE_SIGSETMASK 1
-
-/* Define if you have the strptime function. */
-#define HAVE_STRPTIME 1
-
-/* Define if you have the strtoq function. */
-#define HAVE_STRTOQ 1
-
-/* Define if you have the tdelete function. */
-#define HAVE_TDELETE 1
-
-/* Define if you have the tfind function. */
-#define HAVE_TFIND 1
-
-/* Define if you have the tsearch function. */
-#define HAVE_TSEARCH 1
-
-/* Define if you have the uname function. */
-#define HAVE_UNAME 1
-
-/* Define if you have the utime function. */
-#define HAVE_UTIME 1
-
-/* Define if you have the utimes function. */
-#define HAVE_UTIMES 1
-
-/* Define if you have the <X11/X.h> header file. */
-#define HAVE_X11_X_H 1
-
-/* Define if you have the <X11/Xatom.h> header file. */
-#define HAVE_X11_XATOM_H 1
-
-/* Define if you have the <X11/Xlib.h> header file. */
-#define HAVE_X11_XLIB_H 1
-
-/* Define if you have the <X11/Xlocale.h> header file. */
-#define HAVE_X11_XLOCALE_H 1
-
-/* Define if you have the <X11/Xutil.h> header file. */
-#define HAVE_X11_XUTIL_H 1
-
-/* Define if you have the <X11/keysymdef.h> header file. */
-#define HAVE_X11_KEYSYMDEF_H 1
-
-/* Define if you have the <arpa/inet.h> header file. */
-#define HAVE_ARPA_INET_H 1
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <event.h> header file. */
-#define HAVE_EVENT_H 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <grp.h> header file. */
-#define HAVE_GRP_H 1
-
-/* Define if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define if you have the <langinfo.h> header file. */
-#define HAVE_LANGINFO_H 1
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-#if defined(__linux__)
-/* Define if you have the <linux/falloc.h> header file. */
-#define HAVE_LINUX_FALLOC_H 1
-
-/* Define if you have the <linux/fb.h> header file. */
-#define HAVE_LINUX_FB_H 1
-
-/* Define if you have the <linux/kd.h> header file. */
-#define HAVE_LINUX_KD_H 1
-
-/* Define if you have the <linux/vt.h> header file. */
-#define HAVE_LINUX_VT_H 1
-#endif
-
-/* Define if you have the <locale.h> header file. */
-#define HAVE_LOCALE_H 1
-
-/* Define if you have the <netinet/in_systm.h> header file. */
-#define HAVE_NETINET_IN_SYSTM_H 1
-
-/* Define if you have the <netinet/ip.h> header file. */
-#define HAVE_NETINET_IP_H 1
-
-/* Define if you have the <openssl/x509v3.h> header file. */
-#define HAVE_OPENSSL_X509V3_H 1
-
-/* Define if you have the <png.h> header file. */
-/*#define HAVE_PNG_H 1*/
-
-/* Define if you have the <poll.h> header file. */
-#define HAVE_POLL_H 1
-
-/* Define if you have the <pwd.h> header file. */
-#define HAVE_PWD_H 1
-
-/* Define if you have the <search.h> header file. */
-#define HAVE_SEARCH_H 1
-
-/* Define if you have the <setjmp.h> header file. */
-#define HAVE_SETJMP_H 1
-
-/* Define if you have the <stdarg.h> header file. */
-#define HAVE_STDARG_H 1
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define if you have the <sys/file.h> header file. */
-#define HAVE_SYS_FILE_H 1
-
-/* Define if you have the <sys/ioctl.h> header file. */
-#define HAVE_SYS_IOCTL_H 1
-
-/* Define if you have the <sys/mman.h> header file. */
-#define HAVE_SYS_MMAN_H 1
-
-/* Define if you have the <sys/resource.h> header file. */
-#define HAVE_SYS_RESOURCE_H 1
-
-/* Define if you have the <sys/select.h> header file. */
-#define HAVE_SYS_SELECT_H 1
-
-/* Define if you have the <sys/un.h> header file. */
-#define HAVE_SYS_UN_H 1
-
-/* Define if you have the <sys/utsname.h> header file. */
-#define HAVE_SYS_UTSNAME_H 1
-
-/* Define if you have the <termios.h> header file. */
-#define HAVE_TERMIOS_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the <zlib.h> header file. */
-#define HAVE_ZLIB_H 1
-
/* Define if you have the event library (-levent). */
#define HAVE_LIBEVENT 1
-/* Define if you have the m library (-lm). */
-#define HAVE_LIBM 1
-
/* Define if you have the pthread library (-lpthread). */
#define HAVE_LIBPTHREAD 1
-/* Define if you have the z library (-lz). */
-#define HAVE_LIBZ 1
-
/* Name of package */
#define PACKAGE "links"
/* Version number of package */
-#define VERSION "2.15"
-
-/* */
-#define VERSION "2.15"
-
-/* */
-#define HAVE_LONG_LONG 1
-
-/* */
-#define HAVE_STDLIB_H_X 1
-
-/* */
-#define HAVE_SOCKLEN_T 1
-
-/* */
-#define HAVE_VOLATILE 1
-
-/* */
-#define HAVE___RESTRICT 1
-
-/* */
-#define HAVE_ERRNO 1
-
-/* */
-#define C_LITTLE_ENDIAN 1
-
-/* */
-#define RENAME_OVER_EXISTING_FILES 1
+#define VERSION "2.16"
/* */
#define HAVE_SIGFILLSET 1
/* */
-#define HAVE_SIGSETJMP 1
-
-/* */
-#define DEBUGLEVEL 0
-
-/* */
-#define HAVE_GETHOSTBYNAME 1
-
-/* */
#define SUPPORT_IPV6 1
/* */
#define SUPPORT_IPV6_SCOPE 1
/* */
-#define HAVE_POW 1
-
-/* */
-#define HAVE_POWF 1
-
-/* */
-#define HAVE_XSETLOCALE 1
-
-/* */
#define HAVE_SSL 1
/* */
-#define HAVE_OPENSSL 1
-
-/* */
#define HAVE_CRYPTO_SET_MEM_FUNCTIONS_1 1
-/* */
-#define HAVE_ZLIB 1
-
-/* Gpm_Event has wdx and wdy */
-/* #undef HAVE_WDX_WDY */
-
#define HAVE_GETHOSTBYNAME 1
#define SUPPORT_IPV6 1
-#define DONT_USE_AF_UNIX 1
-
-#undef HAVE_GETHOSTBYNAME_BUG
-#undef EXTERNAL_LOOKUP
-
#undef USE_GPM
#undef HAVE_BUILTIN_SSL_CERTIFICATES
diff --git a/connect.c b/connect.c
@@ -63,10 +63,8 @@ static void log_ssl_error(unsigned char *url, int line, int ret1, int ret2)
unsigned char *u, *uu;
u = stracpy(url);
if ((uu = cast_uchar strchr(cast_const_char u, POST_CHAR))) *uu = 0;
-#if defined(HAVE_SSL_LOAD_ERROR_STRINGS) || defined(SSL_load_error_strings)
SSL_load_error_strings();
-#endif
-#if defined(HAVE_OPENSSL) && !defined(OPENSSL_NO_STDIO)
+#if !defined(OPENSSL_NO_STDIO)
ERR_print_errors_fp(stderr);
#else
{
@@ -578,13 +576,11 @@ void retry_connect(struct connection *c, int err, int ssl_downgrade)
{
struct conn_info *b = c->newconn;
if (!b->l.addr_index) b->first_error = err;
-#ifdef HAVE_SSL
if (c->ssl) {
freeSSL(c->ssl);
if (is_proxy_url(c->url)) c->ssl = NULL;
else c->ssl = DUMMY;
}
-#endif
if (ssl_downgrade) {
log_string(cast_uchar "\nSSL DOWNGRADE\n");
close_socket(b->sock);
@@ -685,7 +681,6 @@ static void try_connect(struct connection *c)
}
}
-#ifdef HAVE_SSL
void continue_connection(struct connection *c, int *sock, void (*func)(struct connection *))
{
struct conn_info *b;
@@ -700,7 +695,6 @@ void continue_connection(struct connection *c, int *sock, void (*func)(struct co
log_string(cast_uchar "\nCONTINUE CONNECTION\n");
connected(c);
}
-#endif
static void connected(void *c_)
{
@@ -911,7 +905,6 @@ static void write_select(void *c_)
for (wr = wb->pos; wr < wb->len; wr++) printf("%c", wb->data[wr]);
printf("-\n");*/
-#ifdef HAVE_SSL
if (c->ssl) {
set_handlers(wb->sock, NULL, write_select, c);
if ((wr = SSL_write(c->ssl->ssl, (void *)(wb->data + wb->pos), wb->len - wb->pos)) <= 0) {
@@ -931,9 +924,7 @@ static void write_select(void *c_)
return;
}
c->ssl->bytes_written += wr;
- } else
-#endif
- {
+ } else {
EINTRLOOP(wr, (int)write(wb->sock, wb->data + wb->pos, wb->len - wb->pos));
if (wr <= 0) {
setcstate(c, wr ? get_error_from_errno(errno) : S_CANT_WRITE);
@@ -989,7 +980,6 @@ read_more:
rb = mem_realloc(rb, sizeof(struct read_buffer) + rb->len + READ_SIZE);
c->buffer = rb;
-#ifdef HAVE_SSL
if (c->ssl) {
if ((rd = SSL_read(c->ssl->ssl, (void *)(rb->data + rb->len), READ_SIZE)) <= 0) {
int err;
@@ -1015,9 +1005,7 @@ read_more:
return;
}
c->ssl->bytes_read += rd;
- } else
-#endif
- {
+ } else {
EINTRLOOP(rd, (int)read(rb->sock, rb->data + rb->len, READ_SIZE));
if (rd <= 0) {
if (total_read) goto success;
@@ -1035,11 +1023,7 @@ read_more:
rb->len += rd;
total_read += rd;
- if ((rd == READ_SIZE
-#ifdef HAVE_SSL
- || c->ssl
-#endif
- ) && total_read <= TOTAL_READ) {
+ if ((rd == READ_SIZE || c->ssl) && total_read <= TOTAL_READ) {
if (can_read(rb->sock))
goto read_more;
}
diff --git a/default.c b/default.c
@@ -11,7 +11,6 @@ unsigned char system_name[MAX_STR_LEN];
static void get_system_name(void)
{
-#if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
{
struct utsname name;
int rs;
@@ -30,27 +29,6 @@ static void get_system_name(void)
return;
}
}
-#endif
-#ifdef HAVE_POPEN
- /*if (0) {
- FILE *f;
- unsigned char *p;
- memset(system_name, 0, MAX_STR_LEN);
- ENULLLOOP(f, popen("uname -srm", "r"));
- if (!f) goto fail;
- if (!fread(system_name, 1, MAX_STR_LEN - 1, f)) {
- pclose(f);
- goto fail;
- }
- pclose(f);
- for (p = system_name; *p; p++) if (*p < ' ') {
- *p = 0;
- break;
- }
- if (system_name[0]) return;
- }
- fail:*/
-#endif
strcpy(cast_char system_name, SYSTEM_NAME);
}
@@ -1325,7 +1303,7 @@ static unsigned char *lookup_cmd(struct option *o, unsigned char ***argv, int *a
do_real_lookup(h3, ipv6_options.addr_preference, &addr);
mem_free(h3);
if (!addr.n) {
-#if !defined(USE_GETADDRINFO) && defined(HAVE_GETHOSTBYNAME) && defined(HAVE_HERROR)
+#if !defined(USE_GETADDRINFO)
herror("error");
#else
fprintf(stderr, "error: host not found\n");
diff --git a/dip.c b/dip.c
@@ -110,23 +110,7 @@ static struct lru font_cache;
* for letters with an image under them )
*/
-#if defined(__i686__) || defined(__athlon__) || defined(__SSE2__) || defined(__x86_64__) || defined(__alpha) || defined(__hppa)
-/*
- * On modern processors it is faster to do this in floating point.
- * Do it only if we are sure that the coprocessor is present.
- */
typedef double scale_t;
-#define USE_FP_SCALE
-#elif defined(HAVE_LONG_LONG)
-typedef unsigned long long scale_t;
-#else
-/*
- * This may overflow, but systems without long long are very old
- * and we will rather accept overflow on big images (65536 pixels)
- * than slowing down the process unacceptably with possibly emulated FPU.
- */
-typedef unsigned long scale_t;
-#endif
/* Each input byte represents 1 byte (gray). The question whether 0 is
* black or 255 is black doesn't matter.
@@ -159,18 +143,6 @@ static void add_col_color(scale_t *my_restrict col_buf, unsigned short *my_restr
int line_skip, int n, ulonglong weight)
{
if (!weight) return;
-#ifndef USE_FP_SCALE
- if (weight < 0x10000) {
- unsigned short weight_16 = (unsigned short)weight;
- for (;n;n--){
- col_buf[0]+=(scale_t)((unsigned)weight_16*(unsigned)ptr[0]);
- col_buf[1]+=(scale_t)((unsigned)weight_16*(unsigned)ptr[1]);
- col_buf[2]+=(scale_t)((unsigned)weight_16*(unsigned)ptr[2]);
- ptr+=line_skip;
- col_buf+=3;
- }
- } else
-#endif
{
scale_t w = (scale_t)(longlong)weight;
for (;n;n--){
@@ -189,18 +161,6 @@ static void add_row_color(scale_t *my_restrict row_buf, unsigned short *my_restr
int n, ulonglong weight)
{
if (!weight) return;
-#ifndef USE_FP_SCALE
- if (weight < 0x10000) {
- unsigned short weight_16 = (unsigned short)weight;
- for (;n;n--){
- row_buf[0]+=(scale_t)((unsigned)weight_16*(unsigned)ptr[0]);
- row_buf[1]+=(scale_t)((unsigned)weight_16*(unsigned)ptr[1]);
- row_buf[2]+=(scale_t)((unsigned)weight_16*(unsigned)ptr[2]);
- ptr+=3;
- row_buf+=3;
- }
- } else
-#endif
{
scale_t w = (scale_t)(longlong)weight;
for (;n;n--){
@@ -256,11 +216,7 @@ static void bias_buf_color(scale_t *my_restrict col_buf, int n, scale_t half)
/* System activated */
}
-#ifdef USE_FP_SCALE
#define op(x) ((x) * inv_weight)
-#else
-#define op(x) (sizeof(unsigned long) < sizeof(scale_t) && (x) == (unsigned long)(x) ? (unsigned long)(x) / weight : (x) / weight)
-#endif
/* line skip is in pixels. Pixel is 3*unsigned short */
/* We assume unsigned holds at least 32 bits */
@@ -269,9 +225,7 @@ static void emit_and_bias_col_color(scale_t *my_restrict col_buf,
unsigned short *my_restrict out, int line_skip, int n, unsigned weight)
{
scale_t half=(scale_t)weight / 2;
-#ifdef USE_FP_SCALE
scale_t inv_weight = (scale_t)1 / weight;
-#endif
for (;n;n--){
out[0]=(unsigned short)op(col_buf[0]);
col_buf[0]=half;
@@ -296,9 +250,7 @@ static void emit_and_bias_row_color(scale_t *my_restrict row_buf,
unsigned short *my_restrict out, int n, unsigned weight)
{
scale_t half=(scale_t)weight / 2;
-#ifdef USE_FP_SCALE
scale_t inv_weight = (scale_t)1 / weight;
-#endif
for (;n;n--){
out[0]=(unsigned short)op(row_buf[0]);
row_buf[0]=half;
@@ -371,20 +323,7 @@ static void enlarge_gray_horizontal(unsigned char *in, int ix, int y,
static inline longlong multiply_int(int a, int b)
{
-#ifndef HAVE_LONG_LONG
- volatile
-#endif
longlong result = (ulonglong)a * (ulonglong)b;
-#if !defined(__TINYC__) && !defined(HAVE_LONG_LONG)
- if (result / a != (longlong)b) {
- /*fprintf(stderr, "%lld, %lld, %d, %d\n", result / a, result, a, b);*/
- overflow();
- }
-#endif
-#ifndef HAVE_LONG_LONG
- if (result == result + 1 || result == result - 1)
- overflow();
-#endif
return result;
}
@@ -1630,22 +1569,14 @@ const unsigned char *png_data, int png_length)
}
if (color_type==PNG_COLOR_TYPE_PALETTE){
png_set_expand(png_ptr);
-#ifdef HAVE_PNG_SET_RGB_TO_GRAY
png_set_rgb_to_gray(png_ptr, 1, -1, -1);
-#else
- goto end;
-#endif
}
if (color_type & PNG_COLOR_MASK_ALPHA){
png_set_strip_alpha(png_ptr);
}
if (color_type==PNG_COLOR_TYPE_RGB ||
color_type==PNG_COLOR_TYPE_RGB_ALPHA){
-#ifdef HAVE_PNG_SET_RGB_TO_GRAY
png_set_rgb_to_gray(png_ptr, 1, -1, -1);
-#else
- goto end;
-#endif
}
}
/* If the depth is different from 8 bits/gray, make the libpng expand
@@ -1666,13 +1597,6 @@ const unsigned char *png_data, int png_length)
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
mem_free(ptrs);
return;
-#ifndef HAVE_PNG_SET_RGB_TO_GRAY
- end:
- if (*x && (unsigned)*x * (unsigned)*y / (unsigned)*x != (unsigned)*y) overalloc();
- if ((unsigned)*x * (unsigned)*y > MAXINT) overalloc();
- *dest=mem_calloc(*x*(*y));
- return;
-#endif
}
/* Like load_char, but we dictate the y.
diff --git a/dither.c b/dither.c
@@ -10,8 +10,6 @@
#include "links.h"
-#include "bits.h"
-
#include <math.h>
/* The input of dithering function is 3 times 16-bit value. The value is
@@ -311,19 +309,10 @@ ROUND_TEMPLATE(round_1byte)
#undef SAVE_CODE
#define SKIP_CODE out->x*2
-#if defined(t2c) && defined(C_LITTLE_ENDIAN)
-#define SAVE_CODE \
- o=rt|gt|bt;\
- *(t2c *)outp=(o>>16);\
- outp+=2;
-#else
#define SAVE_CODE \
o=rt|gt|bt;\
- o>>=16;\
- *(unsigned char *)outp=o;\
- ((unsigned char *)outp)[1]=o>>8;\
+ *(unsigned short *)outp=(o>>16);\
outp+=2;
-#endif /* #ifdef t2c */
DITHER_TEMPLATE(dither_2byte)
ROUND_TEMPLATE(round_2byte)
diff --git a/dns.c b/dns.c
@@ -9,10 +9,6 @@
int support_ipv6;
#endif
-#if !defined(USE_GETADDRINFO) && (defined(HAVE_GETHOSTBYNAME_BUG) || !defined(HAVE_GETHOSTBYNAME))
-#define EXTERNAL_LOOKUP
-#endif
-
struct dnsentry {
list_entry_1st
uttime absolute_time;
@@ -96,14 +92,11 @@ int numeric_ipv6_address(unsigned char *name, unsigned char address[16], unsigne
unsigned char dummy_a[16];
unsigned dummy_s;
int r;
-#ifdef HAVE_INET_PTON
struct in6_addr i6a;
-#endif
struct addrinfo hints, *res;
if (!address) address = dummy_a;
if (!scope_id) scope_id = &dummy_s;
-#ifdef HAVE_INET_PTON
if (inet_pton(AF_INET6, cast_const_char name, &i6a) == 1) {
memcpy(address, &i6a, 16);
*scope_id = 0;
@@ -111,7 +104,6 @@ int numeric_ipv6_address(unsigned char *name, unsigned char address[16], unsigne
}
if (!strchr(cast_const_char name, '%'))
return -1;
-#endif
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET6;
@@ -125,71 +117,6 @@ int numeric_ipv6_address(unsigned char *name, unsigned char address[16], unsigne
#endif
-#ifdef EXTERNAL_LOOKUP
-
-static int do_external_lookup(unsigned char *name, unsigned char *host)
-{
- unsigned char buffer[1024];
- unsigned char sink[16];
- int rd;
- int pi[2];
- pid_t f;
- unsigned char *n;
- int rs;
- if (c_pipe(pi) == -1)
- return -1;
- EINTRLOOP(f, fork());
- if (f == -1) {
- EINTRLOOP(rs, close(pi[0]));
- EINTRLOOP(rs, close(pi[1]));
- return -1;
- }
- if (!f) {
-#ifdef HAVE_SETSID
- /* without setsid it gets stuck when on background */
- EINTRLOOP(rs, setsid());
-#endif
- EINTRLOOP(rs, close(pi[0]));
- EINTRLOOP(rs, dup2(pi[1], 1));
- if (rs == -1) _exit(1);
- EINTRLOOP(rs, dup2(pi[1], 2));
- if (rs == -1) _exit(1);
- EINTRLOOP(rs, close(pi[1]));
- EINTRLOOP(rs, execlp("host", "host", cast_const_char name, (char *)NULL));
- EINTRLOOP(rs, execl("/usr/sbin/host", "host", cast_const_char name, (char *)NULL));
- _exit(1);
- }
- EINTRLOOP(rs, close(pi[1]));
- rd = hard_read(pi[0], buffer, sizeof buffer - 1);
- if (rd >= 0) buffer[rd] = 0;
- if (rd > 0) {
- while (hard_read(pi[0], sink, sizeof sink) > 0);
- }
- EINTRLOOP(rs, close(pi[0]));
- /* Don't wait for the process, we already have sigchld handler that
- * does cleanup.
- * waitpid(f, NULL, 0); */
- if (rd < 0) return -1;
- /*fprintf(stderr, "query: '%s', result: %s\n", name, buffer);*/
- while ((n = strstr(buffer, name))) {
- memset(n, '-', strlen(cast_const_char name));
- }
- for (n = buffer; n < buffer + rd; n++) {
- if (*n >= '0' && *n <= '9') {
- if (get_addr_byte(&n, host + 0, '.')) goto skip_addr;
- if (get_addr_byte(&n, host + 1, '.')) goto skip_addr;
- if (get_addr_byte(&n, host + 2, '.')) goto skip_addr;
- if (get_addr_byte(&n, host + 3, 255)) goto skip_addr;
- return 0;
-skip_addr:
- if (n >= buffer + rd) break;
- }
- }
- return -1;
-}
-
-#endif
-
#if MAX_ADDRESSES > 1
static int memcmp_host_address(struct host_address *a, struct host_address *b)
{
@@ -378,13 +305,6 @@ void do_real_lookup(unsigned char *name, int preference, struct lookup_result *h
}
#endif
-#ifdef EXTERNAL_LOOKUP
- if (!do_external_lookup(name, address)) {
- add_address(host, AF_INET, address, 0, preference);
- goto ret;
- }
-#endif
-
ret:
return;
}
@@ -599,7 +519,6 @@ unsigned char *print_address(struct host_address *a)
#else
static unsigned char buffer[INET_ADDRSTRLEN + SCOPE_ID_LEN];
#endif
-#ifdef HAVE_INET_NTOP
union {
struct in_addr in;
#ifdef SUPPORT_IPV6
@@ -610,24 +529,6 @@ unsigned char *print_address(struct host_address *a)
memcpy(&u, a->addr, 16);
if (!inet_ntop(a->af, &u, cast_char buffer, sizeof buffer - SCOPE_ID_LEN))
return NULL;
-#else
- if (a->af == AF_INET)
- snprintf(cast_char buffer, sizeof buffer, "%d.%d.%d.%d", a->addr[0], a->addr[1], a->addr[2], a->addr[3]);
-#ifdef SUPPORT_IPV6
- else if (a->af == AF_INET6)
- snprintf(cast_char buffer, sizeof buffer, "%x:%x:%x:%x:%x:%x:%x:%x",
- (a->addr[0] << 8) | a->addr[1],
- (a->addr[2] << 8) | a->addr[3],
- (a->addr[4] << 8) | a->addr[5],
- (a->addr[6] << 8) | a->addr[7],
- (a->addr[8] << 8) | a->addr[9],
- (a->addr[10] << 8) | a->addr[11],
- (a->addr[12] << 8) | a->addr[13],
- (a->addr[14] << 8) | a->addr[15]);
-#endif
- else
- return NULL;
-#endif
if (a->scope_id) {
unsigned char *end = cast_uchar strchr(cast_const_char buffer, 0);
snprintf(cast_char end, buffer + sizeof(buffer) - end, "%%%u", a->scope_id);
diff --git a/fbcommon.inc b/fbcommon.inc
@@ -21,57 +21,29 @@ static inline void pixel_set(unsigned char *dest, int n,void * pattern)
case 2:
{
-#ifdef t2c
- t2c v=*(t2c *)do_not_optimize_here(pattern);
+ unsigned short v=*(unsigned short *)do_not_optimize_here(pattern);
/* ICC has an optimization bug here */
icc_volatile int a;
if ((v & 255) == ((v >> 8) & 255)) {
memset(dest, v, n);
} else {
-#ifdef t8c
- t8c vvvv=((t8c)v << 48) | ((t8c)v << 32) | ((t8c)v << 16) | v;
-#elif defined(t4c)
- t4c vv=((t4c)v << 16) | v;
-#endif
+ unsigned long vvvv=((unsigned long)v << 48) | ((unsigned long)v << 32) | ((unsigned long)v << 16) | v;
a = n >> 1;
while (a) {
-#ifdef t8c
if (!((unsigned long)dest & 7) && a >= 4) {
do {
- *((t8c *)dest) = vvvv;
+ *((unsigned long *)dest) = vvvv;
dest += 8;
a -= 4;
} while (a >= 4);
- } else
-#elif defined(t4c)
- if (!((unsigned long)dest & 3) && a >= 2) {
- do {
- *((t4c *)dest) = vv;
- dest += 4;
- a -= 2;
- } while (a >= 2);
- } else
-#endif
- {
- *((t2c *)dest) = v;
+ } else {
+ *((unsigned short *)dest) = v;
dest += 2;
a--;
}
}
}
-#else
- unsigned char a,b;
- int i;
-
- a=*(unsigned char*)pattern;
- b=((unsigned char*)pattern)[1];
- if (a == b) memset(dest, a, n);
- else for (i=0;i<=n-2;i+=2){
- dest[i]=a;
- dest[i+1]=b;
- }
-#endif
}
break;
@@ -97,48 +69,27 @@ static inline void pixel_set(unsigned char *dest, int n,void * pattern)
((unsigned char *)pattern)[1] == ((unsigned char *)pattern)[drv->depth & ~255 ? 3 : 0]) {
memset(dest, ((unsigned char *)pattern)[1], n);
} else {
-#ifdef t4c
- t4c v=*(t4c *)do_not_optimize_here(pattern);
+ unsigned v=*(unsigned *)do_not_optimize_here(pattern);
/* ICC has an optimization bug here */
icc_volatile int a;
{
-#ifdef t8c
- t8c vv = ((t8c)v << 32) | v;
-#endif
+ unsigned long vv = ((unsigned long)v << 32) | v;
a = n >> 2;
while (a) {
-#ifdef t8c
if (!((unsigned long)dest & 7) && a >= 2) {
do {
- *((t8c *)dest) = vv;
+ *((unsigned long *)dest) = vv;
dest += 8;
a -= 2;
} while (a >= 2);
- } else
-#endif
- {
- *(t4c *)dest = v;
+ } else {
+ *(unsigned *)dest = v;
dest += 4;
a--;
}
}
}
-#else
- unsigned char a,b,c,d;
- int i;
-
- a=*(unsigned char*)pattern;
- b=((unsigned char*)pattern)[1];
- c=((unsigned char*)pattern)[2];
- d=((unsigned char*)pattern)[3];
- for (i=0;i<=n-4;i+=4){
- dest[i]=a;
- dest[i+1]=b;
- dest[i+2]=c;
- dest[i+3]=d;
- }
-#endif
}
break;
diff --git a/http.c b/http.c
@@ -224,10 +224,8 @@ static void http_send_header(struct connection *c)
set_connection_timeout(c);
info = mem_calloc(sizeof(struct http_connection_info));
c->info = info;
-#ifdef HAVE_SSL
info->https_forward = !c->ssl && proxy && host && !casecmp(host, cast_uchar "https://", 8);
if (c->ssl) proxy = 0;
-#endif
hdr = init_str();
if (!host) {
http_bad_url:
@@ -246,7 +244,6 @@ static void http_send_header(struct connection *c)
if (post) post++;
}
info->send_close = info->https_forward || http10 || (post && http_options.bug_post_no_keepalive);
-#ifdef HAVE_SSL
if (info->https_forward) {
add_to_str(&hdr, &l, cast_uchar "CONNECT ");
h = get_host_name(host);
@@ -259,23 +256,21 @@ static void http_send_header(struct connection *c)
add_to_str(&hdr, &l, h);
mem_free(h);
goto added_connect;
- } else
-#endif
- if (!post) {
+ } else if (!post)
add_to_str(&hdr, &l, cast_uchar "GET ");
- } else {
+ else {
add_to_str(&hdr, &l, cast_uchar "POST ");
c->unrestartable = 2;
}
if (!proxy) {
add_to_str(&hdr, &l, cast_uchar "/");
u = get_url_data(host);
- } else {
+ } else
u = host;
- }
- if (post && post < u) {
+
+ if (post && post < u)
goto http_bad_url;
- }
+
u2 = u;
if (proxy && !*c->socks_proxy && *proxies.dns_append) {
unsigned char *u_host;
@@ -289,9 +284,7 @@ static void http_send_header(struct connection *c)
}
add_url_to_str(&hdr, &l, u2);
if (u2 != u) mem_free(u2);
-#ifdef HAVE_SSL
added_connect:
-#endif
if (!http10) add_to_str(&hdr, &l, cast_uchar " HTTP/1.1\r\n");
else add_to_str(&hdr, &l, cast_uchar " HTTP/1.0\r\n");
if (!info->https_forward && (h = get_host_name(host))) {
@@ -361,7 +354,6 @@ static void test_restart(struct connection *c)
mem_free(d);
c->from = 0;
c->no_compress = 1;
-#ifdef HAVE_ANY_COMPRESSION
if (c->tries >= 1) {
unsigned char *h;
if ((h = get_host_name(c->url))) {
@@ -369,7 +361,6 @@ static void test_restart(struct connection *c)
mem_free(h);
}
}
-#endif
}
}
}
@@ -492,7 +483,6 @@ static void add_accept_language(unsigned char **hdr, int *l, struct http_connect
}
}
-#ifdef HAVE_ANY_COMPRESSION
static int advertise_compression(unsigned char *url, struct connection *c)
{
struct http_connection_info *info = c->info;
@@ -510,26 +500,21 @@ static int advertise_compression(unsigned char *url, struct connection *c)
return 0;
return 1;
}
-#endif
static void add_accept_encoding(unsigned char **hdr, int *l, unsigned char *url, struct connection *c)
{
-#if defined(HAVE_ANY_COMPRESSION)
#define info ((struct http_connection_info *)c->info)
if (advertise_compression(url, c)) {
int orig_l = *l;
int l1;
add_to_str(hdr, l, cast_uchar "Accept-Encoding: ");
l1 = *l;
-#if defined(HAVE_ZLIB)
if (*l != l1) add_to_str(hdr, l, cast_uchar ", ");
add_to_str(hdr, l, cast_uchar "gzip, deflate");
-#endif
if (*l != l1) add_to_str(hdr, l, cast_uchar "\r\n");
else *l = orig_l;
}
#undef info
-#endif
}
static void add_accept_charset(unsigned char **hdr, int *l, struct http_connection_info *info)
@@ -915,7 +900,6 @@ static void http_got_header(struct connection *c, struct read_buffer *rb)
abort_connection(c);
return;
}
-#ifdef HAVE_SSL
if (info->https_forward && h >= 200 && h < 300) {
mem_free(head);
mem_free(c->info);
@@ -930,7 +914,6 @@ static void http_got_header(struct connection *c, struct read_buffer *rb)
abort_connection(c);
return;
}
-#endif
if (h != 401 && h != 407) {
unsigned char *cookie;
unsigned char *ch = head;
@@ -1023,12 +1006,10 @@ static void http_got_header(struct connection *c, struct read_buffer *rb)
}
mem_free(d);
}
-#ifdef HAVE_SSL
if (c->ssl) {
if (e->ssl_info) mem_free(e->ssl_info);
e->ssl_info = get_cipher_string(c->ssl);
}
-#endif
if (e->redirect) mem_free(e->redirect), e->redirect = NULL;
if ((h == 302 || h == 303 || h == 307 || h == 511) && !e->expire_time) e->expire_time = 1;
if (h == 301 || h == 302 || h == 303 || h == 307) {
diff --git a/https.c b/https.c
@@ -130,13 +130,7 @@ links_ssl *getSSL(void)
mem_free(os_pool);
}
-#if defined(HAVE_OPENSSL_INIT_SSL)
OPENSSL_init_ssl(0, NULL);
-#elif defined(OpenSSL_add_ssl_algorithms)
- OpenSSL_add_ssl_algorithms();
-#else
- SSLeay_add_ssl_algorithms();
-#endif
ssl_initialized = 1;
}
@@ -233,158 +227,6 @@ void https_func(struct connection *c)
#ifdef HAVE_SSL_CERTIFICATES
-#if !(defined(HAVE_X509_CHECK_HOST) && defined(HAVE_X509_CHECK_IP))
-
-static int check_host_name(const unsigned char *templ, const unsigned char *host)
-{
- int templ_len = (int)strlen(cast_const_char templ);
- int host_len = (int)strlen(cast_const_char host);
- unsigned char *wildcard;
-
- if (templ_len > 0 && templ[templ_len - 1] == '.') templ_len--;
- if (host_len > 0 && host[host_len - 1] == '.') host_len--;
-
- wildcard = memchr(templ, '*', templ_len);
- if (!wildcard) {
- if (templ_len == host_len && !casecmp(templ, host, templ_len))
- return 0;
- return -1;
- } else {
- int prefix_len, suffix_len;
- if (templ_len > host_len)
- return -1;
- prefix_len = (int)(wildcard - templ);
- suffix_len = (int)(templ + templ_len - (wildcard + 1));
- if (memchr(templ, '.', prefix_len))
- return -1;
- if (memchr(wildcard + 1, '*', suffix_len))
- return -1;
- if (casecmp(host, templ, prefix_len))
- return -1;
- if (memchr(host + prefix_len, '.', host_len - prefix_len - suffix_len))
- return -1;
- if (casecmp(host + host_len - suffix_len, wildcard + 1, suffix_len))
- return -1;
- return 0;
- }
-}
-
-#ifdef HAVE_ASN1_STRING_GET0_DATA
-#define asn_string_data ASN1_STRING_get0_data
-#else
-#define asn_string_data ASN1_STRING_data
-#endif
-
-/*
- * This function is based on verifyhost in libcurl - I hope that it is correct.
- */
-static int verify_ssl_host_name(X509 *server_cert, unsigned char *host)
-{
- unsigned char ipv4_address[4];
-#ifdef SUPPORT_IPV6
- unsigned char ipv6_address[16];
-#endif
- unsigned char *address = NULL;
- int address_len = 0;
- int type = GEN_DNS;
-
- STACK_OF(GENERAL_NAME) *altnames;
-
- if (!numeric_ip_address(host, ipv4_address)) {
- address = ipv4_address;
- address_len = 4;
- type = GEN_IPADD;
- }
-#ifdef SUPPORT_IPV6
- if (!numeric_ipv6_address(host, ipv6_address, NULL)) {
- address = ipv6_address;
- address_len = 16;
- type = GEN_IPADD;
- }
-#endif
-
-#if 1
- altnames = X509_get_ext_d2i(server_cert, NID_subject_alt_name, NULL, NULL);
- if (altnames) {
- int retval = 1;
- int i;
- int n_altnames = sk_GENERAL_NAME_num(altnames);
- for (i = 0; i < n_altnames; i++) {
- const GENERAL_NAME *altname = sk_GENERAL_NAME_value(altnames, i);
- const unsigned char *altname_ptr;
- int altname_len;
- if (altname->type != type) {
- if (altname->type == GEN_IPADD || altname->type == GEN_DNS || altname->type == GEN_URI)
- retval = S_INVALID_CERTIFICATE;
- continue;
- }
- altname_ptr = asn_string_data(altname->d.ia5);
- altname_len = ASN1_STRING_length(altname->d.ia5);
- if (type == GEN_IPADD) {
- if (altname_len == address_len && !memcmp(altname_ptr, address, address_len)) {
- retval = 0;
- break;
- }
- } else {
- if (altname_len == (int)strlen(cast_const_char altname_ptr) && !check_host_name(altname_ptr, host)) {
- retval = 0;
- break;
- }
- }
- retval = S_INVALID_CERTIFICATE;
- }
- GENERAL_NAMES_free(altnames);
- if (retval != 1)
- return retval;
- }
-#endif
-
- {
- unsigned char *nulstr = cast_uchar "";
- unsigned char *peer_CN = nulstr;
- X509_NAME *name;
- int j, i = -1;
-
- retval = 1;
-
- name = X509_get_subject_name(server_cert);
- if (name)
- while ((j = X509_NAME_get_index_by_NID(name, NID_commonName, i)) >= 0)
- i = j;
- if (i >= 0) {
- ASN1_STRING *tmp = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i));
- if (tmp) {
- if (ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {
- j = ASN1_STRING_length(tmp);
- if (j >= 0) {
- peer_CN = OPENSSL_malloc(j + 1);
- if (peer_CN) {
- memcpy(peer_CN, asn_string_data(tmp), j);
- peer_CN[j] = '\0';
- }
- }
- } else {
- j = ASN1_STRING_to_UTF8(&peer_CN, tmp);
- }
- if (peer_CN && (int)strlen(cast_const_char peer_CN) != j) {
- retval = S_INVALID_CERTIFICATE;
- }
- }
- }
- if (peer_CN && peer_CN != nulstr) {
- if (retval == 1 && !check_host_name(peer_CN, host))
- retval = 0;
- OPENSSL_free(peer_CN);
- }
- if (retval != 1)
- return retval;
- }
-
- return S_INVALID_CERTIFICATE;
-}
-
-#else
-
static int verify_ssl_host_name(X509 *server_cert, unsigned char *host)
{
int v;
@@ -408,8 +250,6 @@ static int verify_ssl_host_name(X509 *server_cert, unsigned char *host)
return v == 1 ? 0 : S_INVALID_CERTIFICATE;
}
-#endif
-
int verify_ssl_certificate(links_ssl *ssl, unsigned char *host)
{
X509 *server_cert;
diff --git a/kbd.c b/kbd.c
@@ -167,10 +167,6 @@ static void resize_terminal(void)
queue_event(ditrm, (unsigned char *)&ev, sizeof(struct links_event));
}
-#if defined(OS_SETRAW)
-
-#elif defined(HAVE_TERMIOS_H)
-
static void os_cfmakeraw(struct termios *t)
{
cfmakeraw(t);
@@ -296,45 +292,6 @@ static void setcooked(int ctl)
ttcsetattr(ctl, TCSANOW, &saved_termios);
}
-#elif defined(HAVE_SGTTY_H)
-
-static struct sgttyb saved_sgtty;
-
-static int setraw(int ctl, int save)
-{
- struct sgttyb sgtty;
- if (ctl < 0) return 0;
- if (gtty(ctl, &sgtty)) {
- return -1;
- }
- if (save) memcpy(&saved_sgtty, &sgtty, sizeof(struct sgttyb));
- sgtty.sg_flags |= CBREAK;
- sgtty.sg_flags &= ~ECHO;
- if (stty(ctl, &sgtty)) {
- return -1;
- }
- return 0;
-}
-
-static void setcooked(int ctl)
-{
- if (ctl < 0) return;
- stty(ctl, &saved_sgtty);
-}
-
-#else
-
-static int setraw(int ctl, int save)
-{
- return 0;
-}
-
-static void setcooked(int ctl)
-{
-}
-
-#endif
-
void handle_trm(int std_in, int std_out, int sock_in, int sock_out, int ctl_in, void *init_string, int init_len)
{
int x, y;
diff --git a/links.h b/links.h
@@ -47,31 +47,19 @@
#include "os_dep.h"
#include <stdio.h>
-#ifdef HAVE_STDLIB_H_X
#include <stdlib.h>
-#endif
#include <stdarg.h>
#include <stddef.h>
-#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifdef HAVE_BSD_STRING_H
#include <bsd/string.h>
#endif
-#ifdef HAVE_STRINGS_H
#include <strings.h>
-#endif
#include <errno.h>
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#include <sys/types.h>
-#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#endif
#ifndef __USE_XOPEN
#define U_X
@@ -91,35 +79,16 @@
#endif
#include <sys/stat.h>
-#ifdef HAVE_FCNTL_H
#include <fcntl.h>
-#endif
-#if defined(HAVE_LINUX_FALLOC_H) && !defined(FALLOC_FL_KEEP_SIZE)
+#if defined(__linux__) && !defined(FALLOC_FL_KEEP_SIZE)
#include <linux/falloc.h>
#endif
-#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
-#endif
-#if defined(HAVE_DIRENT_H)
#include <dirent.h>
-#elif defined(HAVE_SYS_NDIR_H)
-#include <sys/ndir.h>
-#elif defined(HAVE_SYS_DIR_H)
-#include <sys/dir.h>
-#ifndef dirent
-#define dirent direct
-#endif
-#elif defined(HAVE_NDIR_H)
-#include <ndir.h>
-#endif
#include <signal.h>
#include <sys/wait.h>
-#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
-#endif
-#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
-#endif
#ifdef HAVE_UWIN_H
#include <uwin.h>
#endif
@@ -132,41 +101,23 @@
#ifdef HAVE_UNIXLIB_H
#include <unixlib.h>
#endif
-#ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
-#endif
-#ifdef HAVE_PWD_H
#include <pwd.h>
-#endif
-#ifdef HAVE_GRP_H
#include <grp.h>
-#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
-#ifdef HAVE_SEARCH_H
#include <search.h>
-#endif
-#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
-#else
-#ifdef HAVE_NETINET_IN_SYSTEM_H
-#include <netinet/in_system.h>
-#endif
-#endif
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
-#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
-#endif
#include <utime.h>
#if defined(HAVE_CRYPTO_SET_MEM_FUNCTIONS_1) && defined(HAVE_CRYPTO_SET_MEM_FUNCTIONS_2)
@@ -177,11 +128,7 @@
#define HAVE_CRYPTO_SET_MEM_FUNCTIONS
#endif
-#ifdef HAVE_SSL
-
-#ifdef HAVE_OPENSSL
-
-#if !defined(NO_SSL_CERTIFICATES) && defined(HAVE_OPENSSL_X509V3_H) && defined(HAVE_ASN1_STRING_TO_UTF8)
+#if !defined(NO_SSL_CERTIFICATES)
#define HAVE_SSL_CERTIFICATES
#endif
@@ -193,18 +140,12 @@
#include <openssl/err.h>
#include <openssl/crypto.h>
-#ifdef HAVE_SSL_GET1_SESSION
#define SSL_SESSION_RESUME
-#endif
-
-#endif
#ifdef HAVE_NSS
#include <nss_compat_ossl/nss_compat_ossl.h>
#endif
-#endif
-
#if defined(G)
#if defined(HAVE_PNG_H)
#define PNG_THREAD_UNSAFE_OK
@@ -224,25 +165,13 @@
#endif /* _SETJMP_H */
#endif
-#ifdef HAVE_TERMIOS_H
#include <termios.h>
-#elif defined(HAVE_SGTTY_H)
-#include <sgtty.h>
-#endif
-#if defined(HAVE_POLL_H) && defined(HAVE_POLL) && !defined(__HOS_AIX__)
#define USE_POLL
#include <poll.h>
-#endif
-#if (defined(HAVE_EVENT_H) || defined(HAVE_EV_EVENT_H)) && (defined(HAVE_LIBEVENT) || defined(HAVE_LIBEV))
-#if defined(HAVE_EVENT_H)
#include <event.h>
-#else
-#include <ev-event.h>
-#endif
#define USE_LIBEVENT
-#endif
#define omp_get_num_threads() 1
#define omp_get_thread_num() 0
@@ -253,13 +182,8 @@
#define OPENMP_NONATOMIC 0
#endif
-#ifdef HAVE_LONG_LONG
#define longlong long long
#define ulonglong unsigned long long
-#else
-#define longlong double
-#define ulonglong double
-#endif
#define stringify_internal(arg) #arg
#define stringify(arg) stringify_internal(arg)
@@ -302,7 +226,7 @@ do { \
(ret_) = (call_); \
} while (!(ret_) && errno == EINTR)
-#if defined(HAVE_PTHREAD_SIGMASK) && !defined(__BIONIC__)
+#if defined(HAVE_PTHREAD_SIGMASK)
static inline int do_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
{
int r;
@@ -313,12 +237,8 @@ static inline int do_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
}
return 0;
}
-#elif defined(HAVE_SIGPROCMASK)
-#define do_sigprocmask sigprocmask
#else
-#ifdef sigset_t
-#undef sigset_t
-#endif
+#define do_sigprocmask sigprocmask
#define sigset_t int
#ifndef SIG_BLOCK
#define SIG_BLOCK 0
@@ -329,7 +249,6 @@ static inline int do_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
static inline int do_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
{
sigset_t old = 0;
-#if defined(HAVE_SIGBLOCK) && defined(HAVE_SIGSETMASK)
switch (how) {
case SIG_BLOCK:
old = sigblock(*set);
@@ -338,7 +257,6 @@ static inline int do_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
old = sigsetmask(*set);
break;
}
-#endif
if (oset) *oset = old;
return 0;
}
@@ -346,9 +264,6 @@ static inline int do_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
#undef sigdelset
#endif
#define sigdelset(x, s) (*(x) &= ~(1 << (s)), 0)
-#ifndef HAVE_SIGDELSET
-#define HAVE_SIGDELSET 1
-#endif
#ifdef HAVE_SIGFILLSET
#undef HAVE_SIGFILLSET
#endif
@@ -673,13 +588,8 @@ static inline int cmpbeg(const unsigned char *str, const unsigned char *b)
/* os_dep.c */
-#ifdef HAVE_LONG_LONG
typedef unsigned long long uttime;
typedef unsigned long long tcount;
-#else
-typedef unsigned long uttime;
-typedef unsigned long tcount;
-#endif
#if defined(HAVE_GPM_H) && defined(HAVE_LIBGPM)
#define USE_GPM
@@ -931,9 +841,7 @@ struct cache_entry {
unsigned char *decompressed;
size_t decompressed_len;
unsigned char *ip_address;
-#ifdef HAVE_SSL
unsigned char *ssl_info;
-#endif
list_entry_last
unsigned char url[1];
};
@@ -968,7 +876,6 @@ void trim_cache_entry(struct cache_entry *e);
/* sched.c */
-#ifdef HAVE_SSL
typedef struct {
SSL *ssl;
SSL_CTX *ctx;
@@ -977,7 +884,6 @@ typedef struct {
int session_set;
int session_retrieved;
} links_ssl;
-#endif
#define PRI_MAIN 0
#define PRI_DOWNLOAD 0
@@ -1034,11 +940,9 @@ struct connection {
unsigned char socks_proxy[MAX_STR_LEN];
unsigned char dns_append[MAX_STR_LEN];
struct lookup_state last_lookup_state;
-#ifdef HAVE_SSL
links_ssl *ssl;
int no_ssl_session;
int no_tls;
-#endif
list_entry_last
};
@@ -1055,9 +959,7 @@ struct k_conn {
uttime timeout;
uttime add_time;
int protocol_data;
-#ifdef HAVE_SSL
links_ssl *ssl;
-#endif
struct lookup_state last_lookup_state;
list_entry_last
};
@@ -1247,9 +1149,7 @@ struct read_buffer {
unsigned char data[1];
};
-#ifdef HAVE_SSL
void clear_ssl_errors(int line);
-#endif
int socket_and_bind(int pf, unsigned char *address);
void close_socket(int *);
void make_connection(struct connection *, int, int *, void (*)(struct connection *));
@@ -1319,7 +1219,6 @@ void proxy_func(struct connection *);
/* https.c */
void https_func(struct connection *c);
-#ifdef HAVE_SSL
extern int ssl_asked_for_password;
void ssl_finish(void);
links_ssl *getSSL(void);
@@ -1331,9 +1230,8 @@ int verify_ssl_cipher(links_ssl *ssl);
#endif
int ssl_not_reusable(links_ssl *ssl);
unsigned char *get_cipher_string(links_ssl *ssl);
-#endif
-#if defined(HAVE_SSL) && defined(SSL_SESSION_RESUME)
+#if defined(SSL_SESSION_RESUME)
SSL_SESSION *get_session_cache_entry(SSL_CTX *ctx, unsigned char *host, int port);
void retrieve_ssl_session(struct connection *c);
unsigned long session_info(int type);
@@ -1666,13 +1564,8 @@ void generic_set_clip_area(struct graphics_device *dev, struct rect *r);
* on a monochromatic backround and font operations.
*/
-#if !SIZEOF_UNSIGNED_SHORT || SIZEOF_UNSIGNED_SHORT > 2
-#define limit_16(x) ((x) >= 0xffff ? 0xffff : (x))
-#define cmd_limit_16(x) do { if ((x) >= 0xffff) (x) = 0xffff; } while (0)
-#else
#define limit_16(x) (x)
#define cmd_limit_16(x) do { } while (0)
-#endif
#define sRGB_gamma 0.45455 /* For HTML, which runs
* according to sRGB standard. Number
@@ -2154,10 +2047,6 @@ void detach_object_connection(struct object_request *, off_t);
/* compress.c */
-#if defined(HAVE_ZLIB)
-#define HAVE_ANY_COMPRESSION
-#endif
-
extern my_uintptr_t decompressed_cache_size;
int get_file_by_term(struct terminal *term, struct cache_entry *ce, unsigned char **start, unsigned char **end, int *errp);
diff --git a/main.c b/main.c
@@ -40,7 +40,7 @@ void sig_tstp(void *t_)
{
struct terminal *t = (struct terminal *)t_;
#if defined(SIGSTOP) && !defined(NO_CTRL_Z)
-#if defined(SIGCONT) && defined(SIGTTOU) && defined(HAVE_GETPID)
+#if defined(SIGCONT) && defined(SIGTTOU)
pid_t pid, newpid;
EINTRLOOP(pid, getpid());
#endif
@@ -52,7 +52,7 @@ void sig_tstp(void *t_)
drv->block(NULL);
}
#endif
-#if defined(SIGCONT) && defined(SIGTTOU) && defined(HAVE_GETPID)
+#if defined(SIGCONT) && defined(SIGTTOU)
EINTRLOOP(newpid, fork());
if (!newpid) {
while (1) {
@@ -66,7 +66,7 @@ void sig_tstp(void *t_)
int rr;
EINTRLOOP(rr, raise(SIGSTOP));
}
-#if defined(SIGCONT) && defined(SIGTTOU) && defined(HAVE_GETPID)
+#if defined(SIGCONT) && defined(SIGTTOU)
if (newpid != -1) {
int rr;
EINTRLOOP(rr, kill(newpid, SIGKILL));
@@ -472,9 +472,7 @@ static void terminate_all_subsystems(void)
free_all_caches();
free_format_text_cache();
-#ifdef HAVE_SSL
ssl_finish();
-#endif
if (init_b) save_url_history();
free_history_lists();
free_term_specs();
diff --git a/memory.c b/memory.c
@@ -118,9 +118,7 @@ retry:
fprintf(stderr, "\n");
fprintf(stderr, "File cache: %lu bytes, %lu files, %lu locked, %lu loading\n", (unsigned long)cache_info(CI_BYTES), (unsigned long)cache_info(CI_FILES), (unsigned long)cache_info(CI_LOCKED), (unsigned long)cache_info(CI_LOADING));
-#ifdef HAVE_ANY_COMPRESSION
fprintf(stderr, "Decompressed cache: %lu bytes, %lu files, %lu locked\n", (unsigned long)decompress_info(CI_BYTES), (unsigned long)decompress_info(CI_FILES), (unsigned long)decompress_info(CI_LOCKED));
-#endif
#ifdef G
if (F) {
fprintf(stderr, "Image cache: %lu bytes, %lu files, %lu locked\n", (unsigned long)imgcache_info(CI_BYTES), (unsigned long)imgcache_info(CI_FILES), (unsigned long)imgcache_info(CI_LOCKED));
diff --git a/menu.c b/menu.c
@@ -86,7 +86,7 @@ static void menu_version(void *term_)
add_to_str(&s, &l, cast_uchar "\n");
add_and_pad(&s, &l, term, *text_ptr++, maxlen);
- add_num_to_str(&s, &l, DEBUGLEVEL);
+ add_num_to_str(&s, &l, 0);
add_to_str(&s, &l, cast_uchar "\n");
add_and_pad(&s, &l, term, *text_ptr++, maxlen);
@@ -104,11 +104,7 @@ static void menu_version(void *term_)
add_to_str(&s, &l, cast_uchar "\n");
add_and_pad(&s, &l, term, *text_ptr++, maxlen);
-#ifdef HAVE_ANY_COMPRESSION
add_compress_methods(&s, &l);
-#else
- add_to_str(&s, &l, get_text_translation(TEXT_(T_NO), term));
-#endif
add_to_str(&s, &l, cast_uchar "\n");
add_and_pad(&s, &l, term, *text_ptr++, maxlen);
@@ -380,7 +376,6 @@ static int resource_info(struct terminal *term, struct refresh *r2)
add_to_str(&a, &l, get_text_translation(TEXT_(T_LOADING), term));
add_to_str(&a, &l, cast_uchar ".\n");
-#ifdef HAVE_ANY_COMPRESSION
add_to_str(&a, &l, get_text_translation(TEXT_(T_DECOMPRESSED_CACHE), term));
add_to_str(&a, &l, cast_uchar ": ");
add_unsigned_long_num_to_str(&a, &l, decompress_info(CI_BYTES));
@@ -395,7 +390,6 @@ static int resource_info(struct terminal *term, struct refresh *r2)
add_to_str(&a, &l, cast_uchar " ");
add_to_str(&a, &l, get_text_translation(TEXT_(T_LOCKED), term));
add_to_str(&a, &l, cast_uchar ".\n");
-#endif
#ifdef G
if (F) {
@@ -1233,18 +1227,12 @@ static void dlg_ipv6_options(struct terminal *term, void *xxx, void *yyy)
#endif
-#ifdef HAVE_SSL
#define N_N 6
-#else
-#define N_N 5
-#endif
static unsigned char * const proxy_msg[] = {
TEXT_(T_HTTP_PROXY__HOST_PORT),
TEXT_(T_FTP_PROXY__HOST_PORT),
-#ifdef HAVE_SSL
TEXT_(T_HTTPS_PROXY__HOST_PORT),
-#endif
TEXT_(T_SOCKS_4A_PROXY__USER_HOST_PORT),
TEXT_(T_APPEND_TEXT_TO_SOCKS_LOOKUPS),
TEXT_(T_NOPROXY_LIST),
@@ -1528,13 +1516,11 @@ static void dlg_proxy_options(struct terminal *term, void *xxx, void *yyy)
d->items[a].data = ftp_proxy;
d->items[a].fn = check_proxy;
a++;
-#ifdef HAVE_SSL
d->items[a].type = D_FIELD;
d->items[a].dlen = MAX_STR_LEN;
d->items[a].data = https_proxy;
d->items[a].fn = check_proxy;
a++;
-#endif
d->items[a].type = D_FIELD;
d->items[a].dlen = MAX_STR_LEN;
d->items[a].data = socks_proxy;
@@ -1731,9 +1717,7 @@ static void dlg_ssl_options(struct terminal *term, void *xxx, void *yyy)
#endif
static unsigned char * const http_labels[] = { TEXT_(T_USE_HTTP_10), TEXT_(T_ALLOW_SERVER_BLACKLIST), TEXT_(T_BROKEN_302_REDIRECT), TEXT_(T_NO_KEEPALIVE_AFTER_POST_REQUEST), TEXT_(T_DO_NOT_SEND_ACCEPT_CHARSET),
-#ifdef HAVE_ANY_COMPRESSION
TEXT_(T_DO_NOT_ADVERTISE_COMPRESSION_SUPPORT),
-#endif
TEXT_(T_RETRY_ON_INTERNAL_ERRORS), NULL };
static unsigned char * const http_header_labels[] = { TEXT_(T_FAKE_FIREFOX), TEXT_(T_DO_NOT_TRACK), TEXT_(T_REFERER_NONE), TEXT_(T_REFERER_SAME_URL), TEXT_(T_REFERER_FAKE), TEXT_(T_REFERER_REAL_SAME_SERVER), TEXT_(T_REFERER_REAL), TEXT_(T_FAKE_REFERER), TEXT_(T_FAKE_USERAGENT), TEXT_(T_EXTRA_HEADER), NULL };
@@ -1884,13 +1868,11 @@ static void dlg_http_options(struct terminal *term, void *xxx, void *yyy)
d->items[a].dlen = sizeof(int);
d->items[a].data = (void *)&http_options.no_accept_charset;
a++;
-#ifdef HAVE_ANY_COMPRESSION
d->items[a].type = D_CHECKBOX;
d->items[a].gid = 0;
d->items[a].dlen = sizeof(int);
d->items[a].data = (void *)&http_options.no_compression;
a++;
-#endif
d->items[a].type = D_CHECKBOX;
d->items[a].gid = 0;
d->items[a].dlen = sizeof(int);
diff --git a/os_dep.c b/os_dep.c
@@ -5,9 +5,7 @@
#include "links.h"
-#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
-#endif
#ifdef HAVE_PTHREADS
#include <pthread.h>
diff --git a/os_dep.h b/os_dep.h
@@ -37,20 +37,9 @@ static inline int dir_sep(unsigned char x) { return x == '/'; }
#define DEFAULT_SHELL "/bin/sh"
#define GETSHELL getenv("SHELL")
#define SHARED_CONFIG_DIR "/etc/"
-#ifdef HAVE_SYS_UN_H
-#define USE_AF_UNIX
-#else
-#define DONT_USE_AF_UNIX
-#endif
#define ASSOC_BLOCK
#define ASSOC_CONS_XWIN
#endif
-#ifdef FS_UNIX_USERS
-#if !defined(HAVE_GETPWUID) || !defined(HAVE_GETGRGID)
-#undef FS_UNIX_USERS
-#endif
-#endif
-
#endif /* #ifndef OS_DEP_H */
diff --git a/os_depx.h b/os_depx.h
@@ -24,10 +24,6 @@
#define MAX_SIZE_T ((size_t)-0x1000)
#endif
-#if !defined(HAVE_ERRNO) && !defined(errno)
-extern int errno;
-#endif
-
#ifndef SEEK_SET
#ifdef L_SET
#define SEEK_SET L_SET
@@ -150,10 +146,6 @@ extern int errno;
#define SIGNAL_HANDLER
#endif
-#ifndef HAVE_SOCKLEN_T
-#define socklen_t int
-#endif
-
#ifndef PF_INET
#define PF_INET AF_INET
#endif
@@ -193,9 +185,7 @@ extern int errno;
#define ATTR_NOINLINE
#endif
-#if defined(HAVE_GETADDRINFO) && defined(HAVE_FREEADDRINFO)
#define USE_GETADDRINFO
-#endif
#ifdef SUPPORT_IPV6
#ifndef PF_INET6
@@ -211,14 +201,9 @@ extern int errno;
#endif
#ifdef G
-#ifndef HAVE_POWF
-#define float_double double
-#define fd_pow pow
-#else
#define float_double float
#define fd_pow powf
#endif
-#endif
#if defined(__DECC_VER)
#define static_const static
diff --git a/png.c b/png.c
@@ -12,18 +12,6 @@
#undef REPACK_16
#endif /* #ifdef REPACK_16 */
-#if SIZEOF_UNSIGNED_SHORT != 2
-#define REPACK_16
-#endif /* #if SIZEOF_UNSIGNED_SHORT != 2 */
-
-#ifndef REPACK_16
-#ifndef C_LITTLE_ENDIAN
-#ifndef C_BIG_ENDIAN
-#define REPACK_16
-#endif /* #ifndef C_BIG_ENDIAN */
-#endif /* #ifndef C_LITTLE_ENDIAN */
-#endif /* #ifndef REPACK_16 */
-
/* Decoder structs */
struct png_decoder{
@@ -72,13 +60,11 @@ static void png_info_callback(png_structp png_ptr, png_infop info_ptr)
png_set_gray_to_rgb(png_ptr);
if (bit_depth==16){
#ifndef REPACK_16
-#ifdef C_LITTLE_ENDIAN
/* We use native endianity only if unsigned short is 2-byte
* because otherwise we have to reassemble the buffer so we
* will leave in the libpng-native big endian.
*/
png_set_swap(png_ptr);
-#endif /* #ifdef C_LITTLE_ENDIAN */
#endif /* #ifndef REPACK_16 */
bytes_per_pixel*=(int)sizeof(unsigned short);
}
@@ -264,11 +250,7 @@ void png_destroy_decoder(struct cached_image *cimg)
void add_png_version(unsigned char **s, int *l)
{
add_to_str(s, l, cast_uchar "PNG (");
-#ifdef HAVE_PNG_GET_LIBPNG_VER
add_to_str(s, l, cast_uchar png_get_libpng_ver(NULL));
-#else
- add_to_str(s, l, cast_uchar PNG_LIBPNG_VER_STRING);
-#endif
add_to_str(s, l, cast_uchar ")");
}
diff --git a/sched.c b/sched.c
@@ -178,10 +178,8 @@ int get_keepalive_socket(struct connection *c, int *protocol_data)
if (!(k = is_host_on_keepalive_list(c))) return -1;
cc = k->conn;
if (protocol_data) *protocol_data = k->protocol_data;
-#ifdef HAVE_SSL
freeSSL(c->ssl);
c->ssl = k->ssl;
-#endif
memcpy(&c->last_lookup_state, &k->last_lookup_state, sizeof(struct lookup_state));
del_from_list(k);
mem_free(k->host);
@@ -311,9 +309,7 @@ void add_keepalive_socket(struct connection *c, uttime timeout, int protocol_dat
}
k = mem_alloc(sizeof(struct k_conn));
if (c->netcfg_stamp != netcfg_stamp ||
-#ifdef HAVE_SSL
ssl_not_reusable(c->ssl) ||
-#endif
(k->port = get_port(c->url)) == -1 ||
!(k->protocol = get_protocol_handle(c->url)) ||
!(k->host = get_keepalive_id(c->url))) {
@@ -325,9 +321,7 @@ void add_keepalive_socket(struct connection *c, uttime timeout, int protocol_dat
k->timeout = timeout;
k->add_time = get_absolute_time();
k->protocol_data = protocol_data;
-#ifdef HAVE_SSL
k->ssl = c->ssl;
-#endif
memcpy(&k->last_lookup_state, &c->last_lookup_state, sizeof(struct lookup_state));
add_to_list(keepalive_connections, k);
del:
@@ -345,9 +339,7 @@ static void del_keepalive_socket(struct k_conn *kc)
{
int rs;
del_from_list(kc);
-#ifdef HAVE_SSL
freeSSL(kc->ssl);
-#endif
EINTRLOOP(rs, close(kc->conn));
mem_free(kc->host);
mem_free(kc);
@@ -414,10 +406,8 @@ static void sort_queue(void)
static void interrupt_connection(struct connection *c)
{
-#ifdef HAVE_SSL
freeSSL(c->ssl);
c->ssl = NULL;
-#endif
close_socket(&c->sock1);
free_connection_data(c);
}
@@ -688,9 +678,7 @@ unsigned char *get_proxy_string(unsigned char *url)
return NULL;
if (*proxies.http_proxy && !casecmp(url, cast_uchar "http://", 7)) return proxies.http_proxy;
if (*proxies.ftp_proxy && !casecmp(url, cast_uchar "ftp://", 6)) return proxies.ftp_proxy;
-#ifdef HAVE_SSL
if (*proxies.https_proxy && !casecmp(url, cast_uchar "https://", 8)) return proxies.https_proxy;
-#endif
return NULL;
}
@@ -892,11 +880,7 @@ void load_url(unsigned char *url, unsigned char *prev_url, struct status *stat,
c->cache = NULL;
c->est_length = -1;
c->unrestartable = 0;
-#ifdef HAVE_ANY_COMPRESSION
c->no_compress = http_options.no_compression || no_compress || dmp == D_SOURCE;
-#else
- c->no_compress = 1;
-#endif
c->prg.timer = NULL;
c->timer = NULL;
if (position || must_detach) {
diff --git a/select.c b/select.c
@@ -234,7 +234,7 @@ static void restrict_fds(void)
#if defined(RLIMIT_OFILE) && !defined(RLIMIT_NOFILE)
#define RLIMIT_NOFILE RLIMIT_OFILE
#endif
-#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
+#if defined(RLIMIT_NOFILE)
struct rlimit limit;
int rs;
EINTRLOOP(rs, getrlimit(RLIMIT_NOFILE, &limit));
@@ -266,9 +266,7 @@ static inline struct event *timer_event(struct timer *tm)
return (struct event *)((unsigned char *)tm - sizeof_struct_event);
}
-#ifdef HAVE_EVENT_BASE_SET
static struct event_base *event_base;
-#endif
static void event_callback(int h, short ev, void *data)
{
@@ -313,10 +311,8 @@ static void set_event_for_action(int h, void (*func)(void *), struct event **evp
#endif
*evptr = mem_alloc(sizeof_struct_event);
event_set(*evptr, h, evtype, event_callback, *evptr);
-#ifdef HAVE_EVENT_BASE_SET
if (event_base_set(event_base, *evptr) == -1)
fatal_exit("ERROR: event_base_set failed: %s at %s:%d, handle %d", strerror(errno), sh_file, sh_line, h);
-#endif
}
if (event_add(*evptr, NULL) == -1)
fatal_exit("ERROR: event_add failed: %s at %s:%d, handle %d", strerror(errno), sh_file, sh_line, h);
@@ -339,10 +335,8 @@ static void set_event_for_timer(struct timer *tm)
struct timeval tv;
struct event *ev = timer_event(tm);
timeout_set(ev, timer_callback, tm);
-#ifdef HAVE_EVENT_BASE_SET
if (event_base_set(event_base, ev) == -1)
fatal_exit("ERROR: event_base_set failed: %s", strerror(errno));
-#endif
tv.tv_sec = tm->interval / 1000;
tv.tv_usec = (tm->interval % 1000) * 1000;
#if defined(HAVE_LIBEV)
@@ -364,38 +358,9 @@ static void enable_libevent(void)
if (disable_libevent)
return;
-#if !defined(NO_FORK_ON_EXIT) && defined(HAVE_KQUEUE) && !defined(HAVE_EVENT_REINIT)
- /* kqueue doesn't work after fork */
- if (!F)
- return;
-#endif
-
-#if defined(HAVE_EVENT_CONFIG_SET_FLAG)
- {
- struct event_config *cfg;
- cfg = event_config_new();
- if (!cfg)
- return;
- if (event_config_set_flag(cfg, EVENT_BASE_FLAG_NOLOCK) == -1) {
- event_config_free(cfg);
- return;
- }
- event_base = event_base_new_with_config(cfg);
- event_config_free(cfg);
- if (!event_base)
- return;
- }
-#elif defined(HAVE_EVENT_BASE_NEW)
event_base = event_base_new();
if (!event_base)
return;
-#elif defined(HAVE_EVENT_BASE_SET)
- event_base = event_init();
- if (!event_base)
- return;
-#else
- event_init();
-#endif
event_enabled = 1;
sh_file = (unsigned char *)__FILE__;
@@ -419,9 +384,7 @@ static void terminate_libevent(void)
if (threads[i].write_event)
mem_free(threads[i].write_event);
}
-#ifdef HAVE_EVENT_BASE_FREE
event_base_free(event_base);
-#endif
event_enabled = 0;
}
}
@@ -429,11 +392,7 @@ static void terminate_libevent(void)
static void do_event_loop(int flags)
{
int e;
-#ifdef HAVE_EVENT_BASE_SET
e = event_base_loop(event_base, flags);
-#else
- e = event_loop(flags);
-#endif
if (e == -1)
fatal_exit("ERROR: event_base_loop failed: %s", strerror(errno));
}
@@ -456,7 +415,6 @@ void add_event_string(unsigned char **s, int *l, struct terminal *term)
#else
add_to_str(s, l, cast_uchar "LibEvent");
#endif
-#ifdef HAVE_EVENT_GET_VERSION
add_to_str(s, l, cast_uchar " ");
{
#if defined(HAVE_LIBEV)
@@ -469,19 +427,13 @@ void add_event_string(unsigned char **s, int *l, struct terminal *term)
#endif
add_to_str(s, l, cast_uchar event_get_version());
}
-#endif
if (!event_enabled) {
add_to_str(s, l, cast_uchar " ");
add_to_str(s, l, get_text_translation(TEXT_(T_dISABLED), term));
add_to_str(s, l, cast_uchar ")");
} else {
-#if defined(HAVE_EVENT_BASE_GET_METHOD)
add_to_str(s, l, cast_uchar " ");
add_to_str(s, l, cast_uchar event_base_get_method(event_base));
-#elif defined(HAVE_EVENT_GET_METHOD)
- add_to_str(s, l, cast_uchar " ");
- add_to_str(s, l, cast_uchar event_get_method());
-#endif
}
#endif
}
@@ -691,10 +643,6 @@ SIGNAL_HANDLER static void got_signal(int sig)
int sv_errno = errno;
/*fprintf(stderr, "ERROR: signal number: %d\n", sig);*/
-#if !defined(HAVE_SIGACTION)
- do_signal(sig, got_signal);
-#endif
-
/* if we get signal from a forked child, don't do anything */
if (getpid() != signal_pid) goto ret;
@@ -717,16 +665,12 @@ SIGNAL_HANDLER static void got_signal(int sig)
errno = sv_errno;
}
-#ifdef HAVE_SIGACTION
static struct sigaction sa_zero;
-#endif
#endif
void install_signal_handler(int sig, void (*fn)(void *), void *data, int critical)
{
-#if defined(NO_SIGNAL_HANDLERS)
-#elif defined(HAVE_SIGACTION)
int rs;
struct sigaction sa = sa_zero;
/*debug("install (%d) -> %p,%d", sig, fn, critical);*/
@@ -745,18 +689,11 @@ void install_signal_handler(int sig, void (*fn)(void *), void *data, int critica
signal_handlers[sig].critical = critical;
if (fn)
EINTRLOOP(rs, sigaction(sig, &sa, NULL));
-#else
- if (!fn) do_signal(sig, SIG_IGN);
- signal_handlers[sig].fn = fn;
- signal_handlers[sig].data = data;
- signal_handlers[sig].critical = critical;
- if (fn) do_signal(sig, got_signal);
-#endif
}
void interruptible_signal(int sig, int in)
{
-#if defined(HAVE_SIGACTION) && !defined(NO_SIGNAL_HANDLERS)
+#if !defined(NO_SIGNAL_HANDLERS)
struct sigaction sa = sa_zero;
int rs;
if (sig >= NUM_SIGNALS || sig < 0) {
@@ -779,7 +716,6 @@ void block_signals(int except1, int except2)
int rs;
sigset_t mask;
sig_fill_set(&mask);
-#ifdef HAVE_SIGDELSET
if (except1) sigdelset(&mask, except1);
if (except2) sigdelset(&mask, except2);
#ifdef SIGILL
@@ -797,9 +733,6 @@ void block_signals(int except1, int except2)
#ifdef SIGBUS
sigdelset(&mask, SIGBUS);
#endif
-#else
- if (except1 || except2) return;
-#endif
EINTRLOOP(rs, do_sigprocmask(SIG_BLOCK, &mask, &sig_old_mask));
if (!rs) sig_unblock = 1;
}
@@ -868,10 +801,8 @@ void reinit_child(void)
#endif
#ifdef USE_LIBEVENT
if (event_enabled) {
-#ifdef HAVE_EVENT_REINIT
if (event_reinit(event_base))
fatal_exit("ERROR: event_reinit failed: %s", strerror(errno));
-#endif
}
#endif
}
@@ -885,9 +816,7 @@ void select_loop(void (*init)(void))
#endif
#if !defined(NO_SIGNAL_HANDLERS)
-#if defined(HAVE_SIGACTION)
memset(&sa_zero, 0, sizeof sa_zero);
-#endif
memset((void *)signal_mask, 0, sizeof signal_mask);
memset((void *)signal_handlers, 0, sizeof signal_handlers);
#endif
diff --git a/session.c b/session.c
@@ -675,7 +675,6 @@ found:
time_t parse_http_date(unsigned char *date) /* this functions is bad !!! */
{
-#ifdef HAVE_MKTIME
static unsigned char *months[12] = {
cast_uchar "Jan",
cast_uchar "Feb",
@@ -786,9 +785,6 @@ time_t parse_http_date(unsigned char *date) /* this functions is bad !!! */
t = mktime(&tm);
if (t == (time_t) -1) return 0;
return t;
-#else
- return 0;
-#endif
}
@@ -956,35 +952,21 @@ have_frag:
exec_on_terminal(get_download_ses(down)->term, down->prog, down->orig_file, !!down->prog_flag_block);
mem_free(down->prog), down->prog = NULL;
} else if (down->remotetime && download_utime) {
-#if defined(HAVE_UTIME) || defined(HAVE_UTIMES)
-#ifdef HAVE_UTIMES
struct timeval utv[2];
-#else
- struct utimbuf ut;
-#endif
unsigned char *file = stracpy(down->orig_file);
unsigned char *wd = get_cwd();
set_cwd(down->cwd);
-#ifdef HAVE_UTIMES
utv[0].tv_usec = utv[1].tv_usec = 0;
utv[0].tv_sec = utv[1].tv_sec = down->remotetime;
-#else
- ut.actime = ut.modtime = down->remotetime;
-#endif
while (1) {
unsigned char *f = translate_download_file(file);
-#ifdef HAVE_UTIMES
EINTRLOOP(rs, utimes(cast_char f, utv));
-#else
- EINTRLOOP(rs, utime(cast_const_char f, &ut));
-#endif
mem_free(f);
if (!strcmp(cast_const_char file, cast_const_char down->file)) break;
increase_download_file(&file);
}
mem_free(file);
if (wd) set_cwd(wd), mem_free(wd);
-#endif
}
}
abort_download(down);
diff --git a/setup.h b/setup.h
@@ -16,9 +16,7 @@
* 3=leaky, ruda zona, alloc, realloc a free patterny
* -1=tajny level ;-)
*/
-/* nastavuje se v configure --enable-debuglevel=-1,0,1,2,3
-#define DEBUGLEVEL 2
-*/
+/* nastavuje se v configure --enable-debuglevel=-1,0,1,2,3 */
#define LINKS_SOCK_NAME "socket"
#define LINKS_ANONYMOUS_SOCK_SUFFIX "-a"
diff --git a/terminal.c b/terminal.c
@@ -1289,7 +1289,7 @@ void exec_thread(void *path_, int p)
{
unsigned char *path = (unsigned char *)path_;
int rs;
-#if defined(HAVE_SETPGID) && !defined(EXEC_IN_THREADS)
+#if !defined(EXEC_IN_THREADS)
if (path[0] == 2)
EINTRLOOP(rs, setpgid(0, 0));
#endif
diff --git a/view.c b/view.c
@@ -4098,14 +4098,12 @@ void loc_msg(struct terminal *term, struct location *lo, struct f_data_c *frame)
add_to_str(&s, &l, a);
mem_free(a);
}
-#ifdef HAVE_SSL
if (ce->ssl_info) {
add_to_str(&s, &l, cast_uchar "\n");
add_to_str(&s, &l, get_text_translation(TEXT_(T_SSL_CIPHER), term));
add_to_str(&s, &l, cast_uchar ": ");
add_to_str(&s, &l, ce->ssl_info);
}
-#endif
ce->refcount--;
}
if ((a = print_current_linkx_plus(frame, term))) {
diff --git a/x.c b/x.c
@@ -79,22 +79,11 @@
#undef format
#endif
-#if defined(HAVE_XOPENIM) && defined(HAVE_XCLOSEIM) && defined(HAVE_XCREATEIC) && defined(HAVE_XDESTROYIC) && (defined(HAVE_XWCLOOKUPSTRING) || defined(HAVE_XUTF8LOOKUPSTRING))
-#define X_INPUT_METHOD
-#endif
-
#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
-#if defined(HAVE_X11_XLOCALE_H) && defined(HAVE_XSETLOCALE)
#include <X11/Xlocale.h>
-#else
-#ifdef HAVE_SETLOCALE
-#undef HAVE_SETLOCALE
-#endif
-#endif
-
#ifndef XK_MISCELLANY
#define XK_MISCELLANY
@@ -105,9 +94,7 @@
#endif
#include <X11/keysymdef.h>
-#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
-#endif
#define X_BORDER_WIDTH 4
#define X_HASH_TABLE_SIZE 64
@@ -145,9 +132,7 @@ static Atom x_delete_window_atom, x_wm_protocols_atom, x_sel_atom, x_targets_ato
static Visual* x_default_visual;
static Pixmap x_icon = 0;
-#ifdef X_INPUT_METHOD
static XIM xim = NULL;
-#endif
extern struct graphics_driver x_driver;
@@ -180,9 +165,7 @@ x_hash_table[X_HASH_TABLE_SIZE];
static unsigned char * x_my_clipboard=NULL;
struct window_info {
-#ifdef X_INPUT_METHOD
XIC xic;
-#endif
Window window;
};
@@ -358,32 +341,16 @@ static int x_translate_key(struct graphics_device *gd, XKeyEvent *e,int *key,int
int table = x_input_encoding < 0 ? g_kbd_codepage(&x_driver) : x_input_encoding;
int len;
-#ifdef X_INPUT_METHOD
if (get_window_info(gd)->xic) {
Status status;
-#ifndef HAVE_XUTF8LOOKUPSTRING
- {
- wchar_t wc;
- len = XwcLookupString(get_window_info(gd)->xic, e, &wc, 1, &ks, &status);
- if (len == 1) {
- strcpy(cast_char str, cast_const_char encode_utf_8(wc));
- len = strlen(cast_const_char str);
- } else
- len = 0;
- }
-#else
{
len = Xutf8LookupString(get_window_info(gd)->xic, e, cast_char str, str_size, &ks, &status);
}
-#endif
table = utf8_table;
/*fprintf(stderr, "len: %d, ks %ld, status %d\n", len, ks, status);*/
} else
-#endif
-
- {
len = XLookupString(e,cast_char str,str_size,&ks,&comp);
- }
+
str[len>str_size?str_size:len]=0;
if (!len) str[0]=(unsigned char)ks, str[1]=0;
*flag=0;
@@ -557,9 +524,7 @@ static void x_free_hash_table(void)
if (x_copy_gc) XFreeGC(x_display,x_copy_gc), x_copy_gc = 0;
if (x_drawbitmap_gc) XFreeGC(x_display,x_drawbitmap_gc), x_drawbitmap_gc = 0;
if (x_scroll_gc) XFreeGC(x_display,x_scroll_gc), x_scroll_gc = 0;
-#ifdef X_INPUT_METHOD
if (xim) XCloseIM(xim), xim = NULL;
-#endif
XCloseDisplay(x_display), x_display = NULL;
}
@@ -784,10 +749,8 @@ static void x_process_events(void *data)
MESSAGE(txt);
}
#endif
-#ifdef X_INPUT_METHOD
if (XFilterEvent(&event, None))
break;
-#endif
gd=x_find_gd(&(event.xkey.window));
if (!gd)break;
if (x_translate_key(gd, (XKeyEvent*)(&event),&k,&f))
@@ -1038,9 +1001,7 @@ static unsigned char *x_get_af_unix_name(void)
return x_display_string;
}
-#ifdef X_INPUT_METHOD
static XIC x_open_xic(Window w);
-#endif
/* initiate connection with X server */
static unsigned char *x_init_driver(unsigned char *param, unsigned char *display)
@@ -1054,7 +1015,7 @@ static unsigned char *x_init_driver(unsigned char *param, unsigned char *display
n_wins=0;
-#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
+#if defined(LC_CTYPE)
setlocale(LC_CTYPE, "");
#endif
#ifdef X_DEBUG
@@ -1065,7 +1026,7 @@ static unsigned char *x_init_driver(unsigned char *param, unsigned char *display
}
#endif
x_input_encoding=-1;
-#if defined(HAVE_NL_LANGINFO) && defined(HAVE_LANGINFO_H) && defined(CODESET) && !defined(WIN)
+#if defined(CODESET)
{
unsigned char *cp;
cp = cast_uchar nl_langinfo(CODESET);
@@ -1348,9 +1309,8 @@ visual_found:;
XSetLineAttributes(x_display,x_normal_gc,1,LineSolid,CapRound,JoinRound);
-#ifdef X_INPUT_METHOD
{
-#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
+#if defined(LC_CTYPE)
/*
* Unfortunatelly, dead keys are translated according to
* current locale, even if we use Xutf8LookupString.
@@ -1376,7 +1336,7 @@ visual_found:;
}
#endif
xim = XOpenIM(x_display, NULL, NULL, NULL);
-#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
+#if defined(LC_CTYPE)
if (!xim) {
l = cast_uchar setlocale(LC_CTYPE, "en_US.UTF-8");
xim = XOpenIM(x_display, NULL, NULL, NULL);
@@ -1390,17 +1350,13 @@ visual_found:;
XCloseIM(xim), xim = NULL;
}
}
-#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
+#if defined(LC_CTYPE)
setlocale(LC_CTYPE, "");
#endif
}
-#endif
- if (x_input_encoding<0
-#ifdef X_INPUT_METHOD
- && !xim
-#endif
- ) x_driver.flags|=GD_NEED_CODEPAGE;
+ if (x_input_encoding < 0 && !xim)
+ x_driver.flags|=GD_NEED_CODEPAGE;
x_fd=XConnectionNumber(x_display);
set_handlers(x_fd, x_process_events, NULL, NULL);
@@ -1420,12 +1376,10 @@ static void x_shutdown_driver(void)
x_free_hash_table();
}
-#ifdef X_INPUT_METHOD
static XIC x_open_xic(Window w)
{
return XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, w, XNFocusWindow, w, NULL);
}
-#endif
/* create new window */
static struct graphics_device* x_init_device(void)
@@ -1530,11 +1484,8 @@ nic_nebude_bobankove:;
0
);
-#ifdef X_INPUT_METHOD
- if (xim) {
+ if (xim)
wi->xic = x_open_xic(wi->window);
- }
-#endif
XSync(x_display, False);
X_SCHEDULE_PROCESS_EVENTS();
@@ -1553,11 +1504,8 @@ static void x_shutdown_device(struct graphics_device *gd)
n_wins--;
XDestroyWindow(x_display, wi->window);
-#ifdef X_INPUT_METHOD
- if (wi->xic) {
+ if (wi->xic)
XDestroyIC(wi->xic);
- }
-#endif
XSync(x_display, False);
X_SCHEDULE_PROCESS_EVENTS();
@@ -2132,12 +2080,10 @@ static void x_set_window_title(struct graphics_device *gd, unsigned char *title)
int output_encoding;
Status ret;
-#if defined(HAVE_XSUPPORTSLOCALE) && defined(HAVE_XMBTEXTLISTTOTEXTPROPERTY)
if (XSupportsLocale()) {
output_encoding = x_input_encoding >= 0 ? x_input_encoding : 0;
} else
retry_encode_ascii:
-#endif
{
output_encoding = 0;
}
@@ -2147,7 +2093,6 @@ retry_encode_ascii:
clr_white(t);
/*XStoreName(x_display,get_window_info(gd)->window,"blabla");*/
-#if defined(HAVE_XSUPPORTSLOCALE) && defined(HAVE_XMBTEXTLISTTOTEXTPROPERTY)
if (XSupportsLocale()) {
ret = XmbTextListToTextProperty(x_display, (char**)(void *)(&t), 1, XStdICCTextStyle, &windowName);
#ifdef X_HAVE_UTF8_STRING
@@ -2169,7 +2114,6 @@ retry_encode_ascii:
}
} else
retry_print_ascii:
-#endif
{
ret = XStringListToTextProperty((char**)(void *)(&t), 1, &windowName);
if (!ret) {