15 |
extern account_data account; |
extern account_data account; |
16 |
|
|
17 |
|
|
18 |
|
/* |
19 |
|
* In the begining there was main()... |
20 |
|
*/ |
21 |
int main(int argc, char **argv) |
int main(int argc, char **argv) |
22 |
{ |
{ |
23 |
char *config = NULL; /* Configuration file. */ |
char *config = NULL; /* Configuration file. */ |
26 |
options = OPTION_DETAILS_NORMAL; |
options = OPTION_DETAILS_NORMAL; |
27 |
account.logfile[0] = 0; |
account.logfile[0] = 0; |
28 |
|
|
29 |
while ((c = getopt(argc, argv, "l:qtvc:L")) != -1) { |
while ((c = getopt(argc, argv, "hl:qtvc:L")) != -1) { |
30 |
switch (c) { |
switch (c) { |
31 |
|
case 'h': |
32 |
|
usage(); |
33 |
|
exit(1); |
34 |
|
break; |
35 |
case 'l': |
case 'l': |
36 |
strncpy(account.logfile, optarg, FILENAME_MAX); |
strncpy(account.logfile, optarg, FILENAME_MAX); |
37 |
break; |
break; |
53 |
options |= OPTION_LOGGING_DISABLED; |
options |= OPTION_LOGGING_DISABLED; |
54 |
break; |
break; |
55 |
default: |
default: |
56 |
fprintf(stderr, |
usage(); |
|
"usage: imapfilter [-hqtvL] [-c configfile] [-l logfile]\n"); |
|
57 |
exit(1); |
exit(1); |
58 |
break; |
break; |
59 |
} |
} |
60 |
} |
} |
61 |
|
|
62 |
if (read_config(config) || open_logfile()) |
if (read_config(config) || open_logfile()) |
63 |
exit(1); |
exit(2); |
64 |
|
|
65 |
if (establish_connection()) { |
if (establish_connection()) { |
66 |
close_logfile(); |
close_logfile(); |
67 |
exit(2); |
exit(3); |
68 |
} |
} |
69 |
|
|
70 |
clear_stream(); |
clear_stream(); |
104 |
imap_expunge(); |
imap_expunge(); |
105 |
} |
} |
106 |
} |
} |
107 |
|
|
108 |
|
|
109 |
|
/* |
110 |
|
* Prints a summary of prorgam's options. |
111 |
|
*/ |
112 |
|
void usage(void) |
113 |
|
{ |
114 |
|
fprintf(stderr, |
115 |
|
"usage: imapfilter [-hqtvL] [-c configfile] [-l logfile]\n"); |
116 |
|
} |