]> git.deb.at Git - pkg/abook.git/commitdiff
csv export: "allcsv" output changed
authorRaphaël Droz <raphael.droz+floss@gmail.com>
Fri, 19 Apr 2013 15:32:39 +0000 (17:32 +0200)
committerRaphaël Droz <raphael.droz+floss@gmail.com>
Fri, 19 Apr 2013 15:32:39 +0000 (17:32 +0200)
- fields name in the header are now lowercase
- "MOBILEPHONE" changed to "mobile"

RELEASE_NOTES
filter.c

index 32e530988a0cf2e82ac5eea499dedc97c46b54fe..412bc202677e4c270f3be6d124ea53adc5c100ce 100644 (file)
@@ -27,6 +27,8 @@ Git:
     - It depends on the --enable-vformat ./configure switch
     - It's only used as an input filter, especially useful to
       deal with multi-valued fields and encoded characters.
+  * allcsv output's header changed to lowercase
+    and "MOBILEPHONE" changed to "mobile" (consistent w.r.t. standard_fields)
 
 0.6.0pre2 (2010-07-22):
   * Added anniversary as a default field
index 20c89739623de515398e183a4873d247d0b36f0e..0447a3c87081a7a06fc41fbbecef91189d3801e7 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -35,6 +35,8 @@
 
 extern abook_field_list *fields_list;
 extern int fields_count;
+// see also enum field_types @database.h
+extern abook_field standard_fields[];
 
 /*
  * function declarations
@@ -1868,7 +1870,7 @@ allcsv_export_database(FILE *out, struct db_enumerator e)
                PHONE,
                WORKPHONE,
                FAX,
-               MOBILEPHONE,
+               MOBILEPHONE, // spelled "mobile" in standard_fields
                NICK,
                URL,
                NOTES,
@@ -1878,23 +1880,11 @@ allcsv_export_database(FILE *out, struct db_enumerator e)
        };
 
        fprintf(out, "#");
-       fprintf(out, "\"NAME\",");
-       fprintf(out, "\"EMAIL\",");
-       fprintf(out, "\"ADDRESS\",");
-       fprintf(out, "\"ADDRESS2\",");
-       fprintf(out, "\"CITY\",");
-       fprintf(out, "\"STATE\",");
-       fprintf(out, "\"ZIP\",");
-       fprintf(out, "\"COUNTRY\",");
-       fprintf(out, "\"PHONE\",");
-       fprintf(out, "\"WORKPHONE\",");
-       fprintf(out, "\"FAX\",");
-       fprintf(out, "\"MOBILEPHONE\",");
-       fprintf(out, "\"NICK\",");
-       fprintf(out, "\"URL\",");
-       fprintf(out, "\"NOTES\",");
-       fprintf(out, "\"ANNIVERSARY\",");
-       fprintf(out, "\"GROUPS\"\n");
+       int i = 0;
+       while(allcsv_export_fields[i+1] != CSV_LAST) {
+               fprintf(out, "\"%s\",", standard_fields[i++].key);
+       }
+       fprintf(out, "\"%s\"\n", standard_fields[i].key);
 
        csv_export_common(out, e, allcsv_export_fields, NULL);
 
@@ -2478,8 +2468,6 @@ bsdcal_export_database(FILE *out, struct db_enumerator e)
        return 0;
 }
 
-// see also enum field_types @database.h
-extern abook_field standard_fields[];
 static int
 find_field_enum(char *s) {
        int i = -1;