* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
-static int socket_connect (int fd, struct sockaddr* sa);
-static CONNECTION* socket_new_conn ();
+static int socket_connect (int fd, struct sockaddr *sa);
+static CONNECTION *socket_new_conn ();
- dprint (dbg, (debugfile,"> %s", buf));
+ dprint (dbg, (debugfile, "> %s", buf));
- conn->available = conn->conn_read (conn, conn->inbuf, sizeof (conn->inbuf));
- else
- {
- dprint (1, (debugfile, "mutt_socket_readchar: attempt to read from closed connection.\n"));
+ conn->available =
+ conn->conn_read (conn, conn->inbuf, sizeof (conn->inbuf));
+ else {
+ dprint (1,
+ (debugfile,
+ "mutt_socket_readchar: attempt to read from closed connection.\n"));
-int mutt_socket_readln_d (char* buf, size_t buflen, CONNECTION* conn, int dbg)
+int mutt_socket_readln_d (char *buf, size_t buflen, CONNECTION * conn,
+ int dbg)
- for (i = 0; i < buflen-1; i++)
- {
- if (mutt_socket_readchar (conn, &ch) != 1)
- {
+ for (i = 0; i < buflen - 1; i++) {
+ if (mutt_socket_readchar (conn, &ch) != 1) {
buf[--i] = '\0';
else
buf[i] = '\0';
dprint (dbg, (debugfile, "< %s\n", buf));
buf[--i] = '\0';
else
buf[i] = '\0';
dprint (dbg, (debugfile, "< %s\n", buf));
* connections after the given connection (allows higher level socket code
* to make more fine-grained searches than account info - eg in IMAP we may
* wish to find a connection which is not in IMAP_SELECTED state) */
* connections after the given connection (allows higher level socket code
* to make more fine-grained searches than account info - eg in IMAP we may
* wish to find a connection which is not in IMAP_SELECTED state) */
url.path = NULL;
url_ciss_tostring (&url, hook, sizeof (hook), 0);
mutt_account_hook (hook);
conn = start ? start->next : Connections;
url.path = NULL;
url_ciss_tostring (&url, hook, sizeof (hook), 0);
mutt_account_hook (hook);
conn = start ? start->next : Connections;
conn->conn_read = raw_socket_read;
conn->conn_write = raw_socket_write;
conn->conn_open = raw_socket_open;
conn->conn_read = raw_socket_read;
conn->conn_write = raw_socket_write;
conn->conn_open = raw_socket_open;
dprint (2, (debugfile, "Executing preconnect: %s\n", Preconnect));
rc = mutt_system (Preconnect);
dprint (2, (debugfile, "Preconnect result: %d\n", rc));
dprint (2, (debugfile, "Executing preconnect: %s\n", Preconnect));
rc = mutt_system (Preconnect);
dprint (2, (debugfile, "Preconnect result: %d\n", rc));
- if (connect (fd, sa, sa_size) < 0)
- {
- save_errno = errno;
- dprint (2, (debugfile, "Connection failed. errno: %d...\n", errno));
- SigInt = 0; /* reset in case we caught SIGINTR while in connect() */
+ if (connect (fd, sa, sa_size) < 0) {
+ save_errno = errno;
+ dprint (2, (debugfile, "Connection failed. errno: %d...\n", errno));
+ SigInt = 0; /* reset in case we caught SIGINTR while in connect() */
/* we accept v4 or v6 STREAM sockets */
memset (&hints, 0, sizeof (hints));
/* we accept v4 or v6 STREAM sockets */
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
snprintf (port, sizeof (port), "%d", conn->account.port);
hints.ai_socktype = SOCK_STREAM;
snprintf (port, sizeof (port), "%d", conn->account.port);
rc = getaddrinfo (host_idna, port, &hints, &res);
# ifdef HAVE_LIBIDN
FREE (&host_idna);
# endif
rc = getaddrinfo (host_idna, port, &hints, &res);
# ifdef HAVE_LIBIDN
FREE (&host_idna);
# endif
- if (fd >= 0)
- {
- if ((rc = socket_connect (fd, cur->ai_addr)) == 0)
- {
- fcntl (fd, F_SETFD, FD_CLOEXEC);
- conn->fd = fd;
- break;
+ if (fd >= 0) {
+ if ((rc = socket_connect (fd, cur->ai_addr)) == 0) {
+ fcntl (fd, F_SETFD, FD_CLOEXEC);
+ conn->fd = fd;
+ break;
memcpy (&sin.sin_addr, he->h_addr_list[i], he->h_length);
fd = socket (PF_INET, SOCK_STREAM, IPPROTO_IP);
memcpy (&sin.sin_addr, he->h_addr_list[i], he->h_length);
fd = socket (PF_INET, SOCK_STREAM, IPPROTO_IP);