X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-sys%2Fmutt_socket.c;h=8616440bbf9953f1b902a847ceaa7c43f975d227;hp=0acee2ab1981a5fa9f71b0e3b8eecc210af00ff7;hb=7dcd7ee09b8760133ac8ec00562e4d60b2f0aebd;hpb=bbaf5ab9813d18f9912e00fab83195e368e3f0d7 diff --git a/lib-sys/mutt_socket.c b/lib-sys/mutt_socket.c index 0acee2a..8616440 100644 --- a/lib-sys/mutt_socket.c +++ b/lib-sys/mutt_socket.c @@ -15,7 +15,7 @@ #include #include -#include +#include #include "mutt.h" #include "globals.h" @@ -33,18 +33,21 @@ /* support for multiple socket connections */ static CONNECTION *Connections = NULL; -/* forward declarations */ -static int socket_preconnect (void); -static int socket_connect (int fd, struct sockaddr *sa); -static CONNECTION *socket_new_conn (void); - /* Wrappers */ int mutt_socket_open (CONNECTION * conn) { - if (socket_preconnect ()) - return -1; + int rc; + + if (m_strlen(Preconnect)) { + rc = mutt_system (Preconnect); + if (rc) { + mutt_perror (_("Preconnect command failed.")); + mutt_sleep (1); + return -1; + } + } - return conn->conn_open (conn); + return conn->conn_open(conn); } int mutt_socket_close (CONNECTION * conn) @@ -206,14 +209,6 @@ void mutt_socket_free (CONNECTION * conn) CONNECTION *mutt_conn_find (const CONNECTION * start, const ACCOUNT * account) { CONNECTION *conn; - ciss_url_t url; - char hook[LONG_STRING]; - - /* account isn't actually modified, since url isn't either */ - mutt_account_tourl ((ACCOUNT *) account, &url); - url.path = NULL; - url_ciss_tostring (&url, hook, sizeof (hook), 0); - mutt_account_hook (hook); conn = start ? start->next : Connections; while (conn) { @@ -222,10 +217,10 @@ CONNECTION *mutt_conn_find (const CONNECTION * start, const ACCOUNT * account) conn = conn->next; } - conn = socket_new_conn (); - memcpy (&conn->account, account, sizeof (ACCOUNT)); - - conn->next = Connections; + conn = p_new(CONNECTION, 1); + conn->fd = -1; + conn->account = *account; + conn->next = Connections; Connections = conn; if (Tunnel && *Tunnel) @@ -245,25 +240,6 @@ CONNECTION *mutt_conn_find (const CONNECTION * start, const ACCOUNT * account) return conn; } -static int socket_preconnect (void) -{ - int rc; - int save_errno; - - if (m_strlen(Preconnect)) { - rc = mutt_system (Preconnect); - if (rc) { - save_errno = errno; - mutt_perror (_("Preconnect command failed.")); - mutt_sleep (1); - - return save_errno; - } - } - - return 0; -} - /* socket_connect: set up to connect to a socket fd. */ static int socket_connect (int fd, struct sockaddr *sa) { @@ -297,17 +273,6 @@ static int socket_connect (int fd, struct sockaddr *sa) return save_errno; } -/* socket_new_conn: allocate and initialise a new connection. */ -static CONNECTION *socket_new_conn (void) -{ - CONNECTION *conn; - - conn = p_new(CONNECTION, 1); - conn->fd = -1; - - return conn; -} - int raw_socket_close (CONNECTION * conn) { return close (conn->fd); @@ -355,11 +320,7 @@ int raw_socket_open (CONNECTION * conn) /* we accept v4 or v6 STREAM sockets */ p_clear(&hints, 1); - if (option (OPTUSEIPV6)) - hints.ai_family = AF_UNSPEC; - else - hints.ai_family = AF_INET; - + hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; snprintf (port, sizeof (port), "%d", conn->account.port);