fixing leak
[oweals/gnunet.git] / src / monkey / mail_sender.c
index ff5d13e47c75ce999e3255c7fdd82813adc6339d..122a4d0abbeeeb3e1b0f94f92e54f6911e704a31 100644 (file)
@@ -16,7 +16,6 @@
 #if !defined (__GNUC__) || __GNUC__ < 2
 # define __attribute__(x)
 #endif
-#define unused      __attribute__((unused))
 
 
 int
@@ -136,7 +135,7 @@ void event_cb (smtp_session_t session, int event_no, void *arg,...)
 /* Callback to prnt the recipient status */
 void
 print_recipient_status (smtp_recipient_t recipient,
-                       const char *mailbox, void *arg unused)
+                       const char *mailbox, void *arg)
 {
   const smtp_status_t *status;
 
@@ -145,18 +144,17 @@ print_recipient_status (smtp_recipient_t recipient,
 }
 
 
-void sendMail(
+void sendMail(const char *messageContents, const char *emailAddress)
 {
        smtp_session_t session;
        smtp_message_t message;
        smtp_recipient_t recipient;
-       auth_context_t authctx;
        const smtp_status_t *status;
        struct sigaction sa;
        char *host = "localhost:25";
        char *from = "gnunet-monkey";
        char *subject = "e-mail from Libesmtp!";
-       const char *recipient_address = "halims@in.tum.de";
+       const char *recipient_address = emailAddress;
        char tempFileName[1000];
        int tempFd;
        FILE *fp;
@@ -193,7 +191,7 @@ void sendMail()
        sprintf(tempFileName, "/tmp/messageXXXXXX");
        tempFd = mkstemp(tempFileName);
        fp = fdopen(tempFd, "w");
-       fprintf(fp, "Hello! This is a test message!\r\n");
+       fprintf(fp, "%s", messageContents);
        fclose(fp);     
        fp = fopen(tempFileName, "r");
        smtp_set_message_fp(message, fp);
@@ -222,14 +220,7 @@ void sendMail()
        /* Free resources consumed by the program.
         */
        smtp_destroy_session(session);
-       auth_destroy_context(authctx);
        fclose(fp);
        auth_client_exit();
-       exit(0);
 }
 
-int main()
-{
-       sendMail();
-       return 0;
-}