Replace uses of HAVE_SSL with HAVE_LIBSSL

autoconf's AC_CHECK_LIB automatically sets HAVE_LIBSSL, whereas HAVE_SSL has to be set manually.

This prepares us to remove some code from configure.
This commit is contained in:
Kevin Easton
2017-03-17 00:07:38 +11:00
parent 1fbafddc59
commit 2fa0bf818a
8 changed files with 44 additions and 44 deletions

View File

@@ -157,7 +157,7 @@ typedef struct
#endif #endif
char *orignick; char *orignick;
struct timeval connect_time; struct timeval connect_time;
#if defined(HAVE_SSL) && !defined(IN_MODULE) #if defined(HAVE_LIBSSL) && !defined(IN_MODULE)
SSL_CTX* ctx; SSL_CTX* ctx;
int enable_ssl; int enable_ssl;
int ssl_error; int ssl_error;
@@ -328,7 +328,7 @@ ChannelList *BX_get_server_channels (int);
int get_server_reconnect (int); int get_server_reconnect (int);
int get_server_reconnecting (int); int get_server_reconnecting (int);
int get_server_change_pending (int); int get_server_change_pending (int);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
void set_server_ssl(int, int); void set_server_ssl(int, int);
int get_server_ssl(int); int get_server_ssl(int);
#endif #endif

View File

@@ -1,4 +1,4 @@
#if defined(HAVE_SSL) && !defined(IN_MODULE) #if defined(HAVE_LIBSSL) && !defined(IN_MODULE)
#ifndef __ssl_h__ #ifndef __ssl_h__
#define __ssl_h__ #define __ssl_h__

View File

@@ -97,7 +97,7 @@ typedef struct
void (*func_write) (int); void (*func_write) (int);
void (*cleanup) (int); void (*cleanup) (int);
void *info; void *info;
#if defined(HAVE_SSL) && !defined(IN_MODULE) #if defined(HAVE_LIBSSL) && !defined(IN_MODULE)
SSL_CTX* ctx; SSL_CTX* ctx;
int ssl_error; int ssl_error;
SSL* ssl_fd; SSL* ssl_fd;

View File

@@ -468,7 +468,7 @@ struct stat buf;
send(s, (const char *)&n->transfer_orders, sizeof(struct transfer_struct), 0); send(s, (const char *)&n->transfer_orders, sizeof(struct transfer_struct), 0);
} }
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
int SSL_dcc_create(SocketList *s, int sock, int doconnect) int SSL_dcc_create(SocketList *s, int sock, int doconnect)
{ {
set_blocking(sock); set_blocking(sock);
@@ -526,12 +526,12 @@ DCC_List *new_i;
new = (DCC_int *)s->info; new = (DCC_int *)s->info;
if ((new_s = connect_by_number(inet_ntoa(new->remote), &new->remport, SERVICE_CLIENT, PROTOCOL_TCP, 0)) < 0 if ((new_s = connect_by_number(inet_ntoa(new->remote), &new->remport, SERVICE_CLIENT, PROTOCOL_TCP, 0)) < 0
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
|| (flags & DCC_SSL ? SSL_dcc_create(s, new_s, 1) : 0) < 0 || (flags & DCC_SSL ? SSL_dcc_create(s, new_s, 1) : 0) < 0
#endif #endif
) )
{ {
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
SSL_show_errors(); SSL_show_errors();
#endif #endif
erase_dcc_info(s->is_read, 1, "%s", convert_output_format("$G %RDCC%n Unable to create connection: $0-", "%s", errno ? strerror(errno) : "Unknown Host")); erase_dcc_info(s->is_read, 1, "%s", convert_output_format("$G %RDCC%n Unable to create connection: $0-", "%s", errno ? strerror(errno) : "Unknown Host"));
@@ -574,7 +574,7 @@ DCC_List *new_i;
if (type == DCC_REFILEREAD) if (type == DCC_REFILEREAD)
refileread_send_start(new_s, new); refileread_send_start(new_s, new);
if (get_int_var(DCC_FAST_VAR) if (get_int_var(DCC_FAST_VAR)
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
&& !(flags & DCC_SSL) && !(flags & DCC_SSL)
#endif #endif
) )
@@ -737,7 +737,7 @@ void (*func)(int) = process_dcc_chat;
set_socketinfo(new_s, n); set_socketinfo(new_s, n);
new_sa = get_socket(new_s); new_sa = get_socket(new_s);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if((flags & DCC_SSL) && SSL_dcc_create(new_sa, new_s, 0) < 0) if((flags & DCC_SSL) && SSL_dcc_create(new_sa, new_s, 0) < 0)
{ {
say("SSL_accept failed."); say("SSL_accept failed.");
@@ -781,7 +781,7 @@ SocketList *sl;
if (dcc_types[type]->input) if (dcc_types[type]->input)
bytesread = (*dcc_types[type]->input)(s, type, bufptr, 1, BIG_BUFFER_SIZE); bytesread = (*dcc_types[type]->input)(s, type, bufptr, 1, BIG_BUFFER_SIZE);
else else
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
bytesread = dgets(bufptr, s, 1, BIG_BUFFER_SIZE, sl->ssl_fd); bytesread = dgets(bufptr, s, 1, BIG_BUFFER_SIZE, sl->ssl_fd);
#else #else
bytesread = dgets(bufptr, s, 1, BIG_BUFFER_SIZE, NULL); bytesread = dgets(bufptr, s, 1, BIG_BUFFER_SIZE, NULL);
@@ -915,7 +915,7 @@ SocketList *sl;
if (dcc_types[type]->input) if (dcc_types[type]->input)
bytesread = (*dcc_types[type]->input) (type, s, bufptr, 1, BIG_BUFFER_SIZE); bytesread = (*dcc_types[type]->input) (type, s, bufptr, 1, BIG_BUFFER_SIZE);
else else
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
bytesread = dgets(bufptr, s, 1, BIG_BUFFER_SIZE, sl->ssl_fd); bytesread = dgets(bufptr, s, 1, BIG_BUFFER_SIZE, sl->ssl_fd);
#else #else
bytesread = dgets(bufptr, s, 1, BIG_BUFFER_SIZE, NULL); bytesread = dgets(bufptr, s, 1, BIG_BUFFER_SIZE, NULL);
@@ -1017,7 +1017,7 @@ char thing = 0;
if (dcc_types[type]->output) if (dcc_types[type]->output)
(*dcc_types[type]->output) (type, s->is_read, tmp, len); (*dcc_types[type]->output) (type, s->is_read, tmp, len);
else else
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(s->ssl_fd) if(s->ssl_fd)
SSL_write(s->ssl_fd, tmp, len); SSL_write(s->ssl_fd, tmp, len);
else else
@@ -1669,7 +1669,7 @@ void dcc_chat(char *command, char *args)
bot++; bot++;
#endif #endif
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(my_strnicmp(args, "-SSL", 4) == 0) if(my_strnicmp(args, "-SSL", 4) == 0)
{ {
new_next_arg(args, &args); new_next_arg(args, &args);
@@ -3024,7 +3024,7 @@ BUILT_IN_COMMAND(chat)
if (!my_strnicmp(command, "NOC", 3)) if (!my_strnicmp(command, "NOC", 3))
no_chat = 1; no_chat = 1;
#if HAVE_SSL #if HAVE_LIBSSL
if(my_strnicmp(args, "-SSL", 4) == 0) if(my_strnicmp(args, "-SSL", 4) == 0)
{ {
new_next_arg(args, &args); new_next_arg(args, &args);
@@ -3038,7 +3038,7 @@ BUILT_IN_COMMAND(chat)
if (no_chat) if (no_chat)
malloc_sprintf(&tmp, "CLOSE CHAT %s", args); malloc_sprintf(&tmp, "CLOSE CHAT %s", args);
else else
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(flags & DCC_SSL) if(flags & DCC_SSL)
malloc_sprintf(&tmp, "CHAT -ssl %s", args); malloc_sprintf(&tmp, "CHAT -ssl %s", args);
else else

View File

@@ -109,7 +109,7 @@ int irc_port = IRC_PORT, /* port of ircd */
background = 0, background = 0,
do_check_pid = 0, do_check_pid = 0,
do_ignore_ajoin = 0, do_ignore_ajoin = 0,
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
do_use_ssl = 0, do_use_ssl = 0,
#endif #endif
run_level = 0, run_level = 0,
@@ -244,7 +244,7 @@ static char *switch_help[] = {
" -Z\t\tuse NAT address when doing dcc.\n", " -Z\t\tuse NAT address when doing dcc.\n",
" -P\t\ttoggle check pid.nickname for running program.\n", " -P\t\ttoggle check pid.nickname for running program.\n",
" -v\t\ttells you about the client's version\n", " -v\t\ttells you about the client's version\n",
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
" -s\t\tservers specified are SSL.\n", " -s\t\tservers specified are SSL.\n",
#endif #endif
" -i\t\tignores the autojoin list entries.\n", " -i\t\tignores the autojoin list entries.\n",
@@ -924,7 +924,7 @@ static char *parse_args (char *argv[], int argc, char **envp)
case 'i': case 'i':
do_ignore_ajoin = 1; do_ignore_ajoin = 1;
break; break;
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
case 's': case 's':
do_use_ssl = 1; do_use_ssl = 1;
break; break;
@@ -953,7 +953,7 @@ static char *parse_args (char *argv[], int argc, char **envp)
strlcpy(nickname, argv[ac], sizeof nickname); strlcpy(nickname, argv[ac], sizeof nickname);
else else
build_server_list(argv[ac]); build_server_list(argv[ac]);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
do_use_ssl = 0; do_use_ssl = 0;
#endif #endif
} }
@@ -1610,7 +1610,7 @@ int main(int argc, char *argv[], char *envp[])
#endif #endif
add_tcl_vars(); add_tcl_vars();
#endif #endif
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
{ {
char *entropy = malloc(100); char *entropy = malloc(100);
int i; int i;

View File

@@ -86,7 +86,7 @@ static void init_io (void)
} }
} }
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
void SSL_show_errors(void) void SSL_show_errors(void)
{ {
char buf[1000]; char buf[1000];
@@ -234,13 +234,13 @@ int BX_dgets (char *str, int des, int buffer, int buffersize, void *ssl_fd)
else if (nbytes) else if (nbytes)
{ {
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
int rc = 0; int rc = 0;
#endif #endif
if (nbytes >= IO_BUFFER_SIZE) if (nbytes >= IO_BUFFER_SIZE)
nbytes = IO_BUFFER_SIZE-1; nbytes = IO_BUFFER_SIZE-1;
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(ssl_fd) if(ssl_fd)
{ {
c = SSL_read((SSL *)ssl_fd, ioe->buffer + ioe->write_pos, c = SSL_read((SSL *)ssl_fd, ioe->buffer + ioe->write_pos,
@@ -266,7 +266,7 @@ int BX_dgets (char *str, int des, int buffer, int buffersize, void *ssl_fd)
if (c <= 0) if (c <= 0)
{ {
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(ssl_fd) if(ssl_fd)
{ {
say("SSL_read() failed, SSL error %d", rc); say("SSL_read() failed, SSL error %d", rc);

View File

@@ -150,7 +150,7 @@ void BX_close_server (int cs_index, char *message)
cs_index, message ? message : empty_string); cs_index, message ? message : empty_string);
snprintf(buffer, MAX_PROTOCOL_SIZE + 1, "QUIT :%s", message); snprintf(buffer, MAX_PROTOCOL_SIZE + 1, "QUIT :%s", message);
strlcat(buffer, "\r\n", sizeof buffer); strlcat(buffer, "\r\n", sizeof buffer);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if (get_server_ssl(cs_index)) if (get_server_ssl(cs_index))
{ {
SSL_write(server_list[cs_index].ssl_fd, buffer, strlen(buffer)); SSL_write(server_list[cs_index].ssl_fd, buffer, strlen(buffer));
@@ -498,13 +498,13 @@ void do_server (fd_set *rd, fd_set *wr)
if (getpeername(des, (struct sockaddr *) &sa, &salen) != -1) if (getpeername(des, (struct sockaddr *) &sa, &salen) != -1)
{ {
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(!server_list[i].ctx || server_list[i].ssl_error == SSL_ERROR_WANT_WRITE) if(!server_list[i].ctx || server_list[i].ssl_error == SSL_ERROR_WANT_WRITE)
{ {
#endif #endif
server_list[i].connect_wait = 0; server_list[i].connect_wait = 0;
finalize_server_connect(i, server_list[i].c_server, i); finalize_server_connect(i, server_list[i].c_server, i);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
} }
#endif #endif
} }
@@ -521,7 +521,7 @@ void do_server (fd_set *rd, fd_set *wr)
junk = (*serv_input_func)(i, bufptr, des, 1, BIG_BUFFER_SIZE); junk = (*serv_input_func)(i, bufptr, des, 1, BIG_BUFFER_SIZE);
else else
{ {
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(get_server_ssl(i)) if(get_server_ssl(i))
{ {
#ifdef NON_BLOCKING_CONNECTS #ifdef NON_BLOCKING_CONNECTS
@@ -798,7 +798,7 @@ extern int default_swatch;
server_list[from_server].motd = 1; server_list[from_server].motd = 1;
server_list[from_server].ircop_flags = default_swatch; server_list[from_server].ircop_flags = default_swatch;
server_list[from_server].port = port; server_list[from_server].port = port;
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
set_server_ssl(from_server, ssl); set_server_ssl(from_server, ssl);
#endif #endif
malloc_strcpy(&server_list[from_server].umodes, umodes); malloc_strcpy(&server_list[from_server].umodes, umodes);
@@ -863,7 +863,7 @@ void remove_from_server_list (int i)
new_free(&server_list[i].recv_nick); new_free(&server_list[i].recv_nick);
new_free(&server_list[i].sent_nick); new_free(&server_list[i].sent_nick);
new_free(&server_list[i].sent_body); new_free(&server_list[i].sent_body);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
SSL_CTX_free(server_list[i].ctx); SSL_CTX_free(server_list[i].ctx);
#endif #endif
clear_server_sping(i, NULL); clear_server_sping(i, NULL);
@@ -984,7 +984,7 @@ int BX_build_server_list (char *servers)
int port_num; int port_num;
int i = 0; int i = 0;
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
extern int do_use_ssl; extern int do_use_ssl;
#else #else
int do_use_ssl = 0; int do_use_ssl = 0;
@@ -1336,7 +1336,7 @@ int finalize_server_connect(int refnum, int c_server, int my_from_server)
close_server(c_server, "changing servers"); close_server(c_server, "changing servers");
} }
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(get_server_ssl(refnum)) if(get_server_ssl(refnum))
{ {
int err = 0; int err = 0;
@@ -1551,7 +1551,7 @@ void try_connect (int server, int old_server)
else if (server < 0) else if (server < 0)
server = 0; server = 0;
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
server_list[server].ctx = NULL; server_list[server].ctx = NULL;
#endif #endif
if(server_list[server].server_change_refnum > -1) if(server_list[server].server_change_refnum > -1)
@@ -1645,7 +1645,7 @@ BUILT_IN_COMMAND(servercmd)
{ {
char *server = NULL; char *server = NULL;
int i, my_from_server = from_server; int i, my_from_server = from_server;
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
int ssl_connect = 0; int ssl_connect = 0;
#endif #endif
@@ -1655,7 +1655,7 @@ BUILT_IN_COMMAND(servercmd)
return; return;
} }
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if((i = find_in_server_list(server, 0)) != -1) if((i = find_in_server_list(server, 0)) != -1)
set_server_ssl(i, 0); set_server_ssl(i, 0);
@@ -1738,7 +1738,7 @@ BUILT_IN_COMMAND(servercmd)
if (*++server) if (*++server)
{ {
i = find_server_refnum(server, &args); i = find_server_refnum(server, &args);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(ssl_connect) if(ssl_connect)
set_server_ssl(i, 1); set_server_ssl(i, 1);
#endif #endif
@@ -1773,7 +1773,7 @@ BUILT_IN_COMMAND(servercmd)
else else
{ {
i = find_server_refnum(server, &args); i = find_server_refnum(server, &args);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(ssl_connect) if(ssl_connect)
set_server_ssl(i, 1); set_server_ssl(i, 1);
#endif #endif
@@ -2450,7 +2450,7 @@ int err = 0;
err = (*serv_output_func)(server, des, buffer, strlen(buffer)); err = (*serv_output_func)(server, des, buffer, strlen(buffer));
else else
{ {
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(get_server_ssl(server)) if(get_server_ssl(server))
{ {
if(!server_list[server].ssl_fd) if(!server_list[server].ssl_fd)
@@ -2467,7 +2467,7 @@ int err = 0;
if ((err == -1) && !get_int_var(NO_FAIL_DISCONNECT_VAR)) if ((err == -1) && !get_int_var(NO_FAIL_DISCONNECT_VAR))
{ {
say("Write to server failed. Closing connection."); say("Write to server failed. Closing connection.");
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(get_server_ssl(server)) if(get_server_ssl(server))
SSL_shutdown (server_list[server].ssl_fd); SSL_shutdown (server_list[server].ssl_fd);
#endif #endif
@@ -3307,7 +3307,7 @@ void set_server_reconnect(int s, int val)
} }
} }
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
void set_server_ssl(int s, int val) void set_server_ssl(int s, int val)
{ {
if (s > -1 && s < number_of_servers) if (s > -1 && s < number_of_servers)

View File

@@ -3849,13 +3849,13 @@ static Window *window_remove (Window *window, char **args, char *usage)
BUILT_IN_WINDOW(window_server) BUILT_IN_WINDOW(window_server)
{ {
char *arg; char *arg;
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
int withSSL = 0; int withSSL = 0;
#endif #endif
if ((arg = next_arg(*args, args))) if ((arg = next_arg(*args, args)))
{ {
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if (!my_strnicmp(arg, "-SSL", strlen(arg))) if (!my_strnicmp(arg, "-SSL", strlen(arg)))
{ {
withSSL = 1; withSSL = 1;
@@ -3867,7 +3867,7 @@ BUILT_IN_WINDOW(window_server)
#endif #endif
int i = find_server_refnum(arg, NULL); int i = find_server_refnum(arg, NULL);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
if(i != -1) if(i != -1)
{ {
if(withSSL) if(withSSL)
@@ -3890,7 +3890,7 @@ BUILT_IN_WINDOW(window_server)
#endif #endif
} }
window_check_servers(from_server); window_check_servers(from_server);
#ifdef HAVE_SSL #ifdef HAVE_LIBSSL
} }
#endif #endif
} }