/[imapfilter]/imapfilter/imapfilter.c
ViewVC logotype

Contents of /imapfilter/imapfilter.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (show annotations)
Mon Oct 8 08:52:49 2001 UTC (22 years, 5 months ago) by lefcha
Branch: MAIN
CVS Tags: release-0_6_2
Branch point for: release-0_6_2-patches
Changes since 1.14: +9 -9 lines
File MIME type: text/plain
Fixes and improvements on IMAP4rev1 compliance.

1 #include <stdio.h>
2 #include <unistd.h>
3 #include <string.h>
4 #include <limits.h>
5 #include <errno.h>
6
7 #include "config.h"
8 #include "imapfilter.h"
9 #include "data.h"
10
11
12 extern account_t *accounts;
13 extern filter_t *filters;
14
15 unsigned int options; /* Program options. */
16 char logfile[PATH_MAX]; /* Log file. */
17
18
19 /*
20 * In the beginning there was main()...
21 */
22 int main(int argc, char **argv)
23 {
24 int c;
25 char *confile = NULL; /* Configuration file. */
26 account_t *ca; /* Current account. */
27 mbox_t *cm; /* Current mailbox. */
28
29 options = OPTION_DETAILS_NORMAL;
30 *logfile = 0;
31
32 while ((c = getopt(argc, argv, "c:hl:qv")) != -1) {
33 switch (c) {
34 case 'c':
35 confile = optarg;
36 break;
37 case 'h':
38 usage();
39 exit(ERROR_UNDEFINED);
40 break;
41 case 'l':
42 strncat(logfile, optarg, PATH_MAX - 1);
43 break;
44 case 'q':
45 options &= OPTION_DETAILS_CLEAR;
46 options |= OPTION_DETAILS_QUIET;
47 break;
48 case 'v':
49 options &= OPTION_DETAILS_CLEAR;
50 options |= OPTION_DETAILS_VERBOSE;
51 break;
52 default:
53 usage();
54 exit(ERROR_UNDEFINED);
55 break;
56 }
57 }
58
59 read_config(confile);
60 open_logfile();
61
62 for (ca = accounts; ca; ca = ca->next) {
63
64 if (init_connection(ca->server, ca->port)) {
65 close_logfile();
66 exit(ERROR_NETWORK);
67 }
68 if (greeting_response() || check_capabilities())
69 continue;
70
71 #ifdef DEBUG
72 test();
73 #endif
74
75 if (login(ca->username, ca->password))
76 continue;
77
78 for (cm = ca->mboxes; cm; cm = cm->next)
79 if (!*cm->filters)
80 mailbox_status(cm->name);
81 else if (!select_mailbox(cm->name)) {
82 apply_filters(cm->filters);
83 close_mailbox();
84 }
85 logout();
86
87 close_connection();
88 }
89
90 close_logfile();
91
92 exit(0);
93 }
94
95
96 /*
97 * Print a very brief usage message.
98 */
99 void usage(void)
100 {
101 fprintf(stderr,
102 "usage: imapfilter [-hqv] [-c configfile] [-l logfile]\n");
103 }

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26