NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mutt_account.h File Reference

ConnAccount object used by POP and IMAP. More...

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

Go to the source code of this file.

Enumerations

enum  AccountType {
  MUTT_ACCT_TYPE_NONE = 0 , MUTT_ACCT_TYPE_IMAP , MUTT_ACCT_TYPE_POP , MUTT_ACCT_TYPE_SMTP ,
  MUTT_ACCT_TYPE_NNTP , MUTT_ACCT_TYPE_MAX
}
 Account types. More...
 

Functions

int mutt_account_fromurl (struct ConnAccount *account, const struct Url *url)
 Fill ConnAccount with information from url.
 
void mutt_account_tourl (struct ConnAccount *account, struct Url *url)
 Fill URL with info from account.
 

Detailed Description

ConnAccount object used by POP and IMAP.

Authors
  • Richard Russon
  • Pietro Cerutti

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_account.h.

Enumeration Type Documentation

◆ AccountType

Account types.

Enumerator
MUTT_ACCT_TYPE_NONE 

Account type is unknown.

MUTT_ACCT_TYPE_IMAP 

Imap Account.

MUTT_ACCT_TYPE_POP 

Pop Account.

MUTT_ACCT_TYPE_SMTP 

Smtp Account.

MUTT_ACCT_TYPE_NNTP 

Nntp (Usenet) Account.

MUTT_ACCT_TYPE_MAX 

Definition at line 35 of file mutt_account.h.

36{
43};
@ MUTT_ACCT_TYPE_SMTP
Smtp Account.
Definition: mutt_account.h:40
@ MUTT_ACCT_TYPE_POP
Pop Account.
Definition: mutt_account.h:39
@ MUTT_ACCT_TYPE_NNTP
Nntp (Usenet) Account.
Definition: mutt_account.h:41
@ MUTT_ACCT_TYPE_IMAP
Imap Account.
Definition: mutt_account.h:38
@ MUTT_ACCT_TYPE_NONE
Account type is unknown.
Definition: mutt_account.h:37
@ MUTT_ACCT_TYPE_MAX
Definition: mutt_account.h:42

Function Documentation

◆ mutt_account_fromurl()

int mutt_account_fromurl ( struct ConnAccount cac,
const struct Url url 
)

Fill ConnAccount with information from url.

Parameters
cacConnAccount to fill
urlUrl to parse
Return values
0Success
-1Error

Definition at line 44 of file mutt_account.c.

45{
46 /* must be present */
47 if (url->host)
48 mutt_str_copy(cac->host, url->host, sizeof(cac->host));
49 else
50 return -1;
51
52 if (url->user)
53 {
54 mutt_str_copy(cac->user, url->user, sizeof(cac->user));
55 cac->flags |= MUTT_ACCT_USER;
56 }
57 if (url->pass)
58 {
59 mutt_str_copy(cac->pass, url->pass, sizeof(cac->pass));
60 cac->flags |= MUTT_ACCT_PASS;
61 }
62 if (url->port)
63 {
64 cac->port = url->port;
65 cac->flags |= MUTT_ACCT_PORT;
66 }
67
68 return 0;
69}
#define MUTT_ACCT_PASS
Password field has been set.
Definition: connaccount.h:46
#define MUTT_ACCT_USER
User field has been set.
Definition: connaccount.h:44
#define MUTT_ACCT_PORT
Port field has been set.
Definition: connaccount.h:43
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:581
char user[128]
Username.
Definition: connaccount.h:56
char pass[256]
Password.
Definition: connaccount.h:57
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
unsigned short port
Port to connect to.
Definition: connaccount.h:58
char * user
Username.
Definition: url.h:71
unsigned short port
Port.
Definition: url.h:74
char * host
Host.
Definition: url.h:73
char * pass
Password.
Definition: url.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_account_tourl()

void mutt_account_tourl ( struct ConnAccount cac,
struct Url url 
)

Fill URL with info from account.

Parameters
cacSource ConnAccount
urlUrl to fill

The URL information is a set of pointers into cac. Don't free or edit cac until you've finished with url (make a copy of cac if you need it for a while).

Definition at line 80 of file mutt_account.c.

81{
82 url->scheme = U_UNKNOWN;
83 url->user = NULL;
84 url->pass = NULL;
85 url->port = 0;
86 url->path = NULL;
87
88 if (cac->type == MUTT_ACCT_TYPE_IMAP)
89 {
90 if (cac->flags & MUTT_ACCT_SSL)
91 url->scheme = U_IMAPS;
92 else
93 url->scheme = U_IMAP;
94 }
95
96 if (cac->type == MUTT_ACCT_TYPE_POP)
97 {
98 if (cac->flags & MUTT_ACCT_SSL)
99 url->scheme = U_POPS;
100 else
101 url->scheme = U_POP;
102 }
103
104 if (cac->type == MUTT_ACCT_TYPE_SMTP)
105 {
106 if (cac->flags & MUTT_ACCT_SSL)
107 url->scheme = U_SMTPS;
108 else
109 url->scheme = U_SMTP;
110 }
111
112 if (cac->type == MUTT_ACCT_TYPE_NNTP)
113 {
114 if (cac->flags & MUTT_ACCT_SSL)
115 url->scheme = U_NNTPS;
116 else
117 url->scheme = U_NNTP;
118 }
119
120 url->host = cac->host;
121 if (cac->flags & MUTT_ACCT_PORT)
122 url->port = cac->port;
123 if (cac->flags & MUTT_ACCT_USER)
124 url->user = cac->user;
125 if (cac->flags & MUTT_ACCT_PASS)
126 url->pass = cac->pass;
127}
#define MUTT_ACCT_SSL
Account uses SSL/TLS.
Definition: connaccount.h:47
unsigned char type
Connection type, e.g. MUTT_ACCT_TYPE_IMAP.
Definition: connaccount.h:59
char * path
Path.
Definition: url.h:75
enum UrlScheme scheme
Scheme, e.g. U_SMTPS.
Definition: url.h:70
@ U_UNKNOWN
Url wasn't recognised.
Definition: url.h:35
@ U_NNTPS
Url is nntps://.
Definition: url.h:42
@ U_SMTPS
Url is smtps://.
Definition: url.h:44
@ U_SMTP
Url is smtp://.
Definition: url.h:43
@ U_NNTP
Url is nntp://.
Definition: url.h:41
@ U_IMAP
Url is imap://.
Definition: url.h:39
@ U_POPS
Url is pops://.
Definition: url.h:38
@ U_IMAPS
Url is imaps://.
Definition: url.h:40
@ U_POP
Url is pop://.
Definition: url.h:37
+ Here is the caller graph for this function: