/[mailutils]/mailutils/doc/texinfo/mailcap.inc
ViewVC logotype

Diff of /mailutils/doc/texinfo/mailcap.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by alainm, Sun Feb 23 23:32:02 2003 UTC revision 1.2 by gray, Mon Feb 24 10:30:10 2003 UTC
# Line 17  Line 17 
17    
18  #include <stdio.h>  #include <stdio.h>
19  #include <mailutils/mailcap.h>  #include <mailutils/mailcap.h>
20    #include <mailutils/stream.h>
21    #include <mailutils/error.h>
22    
23  int main(int argc, char **argv)  int
24    main(int argc, char **argv)
25  @{  @{
26     stream_t stream = NULL;    stream_t stream = NULL;
27     int status = 0;    int status = 0;
28      char *file = argc == 1 ? "/etc/mailcap" : argv[1];
29     status = file_stream_create (&stream, "/etc/mailcap", MU_STREAM_READ);    mu_mailcap_t mailcap = NULL;
30     if (status == 0)      
31       @{    status = file_stream_create (&stream, file, MU_STREAM_READ);
32          status = stream_open (stream);    if (status)
33          if (status == 0)      @{
34            @{        mu_error ("cannot create file stream %s: %s",
35               mu_mailcap_t mailcap = NULL;                  file, mu_strerror (status));
36               status = mu_mailcap_create (&mailcap, stream);        exit (1);
37               if (status == 0)      @}
38                 @{  
39                    int i;    status = stream_open (stream);
40                    size_t count = 0;    if (status)
41                    char buffer[256];      @{
42          mu_error ("cannot open file stream %s: %s",
43                    mu_mailcap_entries_count (mailcap, &count);                  file, mu_strerror (status));
44                    for (i = 1; i <= count; i++)        exit (1);
45                      @{      @}
46                         int j;  
47                         mu_mailcap_entry_t entry = NULL;    status = mu_mailcap_create (&mailcap, stream);
48                         int fields_count = 0;    if (status == 0)
49        @{
50                         printf ("entry[%d]\n", i);        int i;
51          size_t count = 0;
52                         mu_mailcap_get_entry (mailcap, i, &entry);        char buffer[256];
53    
54                         /* typefield.  */        mu_mailcap_entries_count (mailcap, &count);
55                         mu_mailcap_entry_get_typefield (entry, buffer, sizeof (buffer), NULL);        for (i = 1; i <= count; i++)
56                         printf ("\ttypefield: %s\n", buffer);          @{
57              int j;
58                         /* view-command.  */            mu_mailcap_entry_t entry = NULL;
59                         mu_mailcap_entry_get_viewcommand (entry, buffer, sizeof (buffer), NULL);            int fields_count = 0;
60                         printf ("\tview-command: %s\n", buffer);  
61              printf ("entry[%d]\n", i);
62                         /* fields.  */  
63                         mu_mailcap_entry_fields_count (entry, &fields_count);            mu_mailcap_get_entry (mailcap, i, &entry);
64                         for (j = 1; j <= fields_count; j++)  
65                           @{            /* typefield.  */
66                               mu_mailcap_entry_get_field (entry, j, buffer, sizeof (buffer), NULL);            mu_mailcap_entry_get_typefield (entry, buffer,
67                               printf ("\tfields[%d]: %s\n", j, buffer);                                            sizeof (buffer), NULL);
68                           @}            printf ("\ttypefield: %s\n", buffer);
69                         printf ("\n");            
70                      @}            /* view-command.  */
71                      mu_mailcap_destroy (&mailcap);            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;    return 0;
89  @}  @}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26