NeoMutt
2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
mutt_socket.c
Go to the documentation of this file.
1
23
29
30
#include "config.h"
31
#include <string.h>
32
#include "
config/lib.h
"
33
#include "
email/lib.h
"
34
#include "
core/lib.h
"
35
#include "
conn/lib.h
"
36
#include "
mutt_socket.h
"
37
#include "
hooks/lib.h
"
38
#ifndef USE_SSL
39
#include "
mutt/lib.h
"
40
#endif
41
47
struct
Connection
*
mutt_conn_new
(
const
struct
ConnAccount
*cac)
48
{
49
enum
ConnectionType
conn_type;
50
51
const
char
*
const
c_tunnel =
cs_subset_string
(
NeoMutt
->
sub
,
"tunnel"
);
52
if
(c_tunnel)
53
conn_type =
MUTT_CONNECTION_TUNNEL
;
54
else
if
(cac->
flags
&
MUTT_ACCT_SSL
)
55
conn_type =
MUTT_CONNECTION_SSL
;
56
else
57
conn_type =
MUTT_CONNECTION_SIMPLE
;
58
59
struct
Connection
*conn =
mutt_socket_new
(conn_type);
60
if
(conn)
61
{
62
memcpy(&conn->
account
, cac,
sizeof
(
struct
ConnAccount
));
63
}
64
else
65
{
66
if
(conn_type ==
MUTT_CONNECTION_SSL
)
67
{
68
#ifndef USE_SSL
69
/* that's probably why it failed */
70
mutt_error
(
_
(
"SSL is unavailable, can't connect to %s"
), cac->
host
);
71
#endif
72
}
73
}
74
return
conn;
75
}
76
88
struct
Connection
*
mutt_conn_find
(
const
struct
ConnAccount
*cac)
89
{
90
struct
Url
url = { 0 };
91
char
hook[1024] = { 0 };
92
93
/* cac isn't actually modified, since url isn't either */
94
account_to_url
((
struct
ConnAccount
*) cac, &url);
95
url.
path
= NULL;
96
url_tostring
(&url, hook,
sizeof
(hook),
U_NONE
);
97
exec_account_hook
(hook);
98
99
return
mutt_conn_new
(cac);
100
}
cs_subset_string
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition
helpers.c:291
lib.h
Convenience wrapper for the config headers.
lib.h
Connection Library.
MUTT_ACCT_SSL
@ MUTT_ACCT_SSL
Account uses SSL/TLS.
Definition
connaccount.h:51
lib.h
Convenience wrapper for the core headers.
lib.h
Structs that make up an email.
mutt_error
#define mutt_error(...)
Definition
logging2.h:94
exec_account_hook
void exec_account_hook(const char *url)
Perform an account hook.
Definition
exec.c:328
lib.h
Hook Commands.
lib.h
Convenience wrapper for the library headers.
_
#define _(a)
Definition
message.h:28
account_to_url
void account_to_url(struct ConnAccount *cac, struct Url *url)
Fill URL with info from account.
Definition
mutt_account.c:80
mutt_conn_new
struct Connection * mutt_conn_new(const struct ConnAccount *cac)
Create a new Connection.
Definition
mutt_socket.c:47
mutt_conn_find
struct Connection * mutt_conn_find(const struct ConnAccount *cac)
Find a connection from a list.
Definition
mutt_socket.c:88
mutt_socket.h
NeoMutt connections.
mutt_socket_new
struct Connection * mutt_socket_new(enum ConnectionType type)
Allocate and initialise a new connection.
Definition
socket.c:272
ConnectionType
ConnectionType
Type of connection.
Definition
socket.h:35
MUTT_CONNECTION_SSL
@ MUTT_CONNECTION_SSL
SSL/TLS-encrypted connection.
Definition
socket.h:38
MUTT_CONNECTION_SIMPLE
@ MUTT_CONNECTION_SIMPLE
Simple TCP socket connection.
Definition
socket.h:36
MUTT_CONNECTION_TUNNEL
@ MUTT_CONNECTION_TUNNEL
Tunnelled connection.
Definition
socket.h:37
ConnAccount
Login details for a remote server.
Definition
connaccount.h:59
ConnAccount::host
char host[128]
Server to login to.
Definition
connaccount.h:60
ConnAccount::flags
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition
connaccount.h:66
Connection
Definition
connection.h:48
Connection::account
struct ConnAccount account
Account details: username, password, etc.
Definition
connection.h:49
NeoMutt
Container for Accounts, Notifications.
Definition
neomutt.h:41
NeoMutt::sub
struct ConfigSubset * sub
Inherited config items.
Definition
neomutt.h:49
Url
A parsed URL proto://user:password@host:port/path?a=1&b=2.
Definition
url.h:69
Url::path
char * path
Path.
Definition
url.h:75
url_tostring
int url_tostring(const struct Url *url, char *dest, size_t len, uint8_t flags)
Output the URL string for a given Url object.
Definition
url.c:426
U_NONE
#define U_NONE
No flags are set for URL parsing.
Definition
url.h:49