static int text_export_database(FILE *out, struct db_enumerator e);
static int spruce_export_database(FILE *out, struct db_enumerator e);
static int wl_export_database(FILE *out, struct db_enumerator e);
+static int bsdcal_export_database(FILE *out, struct db_enumerator e);
/*
* end of function declarations
{ "text", N_("plain text"), text_export_database },
{ "wl", N_("Wanderlust address book"), wl_export_database },
{ "spruce", N_("Spruce address book"), spruce_export_database },
+ { "bsdcal", N_("BSD calendar"), bsdcal_export_database },
{ "\0", NULL, NULL }
};
{
char email[MAX_EMAIL_LEN];
char *alias = NULL;
+ int email_addresses;
+ char *ptr;
db_enumerate_items(e) {
alias = mutt_alias_genalias(e.item);
get_first_email(email, e.item);
- fprintf(out, *email ? "alias %s %s <%s>\n": "alias %s %s%s\n",
- alias,
- db_name_get(e.item),
- email);
- xfree(alias);
+
+ /* do not output contacts without email address */
+ /* cause this does not make sense in mutt aliases */
+ if (*email) {
+
+ /* output first email address */
+ fprintf(out, "alias %s %s <%s>\n",
+ alias,
+ db_name_get(e.item),
+ email);
+
+ /* number of email addresses */
+ email_addresses = 1;
+ ptr = db_email_get(e.item);
+ while (*ptr != '\0') {
+ if (*ptr == ',') {
+ email_addresses++;
+ }
+ ptr++;
+ }
+
+ /* output other email addresses */
+ while (email_addresses-- > 1) {
+ roll_emails(e.item, ROTATE_RIGHT);
+ get_first_email(email, e.item);
+ fprintf(out, "alias %s__%s %s <%s>\n",
+ alias,
+ email,
+ db_name_get(e.item),
+ email);
+ }
+ roll_emails(e.item, ROTATE_RIGHT);
+ xfree(alias);
+ }
}
return 0;
* end of wanderlust addressbook export filter
*/
+/*
+ * BSD calendar export filter
+ */
+
+static int
+bsdcal_export_database(FILE *out, struct db_enumerator e)
+{
+ db_enumerate_items(e) {
+ int year, month = 0, day = 0;
+ char *anniversary = db_fget(e.item, ANNIVERSARY);
+
+ if(anniversary) {
+ if(!parse_date_string(anniversary, &day, &month, &year))
+ continue;
+
+ fprintf(out,
+ _("%02d/%02d\tAnniversary of %s\n"),
+ month,
+ day,
+ safe_str(db_name_get(e.item))
+ );
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * end of BSD calendar export filter
+ */
+