db_enumerate_items(e) {
get_first_email(tmp, e.item);
- fprintf(out, "<tr>\n<td><a href=\"mailto:%s\">%s</a>\n",
- tmp,
- database[e.item][NAME] );
-
+ if (*tmp)
+ fprintf(out, "<tr>\n<td><a href=\"mailto:%s\">%s</a>\n",
+ tmp,
+ database[e.item][NAME] );
+ else
+ fprintf(out, "<tr>\n<td>%s>\n",
+ database[e.item][NAME] );
+
fprintf(out, "<td>%s\n<td>%s\n",
database[e.item][EMAIL],
safe_str(database[e.item][extra_column]) );
*tmp=0;
for(i=1; ( tmp = strchr(s, ',') ) != NULL ; i++, s=tmp+1 )
- if( i > 3 ) {
+ if( i > MAX_EMAILS - 1 ) {
*tmp = 0;
break;
}
strcat(buf, ptr);
}
- if( *buf == '#' )
+ if( *buf == '#' ) {
+ my_free(buf);
continue;
+ }
pine_fixbuf(buf);
pine_parse_buf(buf);
* printable export filter
*/
+
+static void
+text_write_address_us(FILE *out, int i) {
+ fprintf(out, "\n%s", database[i][ADDRESS]);
+
+ if (database[i][CITY])
+ fprintf(out, "\n%s", database[i][CITY]);
+
+ if (database[i][STATE] || database[i][ZIP]) {
+ fputc('\n', out);
+
+ if(database[i][STATE]) {
+ fprintf(out, "%s", database[i][STATE]);
+ if(database[i][ZIP])
+ fputc(' ', out);
+ }
+
+ if(database[i][ZIP])
+ fprintf(out, "%s", database[i][ZIP]);
+ }
+
+ if (database[i][COUNTRY])
+ fprintf(out, "\n%s", database[i][COUNTRY]);
+}
+
+
+static void
+text_write_address_uk(FILE *out, int i) {
+ int j;
+
+ for (j = ADDRESS; j <= COUNTRY; j++)
+ if (database[i][j])
+ fprintf(out, "\n%s", database[i][j]);
+}
+
+static void
+text_write_address_eu(FILE *out, int i) {
+ fprintf(out, "\n%s", database[i][ADDRESS]);
+
+ if (database[i][ZIP] || database[i][CITY]) {
+ fputc('\n', out);
+
+ if(database[i][ZIP]) {
+ fprintf(out, "%s", database[i][ZIP]);
+ if(database[i][CITY])
+ fputc(' ', out);
+ }
+
+ if(database[i][CITY])
+ fprintf(out, "%s", database[i][CITY]);
+ }
+
+ if (database[i][STATE])
+ fprintf(out, "\n%s", database[i][STATE]);
+
+ if (database[i][COUNTRY])
+ fprintf(out, "\n%s", database[i][COUNTRY]);
+}
+
static int
text_export_database(FILE * out, struct db_enumerator e)
{
}
/* Print address */
if (database[e.item][ADDRESS]) {
- if (!safe_strcmp(style, "us")) { /* US like */
- fprintf(out, "\n%s", database[e.item][ADDRESS]);
- if (database[e.item][CITY])
- fprintf(out, "\n%s",
- database[e.item][CITY]);
- if (database[e.item][STATE] || database[e.item][ZIP])
- fprintf(out, "\n%s %s",
- safe_str(database[e.item]
- [STATE]),
- safe_str(database[e.item]
- [ZIP]));
- if (database[e.item][COUNTRY])
- fprintf(out, "\n%s",
- database[e.item][COUNTRY]);
- }
-
- else if (!safe_strcmp(style, "uk")) { /* UK like */
- for (j = ADDRESS; j <= COUNTRY; j++)
- if (database[e.item][j])
- fprintf(out, "\n%s",
- database[e.item][j]);
- } else { /* EU like */
- fprintf(out, "\n%s", database[e.item][ADDRESS]);
- if (database[e.item][ZIP] ||
- database[e.item][CITY])
- fprintf(out, "\n%s %s",
- safe_str(database[e.item][ZIP]),
- safe_str(database[e.item]
- [CITY]));
- if (database[e.item][STATE])
- fprintf(out, "\n%s",
- database[e.item][STATE]);
- if (database[e.item][COUNTRY])
- fprintf(out, "\n%s",
- database[e.item][COUNTRY]);
- }
+ if (!safe_strcmp(style, "us")) /* US like */
+ text_write_address_us(out, e.item);
+ else if (!safe_strcmp(style, "uk")) /* UK like */
+ text_write_address_uk(out, e.item);
+ else /* EU like */
+ text_write_address_eu(out, e.item);
fprintf(out, "\n");
}