]> git.deb.at Git - pkg/abook.git/blobdiff - abook.c
quit and print command added
[pkg/abook.git] / abook.c
diff --git a/abook.c b/abook.c
index 57db4e46be931493510da3f2e981595020e126ad..de333180c757a91bfe6f2bc0b8165aa6400b6f1f 100644 (file)
--- a/abook.c
+++ b/abook.c
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * by JH <jheinonen@bigfoot.com>
+ * by JH <jheinonen@users.sourceforge.net>
  *
  * Copyright (C) Jaakko Heinonen
  */
@@ -284,34 +284,66 @@ make_mailstr(int item)
 
        ret = *database[item][EMAIL] ?
                mkstr("%s <%s>", name, email) :
-               name;
+               strdup(name);
 
        free(name);
        
        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)
 {
        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);
-
-       /*
-        * need to implement for multiple addresses
-        */
-               /*
-       } else {
+       else {
                struct db_enumerator e = init_db_enumerator(ENUM_SELECTED);
+               char *tmp = NULL;
                db_enumerate_items(e) {
                        tmp = mailstr;
-                       mailstr = strconcat(tmp, make_mailstr(e.item);
-                       
-       }*/
+                       mailstr = tmp ?
+                               strconcat(tmp, ",", make_mailstr(e.item), NULL):
+                               strconcat(make_mailstr(e.item), NULL);
+                       free(tmp);
+               }
+       }
 
-       cmd = strconcat(options_get_str("mutt_command"), " \'", mailstr,
+       cmd = strconcat(mutt_command, " \'", mailstr,
                                "\'", NULL);
        free(mailstr);
 #ifdef DEBUG
@@ -319,6 +351,11 @@ launch_mutt(int item)
 #endif
        system(cmd);    
        free(cmd);
+       
+       /*
+        * we need to make sure that curses settings are correct
+        */
+       ui_init_curses();
 }
 
 void
@@ -340,6 +377,11 @@ launch_wwwbrowser(int item)
                system(cmd);
 
        free(cmd);
+
+       /*
+        * we need to make sure that curses settings are correct
+        */
+       ui_init_curses();
 }
 
 void *
@@ -404,11 +446,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();