NeoMutt  2021-10-29-220-g2b1eec
Teaching an old dog new tricks
mutt_socket.h File Reference

NeoMutt connections. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define MUTT_SOCK_LOG_CMD   2
#define MUTT_SOCK_LOG_HDR   3
#define MUTT_SOCK_LOG_FULL   5
#define mutt_socket_readln(buf, buflen, conn)   mutt_socket_readln_d(buf, buflen, conn, MUTT_SOCK_LOG_CMD)
#define mutt_socket_send(conn, buf)   mutt_socket_send_d(conn, buf, MUTT_SOCK_LOG_CMD)
#define mutt_socket_send_d(conn, buf, dbg)   mutt_socket_write_d(conn, buf, mutt_str_len(buf), dbg)
#define mutt_socket_write_n(conn, buf, len)   mutt_socket_write_d(conn, buf, len, MUTT_SOCK_LOG_CMD)


struct Connectionmutt_conn_find (const struct ConnAccount *account)
 Find a connection from a list. More...
struct Connectionmutt_conn_new (const struct ConnAccount *account)
 Create a new Connection. More...

Detailed Description

NeoMutt connections.

  • Brendan Cully

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

Definition in file mutt_socket.h.

Macro Definition Documentation


#define MUTT_SOCK_LOG_CMD   2

Definition at line 29 of file mutt_socket.h.


#define MUTT_SOCK_LOG_HDR   3

Definition at line 30 of file mutt_socket.h.


#define MUTT_SOCK_LOG_FULL   5

Definition at line 31 of file mutt_socket.h.

◆ mutt_socket_readln

#define mutt_socket_readln (   buf,
)    mutt_socket_readln_d(buf, buflen, conn, MUTT_SOCK_LOG_CMD)

Definition at line 36 of file mutt_socket.h.

◆ mutt_socket_send

#define mutt_socket_send (   conn,
)    mutt_socket_send_d(conn, buf, MUTT_SOCK_LOG_CMD)

Definition at line 37 of file mutt_socket.h.

◆ mutt_socket_send_d

#define mutt_socket_send_d (   conn,
)    mutt_socket_write_d(conn, buf, mutt_str_len(buf), dbg)

Definition at line 38 of file mutt_socket.h.

◆ mutt_socket_write_n

#define mutt_socket_write_n (   conn,
)    mutt_socket_write_d(conn, buf, len, MUTT_SOCK_LOG_CMD)

Definition at line 39 of file mutt_socket.h.

Function Documentation

◆ mutt_conn_find()

struct Connection* mutt_conn_find ( const struct ConnAccount cac)

Find a connection from a list.

cacConnAccount to match
Return values
ptrMatching Connection

find a connection off the list of connections whose account matches cac. If start is not null, only search for 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)

Definition at line 89 of file mutt_socket.c.

90 {
91  struct Url url = { 0 };
92  char hook[1024];
94  /* cac isn't actually modified, since url isn't either */
95  mutt_account_tourl((struct ConnAccount *) cac, &url);
96  url.path = NULL;
97  url_tostring(&url, hook, sizeof(hook), U_NO_FLAGS);
98  mutt_account_hook(hook);
100  return mutt_conn_new(cac);
101 }
void mutt_account_hook(const char *url)
Perform an account hook.
Definition: hook.c:785
void mutt_account_tourl(struct ConnAccount *cac, struct Url *url)
Fill URL with info from account.
Definition: mutt_account.c:79
struct Connection * mutt_conn_new(const struct ConnAccount *cac)
Create a new Connection.
Definition: mutt_socket.c:48
Login details for a remote server.
Definition: connaccount.h:53
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:69
char * path
Definition: url.h:75
int url_tostring(struct Url *url, char *dest, size_t len, uint8_t flags)
Output the URL string for a given Url object.
Definition: url.c:418
#define U_NO_FLAGS
Definition: url.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_conn_new()

struct Connection* mutt_conn_new ( const struct ConnAccount cac)

Create a new Connection.

cacCredentials to use
Return values
ptrNew Connection

Definition at line 48 of file mutt_socket.c.

49 {
50  enum ConnectionType conn_type;
52  const char *const c_tunnel = cs_subset_string(NeoMutt->sub, "tunnel");
53  if (c_tunnel)
55  else if (cac->flags & MUTT_ACCT_SSL)
56  conn_type = MUTT_CONNECTION_SSL;
57  else
60  struct Connection *conn = mutt_socket_new(conn_type);
61  if (conn)
62  {
63  memcpy(&conn->account, cac, sizeof(struct ConnAccount));
64  }
65  else
66  {
67  if (conn_type == MUTT_CONNECTION_SSL)
68  {
69 #ifndef USE_SSL
70  /* that's probably why it failed */
71  mutt_error(_("SSL is unavailable, can't connect to %s"), cac->host);
72 #endif
73  }
74  }
75  return conn;
76 }
Account uses SSL/TLS.
Definition: connaccount.h:47
#define mutt_error(...)
Definition: logging.h:87
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
#define _(a)
Definition: message.h:28
struct Connection * mutt_socket_new(enum ConnectionType type)
Allocate and initialise a new connection.
Definition: socket.c:280
Type of connection.
Definition: socket.h:35
SSL/TLS-encrypted connection.
Definition: socket.h:38
Simple TCP socket connection.
Definition: socket.h:36
Tunnelled connection.
Definition: socket.h:37
char host[128]
Server to login to.
Definition: connaccount.h:54
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:60
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:50
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function: