X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=database.c;h=092f56351911766aa44cda62e0116d785ef91454;hb=4164f9d94097406569736b02f5caa6a76eff38f1;hp=0b9b58e6b1c18e750fa508469727f8f73b364569;hpb=baf1c7616dd0a5fa1bafde2045ac2af22d95122a;p=pkg%2Fabook.git diff --git a/database.c b/database.c index 0b9b58e..092f563 100644 --- a/database.c +++ b/database.c @@ -15,6 +15,7 @@ #include "abook.h" #include #include "database.h" +#include "gettext.h" #include "list.h" #include "misc.h" #include "options.h" @@ -53,26 +54,26 @@ extern char *datafile; */ 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 */ - {"Country", "country", TAB_ADDRESS},/* COUNTRY */ - {"Home Phone", "phone", TAB_PHONE},/* PHONE */ - {"Work Phone", "workphone", TAB_PHONE},/* WORKPHONE */ - {"Fax", "fax", TAB_PHONE},/* FAX */ - {"Mobile", "mobile", TAB_PHONE},/* MOBILEPHONE */ - {"Nickname/Alias", "nick", TAB_OTHER},/* NICK */ - {"URL", "url", TAB_OTHER},/* URL */ - {"Notes", "notes", TAB_OTHER},/* NOTES */ - {"Custom1", "custom1", TAB_CUSTOM},/* CUSTOM1 */ - {"Custom2", "custom2", TAB_CUSTOM},/* CUSTOM2 */ - {"Custom3", "custom3", TAB_CUSTOM},/* CUSTOM3 */ - {"Custom4", "custom4", TAB_CUSTOM},/* CUSTOM4 */ - {"Custom5", "custom5", TAB_CUSTOM},/* CUSTOM5 */ + {N_("Name"), "name", TAB_CONTACT},/* NAME */ + {N_("E-mails"), "email", TAB_CONTACT},/* EMAIL */ + {N_("Address"), "address", TAB_ADDRESS},/* ADDRESS */ + {N_("Address2"), "address2", TAB_ADDRESS},/* ADDRESS2 */ + {N_("City"), "city", TAB_ADDRESS},/* CITY */ + {N_("State/Province"),"state", TAB_ADDRESS},/* STATE */ + {N_("ZIP/Postal Code"),"zip", TAB_ADDRESS},/* ZIP */ + {N_("Country"), "country", TAB_ADDRESS},/* COUNTRY */ + {N_("Home Phone"), "phone", TAB_PHONE},/* PHONE */ + {N_("Work Phone"), "workphone", TAB_PHONE},/* WORKPHONE */ + {N_("Fax"), "fax", TAB_PHONE},/* FAX */ + {N_("Mobile"), "mobile", TAB_PHONE},/* MOBILEPHONE */ + {N_("Nickname/Alias"), "nick", TAB_OTHER},/* NICK */ + {N_("URL"), "url", TAB_OTHER},/* URL */ + {N_("Notes"), "notes", TAB_OTHER},/* NOTES */ + {N_("Custom1"), "custom1", TAB_CUSTOM},/* CUSTOM1 */ + {N_("Custom2"), "custom2", TAB_CUSTOM},/* CUSTOM2 */ + {N_("Custom3"), "custom3", TAB_CUSTOM},/* CUSTOM3 */ + {N_("Custom4"), "custom4", TAB_CUSTOM},/* CUSTOM4 */ + {N_("Custom5"), "custom5", TAB_CUSTOM},/* CUSTOM5 */ }; @@ -123,7 +124,7 @@ parse_database(FILE *in) *tmp++ = '\0'; for(i = 0; i < ITEM_FIELDS; i++) if(!strcmp(abook_fields[i].key, line)) { - item[i] = strdup(tmp); + item[i] = xstrdup(tmp); goto next; } } @@ -250,13 +251,13 @@ validate_item(list_item item) char *tmp; if(item[EMAIL] == NULL) - item[EMAIL] = strdup(""); + item[EMAIL] = xstrdup(""); for(i=0; i _MAX_FIELD_LEN(i) ) ) { tmp = item[i]; item[i][_MAX_FIELD_LEN(i)-1] = 0; - item[i] = strdup(item[i]); + item[i] = xstrdup(item[i]); free(tmp); } } @@ -337,7 +338,7 @@ get_surname(char *s) while(p > s && *(p - 1) != ' ') p--; - return strdup(p); + return xstrdup(p); } static int @@ -402,8 +403,8 @@ sort_by_field(int field) if(field < 0) { field = name2field(opt_get_str(STR_SORT_FIELD)); if(field < 0) { - statusline_msg("Not valid field value defined " - "in configuration"); + statusline_msg(_("Invalid field value defined " + "in configuration")); return; } } @@ -437,13 +438,15 @@ find_item(char *str, int start, int search_fields[]) if(list_is_empty() || !is_valid_item(start)) return -2; /* error */ - findstr = strdup(str); + findstr = xstrdup(str); findstr = strlower(findstr); e.item = start - 1; /* must be "real start" - 1 */ db_enumerate_items(e) { - for( i = 0; search_fields[i] >= 0; i++ ) { - tmp = safe_strdup(database[e.item][search_fields[i]]); + for(i = 0; search_fields[i] >= 0; i++) { + if(database[e.item][search_fields[i]] == NULL) + continue; + tmp = xstrdup(database[e.item][search_fields[i]]); if( tmp && strstr(strlower(tmp), findstr) ) { ret = e.item; goto out;