]> git.deb.at Git - pkg/abook.git/blobdiff - database.c
added second address field
[pkg/abook.git] / database.c
index 3d7f1a4b9b2c9e24d3019003ceff5c9a1e39e439..e9d939e57d1de7b46babb2d97c0ce045eea659f6 100644 (file)
@@ -58,6 +58,7 @@ struct abook_field abook_fields[ITEM_FIELDS] = {
        {"Name",        "name",         TAB_CONTACT},/* NAME */
        {"E-mails",     "email",        TAB_CONTACT},/* EMAIL */
        {"Address",     "address",      TAB_ADDRESS},/* ADDRESS */
+       {"Address2",    "address2",     TAB_ADDRESS},/* ADDRESS2 */   
        {"City",        "city",         TAB_ADDRESS},/* CITY */
        {"State/Province","state",      TAB_ADDRESS},/* STATE */
        {"ZIP/Postal Code","zip",       TAB_ADDRESS},/* ZIP */
@@ -107,9 +108,12 @@ parse_database(FILE *in)
                } else if((tmp = strchr(line, '=') ) && sec ) {
                        *tmp++ = '\0';
                        for(i=0; i<ITEM_FIELDS; i++)
-                               if( !strcmp(abook_fields[i].key, line) )
+                               if( !strcmp(abook_fields[i].key, line) ) {
                                        item[i] = strdup(tmp);
+                                       goto next;
+                               }
                }
+next:
                free(line);
        }
 
@@ -144,15 +148,17 @@ write_database(FILE *out, struct db_enumerator e)
        int j;
        int i = 0;
 
-       fprintf(out, "# abook addressbook file\n\n");
-       fprintf(out, "[format]\n");
-       fprintf(out, "program=" PACKAGE "\n");
-       fprintf(out, "version=" VERSION "\n");
-       fprintf(out, "\n\n");
+       fprintf(out,
+               "# abook addressbook file\n\n"
+               "[format]\n"
+               "program=" PACKAGE "\n"
+               "version=" VERSION "\n"
+               "\n\n"
+       );
 
        db_enumerate_items(e) {
                fprintf(out, "[%d]\n", i);
-               for(j=0; j<ITEM_FIELDS; j++) {
+               for(j = 0; j < ITEM_FIELDS; j++) {
                        if( database[e.item][j] != NULL &&
                                        *database[e.item][j] )
                                fprintf(out, "%s=%s\n",
@@ -226,7 +232,7 @@ close_database()
 
 #define _MAX_FIELD_LEN(X)      (X == EMAIL ? MAX_EMAILSTR_LEN:MAX_FIELD_LEN)
 
-inline static void
+static void
 validate_item(list_item item)
 {
        int i;