Did away with lprintf all together now its called CtdlLogPrintf()
[citadel.git] / citadel / modules / pop3 / serv_pop3.c
index e8f975c4dc5999508a6db56ed31aea114f86a0c6..c8bcb2fc93f425c902c60b17c90bc7c10be8ca31 100644 (file)
@@ -41,6 +41,7 @@
 #include <string.h>
 #include <limits.h>
 #include <ctype.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "citserver.h"
@@ -51,7 +52,6 @@
 #include "policy.h"
 #include "database.h"
 #include "msgbase.h"
-#include "tools.h"
 #include "internet_addressing.h"
 #include "serv_pop3.h"
 #include "md5.h"
@@ -71,7 +71,7 @@ void pop3_cleanup_function(void) {
        /* Don't do this stuff if this is not a POP3 session! */
        if (CC->h_command_function != pop3_command_loop) return;
 
-       lprintf(CTDL_DEBUG, "Performing POP3 cleanup hook\n");
+       CtdlLogPrintf(CTDL_DEBUG, "Performing POP3 cleanup hook\n");
        if (POP3->msgs != NULL) free(POP3->msgs);
 
        free(POP3);
@@ -85,7 +85,7 @@ void pop3_cleanup_function(void) {
 void pop3_greeting(void) {
        strcpy(CC->cs_clientname, "POP3 session");
        CC->internal_pgm = 1;
-       POP3 = malloc(sizeof(struct citpop3));
+       CC->session_specific_data = malloc(sizeof(struct citpop3));
        memset(POP3, 0, sizeof(struct citpop3));
 
        cprintf("+OK Citadel POP3 server %s\r\n",
@@ -125,7 +125,7 @@ void pop3_user(char *argbuf) {
        strcpy(username, argbuf);
        striplt(username);
 
-       /* lprintf(CTDL_DEBUG, "Trying <%s>\n", username); */
+       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", username); */
        if (CtdlLoginExistingUser(NULL, username) == login_ok) {
                cprintf("+OK Password required for %s\r\n", username);
        }
@@ -208,7 +208,7 @@ void pop3_login(void)
        if (msgs >= 0) {
                cprintf("+OK %s is logged in (%d messages)\r\n",
                        CC->user.fullname, msgs);
-               lprintf(CTDL_NOTICE, "POP3 authenticated %s\n", CC->user.fullname);
+               CtdlLogPrintf(CTDL_NOTICE, "POP3 authenticated %s\n", CC->user.fullname);
        }
        else {
                cprintf("-ERR Can't open your mailbox\r\n");
@@ -280,7 +280,7 @@ void pop3_pass(char *argbuf) {
        strcpy(password, argbuf);
        striplt(password);
 
-       /* lprintf(CTDL_DEBUG, "Trying <%s>\n", password); */
+       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", password); */
        if (CtdlTryPassword(password) == pass_ok) {
                pop3_login();
        }
@@ -622,15 +622,15 @@ void pop3_command_loop(void) {
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
-               lprintf(CTDL_ERR, "Client disconnected: ending session.\r\n");
+               CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\r\n");
                CC->kill_me = 1;
                return;
        }
        if (!strncasecmp(cmdbuf, "PASS", 4)) {
-               lprintf(CTDL_INFO, "POP3: PASS...\r\n");
+               CtdlLogPrintf(CTDL_INFO, "POP3: PASS...\r\n");
        }
        else {
-               lprintf(CTDL_INFO, "POP3: %s\r\n", cmdbuf);
+               CtdlLogPrintf(CTDL_INFO, "POP3: %s\r\n", cmdbuf);
        }
        while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
 
@@ -716,22 +716,25 @@ const char *CitadelServicePop3S="POP3S";
 
 CTDL_MODULE_INIT(pop3)
 {
-       CtdlRegisterServiceHook(config.c_pop3_port,
-                               NULL,
-                               pop3_greeting,
-                               pop3_command_loop,
-                               NULL,
-                               CitadelServicePop3);
+       if(!threading)
+       {
+               CtdlRegisterServiceHook(config.c_pop3_port,
+                                       NULL,
+                                       pop3_greeting,
+                                       pop3_command_loop,
+                                       NULL,
+                                       CitadelServicePop3);
 #ifdef HAVE_OPENSSL
-       CtdlRegisterServiceHook(config.c_pop3s_port,
-                               NULL,
-                               pop3s_greeting,
-                               pop3_command_loop,
-                               NULL,
-                               CitadelServicePop3S);
+               CtdlRegisterServiceHook(config.c_pop3s_port,
+                                       NULL,
+                                       pop3s_greeting,
+                                       pop3_command_loop,
+                                       NULL,
+                                       CitadelServicePop3S);
 #endif
-       CtdlRegisterSessionHook(pop3_cleanup_function, EVT_STOP);
-
+               CtdlRegisterSessionHook(pop3_cleanup_function, EVT_STOP);
+       }
+       
        /* return our Subversion id for the Log */
        return "$Id$";
 }