char *datafile = NULL;
char *rcfile = NULL;
-int alternative_datafile = FALSE;
-int alternative_rcfile = FALSE;
+bool alternative_datafile = FALSE;
+bool alternative_rcfile = FALSE;
static int
datafile_writeable()
{
struct stat s;
char *dir;
-
+
assert(!is_ui_initialized());
if(alternative_datafile)
dir = strconcat(getenv("HOME"), "/" DIR_IN_HOME, NULL);
assert(dir != NULL);
-
+
if(stat(dir, &s) == -1) {
if(errno != ENOENT) {
perror(dir);
signal(SIGKILL, quit_abook_sig);
signal(SIGTERM, quit_abook_sig);
-
+
if( init_ui() )
exit(1);
-
+
umask(DEFAULT_UMASK);
if(!datafile_writeable()) {
close_database();
close_ui();
-
+
exit(0);
}
#if defined(HAVE_SETLOCALE) && defined(HAVE_LOCALE_H)
setlocale(LC_ALL, "" );
#endif
-
+
parse_command_line(argc, argv);
-
+
init_abook();
get_commands();
-
+
quit_abook();
return 0;
set_filename(char **var, char *path)
{
char *cwd;
-
+
assert(var != NULL);
assert(*var == NULL); /* or else we probably leak memory */
assert(path != NULL);
-
+
if(*path == '/') {
*var = strdup(path);
return;
int i;
split_emailstr(item, emails);
-
+
for(i = 0; i < (options_get_int("mutt_return_all_emails") ?
MAX_EMAILS : 1) ; i++)
if( *emails[i] )
{
set_filenames();
init_options();
-
+
if( load_database(datafile) ) {
printf("Cannot open database\n");
quit_mutt_query(1);
strdup(name);
free(name);
-
+
return ret;
}
#endif
system(cmd);
free(cmd);
-
+
/*
* we need to make sure that curses settings are correct
*/
abook_fopen (const char *path, const char *mode)
{
struct stat s;
-
+
if( ! strchr(mode, 'r') )
return fopen(path, mode);
-
+
if ( (stat(path, &s)) == -1 )
return NULL;
-
+
return S_ISREG(s.st_mode) ? fopen(path, mode) : NULL;
}
-
static void
convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile)
{
atexit(free_filenames);
init_options();
atexit(close_config);
-
+
/*
* we don't actually care if loading fails or not
*/
{
char *line;
char *name = NULL, *email = NULL;
-
+
init_add_email();
do {