Use mh_annotate
Showing
1 changed file
with
4 additions
and
22 deletions
... | @@ -50,9 +50,8 @@ struct mh_option mh_option[] = { | ... | @@ -50,9 +50,8 @@ struct mh_option mh_option[] = { |
50 | { NULL } | 50 | { NULL } |
51 | }; | 51 | }; |
52 | 52 | ||
53 | static char datebuf[80]; | ||
54 | static int inplace; /* Annotate the message in place */ | 53 | static int inplace; /* Annotate the message in place */ |
55 | static char *anno_date; /* Annotation date */ | 54 | static int anno_date = 1; /* Add date to the annotation */ |
56 | static char *component; /* header field */ | 55 | static char *component; /* header field */ |
57 | static char *anno_text; /* header field value */ | 56 | static char *anno_text; /* header field value */ |
58 | 57 | ||
... | @@ -75,11 +74,11 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -75,11 +74,11 @@ opt_handler (int key, char *arg, void *unused) |
75 | break; | 74 | break; |
76 | 75 | ||
77 | case ARG_DATE: | 76 | case ARG_DATE: |
78 | anno_date = datebuf; | 77 | anno_date = is_true (arg); |
79 | break; | 78 | break; |
80 | 79 | ||
81 | case ARG_NODATE: | 80 | case ARG_NODATE: |
82 | anno_date = NULL; | 81 | anno_date = 0; |
83 | break; | 82 | break; |
84 | 83 | ||
85 | case ARG_COMPONENT: | 84 | case ARG_COMPONENT: |
... | @@ -99,18 +98,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -99,18 +98,7 @@ opt_handler (int key, char *arg, void *unused) |
99 | void | 98 | void |
100 | anno (mailbox_t mbox, message_t msg, size_t num, void *data) | 99 | anno (mailbox_t mbox, message_t msg, size_t num, void *data) |
101 | { | 100 | { |
102 | header_t hdr; | 101 | mh_annotate (msg, component, anno_text, anno_date); |
103 | attribute_t attr; | ||
104 | |||
105 | if (message_get_header (msg, &hdr)) | ||
106 | return; | ||
107 | |||
108 | if (anno_date) | ||
109 | header_set_value (hdr, component, anno_date, 0); | ||
110 | header_set_value (hdr, component, anno_text, 0); | ||
111 | |||
112 | message_get_attribute (msg, &attr); | ||
113 | attribute_set_modified (attr); | ||
114 | } | 102 | } |
115 | 103 | ||
116 | int | 104 | int |
... | @@ -120,15 +108,9 @@ main (int argc, char **argv) | ... | @@ -120,15 +108,9 @@ main (int argc, char **argv) |
120 | int index; | 108 | int index; |
121 | mailbox_t mbox; | 109 | mailbox_t mbox; |
122 | mh_msgset_t msgset; | 110 | mh_msgset_t msgset; |
123 | time_t t; | ||
124 | struct tm *tm; | ||
125 | 111 | ||
126 | mu_init_nls (); | 112 | mu_init_nls (); |
127 | 113 | ||
128 | t = time (NULL); | ||
129 | tm = localtime (&t); | ||
130 | strftime (datebuf, sizeof datebuf, "%a, %d %b %Y %H:%M:%S %Z", tm); | ||
131 | |||
132 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 114 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, |
133 | opt_handler, NULL, &index); | 115 | opt_handler, NULL, &index); |
134 | 116 | ... | ... |
-
Please register or sign in to post a comment