Rewritten.
(mail_nounfold,mail_unfold) (mail_header_is_unfoldable): New functions.
Showing
1 changed file
with
54 additions
and
21 deletions
... | @@ -19,29 +19,41 @@ | ... | @@ -19,29 +19,41 @@ |
19 | 19 | ||
20 | static list_t retained_headers = NULL; | 20 | static list_t retained_headers = NULL; |
21 | static list_t ignored_headers = NULL; | 21 | static list_t ignored_headers = NULL; |
22 | static list_t unfolded_headers = NULL; | ||
22 | 23 | ||
23 | /* | 24 | static int |
24 | * ret[ain] [heder-field...] | 25 | process_list (int argc, char **argv, |
25 | */ | 26 | list_t *list, |
26 | 27 | void (*fun) (list_t *, char *), | |
27 | int | 28 | char *msg) |
28 | mail_retain (int argc, char **argv) | ||
29 | { | 29 | { |
30 | if (argc == 1) | 30 | if (argc == 1) |
31 | { | 31 | { |
32 | if (!retained_headers) | 32 | if (list_is_empty (*list)) |
33 | fprintf (ofile, _("No fields are currently being retained\n")); | 33 | fprintf (ofile, _(msg)); |
34 | else | 34 | else |
35 | util_slist_print (retained_headers, 1); | 35 | util_slist_print (*list, 1); |
36 | return 0; | 36 | return 0; |
37 | } | 37 | } |
38 | 38 | ||
39 | while (--argc) | 39 | while (--argc) |
40 | util_slist_add (&retained_headers, *++argv); | 40 | fun (list, *++argv); |
41 | return 0; | 41 | return 0; |
42 | } | 42 | } |
43 | 43 | ||
44 | /* | 44 | /* |
45 | * ret[ain] [heder-field...] | ||
46 | */ | ||
47 | |||
48 | int | ||
49 | mail_retain (int argc, char **argv) | ||
50 | { | ||
51 | return process_list (argc, argv, &retained_headers, | ||
52 | util_slist_add, | ||
53 | N_("No fields are currently being retained\n")); | ||
54 | } | ||
55 | |||
56 | /* | ||
45 | * di[scard] [header-field...] | 57 | * di[scard] [header-field...] |
46 | * ig[nore] [header-field...] | 58 | * ig[nore] [header-field...] |
47 | */ | 59 | */ |
... | @@ -49,20 +61,41 @@ mail_retain (int argc, char **argv) | ... | @@ -49,20 +61,41 @@ mail_retain (int argc, char **argv) |
49 | int | 61 | int |
50 | mail_discard (int argc, char **argv) | 62 | mail_discard (int argc, char **argv) |
51 | { | 63 | { |
52 | if (argc == 1) | 64 | return process_list (argc, argv, &ignored_headers, |
53 | { | 65 | util_slist_add, |
54 | if (!ignored_headers) | 66 | N_("No fields are currently being ignored\n")); |
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; | 67 | return 0; |
64 | } | 68 | } |
65 | 69 | ||
70 | /* | ||
71 | * unfold [header-field...] | ||
72 | */ | ||
73 | |||
74 | int | ||
75 | mail_unfold (int argc, char **argv) | ||
76 | { | ||
77 | return process_list (argc, argv, &unfolded_headers, | ||
78 | util_slist_add, | ||
79 | N_("No fields are currently being unfolded\n")); | ||
80 | } | ||
81 | |||
82 | /* | ||
83 | * nounfold [header-field...] | ||
84 | */ | ||
85 | |||
86 | int | ||
87 | mail_nounfold (int argc, char **argv) | ||
88 | { | ||
89 | return process_list (argc, argv, &unfolded_headers, | ||
90 | util_slist_remove, | ||
91 | N_("No fields are currently being unfolded\n")); | ||
92 | } | ||
93 | |||
94 | int | ||
95 | mail_header_is_unfoldable (char *str) | ||
96 | { | ||
97 | return util_slist_lookup (unfolded_headers, str); | ||
98 | } | ||
66 | 99 | ||
67 | int | 100 | int |
68 | mail_header_is_visible (char *str) | 101 | mail_header_is_visible (char *str) | ... | ... |
-
Please register or sign in to post a comment