Removed auto-generated file
Showing
1 changed file
with
59 additions
and
43 deletions
... | @@ -17,57 +17,73 @@ | ... | @@ -17,57 +17,73 @@ |
17 | 17 | ||
18 | #include <stdio.h> | 18 | #include <stdio.h> |
19 | #include <mailutils/mailcap.h> | 19 | #include <mailutils/mailcap.h> |
20 | #include <mailutils/stream.h> | ||
21 | #include <mailutils/error.h> | ||
20 | 22 | ||
21 | int main(int argc, char **argv) | 23 | int |
24 | main(int argc, char **argv) | ||
22 | @{ | 25 | @{ |
23 | stream_t stream = NULL; | 26 | stream_t stream = NULL; |
24 | int status = 0; | 27 | int status = 0; |
28 | char *file = argc == 1 ? "/etc/mailcap" : argv[1]; | ||
29 | mu_mailcap_t mailcap = NULL; | ||
30 | |||
31 | status = file_stream_create (&stream, file, MU_STREAM_READ); | ||
32 | if (status) | ||
33 | @{ | ||
34 | mu_error ("cannot create file stream %s: %s", | ||
35 | file, mu_strerror (status)); | ||
36 | exit (1); | ||
37 | @} | ||
25 | 38 | ||
26 | status = file_stream_create (&stream, "/etc/mailcap", MU_STREAM_READ); | 39 | status = stream_open (stream); |
27 | if (status == 0) | 40 | if (status) |
28 | @{ | 41 | @{ |
29 | status = stream_open (stream); | 42 | mu_error ("cannot open file stream %s: %s", |
30 | if (status == 0) | 43 | file, mu_strerror (status)); |
31 | @{ | 44 | exit (1); |
32 | mu_mailcap_t mailcap = NULL; | 45 | @} |
33 | status = mu_mailcap_create (&mailcap, stream); | ||
34 | if (status == 0) | ||
35 | @{ | ||
36 | int i; | ||
37 | size_t count = 0; | ||
38 | char buffer[256]; | ||
39 | 46 | ||
40 | mu_mailcap_entries_count (mailcap, &count); | 47 | status = mu_mailcap_create (&mailcap, stream); |
41 | for (i = 1; i <= count; i++) | 48 | if (status == 0) |
42 | @{ | 49 | @{ |
43 | int j; | 50 | int i; |
44 | mu_mailcap_entry_t entry = NULL; | 51 | size_t count = 0; |
45 | int fields_count = 0; | 52 | char buffer[256]; |
46 | 53 | ||
47 | printf ("entry[%d]\n", i); | 54 | mu_mailcap_entries_count (mailcap, &count); |
55 | for (i = 1; i <= count; i++) | ||
56 | @{ | ||
57 | int j; | ||
58 | mu_mailcap_entry_t entry = NULL; | ||
59 | int fields_count = 0; | ||
48 | 60 | ||
49 | mu_mailcap_get_entry (mailcap, i, &entry); | 61 | printf ("entry[%d]\n", i); |
50 | 62 | ||
51 | /* typefield. */ | 63 | mu_mailcap_get_entry (mailcap, i, &entry); |
52 | mu_mailcap_entry_get_typefield (entry, buffer, sizeof (buffer), NULL); | ||
53 | printf ("\ttypefield: %s\n", buffer); | ||
54 | 64 | ||
55 | /* view-command. */ | 65 | /* typefield. */ |
56 | mu_mailcap_entry_get_viewcommand (entry, buffer, sizeof (buffer), NULL); | 66 | mu_mailcap_entry_get_typefield (entry, buffer, |
57 | printf ("\tview-command: %s\n", buffer); | 67 | sizeof (buffer), NULL); |
68 | printf ("\ttypefield: %s\n", buffer); | ||
69 | |||
70 | /* view-command. */ | ||
71 | mu_mailcap_entry_get_viewcommand (entry, buffer, | ||
72 | sizeof (buffer), NULL); | ||
73 | printf ("\tview-command: %s\n", buffer); | ||
58 | 74 | ||
59 | /* fields. */ | 75 | /* fields. */ |
60 | mu_mailcap_entry_fields_count (entry, &fields_count); | 76 | mu_mailcap_entry_fields_count (entry, &fields_count); |
61 | for (j = 1; j <= fields_count; j++) | 77 | for (j = 1; j <= fields_count; j++) |
62 | @{ | 78 | @{ |
63 | mu_mailcap_entry_get_field (entry, j, buffer, sizeof (buffer), NULL); | 79 | mu_mailcap_entry_get_field (entry, j, buffer, |
64 | printf ("\tfields[%d]: %s\n", j, buffer); | 80 | sizeof (buffer), NULL); |
65 | @} | 81 | printf ("\tfields[%d]: %s\n", j, buffer); |
66 | printf ("\n"); | 82 | @} |
67 | @} | 83 | printf ("\n"); |
68 | mu_mailcap_destroy (&mailcap); | 84 | @} |
69 | @} | 85 | mu_mailcap_destroy (&mailcap); |
70 | @} | 86 | @} |
71 | @} | 87 | |
72 | return 0; | 88 | return 0; |
73 | @} | 89 | @} | ... | ... |
-
Please register or sign in to post a comment