]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/pop3/serv_pop3.c
* More license declarations
[citadel.git] / citadel / modules / pop3 / serv_pop3.c
index e839f5ec9c6e4c72c0148069ed759206c96211e6..baee5a2aafc6926e7687f76d7da763d6a188323f 100644 (file)
@@ -2,8 +2,22 @@
  * $Id$ 
  *
  * POP3 service for the Citadel system
- * Copyright (C) 1998-2001 by Art Cancro and others.
- * This code is released under the terms of the GNU General Public License.
+ *
+ * Copyright (c) 1998-2009 by the citadel.org team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * Current status of standards conformance:
  *
@@ -159,7 +173,7 @@ void pop3_add_message(long msgnum, void *userdata) {
                CC->redirect_buffer = malloc(SIZ);
                CC->redirect_len = 0;
                CC->redirect_alloc = SIZ;
-               CtdlOutputMsg(msgnum, MT_RFC822, HEADERS_ALL, 0, 1, NULL);
+               CtdlOutputMsg(msgnum, MT_RFC822, HEADERS_ALL, 0, 1, NULL, SUPPRESS_ENV_TO);
                smi.meta_rfc822_length = CC->redirect_len;
                free(CC->redirect_buffer);
                CC->redirect_buffer = NULL;
@@ -360,10 +374,6 @@ void pop3_stat(char *argbuf) {
  */
 void pop3_retr(char *argbuf) {
        int which_one;
-       char *msgtext;
-       char *nextline;
-       char *chunk_to_send;
-       char prev_char;
 
        which_one = atoi(argbuf);
        if ( (which_one < 1) || (which_one > POP3->num_msgs) ) {
@@ -377,41 +387,10 @@ void pop3_retr(char *argbuf) {
        }
 
        cprintf("+OK Message %d:\r\n", which_one);
-       CC->redirect_buffer = malloc(SIZ);
-       CC->redirect_len = 0;
-       CC->redirect_alloc = SIZ;
        CtdlOutputMsg(POP3->msgs[which_one - 1].msgnum,
-                       MT_RFC822, HEADERS_ALL, 0, 1, NULL);
-       msgtext = CC->redirect_buffer;
-       CC->redirect_buffer = NULL;
-       CC->redirect_len = 0;
-       CC->redirect_alloc = 0;
-
-       /* If we reach this point, the client is expecting data.
-        * Need to parse each line of the message here since someone may have sent
-        * a message containing a single dot on a line of its own. In that case we
-        * need to escape it in accordance with RFC821.
-        * We could do this with the tokenizer functions but num_tokens returns an
-        * int and the message may contain more lines than that, also copying each
-        * line would be slow.
-        */
-       nextline = msgtext;
-       while (*nextline)
-       {
-               chunk_to_send = nextline;
-               while (*nextline != '\n')
-                       nextline++;
-               nextline++;
-               prev_char = *nextline;
-               *nextline = '\0';
-               if (!strcmp(chunk_to_send, ".\r\n")) {
-                       client_write("..\r\n", 4);
-               }
-               else {
-                       client_write(chunk_to_send, (size_t)(nextline-chunk_to_send));
-               }
-               *nextline = prev_char;
-       }
+               MT_RFC822, HEADERS_ALL, 0, 1, NULL,
+               (ESC_DOT|SUPPRESS_ENV_TO)
+       );
        cprintf(".\r\n");
 }
 
@@ -443,8 +422,7 @@ void pop3_top(char *argbuf) {
        CC->redirect_buffer = malloc(SIZ);
        CC->redirect_len = 0;
        CC->redirect_alloc = SIZ;
-       CtdlOutputMsg(POP3->msgs[which_one - 1].msgnum,
-                       MT_RFC822, HEADERS_ALL, 0, 1, NULL);
+       CtdlOutputMsg(POP3->msgs[which_one - 1].msgnum, MT_RFC822, HEADERS_ALL, 0, 1, NULL, SUPPRESS_ENV_TO);
        msgtext = CC->redirect_buffer;
        CC->redirect_buffer = NULL;
        CC->redirect_len = 0;
@@ -709,6 +687,11 @@ void pop3_command_loop(void) {
        else if (!CC->logged_in) {
                cprintf("-ERR Not logged in.\r\n");
        }
+       
+       else if (CC->nologin) {
+               cprintf("-ERR System busy, try later.\r\n");
+               CC->kill_me = 1;
+       }
 
        else if (!strncasecmp(cmdbuf, "LIST", 4)) {
                pop3_list(&cmdbuf[5]);