NeoMutt  2020-09-25
Teaching an old dog new tricks
DOXYGEN
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
}
 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.

35 {
41 };
Account type is unknown.
Definition: mutt_account.h:36
Imap Account.
Definition: mutt_account.h:37
Nntp (Usenet) Account.
Definition: mutt_account.h:40
Pop Account.
Definition: mutt_account.h:38
Smtp Account.
Definition: mutt_account.h:39

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 }
char * pass
Password.
Definition: url.h:70
char user[128]
Username.
Definition: connaccount.h:55
#define MUTT_ACCT_USER
User field has been set.
Definition: connaccount.h:43
char host[128]
Server to login to.
Definition: connaccount.h:53
#define MUTT_ACCT_PASS
Password field has been set.
Definition: connaccount.h:45
char pass[256]
Password.
Definition: connaccount.h:56
unsigned short port
Port to connect to.
Definition: connaccount.h:57
#define MUTT_ACCT_PORT
Port field has been set.
Definition: connaccount.h:42
char * user
Username.
Definition: url.h:69
char * host
Host.
Definition: url.h:71
unsigned short port
Port.
Definition: url.h:72
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
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:59
+ 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 }
char * pass
Password.
Definition: url.h:70
enum UrlScheme scheme
Scheme, e.g. U_SMTPS.
Definition: url.h:68
Url is imaps://.
Definition: url.h:39
char user[128]
Username.
Definition: connaccount.h:55
Url wasn't recognised.
Definition: url.h:34
Url is imap://.
Definition: url.h:38
#define MUTT_ACCT_USER
User field has been set.
Definition: connaccount.h:43
char host[128]
Server to login to.
Definition: connaccount.h:53
#define MUTT_ACCT_PASS
Password field has been set.
Definition: connaccount.h:45
char pass[256]
Password.
Definition: connaccount.h:56
Url is nntps://.
Definition: url.h:41
unsigned short port
Port to connect to.
Definition: connaccount.h:57
#define MUTT_ACCT_PORT
Port field has been set.
Definition: connaccount.h:42
char * user
Username.
Definition: url.h:69
Url is smtps://.
Definition: url.h:43
unsigned char type
Connection type, e.g. MUTT_ACCT_TYPE_IMAP.
Definition: connaccount.h:58
char * host
Host.
Definition: url.h:71
Imap Account.
Definition: mutt_account.h:37
char * path
Path.
Definition: url.h:73
Nntp (Usenet) Account.
Definition: mutt_account.h:40
Pop Account.
Definition: mutt_account.h:38
Url is pop://.
Definition: url.h:36
unsigned short port
Port.
Definition: url.h:72
Url is nntp://.
Definition: url.h:40
Url is smtp://.
Definition: url.h:42
Smtp Account.
Definition: mutt_account.h:39
#define MUTT_ACCT_SSL
Account uses SSL/TLS.
Definition: connaccount.h:46
Url is pops://.
Definition: url.h:37
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:59
+ Here is the caller graph for this function: