31 |
{ |
{ |
32 |
node->next = NULL; |
node->next = NULL; |
33 |
node->server[0] = node->username[0] = node->password[0] = 0; |
node->server[0] = node->username[0] = node->password[0] = 0; |
34 |
|
node->nopassword = 0; |
35 |
node->port = 143; |
node->port = 143; |
36 |
#ifdef SSL_TLS |
#ifdef SSL_TLS |
37 |
node->ssl = SSL_DISABLED; |
node->ssl = SSL_DISABLED; |
65 |
node = (account_t *) create_node(sizeof(account_t)); |
node = (account_t *) create_node(sizeof(account_t)); |
66 |
|
|
67 |
init_account(node); |
init_account(node); |
68 |
|
|
69 |
strncat(node->username, line + match[1].rm_so, |
if (match[2].rm_so != -1) { |
70 |
min(match[1].rm_eo - match[1].rm_so, USERNAME_LEN - 1)); |
strncat(node->username, line + match[2].rm_so, |
71 |
|
min(match[2].rm_eo - match[2].rm_so, USERNAME_LEN - 1)); |
72 |
|
} else { |
73 |
|
strncat(node->username, line + match[4].rm_so, |
74 |
|
min(match[4].rm_eo - match[4].rm_so, USERNAME_LEN - 1)); |
75 |
|
} |
76 |
if (strchr(node->username, '%')) |
if (strchr(node->username, '%')) |
77 |
if (string_decode(node->username)) |
if (string_decode(node->username)) |
78 |
return ERROR_CONFIG_PARSE; |
return ERROR_CONFIG_PARSE; |
79 |
#ifdef DEBUG |
#ifdef DEBUG |
80 |
printf("debug: USERNAME: '%s'\n", node->username); |
printf("debug: USERNAME: '%s'\n", node->username); |
81 |
#endif |
#endif |
82 |
|
|
83 |
strncat(node->password, line + match[2].rm_so, |
if (match[3].rm_so != -1) { |
84 |
min(match[2].rm_eo - match[2].rm_so, PASSWORD_LEN - 1)); |
strncat(node->password, line + match[3].rm_so, |
85 |
if (strchr(node->password, '%')) |
min(match[3].rm_eo - match[3].rm_so, PASSWORD_LEN - 1)); |
86 |
if (string_decode(node->password)) |
if (strchr(node->password, '%')) |
87 |
return ERROR_CONFIG_PARSE; |
if (string_decode(node->password)) |
88 |
|
return ERROR_CONFIG_PARSE; |
89 |
|
} else |
90 |
|
node->nopassword = 1; |
91 |
#ifdef DEBUG |
#ifdef DEBUG |
92 |
printf("debug: PASSWORD: '%s'\n", node->password); |
printf("debug: PASSWORD: '%s'\n", node->password); |
93 |
#endif |
#endif |
94 |
|
|
95 |
strncat(node->server, line + match[3].rm_so, |
strncat(node->server, line + match[5].rm_so, |
96 |
min(match[3].rm_eo - match[3].rm_so, SERVER_LEN - 1)); |
min(match[5].rm_eo - match[5].rm_so, SERVER_LEN - 1)); |
97 |
#ifdef DEBUG |
#ifdef DEBUG |
98 |
printf("debug: SERVER: '%s'\n", node->server); |
printf("debug: SERVER: '%s'\n", node->server); |
99 |
#endif |
#endif |
100 |
|
|
101 |
if (match[4].rm_so != -1) { |
if (match[6].rm_so != -1) { |
102 |
n = min(match[4].rm_eo - match[4].rm_so - 1, 5); |
n = min(match[6].rm_eo - match[6].rm_so - 1, 5); |
103 |
xstrncpy(p, line + match[4].rm_so + 1, n); |
xstrncpy(p, line + match[6].rm_so + 1, n); |
104 |
p[n] = 0; |
p[n] = 0; |
105 |
node->port = strtoul(p, NULL, 10); |
node->port = strtoul(p, NULL, 10); |
106 |
#ifdef DEBUG |
#ifdef DEBUG |
108 |
#endif |
#endif |
109 |
} |
} |
110 |
#ifdef SSL_TLS |
#ifdef SSL_TLS |
111 |
if (match[5].rm_so != -1) { |
if (match[7].rm_so != -1) { |
112 |
if (match[4].rm_so == -1) |
if (match[6].rm_so == -1) |
113 |
node->port = 993; |
node->port = 993; |
114 |
|
|
115 |
if (strcasestr(line + match[5].rm_so, "ssl3")) |
if (strcasestr(line + match[7].rm_so, "ssl3")) |
116 |
node->ssl = SSL_SSL_V3; |
node->ssl = SSL_SSL_V3; |
117 |
else if (strcasestr(line + match[5].rm_so, "tls1")) |
else if (strcasestr(line + match[7].rm_so, "tls1")) |
118 |
node->ssl = SSL_TLS_V1; |
node->ssl = SSL_TLS_V1; |
119 |
else |
else |
120 |
node->ssl = SSL_SSL_V2; |
node->ssl = SSL_SSL_V2; |
678 |
|
|
679 |
return 0; |
return 0; |
680 |
} |
} |
681 |
|
|
682 |
|
|
683 |
|
/* |
684 |
|
* Convert the names of personal mailboxes using the namespace specified |
685 |
|
* by the mail server. |
686 |
|
*/ |
687 |
|
char *apply_namespace(char *mbox, char *prefix, char delim) |
688 |
|
{ |
689 |
|
static char m[MBOX_NAME_LEN]; |
690 |
|
char *c; |
691 |
|
|
692 |
|
if ((!prefix[0] && !delim) || (!prefix[0] && delim == '/') |
693 |
|
|| !strcasecmp(mbox, "INBOX")) |
694 |
|
return mbox; |
695 |
|
|
696 |
|
m[0] = 0; |
697 |
|
strncat(m, prefix, MBOX_NAME_LEN - 1); |
698 |
|
strncat(m, mbox, MBOX_NAME_LEN - strlen(m) - 1); |
699 |
|
|
700 |
|
c = m; |
701 |
|
while ((c = strchr(c, '/'))) |
702 |
|
*(c++) = delim; |
703 |
|
|
704 |
|
#ifdef DEBUG |
705 |
|
printf("debug: MAILBOX: '%s'\n", m); |
706 |
|
#endif |
707 |
|
|
708 |
|
return m; |
709 |
|
} |