1 |
#include <stdio.h> |
#include <stdio.h> |
2 |
|
#include <stdlib.h> |
3 |
#include <string.h> |
#include <string.h> |
4 |
#include <ctype.h> |
#include <ctype.h> |
5 |
#include <limits.h> |
#include <limits.h> |
6 |
|
#include <sys/types.h> /* IEEE Std 1003.1-2001 non-conformance. */ |
7 |
|
#include <regex.h> |
8 |
|
|
9 |
#include "config.h" |
#include "config.h" |
10 |
#include "imapfilter.h" |
#include "imapfilter.h" |
12 |
#include "struct.h" |
#include "struct.h" |
13 |
|
|
14 |
|
|
15 |
|
extern opts_t opts; |
16 |
extern unsigned int flags; |
extern unsigned int flags; |
17 |
|
|
18 |
account_t *accounts = NULL; /* First node of accounts linked list. */ |
account_t *accounts = NULL; /* First node of accounts linked list. */ |
67 |
strncat(node->key, line + m[1].rm_so, |
strncat(node->key, line + m[1].rm_so, |
68 |
min(m[1].rm_eo - m[1].rm_so, KEY_LEN - 1)); |
min(m[1].rm_eo - m[1].rm_so, KEY_LEN - 1)); |
69 |
|
|
70 |
#ifdef DEBUG |
debug("ACCOUNT: '%s'\n", node->key); |
|
fprintf(stderr, "debug: ACCOUNT: '%s'\n", node->key); |
|
|
#endif |
|
71 |
|
|
72 |
if (m[3].rm_so != -1) { |
if (m[3].rm_so != -1) { |
73 |
strncat(node->username, line + m[3].rm_so, |
strncat(node->username, line + m[3].rm_so, |
80 |
if (string_decode(node->username)) |
if (string_decode(node->username)) |
81 |
return ERROR_CONFIG_PARSE; |
return ERROR_CONFIG_PARSE; |
82 |
|
|
83 |
#ifdef DEBUG |
debug("USERNAME: '%s'\n", node->username); |
|
fprintf(stderr, "debug: USERNAME: '%s'\n", node->username); |
|
|
#endif |
|
84 |
|
|
85 |
if (m[4].rm_so != -1) { |
if (m[4].rm_so != -1) { |
86 |
strncat(node->password, line + m[4].rm_so, |
strncat(node->password, line + m[4].rm_so, |
89 |
if (string_decode(node->password)) |
if (string_decode(node->password)) |
90 |
return ERROR_CONFIG_PARSE; |
return ERROR_CONFIG_PARSE; |
91 |
node->passwdattr = PASSWORD_PLAIN; |
node->passwdattr = PASSWORD_PLAIN; |
92 |
|
if (opts.debug == 1) |
93 |
|
debug("PASSWORD: *\n"); |
94 |
|
else |
95 |
|
debug("PASSWORD: '%s'\n", node->password); |
96 |
} else |
} else |
97 |
flags |= FLAG_BLANK_PASSWORD; |
flags |= FLAG_BLANK_PASSWORD; |
98 |
|
|
|
#ifdef DEBUG |
|
|
fprintf(stderr, "debug: PASSWORD: '%s'\n", node->password); |
|
|
#endif |
|
|
|
|
99 |
strncat(node->server, line + m[6].rm_so, |
strncat(node->server, line + m[6].rm_so, |
100 |
min(m[6].rm_eo - m[6].rm_so, SERVER_LEN - 1)); |
min(m[6].rm_eo - m[6].rm_so, SERVER_LEN - 1)); |
101 |
|
|
102 |
#ifdef DEBUG |
debug("SERVER: '%s'\n", node->server); |
|
fprintf(stderr, "debug: SERVER: '%s'\n", node->server); |
|
|
#endif |
|
103 |
|
|
104 |
if (m[7].rm_so != -1) { |
if (m[7].rm_so != -1) { |
105 |
n = min(m[7].rm_eo - m[7].rm_so - 1, 5); |
n = min(m[7].rm_eo - m[7].rm_so - 1, 5); |
106 |
xstrncpy(p, line + m[7].rm_so + 1, n); |
xstrncpy(p, line + m[7].rm_so + 1, n); |
107 |
p[n] = '\0'; |
p[n] = '\0'; |
108 |
node->port = strtoul(p, NULL, 10); |
node->port = strtoul(p, NULL, 10); |
109 |
#ifdef DEBUG |
debug("PORT: %d\n", node->port); |
|
fprintf(stderr, "debug: PORT: %d\n", node->port); |
|
|
#endif |
|
110 |
} |
} |
111 |
if (m[8].rm_so != -1) { |
if (m[8].rm_so != -1) { |
112 |
if (m[7].rm_so == -1) |
if (m[7].rm_so == -1) |
180 |
strncat(node->key, line + m[1].rm_so, |
strncat(node->key, line + m[1].rm_so, |
181 |
min(m[1].rm_eo - m[1].rm_so, KEY_LEN - 1)); |
min(m[1].rm_eo - m[1].rm_so, KEY_LEN - 1)); |
182 |
|
|
183 |
#ifdef DEBUG |
debug("FOLDER: '%s'\n", node->key); |
|
fprintf(stderr, "debug: FOLDER: '%s'\n", node->key); |
|
|
#endif |
|
184 |
|
|
185 |
strncat(mboxs, line + m[2].rm_so, |
strncat(mboxs, line + m[2].rm_so, |
186 |
min(m[2].rm_eo - m[2].rm_so, LINE_MAX - 1)); |
min(m[2].rm_eo - m[2].rm_so, LINE_MAX - 1)); |
253 |
|
|
254 |
strncat(node->name, s, MBOX_NAME_LEN - 1); |
strncat(node->name, s, MBOX_NAME_LEN - 1); |
255 |
|
|
256 |
#ifdef DEBUG |
debug("MBOX: '%s'\n", node->name); |
|
fprintf(stderr, "debug: MBOX: '%s'\n", node->name); |
|
|
#endif |
|
257 |
|
|
258 |
APPEND_LINKED_LIST(cur_acct->mboxes, node, mbox); |
APPEND_LINKED_LIST(cur_acct->mboxes, node, mbox); |
259 |
|
|
321 |
while ((c = strchr(c, '/'))) |
while ((c = strchr(c, '/'))) |
322 |
*(c++) = delim; |
*(c++) = delim; |
323 |
|
|
324 |
#ifdef DEBUG |
debug("MAILBOX: '%s'\n", m); |
|
fprintf(stderr, "debug: MAILBOX: '%s'\n", m); |
|
|
#endif |
|
325 |
|
|
326 |
return m; |
return m; |
327 |
} |
} |