X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=abook.c;h=af0d9d03e20d16f9da94e152722184e360822d28;hb=8e8c32953ba65fadd3c99313b4988e4bfc835732;hp=2cbbbd1244b3d115e8ce98b2e8ae7a0775c33eb6;hpb=7c5cfcacf9b413a8b9c41dfd8a41f0c643fbee18;p=pkg%2Fabook.git diff --git a/abook.c b/abook.c index 2cbbbd1..af0d9d0 100644 --- a/abook.c +++ b/abook.c @@ -1,7 +1,7 @@ /* * $Id$ * - * by JH + * by JH * * Copyright (C) Jaakko Heinonen */ @@ -206,7 +206,7 @@ show_usage() extern list_item *database; static void -muttq_print_item(int item) +muttq_print_item(FILE *file, int item) { char emails[MAX_EMAILS][MAX_EMAIL_LEN]; int i; @@ -216,7 +216,7 @@ muttq_print_item(int item) for(i = 0; i < (options_get_int("mutt_return_all_emails") ? MAX_EMAILS : 1) ; i++) if( *emails[i] ) - printf("%s\t%s\t%s\n", emails[i], + fprintf(file, "%s\t%s\t%s\n", emails[i], database[item][NAME], database[item][NOTES] == NULL ? " " : database[item][NOTES] @@ -232,7 +232,7 @@ mutt_query(char *str) struct db_enumerator e = init_db_enumerator(ENUM_ALL); printf("All items\n"); db_enumerate_items(e) - muttq_print_item(e.item); + muttq_print_item(stdout, e.item); } else { int search_fields[] = {NAME, EMAIL, NICK, -1}; int i; @@ -242,7 +242,7 @@ mutt_query(char *str) } putchar('\n'); while(i >= 0) { - muttq_print_item(i); + muttq_print_item(stdout, i); i = find_item(str, i+1, search_fields); } } @@ -291,10 +291,30 @@ make_mailstr(int item) return ret; } +void +print_stderr(int item) +{ + fprintf (stderr, "%c", '\n'); + + if( is_valid_item(item) ) + muttq_print_item(stderr, item); + else { + struct db_enumerator e = init_db_enumerator(ENUM_SELECTED); + db_enumerate_items(e) { + muttq_print_item(stderr, e.item); + } + } + +} + void launch_mutt(int item) { char *cmd = NULL, *mailstr = NULL; + char *mutt_command = options_get_str("mutt_command"); + + if(mutt_command == NULL || !*mutt_command) + return; if( is_valid_item(item) ) mailstr = make_mailstr(item); @@ -310,7 +330,7 @@ launch_mutt(int item) } } - cmd = strconcat(options_get_str("mutt_command"), " \'", mailstr, + cmd = strconcat(mutt_command, " \'", mailstr, "\'", NULL); free(mailstr); #ifdef DEBUG @@ -318,6 +338,11 @@ launch_mutt(int item) #endif system(cmd); free(cmd); + + /* + * we need to make sure that curses settings are correct + */ + ui_init_curses(); } void @@ -339,6 +364,11 @@ launch_wwwbrowser(int item) system(cmd); free(cmd); + + /* + * we need to make sure that curses settings are correct + */ + ui_init_curses(); } void * @@ -403,11 +433,13 @@ convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile) strlower(srcformat); strlower(dstformat); +#ifndef DEBUG if( !strcmp(srcformat, dstformat) ) { printf( "input and output formats are the same\n" "exiting...\n"); exit(1); } +#endif set_filenames(); init_options(); @@ -439,4 +471,3 @@ convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile) exit(ret); } -