5 * by JH <jheinonen@users.sourceforge.net>
7 * Copyright (C) Jaakko Heinonen
15 #include <sys/types.h>
16 #include "abook_curses.h"
27 extern list_item *database;
28 extern struct abook_field abook_fields[];
31 * function declarations
35 * import filter prototypes
38 static int ldif_parse_file(FILE *handle);
39 static int mutt_parse_file(FILE *in);
40 static int pine_parse_file(FILE *in);
41 static int csv_parse_file(FILE *in);
44 * export filter prototypes
47 static int ldif_export_database(FILE *out, struct db_enumerator e);
48 static int html_export_database(FILE *out, struct db_enumerator e);
49 static int pine_export_database(FILE *out, struct db_enumerator e);
50 static int csv_export_database(FILE *out, struct db_enumerator e);
51 static int gcrd_export_database(FILE *out, struct db_enumerator e);
52 static int mutt_alias_export(FILE *out, struct db_enumerator e);
53 static int elm_alias_export(FILE *out, struct db_enumerator e);
54 static int text_export_database(FILE *out, struct db_enumerator e);
55 static int spruce_export_database(FILE *out, struct db_enumerator e);
58 * end of function declarations
61 struct abook_input_filter i_filters[] = {
62 { "abook", "abook native format", parse_database },
63 { "ldif", "ldif / Netscape addressbook", ldif_parse_file },
64 { "mutt", "mutt alias", mutt_parse_file },
65 { "pine", "pine addressbook", pine_parse_file },
66 { "csv", "comma separated values", csv_parse_file },
70 struct abook_output_filter e_filters[] = {
71 { "abook", "abook native format", write_database },
72 { "ldif", "ldif / Netscape addressbook (.4ld)", ldif_export_database },
73 { "mutt", "mutt alias", mutt_alias_export },
74 { "html", "html document", html_export_database },
75 { "pine", "pine addressbook", pine_export_database },
76 { "gcrd", "GnomeCard (VCard) addressbook", gcrd_export_database },
77 { "csv", "comma separated values", csv_export_database },
78 { "elm", "elm alias", elm_alias_export },
79 { "text", "plain text", text_export_database },
80 { "spruce", "Spruce address book", spruce_export_database },
94 for(i=0; *i_filters[i].filtname ; i++)
95 printf("\t%s\t%s\n", i_filters[i].filtname,
101 for(i=0; *e_filters[i].filtname ; i++)
102 printf("\t%s\t%s\n", e_filters[i].filtname,
109 number_of_output_filters()
113 for(i=0; *e_filters[i].filtname ; i++)
120 number_of_input_filters()
124 for(i=0; *i_filters[i].filtname ; i++)
133 char *username = getenv("USER");
134 struct passwd *pwent;
138 pwent = getpwnam(username);
140 if( (tmp = (char *)malloc(strlen(pwent->pw_gecos) +1)) == NULL)
141 return strdup(username);
143 rtn = sscanf(pwent->pw_gecos, "%[^,]", tmp);
144 if (rtn == EOF || rtn == 0) {
146 return strdup(username);
155 static int i_read_file(char *filename, int (*func) (FILE *in));
164 refresh_statusline();
165 headerline("import database");
167 mvaddstr(3, 1, "please select a filter");
170 for(i=0; *i_filters[i].filtname ; i++)
171 mvprintw(5 + i, 6, "%c -\t%s\t%s\n", 'a' + i,
172 i_filters[i].filtname,
175 mvprintw(6 + i, 6, "x -\tcancel");
187 filter = getch() - 'a';
188 if(filter == 'x' - 'a' ||
189 filter >= number_of_input_filters() || filter < 0) {
194 mvaddstr(5+filter, 2, "->");
196 filename = ask_filename("Filename: ", 1);
202 if( i_read_file(filename, i_filters[filter].func ) )
203 statusline_msg("Error occured while opening the file");
206 statusline_msg("Hmm.., file seems not to be a valid file");
217 i_read_file(char *filename, int (*func) (FILE *in))
222 if( ( in = fopen( filename, "r" ) ) == NULL )
233 import(char filtname[FILTNAME_LEN], char *filename)
240 if( ! strncmp(i_filters[i].filtname, filtname, FILTNAME_LEN) )
242 if( ! *i_filters[i].filtname ) {
251 if( !strcmp(filename, "-") )
252 ret = (*i_filters[i].func) (stdin);
254 ret = i_read_file(filename, i_filters[i].func);
266 static int e_write_file(char *filename,
267 int (*func) (FILE *in, struct db_enumerator e), int mode);
277 refresh_statusline();
278 headerline("export database");
280 mvaddstr(3, 1, "please select a filter");
283 for(i=0; *e_filters[i].filtname ; i++)
284 mvprintw(5 + i, 6, "%c -\t%s\t%s\n", 'a' + i,
285 e_filters[i].filtname,
288 mvprintw(6 + i, 6, "x -\tcancel");
295 int enum_mode = ENUM_ALL;
300 filter = getch() - 'a';
301 if(filter == 'x' - 'a' ||
302 filter >= number_of_output_filters(e_filters) || filter < 0) {
307 mvaddstr(5+filter, 2, "->");
309 if( selected_items() ) {
310 statusline_addstr("Export All/Selected/Cancel (A/s/c)");
311 switch( tolower(getch()) ) {
313 enum_mode = ENUM_SELECTED;
322 filename = ask_filename("Filename: ", 0);
328 if( e_write_file(filename, e_filters[filter].func, enum_mode ) )
329 statusline_msg("Error occured while exporting");
338 e_write_file(char *filename, int (*func) (FILE *in, struct db_enumerator e),
343 struct db_enumerator enumerator = init_db_enumerator(mode);
345 if( (out = fopen(filename, "a")) == NULL )
351 ret = (*func) (out, enumerator);
359 fexport(char filtname[FILTNAME_LEN], FILE *handle, int enum_mode)
362 struct db_enumerator e = init_db_enumerator(enum_mode);
365 if( ! strncmp(e_filters[i].filtname, filtname, FILTNAME_LEN) )
367 if( ! *e_filters[i].filtname ) {
373 return (e_filters[i].func) (handle, e);
379 export(char filtname[FILTNAME_LEN], char *filename)
381 const int mode = ENUM_ALL;
384 struct db_enumerator e = init_db_enumerator(mode);
387 if( ! strncmp(e_filters[i].filtname, filtname, FILTNAME_LEN) )
389 if( ! *e_filters[i].filtname ) {
398 if( !strcmp(filename, "-") )
399 ret = (e_filters[i].func) (stdout, e);
401 ret = e_write_file(filename, e_filters[i].func, mode);
407 * end of common functions
416 static void ldif_fix_string(char *str);
418 #define LDIF_ITEM_FIELDS 15
420 typedef char* ldif_item[LDIF_ITEM_FIELDS];
422 static ldif_item ldif_field_names = {
433 "facsimiletelephonenumber",
437 "objectclass", /* this must be the last entry */
440 static int ldif_conv_table[LDIF_ITEM_FIELDS] = {
443 ADDRESS, /* "streetaddress" */
444 CITY, /* "locality" */
446 ZIP, /* "postalcode" */
447 COUNTRY, /* "countryname" */
448 PHONE, /* "homephone" */
449 NOTES, /* "description" */
451 FAX, /* "facsimiletelephonenumber" */
452 MOBILEPHONE, /* "cellphone" */
453 WORKPHONE, /* "xmozillaanyphone" */
454 NICK, /* "xmozillanickname" */
455 -1, /* "objectclass" */ /* this must be the last entry */
460 ldif_read_line(FILE *in)
473 if( feof(in) || !line )
482 fseek(in, pos, SEEK_SET);
492 buf = strconcat(buf, ptr, NULL);
506 ldif_add_item(ldif_item ldif_item)
508 list_item abook_item;
511 memset(abook_item, 0, sizeof(abook_item));
513 if( !ldif_item[LDIF_ITEM_FIELDS -1] )
517 for(i=0; i < LDIF_ITEM_FIELDS; i++) {
518 if(ldif_conv_table[i] >= 0 && ldif_item[i] && *ldif_item[i] )
519 abook_item[ldif_conv_table[i]] = strdup(ldif_item[i]);
522 add_item2database(abook_item);
525 for(i=0; i < LDIF_ITEM_FIELDS; i++)
526 my_free(ldif_item[i]);
531 ldif_convert(ldif_item item, char *type, char *value)
535 if( !strcmp(type, "dn") ) {
540 for(i=0; i < LDIF_ITEM_FIELDS; i++) {
541 if( !safe_strcmp(ldif_field_names[i], type) && *value ) {
542 if( i == LDIF_ITEM_FIELDS -1) /* this is a dirty hack */
543 if( safe_strcmp("person", value))
547 item[i] = strdup(value);
553 ldif_parse_file(FILE *handle)
560 memset(item, 0, sizeof(item));
563 if( ! (line = ldif_read_line(handle)) )
566 if( -1 == ( str_parse_line(line, &type, &value, &vlen)) ) {
568 continue; /* just skip the errors */
571 ldif_fix_string(value);
573 ldif_convert(item, type, value);
576 } while ( !feof(handle) );
578 ldif_convert(item, "dn", "");
584 ldif_fix_string(char *str)
588 for( i = 0, j = 0; j < strlen(str); i++, j++)
589 str[i] = ( str[j] == (char)0xc3 ?
590 (char) str[++j] + (char) 0x40 :
601 * mutt alias import filter
607 mutt_read_line(FILE *in, char **alias, char **rest)
609 char *line, *ptr, *tmp;
611 if( !(line = ptr = getaline(in)) )
612 return 1; /* error / EOF */
614 while( ISSPACE(*ptr) )
617 if( strncmp("alias", ptr, 5) ) {
624 while( ISSPACE(*ptr) )
629 while( ! ISSPACE(*ptr) )
632 if( (*alias = (char *)malloc(ptr-tmp+1)) == NULL) {
637 strncpy(*alias, tmp, ptr-tmp);
638 *(*alias + (ptr - tmp)) = 0;
640 while( ISSPACE(*ptr) )
650 mutt_parse_email(list_item item)
652 char *line = item[NAME];
653 char *start = line, *tmp;
657 tmp = strconcat("From: ", line, NULL);
658 getname(tmp, &name, &email);
670 while( (start = strchr(start, ',')) && i++ < MAX_EMAILS - 1) {
671 tmp = strconcat("From: ", ++start, NULL);
672 getname(tmp, &name, &email);
677 tmp = strconcat(item[EMAIL], ",", email, NULL);
688 mutt_parse_file(FILE *in)
693 memset(item, 0, sizeof(item));
695 if( !mutt_read_line(in, &item[NICK],
697 mutt_parse_email(item);
700 free_list_item(item);
704 add_item2database(item);
711 * end of mutt alias import filter
720 ldif_fput_type_and_value(FILE *out,char *type, char *value )
724 tmp = ldif_type_and_value(type, value, strlen(value));
732 ldif_export_database(FILE *out, struct db_enumerator e)
734 char email[MAX_EMAILSTR_LEN];
736 fprintf(out, "version: 1\n");
738 db_enumerate_items(e) {
741 get_first_email(email, e.item);
743 tmp = mkstr("cn=%s,mail=%s", database[e.item][NAME], email);
744 ldif_fput_type_and_value(out, "dn", tmp);
747 for(j=0; j < LDIF_ITEM_FIELDS; j++) {
748 if(ldif_conv_table[j] >= 0) {
749 if(ldif_conv_table[j] == EMAIL)
750 ldif_fput_type_and_value(out,
751 ldif_field_names[j], email);
752 else if(database[e.item][ldif_conv_table[j]])
753 ldif_fput_type_and_value(out,
755 database[e.item][ldif_conv_table[j]]);
759 fprintf(out, "objectclass: top\n"
760 "objectclass: person\n\n");
767 * end of ldif export filter
774 static void html_export_write_head(FILE *out, int extra_column);
775 static void html_export_write_tail(FILE *out);
778 html_export_database(FILE *out, struct db_enumerator e)
780 char tmp[MAX_EMAILSTR_LEN];
781 int extra_column = options_get_int("extra_column");
786 extra_column = (extra_column > 2 && extra_column < ITEM_FIELDS) ?
787 extra_column : PHONE;
789 html_export_write_head(out, extra_column);
791 db_enumerate_items(e) {
792 get_first_email(tmp, e.item);
794 fprintf(out, "<tr>\n<td><a href=\"mailto:%s\">%s</a>\n",
796 database[e.item][NAME] );
798 fprintf(out, "<tr>\n<td>%s>\n",
799 database[e.item][NAME] );
801 fprintf(out, "<td>%s\n<td>%s\n",
802 database[e.item][EMAIL],
803 safe_str(database[e.item][extra_column]) );
804 fprintf(out, "</tr>\n\n");
807 html_export_write_tail(out);
814 html_export_write_head(FILE *out, int extra_column)
816 char *realname = get_real_name();
818 fprintf(out, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
819 fprintf(out, "<html>\n<head>\n <title>%s's addressbook</title>",
821 fprintf(out, "\n</head>\n<body>\n");
822 fprintf(out, "\n<h2>%s's addressbook</h2>\n", realname );
823 fprintf(out, "<br><br>\n\n");
825 fprintf(out, "<center><table border>\n");
826 fprintf(out, "\n<tr><th>Name<th>E-mail address(es)<th>%s</tr>\n\n",
827 abook_fields[extra_column].name);
833 html_export_write_tail(FILE *out)
835 fprintf(out, "\n</table></center>\n");
836 fprintf(out, "\n</body>\n</html>\n");
840 * end of html export filter
845 * pine addressbook import filter
849 pine_fixbuf(char *buf)
853 for(i=0,j=0; j < strlen(buf); i++, j++)
854 buf[i] = buf[j] == '\n' ? buf[++j] : buf[j];
858 pine_convert_emails(char *s)
863 if( s == NULL || *s != '(' )
869 if( ( tmp = strchr(s,')')) )
872 for(i=1; ( tmp = strchr(s, ',') ) != NULL ; i++, s=tmp+1 )
873 if( i > MAX_EMAILS - 1 ) {
881 pine_parse_buf(char *buf)
888 int pine_conv_table[]= {NICK, NAME, EMAIL, -1, NOTES};
890 memset(&item, 0, sizeof(item) );
892 for(i=0, last=0; !last ; i++) {
893 if( ! (end = strchr(start, '\t')) )
896 len = last ? strlen(start) : (int) (end-start);
897 len = min(len, 400-1);
899 if(i < sizeof(pine_conv_table) / sizeof(*pine_conv_table)
900 && pine_conv_table[i] >= 0) {
901 strncpy(tmp, start, len);
903 item[pine_conv_table[i]] = strdup(tmp);
908 pine_convert_emails(item[EMAIL]);
909 add_item2database(item);
913 #define LINESIZE 1024
916 pine_parse_file(FILE *in)
923 fgets(line, LINESIZE, in);
927 buf = (char *) realloc(buf, i*LINESIZE);
930 fgets(line, LINESIZE, in);
932 if(*ptr != ' ' || feof(in) )
955 * end of pine addressbook import filter
960 * pine addressbook export filter
962 * filter doesn't wrap the lines as it should but Pine seems to handle
963 * created files without problems - JH
967 pine_export_database(FILE *out, struct db_enumerator e)
969 db_enumerate_items(e) {
970 fprintf(out, have_multiple_emails(e.item) ?
971 "%s\t%s\t(%s)\t\t%s\n" : "%s\t%s\t%s\t\t%s\n",
972 safe_str(database[e.item][NICK]),
973 safe_str(database[e.item][NAME]),
974 safe_str(database[e.item][EMAIL]),
975 safe_str(database[e.item][NOTES])
983 * end of pine addressbook export filter
992 * these files should be parsed according to a certain
993 * lay out, or the default if layout is not given, at
994 * the moment only default is done...
997 #define CSV_COMMENT_CHAR '#'
999 static int csv_conv_table[] = {
1008 csv_convert_emails(char *s)
1016 for(i=1; ( tmp = strchr(s, ',') ) != NULL ; i++, s = tmp + 1 )
1017 if( i > MAX_EMAILS - 1 ) {
1025 csv_remove_quotes(char *s)
1027 char *copy, *trimmed;
1030 copy = trimmed = strdup(s);
1033 len = strlen(trimmed);
1034 if(trimmed[len - 1] == '\"' && *trimmed == '\"') {
1039 trimmed[len - 1] = 0;
1041 trimmed = strdup(trimmed);
1051 csv_store_field(list_item item, char *s, int field)
1053 char *newstr = NULL;
1058 if( !(newstr = csv_remove_quotes(s)) )
1061 if(field < (sizeof(csv_conv_table) / sizeof(*csv_conv_table))
1062 && csv_conv_table[field] >= 0) {
1063 item[csv_conv_table[field]] = newstr;
1068 csv_is_valid_quote_end(char *p)
1076 else if(!ISSPACE(*p))
1084 csv_is_valid_quote_start(char *p)
1089 else if(!ISSPACE(*p))
1097 csv_parse_line(char *line)
1101 int in_quote = FALSE;
1104 memset(item, 0, sizeof(item));
1106 for(p = start = line, field = 0; *p; p++) {
1108 if(csv_is_valid_quote_end(p))
1111 if ( (((p - start) / sizeof (char)) < 2 ) &&
1112 csv_is_valid_quote_start(p) )
1116 if( *p == ',' && !in_quote) {
1118 csv_store_field(item, start, field);
1126 csv_store_field(item, start, field);
1128 csv_convert_emails(item[EMAIL]);
1129 add_item2database(item);
1134 csv_parse_file(FILE *in)
1139 line = getaline(in);
1141 if(line && *line && *line != CSV_COMMENT_CHAR)
1142 csv_parse_line(line);
1151 * end of csv import filter
1155 * csv addressbook export filter
1159 csv_export_database(FILE *out, struct db_enumerator e)
1162 int csv_export_fields[] = {
1171 db_enumerate_items(e) {
1172 for(j = 0; csv_export_fields[j] >= 0; j++) {
1174 strchr(safe_str(database[e.item][csv_export_fields[j]]), ',') ||
1175 strchr(safe_str(database[e.item][csv_export_fields[j]]), '\"')
1178 safe_str(database[e.item][csv_export_fields[j]])
1180 if(csv_export_fields[j+1] >= 0)
1192 * end of csv export filter
1197 * GnomeCard (VCard) addressbook export filter
1201 gcrd_export_database(FILE *out, struct db_enumerator e)
1203 char emails[MAX_EMAILS][MAX_EMAIL_LEN];
1207 db_enumerate_items(e) {
1208 fprintf(out, "BEGIN:VCARD\nFN:%s\n",
1209 safe_str(database[e.item][NAME]));
1211 name = get_surname(database[e.item][NAME]);
1212 for( j = strlen(database[e.item][NAME]) - 1; j >= 0; j-- ) {
1213 if(database[e.item][NAME][j] == ' ')
1216 fprintf(out, "N:%s;%.*s\n",
1219 safe_str(database[e.item][NAME])
1224 if ( database[e.item][ADDRESS] )
1225 fprintf(out, "ADR:;;%s;%s;%s;%s;%s\n",
1226 safe_str(database[e.item][ADDRESS]),
1227 safe_str(database[e.item][CITY]),
1228 safe_str(database[e.item][STATE]),
1229 safe_str(database[e.item][ZIP]),
1230 safe_str(database[e.item][COUNTRY])
1233 if (database[e.item][PHONE])
1234 fprintf(out, "TEL;HOME:%s\n", database[e.item][PHONE]);
1235 if (database[e.item][WORKPHONE])
1236 fprintf(out, "TEL;WORK:%s\n", database[e.item][WORKPHONE]);
1237 if (database[e.item][FAX])
1238 fprintf(out, "TEL;FAX:%s\n", database[e.item][FAX]);
1239 if (database[e.item][MOBILEPHONE])
1240 fprintf(out, "TEL;CELL:%s\n", database[e.item][MOBILEPHONE]);
1242 if ( database[e.item][EMAIL] ) {
1243 split_emailstr(e.item, emails);
1244 for(j=0; j < MAX_EMAILS ; j++) {
1246 fprintf(out, "EMAIL;INTERNET:%s\n",
1251 if ( database[e.item][NOTES] )
1252 fprintf(out, "NOTE:%s\n", database[e.item][NOTES]);
1253 if (database[e.item][URL])
1254 fprintf(out, "URL:%s\n", database[e.item][URL]);
1256 fprintf(out, "END:VCARD\n\n");
1264 * end of GnomeCard export filter
1269 * mutt alias export filter
1273 mutt_alias_genalias(int i)
1277 if(database[i][NICK])
1278 return strdup(database[i][NICK]);
1280 tmp = strdup(database[i][NAME]);
1282 if( ( pos = strchr(tmp, ' ') ) )
1291 mutt_alias_export(FILE *out, struct db_enumerator e)
1293 char email[MAX_EMAIL_LEN];
1296 db_enumerate_items(e) {
1297 alias = mutt_alias_genalias(e.item);
1299 get_first_email(email, e.item);
1300 fprintf(out, *email ? "alias %s %s <%s>\n": "alias %s %s%s\n",
1302 database[e.item][NAME],
1311 * end of mutt alias export filter
1316 * printable export filter
1321 text_write_address_us(FILE *out, int i) {
1322 fprintf(out, "\n%s", database[i][ADDRESS]);
1324 if (database[i][CITY])
1325 fprintf(out, "\n%s", database[i][CITY]);
1327 if (database[i][STATE] || database[i][ZIP]) {
1330 if(database[i][STATE]) {
1331 fprintf(out, "%s", database[i][STATE]);
1332 if(database[i][ZIP])
1336 if(database[i][ZIP])
1337 fprintf(out, "%s", database[i][ZIP]);
1340 if (database[i][COUNTRY])
1341 fprintf(out, "\n%s", database[i][COUNTRY]);
1346 text_write_address_uk(FILE *out, int i) {
1349 for (j = ADDRESS; j <= COUNTRY; j++)
1351 fprintf(out, "\n%s", database[i][j]);
1355 text_write_address_eu(FILE *out, int i) {
1356 fprintf(out, "\n%s", database[i][ADDRESS]);
1358 if (database[i][ZIP] || database[i][CITY]) {
1361 if(database[i][ZIP]) {
1362 fprintf(out, "%s", database[i][ZIP]);
1363 if(database[i][CITY])
1367 if(database[i][CITY])
1368 fprintf(out, "%s", database[i][CITY]);
1371 if (database[i][STATE])
1372 fprintf(out, "\n%s", database[i][STATE]);
1374 if (database[i][COUNTRY])
1375 fprintf(out, "\n%s", database[i][COUNTRY]);
1379 text_export_database(FILE * out, struct db_enumerator e)
1381 char emails[MAX_EMAILS][MAX_EMAIL_LEN];
1383 char *realname = get_real_name();
1384 char *style = options_get_str("address_style");
1387 "-----------------------------------------\n%s's address book\n"
1388 "-----------------------------------------\n\n\n",
1392 db_enumerate_items(e) {
1394 "-----------------------------------------\n\n");
1395 fprintf(out, "%s", database[e.item][NAME]);
1396 if (database[e.item][NICK])
1397 fprintf(out, "\n(%s)", database[e.item][NICK]);
1400 if (*database[e.item][EMAIL]) {
1402 split_emailstr(e.item, emails);
1403 for (j = 0; j < MAX_EMAILS; j++)
1405 fprintf(out, "%s\n", emails[j]);
1408 if (database[e.item][ADDRESS]) {
1409 if (!safe_strcmp(style, "us")) /* US like */
1410 text_write_address_us(out, e.item);
1411 else if (!safe_strcmp(style, "uk")) /* UK like */
1412 text_write_address_uk(out, e.item);
1414 text_write_address_eu(out, e.item);
1419 if ((database[e.item][PHONE]) ||
1420 (database[e.item][WORKPHONE]) ||
1421 (database[e.item][FAX]) ||
1422 (database[e.item][MOBILEPHONE])) {
1424 for (j = PHONE; j <= MOBILEPHONE; j++)
1425 if (database[e.item][j])
1426 fprintf(out, "%s: %s\n",
1427 abook_fields[j].name,
1428 database[e.item][j]);
1431 if (database[e.item][URL])
1432 fprintf(out, "\n%s\n", database[e.item][URL]);
1433 if (database[e.item][NOTES])
1434 fprintf(out, "\n%s\n", database[e.item][NOTES]);
1439 fprintf(out, "-----------------------------------------\n");
1445 * end of printable export filter
1449 * elm alias export filter
1453 elm_alias_export(FILE *out, struct db_enumerator e)
1455 char email[MAX_EMAIL_LEN];
1458 db_enumerate_items(e) {
1459 alias = mutt_alias_genalias(e.item);
1460 get_first_email(email, e.item);
1461 fprintf(out, "%s = %s = %s\n",
1463 database[e.item][NAME],
1472 * end of elm alias export filter
1477 * Spruce export filter
1481 spruce_export_database (FILE *out, struct db_enumerator e)
1483 char email[MAX_EMAIL_LEN];
1485 fprintf (out, "# This is a generated file made by abook for the Spruce e-mail client.\n\n");
1487 db_enumerate_items(e) {
1488 if(strcmp (safe_str(database[e.item][EMAIL]), "")) {
1489 get_first_email(email, e.item);
1490 fprintf(out, "# Address %d\nName: %s\nEmail: %s\nMemo: %s\n\n",
1492 database[e.item][NAME],
1494 safe_str(database[e.item][NOTES])
1499 fprintf (out, "# End of address book file.\n");
1505 * end of Spruce export filter