NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
mutt_account.h File Reference
+ 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
}
 account types More...
 

Functions

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

Detailed Description

ConnAccount object used by POP and IMAP

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_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.

Definition at line 34 of file mutt_account.h.

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 43 of file mutt_account.c.

44 {
45  /* must be present */
46  if (url->host)
47  mutt_str_copy(cac->host, url->host, sizeof(cac->host));
48  else
49  return -1;
50 
51  if (url->user)
52  {
53  mutt_str_copy(cac->user, url->user, sizeof(cac->user));
54  cac->flags |= MUTT_ACCT_USER;
55  }
56  if (url->pass)
57  {
58  mutt_str_copy(cac->pass, url->pass, sizeof(cac->pass));
59  cac->flags |= MUTT_ACCT_PASS;
60  }
61  if (url->port)
62  {
63  cac->port = url->port;
64  cac->flags |= MUTT_ACCT_PORT;
65  }
66 
67  return 0;
68 }
+ 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 79 of file mutt_account.c.

80 {
81  url->scheme = U_UNKNOWN;
82  url->user = NULL;
83  url->pass = NULL;
84  url->port = 0;
85  url->path = NULL;
86 
87 #ifdef USE_IMAP
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 #endif
96 
97 #ifdef USE_POP
98  if (cac->type == MUTT_ACCT_TYPE_POP)
99  {
100  if (cac->flags & MUTT_ACCT_SSL)
101  url->scheme = U_POPS;
102  else
103  url->scheme = U_POP;
104  }
105 #endif
106 
107 #ifdef USE_SMTP
108  if (cac->type == MUTT_ACCT_TYPE_SMTP)
109  {
110  if (cac->flags & MUTT_ACCT_SSL)
111  url->scheme = U_SMTPS;
112  else
113  url->scheme = U_SMTP;
114  }
115 #endif
116 
117 #ifdef USE_NNTP
118  if (cac->type == MUTT_ACCT_TYPE_NNTP)
119  {
120  if (cac->flags & MUTT_ACCT_SSL)
121  url->scheme = U_NNTPS;
122  else
123  url->scheme = U_NNTP;
124  }
125 #endif
126 
127  url->host = cac->host;
128  if (cac->flags & MUTT_ACCT_PORT)
129  url->port = cac->port;
130  if (cac->flags & MUTT_ACCT_USER)
131  url->user = cac->user;
132  if (cac->flags & MUTT_ACCT_PASS)
133  url->pass = cac->pass;
134 }
+ Here is the caller graph for this function:
ConnAccount::host
char host[128]
Server to login to.
Definition: connaccount.h:53
U_IMAP
@ U_IMAP
Url is imap://.
Definition: url.h:38
MUTT_ACCT_TYPE_SMTP
@ MUTT_ACCT_TYPE_SMTP
Smtp Account.
Definition: mutt_account.h:39
U_NNTPS
@ U_NNTPS
Url is nntps://.
Definition: url.h:41
MUTT_ACCT_PORT
#define MUTT_ACCT_PORT
Port field has been set.
Definition: connaccount.h:42
U_UNKNOWN
@ U_UNKNOWN
Url wasn't recognised.
Definition: url.h:34
Url::scheme
enum UrlScheme scheme
Scheme, e.g. U_SMTPS.
Definition: url.h:69
Url::pass
char * pass
Password.
Definition: url.h:71
U_SMTPS
@ U_SMTPS
Url is smtps://.
Definition: url.h:43
MUTT_ACCT_TYPE_IMAP
@ MUTT_ACCT_TYPE_IMAP
Imap Account.
Definition: mutt_account.h:37
MUTT_ACCT_TYPE_POP
@ MUTT_ACCT_TYPE_POP
Pop Account.
Definition: mutt_account.h:38
U_IMAPS
@ U_IMAPS
Url is imaps://.
Definition: url.h:39
U_SMTP
@ U_SMTP
Url is smtp://.
Definition: url.h:42
ConnAccount::type
unsigned char type
Connection type, e.g. MUTT_ACCT_TYPE_IMAP.
Definition: connaccount.h:58
Url::port
unsigned short port
Port.
Definition: url.h:73
Url::user
char * user
Username.
Definition: url.h:70
MUTT_ACCT_USER
#define MUTT_ACCT_USER
User field has been set.
Definition: connaccount.h:43
ConnAccount::flags
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:59
MUTT_ACCT_TYPE_NONE
@ MUTT_ACCT_TYPE_NONE
Account type is unknown.
Definition: mutt_account.h:36
MUTT_ACCT_SSL
#define MUTT_ACCT_SSL
Account uses SSL/TLS.
Definition: connaccount.h:46
U_POP
@ U_POP
Url is pop://.
Definition: url.h:36
ConnAccount::port
unsigned short port
Port to connect to.
Definition: connaccount.h:57
MUTT_ACCT_PASS
#define MUTT_ACCT_PASS
Password field has been set.
Definition: connaccount.h:45
U_POPS
@ U_POPS
Url is pops://.
Definition: url.h:37
U_NNTP
@ U_NNTP
Url is nntp://.
Definition: url.h:40
Url::host
char * host
Host.
Definition: url.h:72
ConnAccount::pass
char pass[256]
Password.
Definition: connaccount.h:56
MUTT_ACCT_TYPE_NNTP
@ MUTT_ACCT_TYPE_NNTP
Nntp (Usenet) Account.
Definition: mutt_account.h:40
Url::path
char * path
Path.
Definition: url.h:74
ConnAccount::user
char user[128]
Username.
Definition: connaccount.h:55
mutt_str_copy
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:716