NeoMutt  2019-12-07-60-g0cfa53
Teaching an old dog new tricks
mutt_socket.c File Reference

NeoMutt connections. More...

#include "config.h"
#include <stdio.h>
#include <string.h>
#include "email/lib.h"
#include "conn/conn.h"
#include "mutt_socket.h"
#include "hook.h"
#include "mutt_account.h"
+ Include dependency graph for mutt_socket.c:

Go to the source code of this file.


struct Connectionmutt_conn_new (const struct ConnAccount *account)
 Create a new Connection. More...
struct Connectionmutt_conn_find (const struct Connection *start, const struct ConnAccount *account)
 Find a connection from a list. 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.c.

Function Documentation

◆ mutt_conn_new()

struct Connection* mutt_conn_new ( const struct ConnAccount account)

Create a new Connection.

accountCredentials to use
Return values
ptrNew Connection

Definition at line 46 of file mutt_socket.c.

47 {
48  enum ConnectionType conn_type;
50  if (C_Tunnel)
52  else if (account->flags & MUTT_ACCT_SSL)
53  conn_type = MUTT_CONNECTION_SSL;
54  else
57  struct Connection *conn = mutt_socket_new(conn_type);
58  if (conn)
59  {
60  memcpy(&conn->account, account, sizeof(struct ConnAccount));
61  }
62  else
63  {
64  if (conn_type == MUTT_CONNECTION_SSL)
65  {
66 #ifndef USE_SSL
67  /* that's probably why it failed */
68  mutt_error(_("SSL is unavailable, can't connect to %s"), account->host);
69 #endif
70  }
71  }
72  return conn;
73 }
Tunnelled connection.
Definition: socket.h:36
struct ConnAccount account
Definition: connection.h:36
const char * C_Tunnel
Config: Shell command to establish a tunnel.
Definition: conn_globals.c:50
struct Connection * mutt_socket_new(enum ConnectionType type)
allocate and initialise a new connection
Definition: socket.c:278
An open network connection (socket)
Definition: connection.h:34
#define _(a)
Definition: message.h:28
char host[128]
Definition: connaccount.h:36
SSL/TLS-encrypted connection.
Definition: socket.h:37
Simple TCP socket connection.
Definition: socket.h:35
Login details for a remote server.
Definition: connaccount.h:31
#define mutt_error(...)
Definition: logging.h:84
Account uses SSL/TLS.
Definition: mutt_account.h:64
Type of connection.
Definition: socket.h:33
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_conn_find()

struct Connection* mutt_conn_find ( const struct Connection start,
const struct ConnAccount account 

Find a connection from a list.

startFirst connection to try
accountConnAccount to match
Return values
ptrMatching Connection

find a connection off the list of connections whose account matches account. 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 87 of file mutt_socket.c.

89 {
90  struct Url url;
91  char hook[1024];
93  /* account isn't actually modified, since url isn't either */
94  mutt_account_tourl((struct ConnAccount *) account, &url);
95  url.path = NULL;
96  url_tostring(&url, hook, sizeof(hook), 0);
97  mutt_account_hook(hook);
99  return mutt_conn_new(account);
100 }
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:66
struct Connection * mutt_conn_new(const struct ConnAccount *account)
Create a new Connection.
Definition: mutt_socket.c:46
int url_tostring(struct Url *u, char *dest, size_t len, int flags)
Output the URL string for a given Url object.
Definition: url.c:399
void mutt_account_hook(const char *url)
Perform an account hook.
Definition: hook.c:758
Login details for a remote server.
Definition: connaccount.h:31
void mutt_account_tourl(struct ConnAccount *account, struct Url *url)
Fill URL with info from account.
Definition: mutt_account.c:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function: