diff options
Diffstat (limited to 'addressbook/backend')
-rw-r--r-- | addressbook/backend/ebook/test-card.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/addressbook/backend/ebook/test-card.c b/addressbook/backend/ebook/test-card.c new file mode 100644 index 0000000000..2576c87e6b --- /dev/null +++ b/addressbook/backend/ebook/test-card.c @@ -0,0 +1,71 @@ +#include <gnome.h> +#include <e-card.h> + +#define TEST_VCARD \ +"BEGIN:VCARD +" \ +"FN:Nat +" \ +"N:Friedman;Nat;D;Mr. +" \ +"BDAY:1977-08-06 +" \ +"TEL;WORK:617 679 1984 +" \ +"TEL;CELL:123 456 7890 +" \ +"EMAIL;INTERNET:nat@nat.org +" \ +"EMAIL;INTERNET:nat@helixcode.com +" \ +"END:VCARD +" \ +" +" + +static char * +read_file (char *name) +{ + int len; + char buff[65536]; + char line[1024]; + FILE *f; + + f = fopen (name, "r"); + if (f == NULL) + g_error ("Unable to open %s!\n", name); + + len = 0; + while (fgets (line, sizeof (line), f) != NULL) { + strcpy (buff + len, line); + len += strlen (line); + } + + fclose (f); + + return g_strdup (buff); +} + + + +int +main (int argc, char **argv) +{ + char *cardstr; + ECard *card; + + gnome_init ("TestCard", "0.0", argc, argv); + + cardstr = NULL; + if (argc == 2) + cardstr = read_file (argv [1]); + + if (cardstr == NULL) + cardstr = TEST_VCARD; + + card = e_card_new (cardstr); + + gtk_object_unref (GTK_OBJECT (card)); + + return 0; +} |