# Example

The following program will read a vCard file, iterate over all vCards and print the name of all cards:

    #include <stdio.h>

    #include <glib.h>

    #include <mimedir/mimedir.h>

    int main (int argc, char *argv[])
    {
        GError *error = NULL;
        GList *list, *node;

        if (argc != 2) {
            fprintf (stderr, "Usage: %s FILENAME\n", argv[0]);
            return 1;
        }

        mimedir_init ();

        list = mimedir_vcard_read_list (argv[1], &error);
        if (error) {
            fprintf (stderr, "Error while reading %s: %s\n",
                     argv[1], error->message);
            return 1;
        }

        for (node = list; node != NULL; node = g_list_next (node)) {
            MIMEDirVCard *vcard;
            gchar *name;

            vcard = MIMEDIR_VCARD (node->data);

            g_object_get (G_OBJECT (vcard),
                          "name", &name,
                          NULL);

            printf ("%s\n", name);
        }

        mimedir_vcard_free_list (list);

        return 0;
    }