*
* by JH <jheinonen@bigfoot.com>
*
- * Copyright (C) 1999, 2000 Jaakko Heinonen
+ * Copyright (C) Jaakko Heinonen
*/
#include <string.h>
#include <sys/stat.h>
#include <signal.h>
#include <fcntl.h>
-#include "abook_curses.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE)
# include <locale.h>
#endif
-#ifdef HAVE_TERMIOS_H
-# include <termios.h>
-#else
-# ifdef HAVE_LINUX_TERMIOS_H
-# include <linux/termios.h>
-# endif
-#endif
-#ifdef HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
#include "abook.h"
+#include "ui.h"
#include "database.h"
#include "list.h"
#include "filter.h"
#include "edit.h"
#include "misc.h"
-#include "help.h"
#include "options.h"
-#include "estr.h"
static void init_abook();
static void set_filenames();
static void free_filenames();
-static void display_help(char **tbl);
-static void get_commands();
static void parse_command_line(int argc, char **argv);
static void show_usage();
static void mutt_query(char *str);
static void init_mutt_query();
static void quit_mutt_query();
-static void launch_mutt();
-static void launch_lynx();
-static void win_changed(int dummy);
-static void open_datafile();
-#ifdef SIGWINCH
-static void resize_abook();
-#endif
static void convert(char *srcformat, char *srcfile,
char *dstformat, char *dstfile);
-int should_resize = FALSE;
-int can_resize = FALSE;
-
char *datafile = NULL;
char *rcfile = NULL;
-WINDOW *top = NULL, *bottom = NULL;
-
-static void
-init_windows()
-{
- top = newwin(LIST_TOP - 1, COLS, 0, 0);
-
- bottom = newwin(LINES - LIST_BOTTOM, COLS, LIST_BOTTOM, 0);
-}
-
-static void
-free_windows()
-{
- delwin(top);
- delwin(bottom);
-}
-
static void
init_abook()
{
set_filenames();
init_options();
- initscr(); cbreak(); noecho();
- nonl();
- intrflush(stdscr, FALSE);
- keypad(stdscr, TRUE);
-#ifdef DEBUG
- fprintf(stderr, "init_abook():\n");
- fprintf(stderr, " COLS = %d, LINES = %d\n", COLS, LINES);
-#endif
- if( LINES < MIN_LINES || COLS < MIN_COLS ) {
- clear(); refresh(); endwin();
- fprintf(stderr, "Your terminal size is %dx%d\n", COLS, LINES);
- fprintf(stderr, "Terminal is too small. Minium terminal size "
- "for abook is "
- "%dx%d\n", MIN_COLS, MIN_LINES);
- exit(1);
- }
- umask(DEFAULT_UMASK);
-#ifdef SIGWINCH
- signal(SIGWINCH, win_changed);
-#endif
signal(SIGINT, quit_abook);
signal(SIGKILL, quit_abook);
signal(SIGTERM, quit_abook);
- init_list();
- init_windows();
+ if( init_ui() )
+ exit(1);
+
+ umask(DEFAULT_UMASK);
/*
* this is very ugly for now
}
close_config();
close_database();
- close_list();
- free_windows();
- clear();
- refresh();
- endwin();
+ close_ui();
+
exit(0);
}
my_free(datafile);
}
-void
-headerline(char *str)
-{
- werase(top);
-
- mvwhline(top, 1, 0, ACS_HLINE, COLS);
-
- mvwprintw(top, 0, 0, "%s | %s", PACKAGE " " VERSION, str);
-
- refresh();
- wrefresh(top);
-}
-
-
-void
-refresh_screen()
-{
-#ifdef SIGWINCH
- if( should_resize ) {
- resize_abook();
- return;
- }
-#endif
- clear();
-
- refresh_statusline();
- headerline(MAIN_HELPLINE);
- list_headerline();
-
- refresh_list();
-}
-
-#ifdef DEBUG
-extern int curitem;
-extern list_item *database;
-static void
-dump_item()
-{
- int i;
-
- fprintf(stderr,"sizeof(list_item) = %d\n", sizeof(list_item));
- fprintf(stderr,"--- dumping item %d ---\n", curitem);
-
- for(i=0; i<ITEM_FIELDS; i++)
- fprintf(stderr,"%d - %d\n",
- i, (int)database[curitem][i]);
-
- fprintf(stderr,"--- end of dump ---\n");
-
-}
-#endif
-
-extern char *selected;
-extern int curitem;
-
-static void
-get_commands()
-{
- int ch;
-
- for(;;) {
- can_resize = TRUE; /* it's safe to resize now */
- hide_cursor();
- if( should_resize )
- refresh_screen();
- ch = getch();
- show_cursor();
- can_resize = FALSE; /* it's not safe to resize anymore */
- switch( ch ) {
- case 'q': return;
- case '?': display_help(mainhelp); break;
- case 'a': add_item(); break;
- case '\r': edit_item(-1); break;
- case KEY_DC:
- case 'd':
- case 'r': remove_items(); break;
- case 12: refresh_screen(); break;
-
- case 'k':
- case KEY_UP: scroll_up(); break;
- case 'j':
- case KEY_DOWN: scroll_down(); break;
- case 'K':
- case KEY_PPAGE: page_up(); break;
- case 'J':
- case KEY_NPAGE: page_down(); break;
-
- case 'H':
- case KEY_HOME: goto_home(); break;
- case 'E':
- case KEY_END: goto_end(); break;
-
- case 'w': save_database();
- break;
- case 'l': read_database(); break;
- case 'i': import_database(); break;
- case 'e': export_database(); break;
- case 'C': clear_database(); break;
-
- case 'y': edit_options(); break;
- case 'o': open_datafile(); break;
-
- case 's': sort_database(); break;
- case 'S': sort_surname(); break;
-
- case '/': find(0); break;
- case '\\': find(1); break;
-
- case ' ': if(curitem >= 0) {
- selected[curitem] = !selected[curitem];
- print_number_of_items();
- refresh_list();
- }
- break;
- case '+': select_all();
- refresh_list();
- break;
- case '-': select_none();
- refresh_list();
- break;
- case '*': invert_selection();
- refresh_list();
- break;
- case 'A': move_curitem(MOVE_ITEM_UP);
- break;
- case 'Z': move_curitem(MOVE_ITEM_DOWN);
- break;
-
- case 'm': launch_mutt(); break;
-
- case 'p': print_database(); break;
-
- case 'u': launch_lynx(); break;
-#ifdef DEBUG
- case 'D': dump_item();
-#endif
- }
- }
-}
-
-
-static void
-display_help(char **tbl)
-{
- int i, j = 3;
-
- erase();
- headerline("help");
- refresh_statusline();
-
- for( i = 0; tbl[i] != NULL; i++) {
- mvaddstr(j++, 0, tbl[i]);
- if( ( !( (i+1) % (LINES-7) ) ) ||
- (tbl[i+1] == NULL) ) {
- refresh();
- statusline_msg("Press any key to continue...");
- erase();
- refresh_statusline();
- headerline("help");
- j = 3;
- }
- }
- refresh_screen();
-}
-
-void
-display_editor_help(WINDOW *w)
-{
- int i;
-
- werase(w);
-
- headerline("editor help");
-
- for( i = 0; editorhelp[i] != NULL; i++) {
- waddstr(w, editorhelp[i]);
- if( ( !( (i+1) % (LINES-8) ) ) ||
- (editorhelp[i+1] == NULL) ) {
- refresh();
- wrefresh(w);
- statusline_msg("Press any key to continue...");
- wclear(w);
- }
- }
-}
-
-
-void
-statusline_msg(char *msg)
-{
- clear_statusline();
- statusline_addstr(msg);
- getch();
-#ifdef DEBUG
- fprintf(stderr, "statusline_msg(\"%s\")\n", msg);
-#endif
- clear_statusline();
-}
-
-void
-statusline_addstr(char *str)
-{
- mvwaddstr(bottom, 1, 0, str);
- refresh();
- wrefresh(bottom);
-}
-
-/*
- * function statusline_getnstr
- *
- * parameters:
- * (char *str)
- * if n >= 0 str is a pointer which points a place where to store
- * the string, else str is ingnored
- * (int n)
- * the maximum length of the string
- * If n < 0 function will allocate needed space for the string.
- * Value 0 is not allowed for n.
- * (int use_filesel)
- * if this value is nonzero the fileselector is enabled
- *
- * returns (char *)
- * If n < 0 a pointer to a newly allocated string is returned.
- * If n > 0 a nonzero value is returned if user has typed a valid
- * string. If not NULL value is returned. Never really use the
- * _pointer_ if n > 0.
- *
- */
-
-char *
-statusline_getnstr(char *str, int n, int use_filesel)
-{
- char *buf;
- int y, x;
-
- 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
- strncpy(str, buf, n);
-
- str[n-1] = 0;
-
- free(buf);
-
- return buf;
-}
-
-void
-refresh_statusline()
-{
- werase(bottom);
-
- mvwhline(bottom, 0, 0, ACS_HLINE, COLS);
- mvwhline(bottom, 2, 0, ACS_HLINE, COLS);
-
- refresh();
- wrefresh(bottom);
-}
-
-
-char *
-ask_filename(char *prompt, int flags)
-{
- char *buf = NULL;
-
- clear_statusline();
-
- statusline_addstr(prompt);
- buf = statusline_getnstr(NULL, -1, flags);
-
- clear_statusline();
-
- return buf;
-}
-
-void
-clear_statusline()
-{
- wmove(bottom, 1, 0);
- wclrtoeol(bottom);
- wrefresh(bottom);
- refresh();
-}
-
static void
parse_command_line(int argc, char **argv)
{
}
-static void
+void
launch_mutt()
{
int i;
char *cmd;
char *tmp = options_get_str("mutt_command");
- if(curitem < 0)
+ if( list_is_empty() )
return;
cmd = strconcat(tmp, " '", NULL );
for(i=0; i < items; i++) {
- if( ! selected[i] && i != curitem )
+ if( ! is_selected(i) && i != list_current_item() )
continue;
get_first_email(email, i);
tmp = mkstr("%s \"%s\"", cmd, database[i][NAME]);
refresh_screen();
}
-static void
+void
launch_lynx()
{
char *cmd = NULL;
- if(curitem < 0)
+ if( list_is_empty() )
return;
- if( database[curitem][URL] )
+ if( database[list_current_item()][URL] )
cmd = mkstr("%s '%s'",
options_get_str("www_command"),
- safe_str(database[curitem][URL]));
+ safe_str(database[list_current_item()][URL]));
else
return;
void *ptr;
if ( (ptr = malloc(size)) == NULL ) {
- if(top) /* determinate if init_abook has been called */
+ if( is_ui_initialized() )
quit_abook();
perror("malloc() failed");
exit(1);
return NULL;
if( ptr == NULL ) {
- if(top) /* determinate if init_abook has been called */
+ if( is_ui_initialized() )
quit_abook();
perror("realloc() failed");
exit(1);
}
-static void
-win_changed(int i)
-{
- if( can_resize )
- resize_abook();
- else
- should_resize = TRUE;
-}
-
-#ifdef SIGWINCH
-static void
-resize_abook()
-{
-#ifdef TIOCGWINSZ
- struct winsize winsz;
-
- ioctl (0, TIOCGWINSZ, &winsz);
-#ifdef DEBUG
- if(winsz.ws_col >= MIN_COLS && winsz.ws_row >= MIN_LINES) {
- fprintf(stderr, "Warning: COLS=%d, LINES=%d\n", winsz.ws_col, winsz.ws_row);
- }
-#endif
-
- if(winsz.ws_col >= MIN_COLS && winsz.ws_row >= MIN_LINES) {
-#ifdef HAVE_RESIZETERM
- resizeterm(winsz.ws_row, winsz.ws_col);
-#else
- COLS = winsz.ws_col;
- LINES = winsz.ws_row;
-#endif
- }
-
- should_resize = FALSE;
- close_list(); /* we need to recreate windows */
- init_list();
- free_windows();
- init_windows();
- refresh_screen();
- refresh();
-#endif /* TIOCGWINSZ */
-}
-#endif /* SIGWINCH */
-
static void
convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile)
}
-static void
-open_datafile()
-{
- char *filename;
-
- filename = ask_filename("File to open: ", 1);
-
- if( !filename ) {
- refresh_screen();
- return;
- }
-
- if( options_get_int("autosave") )
- save_database();
- else {
- statusline_addstr("Save current database (y/N)");
- switch( getch() ) {
- case 'y':
- case 'Y':
- save_database();
- default: break;
- }
- }
-
- close_database();
-
- load_database(filename);
-
- if( items == 0 ) {
- statusline_msg("Sorry, that specified file appears not to be a valid abook addressbook");
- load_database(datafile);
- } else {
- free(datafile);
- datafile = strdup(filename);
- }
-
- refresh_screen();
- free(filename);
-}
ac_help="$ac_help
--with-curses=DIR Where ncurses is installed "
ac_help="$ac_help
- --enable-debug Enable debugging support "
+ --enable-debug Enable debugging support "
+ac_help="$ac_help
+ --disable-nonascii Disable usage of non-ascii characters "
# Initialize some variables set by options.
# The variables have the same names as the options, with
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:560: checking for a BSD compatible install" >&5
+echo "configure:562: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
-echo "configure:613: checking whether build environment is sane" >&5
+echo "configure:615: checking whether build environment is sane" >&5
# Just in case
sleep 1
echo timestamp > conftestfile
test "$program_transform_name" = "" && program_transform_name="s,x,x,"
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:670: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:672: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
PACKAGE=abook
-VERSION=0.4.13-cvs
+VERSION=0.4.13-dev
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
missing_dir=`cd $ac_aux_dir && pwd`
echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
-echo "configure:716: checking for working aclocal" >&5
+echo "configure:718: checking for working aclocal" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
fi
echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
-echo "configure:729: checking for working autoconf" >&5
+echo "configure:731: checking for working autoconf" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
fi
echo $ac_n "checking for working automake""... $ac_c" 1>&6
-echo "configure:742: checking for working automake" >&5
+echo "configure:744: checking for working automake" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
fi
echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
-echo "configure:755: checking for working autoheader" >&5
+echo "configure:757: checking for working autoheader" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
fi
echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
-echo "configure:768: checking for working makeinfo" >&5
+echo "configure:770: checking for working makeinfo" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:792: checking host system type" >&5
+echo "configure:794: checking host system type" >&5
host_alias=$host
case "$host_alias" in
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:816: checking for $ac_word" >&5
+echo "configure:818: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:846: checking for $ac_word" >&5
+echo "configure:848: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:897: checking for $ac_word" >&5
+echo "configure:899: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:929: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:931: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
cat > conftest.$ac_ext << EOF
-#line 940 "configure"
+#line 942 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:947: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:971: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:973: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:976: checking whether we are using GNU C" >&5
+echo "configure:978: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:985: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:987: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1004: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1006: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fi
echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:1036: checking for POSIXized ISC" >&5
+echo "configure:1038: checking for POSIXized ISC" >&5
if test -d /etc/conf/kconfig.d &&
grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
then
echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6
-echo "configure:1060: checking for ${CC-cc} option to accept ANSI C" >&5
+echo "configure:1062: checking for ${CC-cc} option to accept ANSI C" >&5
if eval "test \"`echo '$''{'am_cv_prog_cc_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
do
CC="$ac_save_CC $ac_arg"
cat > conftest.$ac_ext <<EOF
-#line 1076 "configure"
+#line 1078 "configure"
#include "confdefs.h"
#include <stdarg.h>
#include <stdio.h>
; return 0; }
EOF
-if { (eval echo configure:1113: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1115: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
am_cv_prog_cc_stdc="$ac_arg"; break
else
esac
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1137: checking how to run the C preprocessor" >&5
+echo "configure:1139: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1152 "configure"
+#line 1154 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1158: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1160: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1169 "configure"
+#line 1171 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1175: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1177: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1186 "configure"
+#line 1188 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1192: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1194: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
echo $ac_n "checking for function prototypes""... $ac_c" 1>&6
-echo "configure:1219: checking for function prototypes" >&5
+echo "configure:1221: checking for function prototypes" >&5
if test "$am_cv_prog_cc_stdc" != no; then
echo "$ac_t""yes" 1>&6
cat >> confdefs.h <<\EOF
U=_ ANSI2KNR=./ansi2knr
# Ensure some checks needed by ansi2knr itself.
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1232: checking for ANSI C header files" >&5
+echo "configure:1234: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1237 "configure"
+#line 1239 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1245: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1247: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1262 "configure"
+#line 1264 "configure"
#include "confdefs.h"
#include <string.h>
EOF
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1280 "configure"
+#line 1282 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
:
else
cat > conftest.$ac_ext <<EOF
-#line 1301 "configure"
+#line 1303 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
exit (0); }
EOF
-if { (eval echo configure:1312: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1339: checking for $ac_hdr" >&5
+echo "configure:1341: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1344 "configure"
+#line 1346 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1349: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1351: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
{ echo "configure: error: Compiler not ANSI compliant" 1>&2; exit 1; }
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:1381: checking for inline" >&5
+echo "configure:1383: checking for inline" >&5
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat > conftest.$ac_ext <<EOF
-#line 1388 "configure"
+#line 1390 "configure"
#include "confdefs.h"
int main() {
} int $ac_kw foo() {
; return 0; }
EOF
-if { (eval echo configure:1395: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1397: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1432: checking for a BSD compatible install" >&5
+echo "configure:1434: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1485: checking for ANSI C header files" >&5
+echo "configure:1487: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1490 "configure"
+#line 1492 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1500: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1515 "configure"
+#line 1517 "configure"
#include "confdefs.h"
#include <string.h>
EOF
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1533 "configure"
+#line 1535 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
:
else
cat > conftest.$ac_ext <<EOF
-#line 1554 "configure"
+#line 1556 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
exit (0); }
EOF
-if { (eval echo configure:1565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1592: checking for $ac_hdr" >&5
+echo "configure:1594: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1597 "configure"
+#line 1599 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1602: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1604: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
ac_safe=`echo "stdarg.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for stdarg.h""... $ac_c" 1>&6
-echo "configure:1630: checking for stdarg.h" >&5
+echo "configure:1632: checking for stdarg.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1635 "configure"
+#line 1637 "configure"
#include "confdefs.h"
#include <stdarg.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1640: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1642: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
for ac_func in setlocale
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1668: checking for $ac_func" >&5
+echo "configure:1670: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1673 "configure"
+#line 1675 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:1696: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6
-echo "configure:1737: checking for initscr in -lncurses" >&5
+echo "configure:1739: checking for initscr in -lncurses" >&5
ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1745 "configure"
+#line 1747 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
initscr()
; return 0; }
EOF
-if { (eval echo configure:1756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1758: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1779: checking for $ac_hdr" >&5
+echo "configure:1781: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1784 "configure"
+#line 1786 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1789: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1791: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
echo "$ac_t""no" 1>&6
echo $ac_n "checking for initscr""... $ac_c" 1>&6
-echo "configure:1819: checking for initscr" >&5
+echo "configure:1821: checking for initscr" >&5
if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1824 "configure"
+#line 1826 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char initscr(); below. */
; return 0; }
EOF
-if { (eval echo configure:1847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_initscr=yes"
else
case $host_os in #(vi
freebsd*) #(vi
echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
-echo "configure:1868: checking for tgoto in -lmytinfo" >&5
+echo "configure:1870: checking for tgoto in -lmytinfo" >&5
ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lmytinfo $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1876 "configure"
+#line 1878 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
tgoto()
; return 0; }
EOF
-if { (eval echo configure:1887: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
;;
hpux10.*|hpux11.*)
echo $ac_n "checking for initscr in -lcur_colr""... $ac_c" 1>&6
-echo "configure:1910: checking for initscr in -lcur_colr" >&5
+echo "configure:1912: checking for initscr in -lcur_colr" >&5
ac_lib_var=`echo cur_colr'_'initscr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lcur_colr $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1918 "configure"
+#line 1920 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
initscr()
; return 0; }
EOF
-if { (eval echo configure:1929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for initscr in -lHcurses""... $ac_c" 1>&6
-echo "configure:1953: checking for initscr in -lHcurses" >&5
+echo "configure:1955: checking for initscr in -lHcurses" >&5
ac_lib_var=`echo Hcurses'_'initscr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lHcurses $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1961 "configure"
+#line 1963 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
initscr()
; return 0; }
EOF
-if { (eval echo configure:1972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
# Check for library containing tgoto. Do this before curses library
# because it may be needed to link the test-case for initscr.
echo $ac_n "checking for tgoto""... $ac_c" 1>&6
-echo "configure:2021: checking for tgoto" >&5
+echo "configure:2023: checking for tgoto" >&5
if eval "test \"`echo '$''{'ac_cv_func_tgoto'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2026 "configure"
+#line 2028 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char tgoto(); below. */
; return 0; }
EOF
-if { (eval echo configure:2049: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2051: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_tgoto=yes"
else
for cf_term_lib in termcap termlib unknown
do
echo $ac_n "checking for tgoto in -l$cf_term_lib""... $ac_c" 1>&6
-echo "configure:2070: checking for tgoto in -l$cf_term_lib" >&5
+echo "configure:2072: checking for tgoto in -l$cf_term_lib" >&5
ac_lib_var=`echo $cf_term_lib'_'tgoto | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-l$cf_term_lib $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2078 "configure"
+#line 2080 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
tgoto()
; return 0; }
EOF
-if { (eval echo configure:2089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
for cf_curs_lib in cursesX curses ncurses xcurses jcurses unknown
do
echo $ac_n "checking for initscr in -l$cf_curs_lib""... $ac_c" 1>&6
-echo "configure:2119: checking for initscr in -l$cf_curs_lib" >&5
+echo "configure:2121: checking for initscr in -l$cf_curs_lib" >&5
ac_lib_var=`echo $cf_curs_lib'_'initscr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-l$cf_curs_lib $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2127 "configure"
+#line 2129 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
initscr()
; return 0; }
EOF
-if { (eval echo configure:2138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2140: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
LIBS="-l$cf_curs_lib $cf_save_LIBS"
if test "$cf_term_lib" = unknown ; then
echo $ac_n "checking if we can link with $cf_curs_lib library""... $ac_c" 1>&6
-echo "configure:2164: checking if we can link with $cf_curs_lib library" >&5
+echo "configure:2166: checking if we can link with $cf_curs_lib library" >&5
cat > conftest.$ac_ext <<EOF
-#line 2166 "configure"
+#line 2168 "configure"
#include "confdefs.h"
#include <${cf_cv_ncurses_header-curses.h}>
int main() {
initscr()
; return 0; }
EOF
-if { (eval echo configure:2173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2175: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
cf_result=yes
else
test $cf_result = no && { echo "configure: error: Cannot link curses library" 1>&2; exit 1; }
elif test "$cf_term_lib" != predefined ; then
echo $ac_n "checking if we need both $cf_curs_lib and $cf_term_lib libraries""... $ac_c" 1>&6
-echo "configure:2187: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
+echo "configure:2189: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
cat > conftest.$ac_ext <<EOF
-#line 2189 "configure"
+#line 2191 "configure"
#include "confdefs.h"
#include <${cf_cv_ncurses_header-curses.h}>
int main() {
initscr(); tgoto((char *)0, 0, 0);
; return 0; }
EOF
-if { (eval echo configure:2196: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
cf_result=no
else
LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2206 "configure"
+#line 2208 "configure"
#include "confdefs.h"
#include <${cf_cv_ncurses_header-curses.h}>
int main() {
initscr()
; return 0; }
EOF
-if { (eval echo configure:2213: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
cf_result=yes
else
for ac_func in resizeterm
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2240: checking for $ac_func" >&5
+echo "configure:2242: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2245 "configure"
+#line 2247 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:2268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2270: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
echo $ac_n "checking for snprintf""... $ac_c" 1>&6
-echo "configure:2294: checking for snprintf" >&5
+echo "configure:2296: checking for snprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_snprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2299 "configure"
+#line 2301 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char snprintf(); below. */
; return 0; }
EOF
-if { (eval echo configure:2322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2324: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_snprintf=yes"
else
fi
echo $ac_n "checking for vsnprintf""... $ac_c" 1>&6
-echo "configure:2345: checking for vsnprintf" >&5
+echo "configure:2347: checking for vsnprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_vsnprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2350 "configure"
+#line 2352 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vsnprintf(); below. */
; return 0; }
EOF
-if { (eval echo configure:2373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2375: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_vsnprintf=yes"
else
CFLAGS="-g $CFLAGS"
fi
+# Check whether --enable-nonascii or --disable-nonascii was given.
+if test "${enable_nonascii+set}" = set; then
+ enableval="$enable_nonascii"
+ case "${enableval}" in
+ yes) nonascii=true ;;
+ no) nonascii=false ;;
+ *) { echo "configure: error: bad value ${enableval} for --disable-nonascii" 1>&2; exit 1; } ;;
+ esac
+else
+ nonascii=true
+fi
+
+
+if test x$nonascii = xfalse; then
+ cat >> confdefs.h <<\EOF
+#define USE_ASCII_ONLY 1
+EOF
+
+fi
+
+if test x$debug = xtrue; then
+ CPPFLAGS="-DDEBUG $CPPFLAGS"
+ CFLAGS="-g $CFLAGS"
+fi
if test x$GCC = xyes; then
CFLAGS="-Wall $CFLAGS"
fi
--- /dev/null
+
+/*
+ * $Id$
+ *
+ * by JH <jheinonen@bigfoot.com>
+ *
+ * Copyright (C) Jaakko Heinonen
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include "abook.h"
+#include "ui.h"
+#include "edit.h"
+#include "database.h"
+#include "list.h"
+#include "misc.h"
+#include "options.h"
+#include "filter.h"
+#include "estr.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#else
+# ifdef HAVE_LINUX_TERMIOS_H
+# include <linux/termios.h>
+# endif
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+
+#ifdef USE_ASCII_ONLY
+# define UI_HLINE_CHAR '-'
+#else
+# define UI_HLINE_CHAR ACS_HLINE
+#endif
+
+
+/*
+ * external variables
+ */
+
+extern int items, curitem;
+extern char *datafile;
+
+/*
+ * internal variables
+ */
+
+int ui_initialized = FALSE;
+
+int should_resize = FALSE;
+int can_resize = FALSE;
+
+WINDOW *top = NULL, *bottom = NULL;
+
+
+
+static void
+init_windows()
+{
+ top = newwin(LIST_TOP - 1, COLS, 0, 0);
+
+ bottom = newwin(LINES - LIST_BOTTOM, COLS, LIST_BOTTOM, 0);
+}
+
+static void
+free_windows()
+{
+ delwin(top);
+ delwin(bottom);
+}
+
+
+#ifdef SIGWINCH
+static void
+resize_abook()
+{
+#ifdef TIOCGWINSZ
+ struct winsize winsz;
+
+ ioctl (0, TIOCGWINSZ, &winsz);
+#ifdef DEBUG
+ if(winsz.ws_col >= MIN_COLS && winsz.ws_row >= MIN_LINES) {
+ fprintf(stderr, "Warning: COLS=%d, LINES=%d\n", winsz.ws_col, winsz.ws_row);
+ }
+#endif
+
+ if(winsz.ws_col >= MIN_COLS && winsz.ws_row >= MIN_LINES) {
+#ifdef HAVE_RESIZETERM
+ resizeterm(winsz.ws_row, winsz.ws_col);
+#else
+ COLS = winsz.ws_col;
+ LINES = winsz.ws_row;
+#endif
+ }
+
+ should_resize = FALSE;
+ close_list(); /* we need to recreate windows */
+ init_list();
+ free_windows();
+ init_windows();
+ refresh_screen();
+ refresh();
+#endif /* TIOCGWINSZ */
+}
+
+
+static void
+win_changed(int i)
+{
+ if( can_resize )
+ resize_abook();
+ else
+ should_resize = TRUE;
+}
+#endif /* SIGWINCH */
+
+
+int
+is_ui_initialized()
+{
+ return ui_initialized;
+}
+
+
+int
+init_ui()
+{
+ initscr(); cbreak(); noecho();
+ nonl();
+ intrflush(stdscr, FALSE);
+ keypad(stdscr, TRUE);
+#ifdef DEBUG
+ fprintf(stderr, "init_abook():\n");
+ fprintf(stderr, " COLS = %d, LINES = %d\n", COLS, LINES);
+#endif
+ if( LINES < MIN_LINES || COLS < MIN_COLS ) {
+ clear(); refresh(); endwin();
+ fprintf(stderr, "Your terminal size is %dx%d\n", COLS, LINES);
+ fprintf(stderr, "Terminal is too small. Minium terminal size "
+ "for abook is "
+ "%dx%d\n", MIN_COLS, MIN_LINES);
+ return 1;
+ }
+
+#ifdef SIGWINCH
+ signal(SIGWINCH, win_changed);
+#endif
+
+ init_list();
+ init_windows();
+
+ ui_initialized = TRUE;
+
+ return 0;
+}
+
+void
+close_ui()
+{
+ close_list();
+ free_windows();
+ clear();
+ refresh();
+ endwin();
+
+ ui_initialized = FALSE;
+}
+
+
+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()
+{
+#ifdef SIGWINCH
+ if( should_resize ) {
+ resize_abook();
+ return;
+ }
+#endif
+ clear();
+
+ refresh_statusline();
+ headerline(MAIN_HELPLINE);
+ list_headerline();
+
+ refresh_list();
+}
+
+
+void
+statusline_msg(char *msg)
+{
+ clear_statusline();
+ statusline_addstr(msg);
+ getch();
+#ifdef DEBUG
+ fprintf(stderr, "statusline_msg(\"%s\")\n", msg);
+#endif
+ clear_statusline();
+}
+
+void
+statusline_addstr(char *str)
+{
+ mvwaddstr(bottom, 1, 0, str);
+ refresh();
+ wrefresh(bottom);
+}
+
+/*
+ * function statusline_getnstr
+ *
+ * parameters:
+ * (char *str)
+ * if n >= 0 str is a pointer which points a place where to store
+ * the string, else str is ingnored
+ * (int n)
+ * the maximum length of the string
+ * If n < 0 function will allocate needed space for the string.
+ * Value 0 is not allowed for n.
+ * (int use_filesel)
+ * if this value is nonzero the fileselector is enabled
+ *
+ * returns (char *)
+ * If n < 0 a pointer to a newly allocated string is returned.
+ * If n > 0 a nonzero value is returned if user has typed a valid
+ * string. If not NULL value is returned. Never really use the
+ * _pointer_ if n > 0.
+ *
+ */
+
+char *
+statusline_getnstr(char *str, int n, int use_filesel)
+{
+ char *buf;
+ int y, x;
+
+ 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
+ strncpy(str, buf, n);
+
+ str[n-1] = 0;
+
+ free(buf);
+
+ return buf;
+}
+
+void
+refresh_statusline()
+{
+ werase(bottom);
+
+ mvwhline(bottom, 0, 0, UI_HLINE_CHAR, COLS);
+ mvwhline(bottom, 2, 0, UI_HLINE_CHAR, COLS);
+
+ refresh();
+ wrefresh(bottom);
+}
+
+
+char *
+ask_filename(char *prompt, int flags)
+{
+ char *buf = NULL;
+
+ clear_statusline();
+
+ statusline_addstr(prompt);
+ buf = statusline_getnstr(NULL, -1, flags);
+
+ clear_statusline();
+
+ return buf;
+}
+
+void
+clear_statusline()
+{
+ wmove(bottom, 1, 0);
+ wclrtoeol(bottom);
+ wrefresh(bottom);
+ refresh();
+}
+
+
+/*
+ * help - need to rewrite
+ */
+
+
+#include "help.h"
+
+void
+display_help(int help)
+{
+ int i;
+ char **tbl;
+ WINDOW *helpw;
+
+ switch(help) {
+ case HELP_MAIN:
+ tbl = mainhelp;
+ break;
+ case HELP_EDITOR:
+ tbl = editorhelp;
+ break;
+ default:return;
+ }
+
+ 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) ) ) ||
+ (tbl[i+1] == NULL) ) {
+ refresh();
+ wrefresh(helpw);
+ refresh_statusline();
+ statusline_msg("Press any key to continue...");
+ wclear(helpw);
+ }
+ }
+
+ clear_statusline();
+ delwin(helpw);
+}
+
+
+/*
+ * end of help
+ */
+
+char *selected;
+extern int curitem;
+
+void
+get_commands()
+{
+ int ch;
+
+ for(;;) {
+ can_resize = TRUE; /* it's safe to resize now */
+ hide_cursor();
+ if( should_resize )
+ refresh_screen();
+ ch = getch();
+ show_cursor();
+ can_resize = FALSE; /* it's not safe to resize anymore */
+ switch( ch ) {
+ case 'q': return;
+ case '?':
+ display_help(HELP_MAIN);
+ refresh_screen();
+ break;
+ case 'a': add_item(); break;
+ case '\r': edit_item(-1); break;
+ case KEY_DC:
+ case 'd':
+ case 'r': ui_remove_items(); break;
+ case 12: refresh_screen(); break;
+
+ case 'k':
+ case KEY_UP: scroll_up(); break;
+ case 'j':
+ case KEY_DOWN: scroll_down(); break;
+ case 'K':
+ case KEY_PPAGE: page_up(); break;
+ case 'J':
+ case KEY_NPAGE: page_down(); break;
+
+ case 'H':
+ case KEY_HOME: goto_home(); break;
+ case 'E':
+ case KEY_END: goto_end(); break;
+
+ case 'w': save_database();
+ break;
+ case 'l': ui_read_database(); break;
+ case 'i': import_database(); break;
+ case 'e': export_database(); break;
+ case 'C': ui_clear_database(); break;
+
+ case 'o': ui_open_datafile(); break;
+
+ case 's': sort_database(); break;
+ case 'S': sort_surname(); break;
+
+ case '/': ui_find(0); break;
+ case '\\': ui_find(1); break;
+
+ case ' ': if(curitem >= 0) {
+ selected[curitem] = !selected[curitem];
+ ui_print_number_of_items();
+ refresh_list();
+ }
+ break;
+ case '+': select_all();
+ refresh_list();
+ break;
+ case '-': select_none();
+ refresh_list();
+ break;
+ case '*': invert_selection();
+ refresh_list();
+ break;
+ case 'A': move_curitem(MOVE_ITEM_UP);
+ break;
+ case 'Z': move_curitem(MOVE_ITEM_DOWN);
+ break;
+
+ case 'm': launch_mutt(); break;
+
+ case 'p': ui_print_database(); break;
+
+ case 'u': launch_lynx(); break;
+ }
+ }
+}
+
+
+void
+ui_remove_items()
+{
+ if( items < 1 || curitem < 0 )
+ return;
+
+ statusline_addstr("Remove selected item(s) (Y/n)");
+ switch( getch() ) {
+ case '\r':
+ case 'y':
+ case 'Y': break;
+ default:
+ clear_statusline();
+ return;
+ }
+
+ remove_selected_items();
+
+ clear_statusline();
+ refresh_list();
+}
+
+void
+ui_clear_database()
+{
+
+ statusline_addstr("Clear WHOLE database (y/N)");
+ switch( getch() ) {
+ case 'y':
+ case 'Y': break;
+ default:
+ clear_statusline();
+ return;
+ }
+
+ close_database();
+
+ refresh_screen();
+}
+
+void
+ui_find(int next)
+{
+ int item;
+ static char findstr[81];
+
+ if(next) {
+ if( !*findstr )
+ return;
+ } else {
+ clear_statusline();
+ statusline_addstr("/");
+ statusline_getnstr(findstr, 67, 0);
+ clear_statusline();
+ }
+
+ if( (item = find_item(findstr, next ? curitem+1 : curitem)) >= 0 ) {
+ curitem = item;
+ refresh_list();
+ }
+
+}
+
+
+void
+ui_print_number_of_items()
+{
+ char *str = mkstr(" " "|%3d/%3d", selected_items(), items);
+
+ mvaddstr(0, COLS-strlen(str), str);
+
+ free(str);
+}
+
+void
+ui_read_database()
+{
+ if(items > 0) {
+ statusline_addstr("Your current data will be lost - Press 'y' to continue");
+ switch( getch() ) {
+ case 'y':
+ case 'Y': break;
+ default: clear_statusline();
+ return;
+ }
+ clear_statusline();
+ }
+
+ load_database(datafile);
+ refresh_list();
+}
+
+
+void
+ui_print_database()
+{
+ FILE *handle;
+ char *command = options_get_str("print_command");
+
+ statusline_addstr("Print addressbook? (y/N)");
+ switch( getch() ) {
+ case 'y':
+ case 'Y':
+ break;
+ default: clear_statusline(); return;
+ }
+ clear_statusline();
+
+ if( ! *command || (handle = popen(command, "w")) == NULL)
+ return;
+
+ fexport("text", handle);
+
+ pclose(handle);
+}
+
+
+void
+ui_open_datafile()
+{
+ char *filename;
+
+ filename = ask_filename("File to open: ", 1);
+
+ if( !filename ) {
+ refresh_screen();
+ return;
+ }
+
+ if( options_get_int("autosave") )
+ save_database();
+ else {
+ statusline_addstr("Save current database (y/N)");
+ switch( getch() ) {
+ case 'y':
+ case 'Y':
+ save_database();
+ default: break;
+ }
+ }
+
+ close_database();
+
+ load_database(filename);
+
+ if( items == 0 ) {
+ statusline_msg("Sorry, that specified file appears not to be a valid abook addressbook");
+ load_database(datafile);
+ } else {
+ free(datafile);
+ datafile = strdup(filename);
+ }
+
+ refresh_screen();
+ free(filename);
+}