#include <string.h>
#include <ctype.h>
#include <pwd.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include "abook_curses.h"
#include "filter.h"
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 )
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 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"