X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-sys%2Fmutt_socket.c;h=8616440bbf9953f1b902a847ceaa7c43f975d227;hb=11ebd35cdf53f877efb11ed1ce9ccb771d2a091c;hp=b90a1f259f417b97b8566c5ad44c914843dfdf82;hpb=e41e4a2116c38767c12c1bc83bb0d03d1385f62e;p=apps%2Fmadmutt.git diff --git a/lib-sys/mutt_socket.c b/lib-sys/mutt_socket.c index b90a1f2..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; - return conn->conn_open (conn); + 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); } int mutt_socket_close (CONNECTION * conn) @@ -214,10 +217,10 @@ CONNECTION *mutt_conn_find (const CONNECTION * start, const ACCOUNT * account) conn = conn->next; } - conn = socket_new_conn (); + conn = p_new(CONNECTION, 1); + conn->fd = -1; conn->account = *account; - - conn->next = Connections; + conn->next = Connections; Connections = conn; if (Tunnel && *Tunnel) @@ -237,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) { @@ -289,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); @@ -347,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);