from.c
support for headers.
Showing
1 changed file
with
17 additions
and
7 deletions
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * | 19 | * |
20 | * Created as an example of using libmailbox | 20 | * Created as an example for using mailutils API |
21 | * Sean 'Shaleh' Perry <shaleh@debian.org>, 1999 | 21 | * Sean 'Shaleh' Perry <shaleh@debian.org>, 1999 |
22 | * Alain Magloire alainm@gnu.org | 22 | * Alain Magloire alainm@gnu.org |
23 | * | 23 | * |
... | @@ -27,7 +27,6 @@ | ... | @@ -27,7 +27,6 @@ |
27 | # include <config.h> | 27 | # include <config.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <mailbox.h> | ||
31 | #include <sys/types.h> | 30 | #include <sys/types.h> |
32 | #include <stdio.h> | 31 | #include <stdio.h> |
33 | #include <stdlib.h> | 32 | #include <stdlib.h> |
... | @@ -38,12 +37,17 @@ | ... | @@ -38,12 +37,17 @@ |
38 | # include <paths.h> | 37 | # include <paths.h> |
39 | #endif | 38 | #endif |
40 | 39 | ||
40 | #include <paths.h> | ||
41 | |||
42 | #include <mailbox.h> | ||
43 | #include <header.h> | ||
44 | |||
41 | #ifndef _PATH_MAILDIR | 45 | #ifndef _PATH_MAILDIR |
42 | # define _PATH_MAILDIR "/var/spool/mail" | 46 | # define _PATH_MAILDIR "/var/spool/mail" |
43 | #endif | 47 | #endif |
44 | 48 | ||
45 | #ifndef VERSION | 49 | #ifndef VERSION |
46 | # define VERSION "unknown" | 50 | # define VERSION "unknow" |
47 | #endif | 51 | #endif |
48 | 52 | ||
49 | #include "getopt.h" | 53 | #include "getopt.h" |
... | @@ -136,6 +140,8 @@ main(int argc, char *argv[]) | ... | @@ -136,6 +140,8 @@ main(int argc, char *argv[]) |
136 | char *mailbox_name = NULL; | 140 | char *mailbox_name = NULL; |
137 | int opt; | 141 | int opt; |
138 | char buffer[BUFSIZ]; | 142 | char buffer[BUFSIZ]; |
143 | char from[BUFSIZ]; | ||
144 | char subject[BUFSIZ]; | ||
139 | 145 | ||
140 | /* set program name */ | 146 | /* set program name */ |
141 | program = argv[0]; | 147 | program = argv[0]; |
... | @@ -189,14 +195,14 @@ main(int argc, char *argv[]) | ... | @@ -189,14 +195,14 @@ main(int argc, char *argv[]) |
189 | exit (0); | 195 | exit (0); |
190 | break; | 196 | break; |
191 | default: | 197 | default: |
192 | usage (2); | 198 | //usage (2); |
193 | exit (1); | 199 | //exit (1); |
194 | break; | 200 | break; |
195 | } | 201 | } |
196 | } | 202 | } |
197 | 203 | ||
198 | /* have an argument */ | 204 | /* have an argument */ |
199 | if (optind > 0) | 205 | if (optind > argc) |
200 | { | 206 | { |
201 | mailbox_name = argv[optind]; | 207 | mailbox_name = argv[optind]; |
202 | /* is it a URL */ | 208 | /* is it a URL */ |
... | @@ -242,7 +248,11 @@ main(int argc, char *argv[]) | ... | @@ -242,7 +248,11 @@ main(int argc, char *argv[]) |
242 | fprintf (stderr, "header %s\n", strerror (rvalue)); | 248 | fprintf (stderr, "header %s\n", strerror (rvalue)); |
243 | exit(2); | 249 | exit(2); |
244 | } | 250 | } |
245 | printf("%s\n", buffer); | 251 | header_gvalue (buffer, size, MU_HDR_FROM, from, sizeof (from), NULL); |
252 | header_gvalue (buffer, size, MU_HDR_SUBJECT, subject, | ||
253 | sizeof (subject), NULL); | ||
254 | |||
255 | printf("%s %s\n", from, subject); | ||
246 | } | 256 | } |
247 | mailbox_close(mbox); | 257 | mailbox_close(mbox); |
248 | mailbox_destroy(&mbox); | 258 | mailbox_destroy(&mbox); | ... | ... |
-
Please register or sign in to post a comment