X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=filter.c;h=70ec2d4e8aa5e054b2227311399b8f8ee13c6976;hb=3370ba68ac9cbbd583da6997c039b29b0fc43b7a;hp=671d2a4c58103223078c7c1230cb485b26f618bf;hpb=6f27db4afffc464b91c1ef23b0b5d85322e8d9b8;p=pkg%2Fabook.git diff --git a/filter.c b/filter.c index 671d2a4..70ec2d4 100644 --- a/filter.c +++ b/filter.c @@ -832,39 +832,56 @@ ldif_export_database(FILE *out, struct db_enumerator e) * html export filter */ -static void html_export_write_head(FILE *out, int extra_column); +static void html_export_write_head(FILE *out); static void html_export_write_tail(FILE *out); +extern struct index_elem *index_elements; + +static void +html_print_emails(FILE *out, struct list_field *f) +{ + abook_list *l = csv_to_abook_list(f->data); + + for(; l; l = l->next) { + fprintf(out, "%s", l->data, l->data); + if(l->next) + fprintf(out, ", "); + } + + abook_list_free(&l); +} + static int html_export_database(FILE *out, struct db_enumerator e) { - char tmp[MAX_EMAILSTR_LEN], *emails; - int extra_column; + struct list_field f; + struct index_elem *cur; if(list_is_empty()) return 2; - extra_column = init_extra_field(STR_EXTRA_COLUMN); - html_export_write_head(out, extra_column); + init_index(); - db_enumerate_items(e) { - get_first_email(tmp, e.item); - if (*tmp) - fprintf(out, "\n" - "%s" - "\n", - tmp, - db_name_get(e.item)); - else - fprintf(out, "\n%s\n", db_name_get(e.item)); + html_export_write_head(out); - emails = db_email_get(e.item); - fprintf(out, "%s\n", emails); - free(emails); - if(extra_column >= 0) - fprintf(out, "%s\n", - safe_str(db_fget_byid(e.item, extra_column))); - fprintf(out, "\n\n"); + db_enumerate_items(e) { + fprintf(out, ""); + for(cur = index_elements; cur; cur = cur->next) { + if(cur->type != INDEX_FIELD) + continue; + + get_list_field(e.item, cur, &f); + + if(f.type == FIELD_EMAILS) { + fprintf(out, ""); + html_print_emails(out, &f); + fprintf(out, ""); + continue; + } else { + fprintf(out, "%s", safe_str(f.data)); + } + } + fprintf(out, "\n"); } html_export_write_tail(out); @@ -873,9 +890,10 @@ html_export_database(FILE *out, struct db_enumerator e) } static void -html_export_write_head(FILE *out, int extra_column) +html_export_write_head(FILE *out) { - char *realname = get_real_name(), *extra_column_name = NULL; + char *realname = get_real_name(), *str; + struct index_elem *cur; fprintf(out, "\n"); fprintf(out, "\n\n %s's addressbook", @@ -884,11 +902,13 @@ html_export_write_head(FILE *out, int extra_column) fprintf(out, "\n

%s's addressbook

\n", realname ); fprintf(out, "

\n\n"); - fprintf(out, "\n"); - fprintf(out, "\n"); - if(extra_column >= 0) { - get_field_keyname(extra_column, NULL, &extra_column_name); - fprintf(out, "", safe_str(extra_column_name)); + fprintf(out, "
NameE-mail address(es)%s
\n"); + for(cur = index_elements; cur; cur = cur->next) { + if(cur->type != INDEX_FIELD) + continue; + + get_field_info(cur->d.field.id, NULL, &str, NULL); + fprintf(out, "", str); } fprintf(out, "\n\n"); @@ -1744,8 +1764,8 @@ text_export_database(FILE * out, struct db_enumerator e) fprintf(out, "\n"); for(j = PHONE; j <= MOBILEPHONE; j++) if(db_fget(e.item, j)) { - get_field_keyname(field_id(j), - NULL, &str); + get_field_info(field_id(j), + NULL, &str, NULL); fprintf(out, "%s: %s\n", str, db_fget(e.item, j)); }
%s