{
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 {
#define MIN_COLS 70
#define DEFAULT_UMASK 066
-#define DIR_IN_HOME ".abook.dev"
-#define DATAFILE "addressbook.0"
+#define DIR_IN_HOME ".abook"
+#define DATAFILE "addressbook"
/*
* some "abookwide" useful macros
{
char *header;
char email[MAX_EMAIL_LEN];
-
+
if( (header = (char *)malloc(EDITW_COLS)) == NULL )
return;
get_first_email(email, item);
-
+
if( *database[item][EMAIL] )
snprintf(header, EDITW_COLS, "%s <%s>",
database[item][NAME],
}
continue;
}
-
+
if(j > 1) {
getyx(editw, y, x); y++;
} else
char tmp[MAX_FIELD_LEN];
int max_len = MAX_FIELD_LEN;
int ret;
-
+
if( !strncmp("E-mail", msg, 6) )
max_len = MAX_EMAIL_LEN;
-
+
statusline_addstr(msg);
if( (ret = statusline_getnstr( tmp, max_len - 1, 0 ) ? 1:0 ) ) {
my_free(*field);
fix_email_str(emails[c - '2']);
} else
*emails[c - '2'] = 0;
-
+
my_free(database[item][EMAIL]);
for(i = 0; i < MAX_EMAILS; i++) {
{
static int tab = 0; /* first tab */
int c;
-
+
werase(editw);
headerline(EDITOR_HELPLINE);
refresh_statusline();
#ifndef _OPTIONS_H
#define _OPTIONS_H
-#define RCFILE "abookrc.0"
+#define RCFILE "abookrc"
#define SYSWIDE_RCFILE "/etc/abookrc"
#include "conff.h"
init_windows()
{
top = newwin(LIST_TOP - 1, COLS, 0, 0);
-
+
bottom = newwin(LINES - LIST_BOTTOM, COLS, LIST_BOTTOM, 0);
}
headerline(char *str)
{
werase(top);
-
+
mvwhline(top, 1, 0, UI_HLINE_CHAR, COLS);
-
+
mvwprintw(top, 0, 0, "%s | %s", PACKAGE " " VERSION, str);
refresh();
wrefresh(top);
}
-
+
void
refresh_screen()
}
#endif
clear();
-
+
refresh_statusline();
headerline(MAIN_HELPLINE);
list_headerline();
}
-void
+int
statusline_msg(char *msg)
{
+ int c;
+
clear_statusline();
statusline_addstr(msg);
- getch();
+ c = getch();
#ifdef DEBUG
fprintf(stderr, "statusline_msg(\"%s\")\n", msg);
#endif
clear_statusline();
+
+ return c;
}
void
getyx(bottom, y, x);
wmove(bottom, 1, x);
-
+
buf = wenter_string(bottom, n,
(use_filesel ? ESTR_USE_FILESEL:0) | ESTR_DONT_WRAP);
if(n < 0)
return buf;
-
+
if(buf == NULL)
str[0] = 0;
else
{
int ret;
char *msg2 = strconcat(msg, def ? " (Y/n)?" : " (y/N)?", NULL);
-
+
statusline_addstr(msg2);
free(msg2);
refresh();
wrefresh(bottom);
}
-
+
char *
ask_filename(char *prompt, int flags)
char *buf = NULL;
clear_statusline();
-
+
statusline_addstr(prompt);
buf = statusline_getnstr(NULL, -1, flags);
helpw = newwin(LINES - 5, COLS - 6, 2, 3);
erase();
headerline("help");
-
+
for( i = 0; tbl[i] != NULL; i++) {
waddstr(helpw, tbl[i]);
if( ( !( (i+1) % (LINES-8) ) ) ||
refresh();
wrefresh(helpw);
refresh_statusline();
- statusline_msg("Press any key to continue...");
+ if(statusline_msg("Press any key to continue...")
+ == 'q')
+ break;
wclear(helpw);
}
}
void close_ui();
void headerline(char *str);
void refresh_screen();
-void statusline_msg(char *msg);
+int statusline_msg(char *msg);
char *ask_filename(char *prompt, int flags);
int statusline_ask_boolean(char *msg, int def);
void clear_statusline();