summaryrefslogtreecommitdiff
path: root/doc/texinfo/mailcap.inc
blob: 117d14e3000546c6c0cd214a8b655c59bc0b0dd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
@comment   GNU Mailutils -- a suite of utilities for electronic mail
@comment   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
@comment
@comment   GNU Mailutils is free software; you can redistribute it and/or modify
@comment   it under the terms of the GNU General Public License as published by
@comment   the Free Software Foundation; either version 2, or (at your option)
@comment   any later version.
@comment
@comment   GNU Mailutils is distributed in the hope that it will be useful,
@comment   but WITHOUT ANY WARRANTY; without even the implied warranty of
@comment   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@comment   GNU General Public License for more details.
@comment
@comment   You should have received a copy of the GNU General Public License
@comment   along with GNU Mailutils; if not, write to the Free Software
@comment   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  

#include <stdio.h>
#include <mailutils/mailcap.h>

int main(int argc, char **argv)
@{
   stream_t stream = NULL;
   int status = 0;

   status = file_stream_create (&stream, "/etc/mailcap", MU_STREAM_READ);
   if (status == 0)
     @{
        status = stream_open (stream);
        if (status == 0)
          @{
             mu_mailcap_t mailcap = NULL;
             status = mu_mailcap_create (&mailcap, stream);
             if (status == 0)
               @{
                  int i;
                  size_t count = 0;
                  char buffer[256];

                  mu_mailcap_entries_count (mailcap, &count);
                  for (i = 1; i <= count; i++)
                    @{
                       int j;
                       mu_mailcap_entry_t entry = NULL;
                       int fields_count = 0;

                       printf ("entry[%d]\n", i);

                       mu_mailcap_get_entry (mailcap, i, &entry);

                       /* typefield.  */
                       mu_mailcap_entry_get_typefield (entry, buffer, sizeof (buffer), NULL);
                       printf ("\ttypefield: %s\n", buffer);

                       /* view-command.  */
                       mu_mailcap_entry_get_viewcommand (entry, buffer, sizeof (buffer), NULL);
                       printf ("\tview-command: %s\n", buffer);

                       /* fields.  */
                       mu_mailcap_entry_fields_count (entry, &fields_count);
                       for (j = 1; j <= fields_count; j++)
                         @{
                             mu_mailcap_entry_get_field (entry, j, buffer, sizeof (buffer), NULL);
                             printf ("\tfields[%d]: %s\n", j, buffer);
                         @}
                       printf ("\n");
                    @}
                    mu_mailcap_destroy (&mailcap);
               @}
           @}
       @}
  return 0;
@}

Return to:

Send suggestions and report system problems to the System administrator.