]> git.deb.at Git - pkg/abook.git/commitdiff
vformat: make use of libvformat to parse vcard input
authorRaphaël Droz <raphael.droz+floss@gmail.com>
Wed, 7 Nov 2012 23:04:01 +0000 (00:04 +0100)
committerRaphaël Droz <raphael.droz+floss@gmail.com>
Mon, 3 Dec 2012 13:55:57 +0000 (14:55 +0100)
filter.c

index 1c96a8896ca974e115e0616a224eb2858b682e98..fd81174bcf102ed6e10db7d81aecf82303dca8f5 100644 (file)
--- a/filter.c
+++ b/filter.c
 #include "xmalloc.h"
 #include <assert.h>
 
+#ifdef VFORMAT
+#include "vcard.h"
+#endif
+
 extern abook_field_list *fields_list;
 extern int fields_count;
 
@@ -293,6 +297,18 @@ import_file(char filtname[FILTNAME_LEN], char *filename)
        if(i < 0)
                return -1;
 
+#ifdef VFORMAT
+       // this is a special case for
+       // libvformat whose API expects a filename
+       if(!strcmp(filtname, "vcard")) {
+         if(!strcmp(filename, "-"))
+           ret = vcard_parse_file_libvformat("/dev/stdin");
+         else
+           ret = vcard_parse_file_libvformat(filename);
+       }
+       else
+#endif
+
        if(!strcmp(filename, "-")) {
                struct stat s;
                if((fstat(fileno(stdin), &s)) == -1 || S_ISDIR(s.st_mode))