NeoMutt  2018-07-16 +952-a2da0a
Teaching an old dog new tricks
DOXYGEN
mutt_socket.c File Reference

NeoMutt connections. More...

#include "config.h"
#include <stdio.h>
#include <string.h>
#include "mutt/mutt.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.

Functions

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.

Authors
  • 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 http://www.gnu.org/licenses/.

Definition in file mutt_socket.c.

Function Documentation

struct Connection* mutt_conn_new ( const struct ConnAccount account)

Create a new Connection.

Parameters
accountCredentials to use
Return values
ptrNew Connection

Definition at line 44 of file mutt_socket.c.

45 {
46  enum ConnectionType conn_type;
47 
48  if (Tunnel && *Tunnel)
49  conn_type = MUTT_CONNECTION_TUNNEL;
50  else if (account->flags & MUTT_ACCT_SSL)
51  conn_type = MUTT_CONNECTION_SSL;
52  else
53  conn_type = MUTT_CONNECTION_SIMPLE;
54 
55  struct Connection *conn = mutt_socket_new(conn_type);
56  if (conn)
57  {
58  memcpy(&conn->account, account, sizeof(struct ConnAccount));
59  }
60  else
61  {
62  if (conn_type == MUTT_CONNECTION_SSL)
63  {
64 #ifndef USE_SSL
65  /* that's probably why it failed */
66  mutt_error(_("SSL is unavailable, cannot connect to %s"), account->host);
67 #endif
68  }
69  }
70  return conn;
71 }
Tunnelled connection.
Definition: socket.h:37
struct ConnAccount account
Definition: connection.h:37
struct Connection * mutt_socket_new(enum ConnectionType type)
allocate and initialise a new connection
Definition: socket.c:285
An open network connection (socket)
Definition: connection.h:35
#define _(a)
Definition: message.h:28
char host[128]
Definition: connaccount.h:34
const char * Tunnel
Config: Shell command to establish a tunnel.
Definition: conn_globals.c:48
SSL/TLS-encrypted connection.
Definition: socket.h:38
Simple TCP socket connection.
Definition: socket.h:36
unsigned char flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:37
Login details for a remote server.
Definition: connaccount.h:29
#define mutt_error(...)
Definition: logging.h:88
#define MUTT_ACCT_SSL
Definition: mutt_account.h:60
ConnectionType
Type of connection.
Definition: socket.h:34

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Find a connection from a list.

Parameters
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 85 of file mutt_socket.c.

87 {
88  struct Url url;
89  char hook[LONG_STRING];
90 
91  /* account isn't actually modified, since url isn't either */
92  mutt_account_tourl((struct ConnAccount *) account, &url);
93  url.path = NULL;
94  url_tostring(&url, hook, sizeof(hook), 0);
95  mutt_account_hook(hook);
96 
97  return mutt_conn_new(account);
98 }
struct Url url
Definition: url.c:45
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:67
struct Connection * mutt_conn_new(const struct ConnAccount *account)
Create a new Connection.
Definition: mutt_socket.c:44
#define LONG_STRING
Definition: string2.h:36
void mutt_account_hook(const char *url)
Perform an account hook.
Definition: hook.c:614
int url_tostring(struct Url *u, char *buf, size_t buflen, int flags)
Output the URL string for a given Url object.
Definition: url.c:351
Login details for a remote server.
Definition: connaccount.h:29
char * path
Definition: url.h:74
void mutt_account_tourl(struct ConnAccount *account, struct Url *url)
Fill URL with info from account.
Definition: mutt_account.c:144

+ Here is the call graph for this function:

+ Here is the caller graph for this function: