]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/spam/serv_spam.c
* Removed the 'protocol' parameter from the sock_connect() function. All we have...
[citadel.git] / citadel / modules / spam / serv_spam.c
index b8f3a6c960d5d669e5cb78005406994402ee7721..3473a82d2a36f032e144d7da001b06abd42190d9 100644 (file)
@@ -58,7 +58,6 @@
 #include "config.h"
 #include "control.h"
 #include "user_ops.h"
-#include "policy.h"
 #include "database.h"
 #include "msgbase.h"
 #include "internet_addressing.h"
@@ -80,8 +79,7 @@ int spam_assassin(struct CtdlMessage *msg) {
        char buf[SIZ];
        int is_spam = 0;
        int sa;
-       char *msgtext;
-       size_t msglen;
+       StrBuf *msgtext;
        CitContext *CCC=CC;
 
        /* For users who have authenticated to this server we never want to
@@ -97,7 +95,7 @@ int spam_assassin(struct CtdlMessage *msg) {
         for (sa=0; sa<num_sahosts; ++sa) {
                 extract_token(buf, sahosts, sa, '|', sizeof buf);
                 CtdlLogPrintf(CTDL_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
-                sock = sock_connect(buf, SPAMASSASSIN_PORT, "tcp");
+                sock = sock_connect(buf, SPAMASSASSIN_PORT);
                 if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
         }
 
@@ -118,18 +116,13 @@ int spam_assassin(struct CtdlMessage *msg) {
        sock_write(&sock, buf, strlen(buf));
 
        /* Message */
-       CCC->redirect_buffer = malloc(SIZ);
-       CCC->redirect_len = 0;
-       CCC->redirect_alloc = SIZ;
+       CCC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
        CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1, 0);
        msgtext = CC->redirect_buffer;
-       msglen = CC->redirect_len;
-       CCC->redirect_buffer = NULL;
-       CCC->redirect_len = 0;
-       CCC->redirect_alloc = 0;
+       CC->redirect_buffer = NULL;
 
-       sock_write(&sock, msgtext, msglen);
-       free(msgtext);
+       sock_write(&sock, SKEY(msgtext));
+       FreeStrBuf(&msgtext);
 
        /* Close one end of the socket connection; this tells SpamAssassin
         * that we're done.