From ceba9214d8bebe32d0c34c7a82916bcb9d798d69 Mon Sep 17 00:00:00 2001 From: Jaakko Heinonen Date: Sun, 10 Feb 2002 10:07:16 +0000 Subject: [PATCH] *** empty log message *** --- abook.c | 39 +++++++++++++++++++-------------------- abook.h | 4 ++-- edit.c | 14 +++++++------- options.h | 2 +- ui.c | 34 ++++++++++++++++++++-------------- ui.h | 2 +- 6 files changed, 50 insertions(+), 45 deletions(-) diff --git a/abook.c b/abook.c index acf95ca..4808dac 100644 --- a/abook.c +++ b/abook.c @@ -68,7 +68,7 @@ check_abook_directory() { struct stat s; char *dir; - + assert(!is_ui_initialized()); if(alternative_datafile) @@ -76,7 +76,7 @@ check_abook_directory() dir = strconcat(getenv("HOME"), "/" DIR_IN_HOME, NULL); assert(dir != NULL); - + if(stat(dir, &s) == -1) { if(errno != ENOENT) { perror(dir); @@ -107,10 +107,10 @@ init_abook() signal(SIGKILL, quit_abook_sig); signal(SIGTERM, quit_abook_sig); - + if( init_ui() ) exit(1); - + umask(DEFAULT_UMASK); if(!datafile_writeable()) { @@ -144,7 +144,7 @@ quit_abook() close_database(); close_ui(); - + exit(0); } @@ -160,13 +160,13 @@ main(int argc, char **argv) #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; @@ -230,11 +230,11 @@ void 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; @@ -416,7 +416,7 @@ muttq_print_item(FILE *file, int item) int i; split_emailstr(item, emails); - + for(i = 0; i < (options_get_int("mutt_return_all_emails") ? MAX_EMAILS : 1) ; i++) if( *emails[i] ) @@ -459,7 +459,7 @@ init_mutt_query() { set_filenames(); init_options(); - + if( load_database(datafile) ) { printf("Cannot open database\n"); quit_mutt_query(1); @@ -482,7 +482,7 @@ make_mailstr(int item) strdup(name); free(name); - + return ret; } @@ -533,7 +533,7 @@ launch_mutt(int item) #endif system(cmd); free(cmd); - + /* * we need to make sure that curses settings are correct */ @@ -603,18 +603,17 @@ FILE * 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) { @@ -703,7 +702,7 @@ init_add_email() atexit(free_filenames); init_options(); atexit(close_config); - + /* * we don't actually care if loading fails or not */ @@ -755,7 +754,7 @@ add_email(int quiet) { char *line; char *name = NULL, *email = NULL; - + init_add_email(); do { diff --git a/abook.h b/abook.h index 1ca9962..d9f401c 100644 --- a/abook.h +++ b/abook.h @@ -23,8 +23,8 @@ int strncasecmp (const char *, const char *, size_t); #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 diff --git a/edit.c b/edit.c index b2e7508..5edebec 100644 --- a/edit.c +++ b/edit.c @@ -120,12 +120,12 @@ print_editor_header(int item) { 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], @@ -165,7 +165,7 @@ editor_print_data(int tab, int item) } continue; } - + if(j > 1) { getyx(editw, y, x); y++; } else @@ -203,10 +203,10 @@ change_field(char *msg, char **field) 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); @@ -264,7 +264,7 @@ edit_emails(char c, int item) fix_email_str(emails[c - '2']); } else *emails[c - '2'] = 0; - + my_free(database[item][EMAIL]); for(i = 0; i < MAX_EMAILS; i++) { @@ -361,7 +361,7 @@ edit_loop(int item) { static int tab = 0; /* first tab */ int c; - + werase(editw); headerline(EDITOR_HELPLINE); refresh_statusline(); diff --git a/options.h b/options.h index 0dc7e17..e458314 100644 --- a/options.h +++ b/options.h @@ -1,7 +1,7 @@ #ifndef _OPTIONS_H #define _OPTIONS_H -#define RCFILE "abookrc.0" +#define RCFILE "abookrc" #define SYSWIDE_RCFILE "/etc/abookrc" #include "conff.h" diff --git a/ui.c b/ui.c index 1630a82..ad781e5 100644 --- a/ui.c +++ b/ui.c @@ -63,7 +63,7 @@ static void init_windows() { top = newwin(LIST_TOP - 1, COLS, 0, 0); - + bottom = newwin(LINES - LIST_BOTTOM, COLS, LIST_BOTTOM, 0); } @@ -184,15 +184,15 @@ void 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() @@ -204,7 +204,7 @@ refresh_screen() } #endif clear(); - + refresh_statusline(); headerline(MAIN_HELPLINE); list_headerline(); @@ -213,16 +213,20 @@ refresh_screen() } -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 @@ -263,13 +267,13 @@ statusline_getnstr(char *str, int n, int use_filesel) 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 @@ -287,7 +291,7 @@ statusline_ask_boolean(char *msg, int def) { int ret; char *msg2 = strconcat(msg, def ? " (Y/n)?" : " (y/N)?", NULL); - + statusline_addstr(msg2); free(msg2); @@ -321,7 +325,7 @@ refresh_statusline() refresh(); wrefresh(bottom); } - + char * ask_filename(char *prompt, int flags) @@ -329,7 +333,7 @@ ask_filename(char *prompt, int flags) char *buf = NULL; clear_statusline(); - + statusline_addstr(prompt); buf = statusline_getnstr(NULL, -1, flags); @@ -373,7 +377,7 @@ display_help(int help) 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) ) ) || @@ -381,7 +385,9 @@ display_help(int help) refresh(); wrefresh(helpw); refresh_statusline(); - statusline_msg("Press any key to continue..."); + if(statusline_msg("Press any key to continue...") + == 'q') + break; wclear(helpw); } } diff --git a/ui.h b/ui.h index 5c3cac1..8320079 100644 --- a/ui.h +++ b/ui.h @@ -14,7 +14,7 @@ int init_ui(); 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(); -- 2.39.2