*** empty log message ***
authorArt Cancro <ajc@citadel.org>
Mon, 17 Jan 2000 05:14:18 +0000 (05:14 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 17 Jan 2000 05:14:18 +0000 (05:14 +0000)
citadel/citserver.c
citadel/msgbase.h
citadel/serv_pop3.c

index 43c466b8590458f87b683bbf7cb31b90072318e6..14ab423b3a829f71ed61fbf2892e6d3b91a82d3e 100644 (file)
@@ -166,7 +166,10 @@ void RemoveContext (struct CitContext *con)
        unlink(con->temp);
        lprintf(3, "citserver[%3d]: ended.\n", con->cs_pid);
        
-       /* Run any cleanup routines registered by loadable modules */
+       /* Run any cleanup routines registered by loadable modules.
+        * (Must occur *before* deallocate_user_data() because the cleanup
+        * functions might touch dynamic session data)
+        */
        PerformSessionHooks(EVT_STOP);
 
        syslog(LOG_NOTICE,"session %d ended", con->cs_pid);
index b6c817848ab4d037493bde026c796b216660cefd..d9a5cf3259bce9c573c6badca85ecc76e6b4034e 100644 (file)
@@ -84,3 +84,10 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags);
 char *CtdlReadMessageBody(char *terminator, size_t maxlen, char *exist);
 char *CtdlGetSysConfig(char *sysconfname);
 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
+int CtdlOutputMsg(long msg_num,                /* message number (local) to fetch */
+               int mode,               /* how would you like that message? */
+               int headers_only,       /* eschew the message body? */
+               int do_proto,           /* do Citadel protocol responses? */
+               FILE *outfp,
+               int outsock
+);
index dfd93087cf68d0d3d22c98487d89af7bb1585fae..150993f240632b495a994a7498e80fbda9e5a57c 100644 (file)
 #include "internet_addressing.h"
 
 
+struct pop3msg {
+       long msgnum;
+       size_t rfc822_length;
+       int deleted;
+       FILE *temp;
+};
+
 struct citpop3 {               /* Information about the current session */
-       char FIX[3];
+       struct pop3msg *msgs;
+       int num_msgs;
 };
 
 #define POP3 ((struct citpop3 *)CtdlGetUserData(SYM_POP3))
@@ -39,6 +47,19 @@ struct citpop3 {             /* Information about the current session */
 long SYM_POP3;
 
 
+void pop3_cleanup_function(void) {
+       int i;
+
+       lprintf(9, "Performing POP3 cleanup hook\n");
+
+       if (POP3->num_msgs > 0) for (i=0; i<POP3->num_msgs; ++i) {
+               fclose(POP3->msgs[i].temp);
+       }
+       if (POP3->msgs != NULL) phree(POP3->msgs);
+}
+
+
+
 /*
  * Here's where our POP3 session begins its happy day.
  */
@@ -47,6 +68,8 @@ void pop3_greeting(void) {
        strcpy(CC->cs_clientname, "POP3 session");
        CC->internal_pgm = 1;
        CtdlAllocUserData(SYM_POP3, sizeof(struct citpop3));
+       POP3->msgs = NULL;
+       POP3->num_msgs = 0;
 
        cprintf("+OK Welcome to the Citadel/UX POP3 server at %s\r\n",
                config.c_fqdn);
@@ -88,8 +111,14 @@ void pop3_pass(char *argbuf) {
 
        lprintf(9, "Trying <%s>\n", password);
        if (CtdlTryPassword(password) == pass_ok) {
-               cprintf("+OK %s is logged in!\r\n", CC->usersupp.fullname);
-               lprintf(9, "POP3 password login successful\n");
+               if (getroom(&CC->quickroom, MAILROOM) == 0) {
+                       cprintf("+OK %s is logged in!\r\n",
+                               CC->usersupp.fullname);
+                       lprintf(9, "POP3 password login successful\n");
+               }
+               else {
+                       cprintf("-ERR can't find your mailbox\r\n");
+               }
        }
        else {
                cprintf("-ERR That is NOT the password!  Go away!\r\n");
@@ -98,6 +127,16 @@ void pop3_pass(char *argbuf) {
 
 
 
+/*
+ * list available msgs
+ */
+void pop3_list(char *argbuf) {
+       cprintf("-ERR oops, not finished\r\n");
+}
+
+
+
+
 /* 
  * Main command loop for POP3 sessions.
  */
@@ -136,6 +175,10 @@ void pop3_command_loop(void) {
                cprintf("-ERR Not logged in.\r\n");
        }
 
+       else if (!strncasecmp(cmdbuf, "LIST", 4)) {
+               pop3_list(&cmdbuf[5]);
+       }
+
        else {
                cprintf("500 I'm afraid I can't do that, Dave.\r\n");
        }
@@ -150,5 +193,6 @@ char *Dynamic_Module_Init(void)
        CtdlRegisterServiceHook(POP3_PORT,
                                pop3_greeting,
                                pop3_command_loop);
+       CtdlRegisterSessionHook(pop3_cleanup_function, EVT_STOP);
        return "$Id$";
 }