X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=mutt_socket.c;h=e5fc1a3dcd0ec22d4af7ad8fb5ef152a7ab9a1d8;hp=acb544afe133cd878dd63190eba7e87b0ac10669;hb=a743b55a20cbf3a33699fdb24dcb8638e878cc46;hpb=bad8211c28d4b229878e0264012009493db48da5 diff --git a/mutt_socket.c b/mutt_socket.c index acb544a..e5fc1a3 100644 --- a/mutt_socket.c +++ b/mutt_socket.c @@ -13,6 +13,10 @@ # include "config.h" #endif +#include +#include +#include + #include "mutt.h" #include "globals.h" #include "mutt_socket.h" @@ -23,9 +27,6 @@ #include "mutt_idna.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" #include "lib/debug.h" #include @@ -103,7 +104,7 @@ int mutt_socket_write_d (CONNECTION * conn, const char *buf, int dbg) return -1; } - len = mutt_strlen (buf); + len = m_strlen(buf); if ((rc = conn->conn_write (conn, buf, len)) < 0) { debug_print (1, ("error writing, closing socket\n")); mutt_socket_close (conn); @@ -169,7 +170,7 @@ int mutt_socket_readln_d (char *buf, size_t buflen, CONNECTION * conn, debug_print (dbg, ("< %s\n", buf)); - /* number of bytes read, not mutt_strlen */ + /* number of bytes read, not m_strlen*/ return i + 1; } @@ -189,7 +190,7 @@ void mutt_socket_free (CONNECTION * conn) /* head is special case, doesn't need prev updated */ if (iter == conn) { Connections = iter->next; - FREE (&iter); + p_delete(&iter); return; } @@ -197,7 +198,7 @@ void mutt_socket_free (CONNECTION * conn) if (iter->next == conn) { tmp = iter->next; iter->next = tmp->next; - FREE (&tmp); + p_delete(&tmp); return; } iter = iter->next; @@ -237,10 +238,8 @@ CONNECTION *mutt_conn_find (const CONNECTION * start, const ACCOUNT * account) if (Tunnel && *Tunnel) mutt_tunnel_socket_setup (conn); else if (account->flags & M_ACCT_SSL) { -#ifdef USE_SSL - ssl_socket_setup (conn); -#elif USE_GNUTLS - if (mutt_gnutls_socket_setup (conn) < 0) { +#if defined (USE_SSL) || defined (USE_GNUTLS) + if (mutt_ssl_socket_setup (conn) < 0) { mutt_socket_free (conn); return NULL; } @@ -268,7 +267,7 @@ static int socket_preconnect (void) int rc; int save_errno; - if (mutt_strlen (Preconnect)) { + if (m_strlen(Preconnect)) { debug_print (2, ("Executing preconnect: %s\n", Preconnect)); rc = mutt_system (Preconnect); debug_print (2, ("Preconnect result: %d\n", rc)); @@ -326,7 +325,7 @@ static CONNECTION *socket_new_conn (void) { CONNECTION *conn; - conn = (CONNECTION *) safe_calloc (1, sizeof (CONNECTION)); + conn = p_new(CONNECTION, 1); conn->fd = -1; return conn; @@ -380,7 +379,7 @@ int raw_socket_open (CONNECTION * conn) struct addrinfo *cur; /* we accept v4 or v6 STREAM sockets */ - memset (&hints, 0, sizeof (hints)); + p_clear(&hints, 1); if (option (OPTUSEIPV6)) hints.ai_family = AF_UNSPEC; @@ -406,11 +405,12 @@ int raw_socket_open (CONNECTION * conn) rc = getaddrinfo (host_idna, port, &hints, &res); # ifdef HAVE_LIBIDN - FREE (&host_idna); + p_delete(&host_idna); # endif if (rc) { mutt_error (_("Could not find the host \"%s\""), conn->account.host); + mutt_sleep (2); return -1; } @@ -439,7 +439,7 @@ int raw_socket_open (CONNECTION * conn) struct hostent *he; int i; - memset (&sin, 0, sizeof (sin)); + p_clear(&sin, 1); sin.sin_port = htons (conn->account.port); sin.sin_family = AF_INET; @@ -456,7 +456,7 @@ int raw_socket_open (CONNECTION * conn) if ((he = gethostbyname (host_idna)) == NULL) { # ifdef HAVE_LIBIDN - FREE (&host_idna); + p_delete(&host_idna); # endif mutt_error (_("Could not find the host \"%s\""), conn->account.host); @@ -464,7 +464,7 @@ int raw_socket_open (CONNECTION * conn) } # ifdef HAVE_LIBIDN - FREE (&host_idna); + p_delete(&host_idna); # endif mutt_message (_("Connecting to %s..."), conn->account.host); @@ -476,6 +476,7 @@ int raw_socket_open (CONNECTION * conn) if (fd >= 0) { if ((rc = socket_connect (fd, (struct sockaddr *) &sin)) == 0) { + fcntl (fd, F_SETFD, FD_CLOEXEC); conn->fd = fd; break; }