aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-09-21 08:24:15 +0800
committerChris Lahey <clahey@src.gnome.org>2000-09-21 08:24:15 +0800
commit7239e19eaa67ee28c4ac19cb8422e0efa6d63856 (patch)
tree5b447f96117d0b1b5a4362ece850279dec34a18f /addressbook
parentad7e6820081d32774e1a4226899fdbf6c1a8e728 (diff)
downloadgsoc2013-evolution-7239e19eaa67ee28c4ac19cb8422e0efa6d63856.tar.gz
gsoc2013-evolution-7239e19eaa67ee28c4ac19cb8422e0efa6d63856.tar.zst
gsoc2013-evolution-7239e19eaa67ee28c4ac19cb8422e0efa6d63856.zip
Make this work when a field is spread across multiple lines.
2000-09-21 Christopher James Lahey <clahey@helixcode.com> * backend/ebook/load-pine-addressbook.c: Make this work when a field is spread across multiple lines. svn path=/trunk/; revision=5531
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog5
-rw-r--r--addressbook/backend/ebook/load-pine-addressbook.c70
2 files changed, 55 insertions, 20 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 626b514b90..8908801cb9 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,8 @@
+2000-09-21 Christopher James Lahey <clahey@helixcode.com>
+
+ * backend/ebook/load-pine-addressbook.c: Make this work when a
+ field is spread across multiple lines.
+
2000-09-20 Christopher James Lahey <clahey@helixcode.com>
* backend/ebook/e-card.c, backend/ebook/e-card.h: Added a
diff --git a/addressbook/backend/ebook/load-pine-addressbook.c b/addressbook/backend/ebook/load-pine-addressbook.c
index 7d74fe20a4..073c35c915 100644
--- a/addressbook/backend/ebook/load-pine-addressbook.c
+++ b/addressbook/backend/ebook/load-pine-addressbook.c
@@ -27,27 +27,16 @@ add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
}
static void
-book_open_cb (EBook *book, EBookStatus status, gpointer closure)
+parse_line (EBook *book, char *line)
{
- FILE *fp = fopen (".addressbook", "r");
- char line[1024];
-
- if (!fp) {
- g_warning ("Can't find .addressbook");
- return;
- }
-
- while(fgets(line, 1024, fp)) {
- int length = strlen(line);
- char **strings;
- ECardName *name;
- ECard *card;
- EList *list;
- if (line[length - 1] == '\n')
- line[--length] = 0;
-
- card = e_card_new("");
- strings = g_strsplit(line, "\t", 3);
+ char **strings;
+ ECardName *name;
+ ECard *card;
+ EList *list;
+
+ card = e_card_new("");
+ strings = g_strsplit(line, "\t", 3);
+ if (strings[0] && strings[1] && strings[2]) {
name = e_card_name_from_string(strings[1]);
gtk_object_set(GTK_OBJECT(card),
"nickname", strings[0],
@@ -63,6 +52,47 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure)
}
}
+static void
+book_open_cb (EBook *book, EBookStatus status, gpointer closure)
+{
+ FILE *fp = fopen (".addressbook", "r");
+ char line[2 * 1024];
+ int which = 0;
+ char *lastline = NULL;
+
+ if (!fp) {
+ g_warning ("Can't find .addressbook");
+ return;
+ }
+
+ while(fgets(line + which * 1024, 1024, fp)) {
+ int length;
+ char *thisline = line + which * 1024;
+ length = strlen(thisline);
+ if (thisline[length - 1] == '\n')
+ line[--length] = 0;
+ if (lastline && *thisline && isspace(*thisline)) {
+ char *temp;
+ while(*thisline && isspace(*thisline))
+ thisline ++;
+ temp = lastline;
+ lastline = g_strdup_printf("%s%s", lastline, thisline);
+ g_free(temp);
+ continue;
+ }
+ if (lastline) {
+ parse_line (book, lastline);
+ g_free(lastline);
+ }
+ lastline = g_strdup(thisline);
+ }
+
+ if (lastline) {
+ parse_line (book, lastline);
+ g_free(lastline);
+ }
+}
+
static guint
ebook_create (void)
{