#include <string.h>
#include <ctype.h>
#include <pwd.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include "abook_curses.h"
#include "filter.h"
mvaddstr(5+filter, 2, "->");
- filename = ask_filename("Filename: ", 1);
+ filename = ask_filename("Filename: ");
if( !filename ) {
refresh_screen();
return 2;
if( i_read_file(filename, i_filters[filter].func ) )
statusline_msg("Error occured while opening the file");
- else
- if( tmp == items )
+ else if( tmp == items )
statusline_msg("Hmm.., file seems not to be a valid file");
refresh_screen();
FILE *in;
int ret = 0;
- if( ( in = fopen( filename, "r" ) ) == NULL )
+ if( ( in = abook_fopen( filename, "r" ) ) == NULL )
return 1;
ret = (*func) (in);
if( i<0 )
return -1;
- if( !strcmp(filename, "-") )
- ret = (*i_filters[i].func) (stdin);
- else
+ if( !strcmp(filename, "-") ) {
+ struct stat s;
+ if( (fstat(fileno(stdin), &s)) == -1 || S_ISDIR(s.st_mode))
+ ret = 1;
+ else
+ ret = (*i_filters[i].func) (stdin);
+ } else
ret = i_read_file(filename, i_filters[i].func);
if( tmp == items )
clear_statusline();
}
- filename = ask_filename("Filename: ", 0);
+ filename = ask_filename("Filename: ");
if( !filename ) {
refresh_screen();
return 2;
free(line);
}
- if( *buf == '#' ) {
+ if(buf && *buf == '#' ) {
free(buf);
return NULL;
}
static void html_export_write_head(FILE *out, int extra_column);
static void html_export_write_tail(FILE *out);
+extern int extra_column;
+
static int
html_export_database(FILE *out, struct db_enumerator e)
{
char tmp[MAX_EMAILSTR_LEN];
- int extra_column = options_get_int("extra_column");
if( items < 1 )
return 2;
{
char *realname = get_real_name();
- fprintf(out, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
- fprintf(out, "<html>\n<head>\n <title>%s's addressbook</title>",
- realname );
+ fprintf(out, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n");
+ fprintf(out, "<html>\n<head>\n <title>%s's addressbook</title>", realname );
fprintf(out, "\n</head>\n<body>\n");
fprintf(out, "\n<h2>%s's addressbook</h2>\n", realname );
fprintf(out, "<br><br>\n\n");
- fprintf(out, "<center><table border>\n");
+ fprintf(out, "<table border=\"1\" align=\"center\">\n");
fprintf(out, "\n<tr><th>Name<th>E-mail address(es)<th>%s</tr>\n\n",
abook_fields[extra_column].name);
static void
html_export_write_tail(FILE *out)
{
- fprintf(out, "\n</table></center>\n");
+ fprintf(out, "\n</table>\n");
fprintf(out, "\n</body>\n</html>\n");
}
{
char *p, *start;
int field;
- int in_quote = FALSE;
+ bool in_quote = FALSE;
list_item item;
memset(item, 0, sizeof(item));
char emails[MAX_EMAILS][MAX_EMAIL_LEN];
int j;
char *realname = get_real_name();
- char *style = options_get_str("address_style");
+ char *style = opt_get_str(STR_ADDRESS_STYLE);
fprintf(out,
"-----------------------------------------\n%s's address book\n"