Commit 9054dbcd 9054dbcd11958b6165a4731829e2270115c8d83c by Sergey Poznyakoff

Removed

1 parent 1c76c699
1 @comment GNU Mailutils -- a suite of utilities for electronic mail
2 @comment Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
3 @comment
4 @comment GNU Mailutils is free software; you can redistribute it and/or modify
5 @comment it under the terms of the GNU General Public License as published by
6 @comment the Free Software Foundation; either version 2, or (at your option)
7 @comment any later version.
8 @comment
9 @comment GNU Mailutils is distributed in the hope that it will be useful,
10 @comment but WITHOUT ANY WARRANTY; without even the implied warranty of
11 @comment MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 @comment GNU General Public License for more details.
13 @comment
14 @comment You should have received a copy of the GNU General Public License
15 @comment along with GNU Mailutils; if not, write to the Free Software
16 @comment Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18 #include <stdio.h>
19 #include <mailutils/mailcap.h>
20 #include <mailutils/stream.h>
21 #include <mailutils/error.h>
22
23 int
24 main (int argc, char **argv)
25 @{
26 stream_t stream = NULL;
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 @}
38
39 status = stream_open (stream);
40 if (status)
41 @{
42 mu_error ("cannot open file stream %s: %s",
43 file, mu_strerror (status));
44 exit (1);
45 @}
46
47 status = mu_mailcap_create (&mailcap, stream);
48 if (status == 0)
49 @{
50 int i;
51 size_t count = 0;
52 char buffer[256];
53
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;
60
61 printf ("entry[%d]\n", i);
62
63 mu_mailcap_get_entry (mailcap, i, &entry);
64
65 /* typefield. */
66 mu_mailcap_entry_get_typefield (entry, 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);
74
75 /* fields. */
76 mu_mailcap_entry_fields_count (entry, &fields_count);
77 for (j = 1; j <= fields_count; j++)
78 @{
79 mu_mailcap_entry_get_field (entry, j, buffer,
80 sizeof (buffer), NULL);
81 printf ("\tfields[%d]: %s\n", j, buffer);
82 @}
83 printf ("\n");
84 @}
85 mu_mailcap_destroy (&mailcap);
86 @}
87
88 return 0;
89 @}