Commit b7e4dfdb b7e4dfdb3484d4ccb8c45e5d9fa37869bc735500 by Sergey Poznyakoff

Implemented retain/ignore. It is more convenient

to keep them in one module so they can share static data.
1 parent e75418cb
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
17 17
18 #include "mail.h" 18 #include "mail.h"
19 19
20 static list_t retained_headers = NULL;
21 static list_t ignored_headers = NULL;
22
20 /* 23 /*
21 * ret[ain] [heder-field...] 24 * ret[ain] [heder-field...]
22 */ 25 */
...@@ -24,7 +27,48 @@ ...@@ -24,7 +27,48 @@
24 int 27 int
25 mail_retain (int argc, char **argv) 28 mail_retain (int argc, char **argv)
26 { 29 {
27 fprintf (ofile, "Function not implemented in %s line %d\n", 30 if (argc == 1)
28 __FILE__, __LINE__); 31 {
29 return 1; 32 if (!retained_headers)
33 fprintf (ofile, "No fields are currently being retained\n");
34 else
35 util_slist_print (retained_headers, 1);
36 return 0;
37 }
38
39 while (--argc)
40 util_slist_add (&retained_headers, *++argv);
41 return 0;
42 }
43
44 /*
45 * di[scard] [header-field...]
46 * ig[nore] [header-field...]
47 */
48
49 int
50 mail_discard (int argc, char **argv)
51 {
52 if (argc == 1)
53 {
54 if (!ignored_headers)
55 fprintf (ofile, "No fields are currently being ignored\n");
56 else
57 util_slist_print (ignored_headers, 1);
58 return 0;
59 }
60
61 while (--argc)
62 util_slist_add (&ignored_headers, *++argv);
63 return 0;
64 }
65
66
67 int
68 mail_header_is_visible (char *str)
69 {
70 if (retained_headers)
71 return util_slist_lookup (retained_headers, str);
72 else
73 return !util_slist_lookup (ignored_headers, str);
30 } 74 }
......