From: Jaakko Heinonen Date: Sat, 29 Sep 2001 16:39:02 +0000 (+0000) Subject: quit and print command added X-Git-Tag: upstream/0.6.1~2^2~337 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=79a77ff8c37fd55fcbe2983974ce82e6348f3926;p=pkg%2Fabook.git quit and print command added --- diff --git a/ChangeLog b/ChangeLog index 21a87ce..b68721a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ - fixed a minor memory leak in pine import filter - filter cleanups - fixes + - "quit and print selected item(s) to stderr" command (Brian Medley) + - contrib update 0.4.13 - major code reorganization (phase 1) diff --git a/abook.c b/abook.c index bb0a347..de33318 100644 --- a/abook.c +++ b/abook.c @@ -291,6 +291,35 @@ make_mailstr(int item) return ret; } +void +print_stderr(int item) +{ + char *mailstr = NULL; + + if( is_valid_item(item) ) + mailstr = make_mailstr(item); + else { + struct db_enumerator e = init_db_enumerator(ENUM_SELECTED); + char *tmp = NULL; + db_enumerate_items(e) { + tmp = mailstr; + mailstr = tmp ? + strconcat(tmp, ",", make_mailstr(e.item), NULL): + strconcat(make_mailstr(e.item), NULL); + free(tmp); + } + } + + fprintf(stderr, "%s", mailstr); + +#ifdef DEBUG + fprintf(stderr, "mailstr: %s\n", mailstr); +#endif + + free(mailstr); + +} + void launch_mutt(int item) { diff --git a/abook.h b/abook.h index bcebcaa..8fa08cd 100644 --- a/abook.h +++ b/abook.h @@ -9,6 +9,7 @@ FILE *abook_fopen (const char *path, const char *mode); void quit_abook(); void launch_wwwbrowser(int item); void launch_mutt(int item); +void print_stderr(int item); #ifdef _AIX int strcasecmp (const char *, const char *); int strncasecmp (const char *, const char *, size_t); diff --git a/configure b/configure index c618021..d35f752 100755 --- a/configure +++ b/configure @@ -695,7 +695,7 @@ fi PACKAGE=abook -VERSION=0.4.14-cvs +VERSION=0.4.14 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; } diff --git a/configure.in b/configure.in index 4db766d..30cc0a3 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl abook configure.in AC_INIT(abook.c) -AM_INIT_AUTOMAKE(abook, 0.4.14-cvs) +AM_INIT_AUTOMAKE(abook, 0.4.14) AM_CONFIG_HEADER(config.h) AC_CANONICAL_HOST diff --git a/help.h b/help.h index a18f8f2..abb040e 100644 --- a/help.h +++ b/help.h @@ -9,6 +9,7 @@ static char *mainhelp[] = { " ? help\n", " q quit\n", +" Q quit and print selected item(s) to stderr\n", " ^L refresh screen\n", "\n", " arrows / j,k scroll list\n", diff --git a/ui.c b/ui.c index c11c26a..1af0ee3 100644 --- a/ui.c +++ b/ui.c @@ -410,6 +410,9 @@ get_commands() can_resize = FALSE; /* it's not safe to resize anymore */ switch( ch ) { case 'q': return; + case 'Q': print_stderr(selected_items() ? + -1 : list_current_item()); + return; case '?': display_help(HELP_MAIN); refresh_screen();