Package: abook
Version: 0.6.0~pre1-1
Severity: wishlist
Tags: patch

Hi!

I've migrated to abook now, thanks for this version in experimental.
The only "big" feature I was missing is being able to export to BSD
calendar format (as I told you already on my feedback mail). Now that
the date type is implemented, adding this was quite easy. So attached
is a patch to do that. The name of the filter maybe it's not the best,
but could not come with anything else, that was clear and short.

thanks,
guillem
diff -Naur abook-0.6.0~pre1.orig/abook.1 abook-0.6.0~pre1/abook.1
--- abook-0.6.0~pre1.orig/abook.1       2005-10-03 08:22:49.000000000 +0300
+++ abook-0.6.0~pre1/abook.1    2006-09-06 03:57:45.000000000 +0300
@@ -1,4 +1,4 @@
-.TH ABOOK 1 "June 6, 2003"
+.TH ABOOK 1 2006-09-06
 .nh
 .SH NAME
 abook \- text-based address book program
@@ -79,6 +79,8 @@
 - \fBspruce\fP Spruce address book
 .br
 - \fBwl\fP Wanderlust address book
+.br
+- \fBbsdcal\fP BSD calendar
 .TP
 \fB\-\-add-email\fP
 Read an e-mail message from stdin and add the sender to the addressbook.
diff -Naur abook-0.6.0~pre1.orig/edit.c abook-0.6.0~pre1/edit.c
--- abook-0.6.0~pre1.orig/edit.c        2006-08-29 22:27:00.000000000 +0300
+++ abook-0.6.0~pre1/edit.c     2006-09-06 03:56:40.000000000 +0300
@@ -33,8 +33,6 @@
 
 WINDOW *editw;
 
-static int parse_date_string(char *s, int *day, int *month, int *year);
-
 
 static void
 editor_tab(const int tab)
@@ -421,7 +419,7 @@
        return valid;
 }
 
-static int
+int
 parse_date_string(char *s, int *day, int *month, int *year)
 {
        int i = 0;
diff -Naur abook-0.6.0~pre1.orig/edit.h abook-0.6.0~pre1/edit.h
--- abook-0.6.0~pre1.orig/edit.h        2005-10-26 02:27:24.000000000 +0300
+++ abook-0.6.0~pre1/edit.h     2006-09-06 03:56:40.000000000 +0300
@@ -4,6 +4,7 @@
 void           edit_item(int item);
 void           get_first_email(char *str, int item);
 void           add_item();
+int            parse_date_string(char *s, int *day, int *month, int *year);
 
 #define EDITW_COLS     (COLS - 6)
 #define EDITW_LINES    (LINES - 5)
diff -Naur abook-0.6.0~pre1.orig/filter.c abook-0.6.0~pre1/filter.c
--- abook-0.6.0~pre1.orig/filter.c      2006-08-08 09:19:05.000000000 +0300
+++ abook-0.6.0~pre1/filter.c   2006-09-06 03:56:40.000000000 +0300
@@ -61,6 +61,7 @@
 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
@@ -91,6 +92,7 @@
        { "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 }
 };
 
@@ -1856,3 +1858,33 @@
  * 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) {
+                       parse_date_string(anniversary, &day, &month, &year);
+
+                       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
+ */
+

Reply via email to