frm.c : support for --field
Showing
1 changed file
with
22 additions
and
3 deletions
... | @@ -38,6 +38,7 @@ static int counter; | ... | @@ -38,6 +38,7 @@ static int counter; |
38 | static struct option long_options[] = | 38 | static struct option long_options[] = |
39 | { | 39 | { |
40 | {"help", no_argument, 0, 'h'}, | 40 | {"help", no_argument, 0, 'h'}, |
41 | {"field", required_argument, 0, 'f'}, | ||
41 | {"to", no_argument, 0, 'l'}, | 42 | {"to", no_argument, 0, 'l'}, |
42 | {"number", no_argument, 0, 'n'}, | 43 | {"number", no_argument, 0, 'n'}, |
43 | {"Quiet", no_argument, 0, 'Q'}, | 44 | {"Quiet", no_argument, 0, 'Q'}, |
... | @@ -49,8 +50,9 @@ static struct option long_options[] = | ... | @@ -49,8 +50,9 @@ static struct option long_options[] = |
49 | {0, 0, 0, 0} | 50 | {0, 0, 0, 0} |
50 | }; | 51 | }; |
51 | 52 | ||
52 | const char *short_options ="hlnQqSs:tv"; | 53 | const char *short_options ="hf:lnQqSs:tv"; |
53 | 54 | ||
55 | static char* show_field; | ||
54 | static int show_to; | 56 | static int show_to; |
55 | static int show_from = 1; | 57 | static int show_from = 1; |
56 | static int show_subject = 1; | 58 | static int show_subject = 1; |
... | @@ -108,7 +110,6 @@ action (observer_t o, size_t type) | ... | @@ -108,7 +110,6 @@ action (observer_t o, size_t type) |
108 | message_t msg = NULL; | 110 | message_t msg = NULL; |
109 | header_t hdr = NULL; | 111 | header_t hdr = NULL; |
110 | attribute_t attr = NULL; | 112 | attribute_t attr = NULL; |
111 | char hsubject[512]; | ||
112 | 113 | ||
113 | counter++; | 114 | counter++; |
114 | 115 | ||
... | @@ -145,6 +146,15 @@ action (observer_t o, size_t type) | ... | @@ -145,6 +146,15 @@ action (observer_t o, size_t type) |
145 | if (show_number) | 146 | if (show_number) |
146 | printf ("%d: ", counter); | 147 | printf ("%d: ", counter); |
147 | 148 | ||
149 | if (show_field) | ||
150 | { | ||
151 | char hfield[256]; | ||
152 | int status = header_get_value (hdr, show_field, hfield, | ||
153 | sizeof (hfield), NULL); | ||
154 | if (status == 0) | ||
155 | printf ("%s\n", hfield); | ||
156 | } | ||
157 | |||
148 | if (show_to) | 158 | if (show_to) |
149 | { | 159 | { |
150 | char hto[16]; | 160 | char hto[16]; |
... | @@ -171,6 +181,7 @@ action (observer_t o, size_t type) | ... | @@ -171,6 +181,7 @@ action (observer_t o, size_t type) |
171 | char hsubject[64]; | 181 | char hsubject[64]; |
172 | int status = header_get_value (hdr, MU_HEADER_SUBJECT, hsubject, | 182 | int status = header_get_value (hdr, MU_HEADER_SUBJECT, hsubject, |
173 | sizeof (hsubject), NULL); | 183 | sizeof (hsubject), NULL); |
184 | if(status == 0) | ||
174 | printf("%s\n", hsubject); | 185 | printf("%s\n", hsubject); |
175 | } | 186 | } |
176 | break; | 187 | break; |
... | @@ -189,8 +200,9 @@ usage (const char *argv) | ... | @@ -189,8 +200,9 @@ usage (const char *argv) |
189 | printf ("GNU Mailutils.\n"); | 200 | printf ("GNU Mailutils.\n"); |
190 | printf ("Usage: %s [OPTIONS]\n\n", argv); | 201 | printf ("Usage: %s [OPTIONS]\n\n", argv); |
191 | printf (" -h, --help display this help and exit\n"); | 202 | printf (" -h, --help display this help and exit\n"); |
203 | printf (" -f, --field=string header field to display\n"); | ||
192 | printf (" -l, --to include the To: information\n"); | 204 | printf (" -l, --to include the To: information\n"); |
193 | printf (" -n, --number display the message numberd\n"); | 205 | printf (" -n, --number display the message numbered\n"); |
194 | printf (" -Q, --Quiet very quiet\n"); | 206 | printf (" -Q, --Quiet very quiet\n"); |
195 | printf (" -q, --query print a message if unread mail\n"); | 207 | printf (" -q, --query print a message if unread mail\n"); |
196 | printf (" -S, --summary print a summary of messages\n"); | 208 | printf (" -S, --summary print a summary of messages\n"); |
... | @@ -227,6 +239,13 @@ main(int argc, char **argv) | ... | @@ -227,6 +239,13 @@ main(int argc, char **argv) |
227 | usage (argv[0]); | 239 | usage (argv[0]); |
228 | break; | 240 | break; |
229 | 241 | ||
242 | case 'f': | ||
243 | show_field = optarg; | ||
244 | show_from = 0; | ||
245 | show_subject = 0; | ||
246 | align = 0; | ||
247 | break; | ||
248 | |||
230 | case 'l': | 249 | case 'l': |
231 | show_to = 1; | 250 | show_to = 1; |
232 | break; | 251 | break; | ... | ... |
-
Please register or sign in to post a comment