Back to index

citadel  8.12
Classes | Defines | Functions
serv_pop3.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pop3msg
struct  citpop3

Defines

#define POP3   ((struct citpop3 *)CC->session_specific_data)

Functions

void pop3_cleanup_function (void)
void pop3_greeting (void)
void pop3_user (char *argbuf)
void pop3_pass (char *argbuf)
void pop3_list (char *argbuf)
void pop3_command_loop (void)
void pop3_login (void)

Class Documentation

struct pop3msg

Definition at line 19 of file serv_pop3.h.

Class Members
int deleted
long msgnum
size_t rfc822_length
struct citpop3

Definition at line 25 of file serv_pop3.h.

Collaboration diagram for citpop3:
Class Members
int lastseen
struct pop3msg * msgs
int num_msgs

Define Documentation

#define POP3   ((struct citpop3 *)CC->session_specific_data)

Definition at line 36 of file serv_pop3.h.


Function Documentation

void pop3_cleanup_function ( void  )

Definition at line 79 of file serv_pop3.c.

                                 {

       /* Don't do this stuff if this is not a POP3 session! */
       if (CC->h_command_function != pop3_command_loop) return;

       syslog(LOG_DEBUG, "Performing POP3 cleanup hook");
       if (POP3->msgs != NULL) free(POP3->msgs);

       free(POP3);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pop3_command_loop ( void  )

Definition at line 566 of file serv_pop3.c.

                             {
       char cmdbuf[SIZ];

       time(&CC->lastcmd);
       memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
       if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
              syslog(LOG_ERR, "POP3 client disconnected: ending session.");
              CC->kill_me = KILLME_CLIENT_DISCONNECTED;
              return;
       }
       if (!strncasecmp(cmdbuf, "PASS", 4)) {
              syslog(LOG_INFO, "POP3: PASS...");
       }
       else {
              syslog(LOG_INFO, "POP3: %s", cmdbuf);
       }
       while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");

       if (!strncasecmp(cmdbuf, "NOOP", 4)) {
              cprintf("+OK No operation.\r\n");
       }

       else if (!strncasecmp(cmdbuf, "CAPA", 4)) {
              pop3_capa();
       }

       else if (!strncasecmp(cmdbuf, "QUIT", 4)) {
              cprintf("+OK Goodbye...\r\n");
              pop3_update();
              CC->kill_me = KILLME_CLIENT_LOGGED_OUT;
              return;
       }

       else if (!strncasecmp(cmdbuf, "USER", 4)) {
              pop3_user(&cmdbuf[5]);
       }

       else if (!strncasecmp(cmdbuf, "PASS", 4)) {
              pop3_pass(&cmdbuf[5]);
       }

#ifdef HAVE_OPENSSL
       else if (!strncasecmp(cmdbuf, "STLS", 4)) {
              pop3_stls();
       }
#endif

       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 = KILLME_NOLOGIN;
       }

       else if (!strncasecmp(cmdbuf, "LIST", 4)) {
              pop3_list(&cmdbuf[5]);
       }

       else if (!strncasecmp(cmdbuf, "STAT", 4)) {
              pop3_stat(&cmdbuf[5]);
       }

       else if (!strncasecmp(cmdbuf, "RETR", 4)) {
              pop3_retr(&cmdbuf[5]);
       }

       else if (!strncasecmp(cmdbuf, "DELE", 4)) {
              pop3_dele(&cmdbuf[5]);
       }

       else if (!strncasecmp(cmdbuf, "RSET", 4)) {
              pop3_rset(&cmdbuf[5]);
       }

       else if (!strncasecmp(cmdbuf, "UIDL", 4)) {
              pop3_uidl(&cmdbuf[5]);
       }

       else if (!strncasecmp(cmdbuf, "TOP", 3)) {
              pop3_top(&cmdbuf[4]);
       }

       else if (!strncasecmp(cmdbuf, "LAST", 4)) {
              pop3_last(&cmdbuf[4]);
       }

       else {
              cprintf("-ERR I'm afraid I can't do that.\r\n");
       }

}

Here is the call graph for this function:

Here is the caller graph for this function:

void pop3_greeting ( void  )

Definition at line 95 of file serv_pop3.c.

                         {
       strcpy(CC->cs_clientname, "POP3 session");
       CC->internal_pgm = 1;
       CC->session_specific_data = malloc(sizeof(struct citpop3));
       memset(POP3, 0, sizeof(struct citpop3));

       cprintf("+OK Citadel POP3 server ready.\r\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pop3_list ( char *  argbuf)

Definition at line 247 of file serv_pop3.c.

                             {
       int i;
       int which_one;

       which_one = atoi(argbuf);

       /* "list one" mode */
       if (which_one > 0) {
              if (which_one > POP3->num_msgs) {
                     cprintf("-ERR no such message, only %d are here\r\n",
                            POP3->num_msgs);
                     return;
              }
              else if (POP3->msgs[which_one-1].deleted) {
                     cprintf("-ERR Sorry, you deleted that message.\r\n");
                     return;
              }
              else {
                     cprintf("+OK %d %ld\r\n",
                            which_one,
                            (long)POP3->msgs[which_one-1].rfc822_length
                            );
                     return;
              }
       }

       /* "list all" (scan listing) mode */
       else {
              cprintf("+OK Here's your mail:\r\n");
              if (POP3->num_msgs > 0) for (i=0; i<POP3->num_msgs; ++i) {
                     if (! POP3->msgs[i].deleted) {
                            cprintf("%d %ld\r\n",
                                   i+1,
                                   (long)POP3->msgs[i].rfc822_length);
                     }
              }
              cprintf(".\r\n");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pop3_login ( void  )

Definition at line 207 of file serv_pop3.c.

{
       int msgs;
       
       msgs = pop3_grab_mailbox();
       if (msgs >= 0) {
              cprintf("+OK %s is logged in (%d messages)\r\n",
                     CC->user.fullname, msgs);
              syslog(LOG_NOTICE, "POP3 authenticated %s", CC->user.fullname);
       }
       else {
              cprintf("-ERR Can't open your mailbox\r\n");
       }
       
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pop3_pass ( char *  argbuf)

Definition at line 227 of file serv_pop3.c.

                             {
       char password[SIZ];

       safestrncpy(password, argbuf, sizeof password);
       striplt(password);

       /* syslog(LOG_DEBUG, "Trying <%s>", password); */
       if (CtdlTryPassword(password, strlen(password)) == pass_ok) {
              pop3_login();
       }
       else {
              cprintf("-ERR That is NOT the password.\r\n");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pop3_user ( char *  argbuf)

Definition at line 126 of file serv_pop3.c.

                             {
       char username[SIZ];

       if (CC->logged_in) {
              cprintf("-ERR You are already logged in.\r\n");
              return;
       }

       strcpy(username, argbuf);
       striplt(username);

       /* syslog(LOG_DEBUG, "Trying <%s>", username); */
       if (CtdlLoginExistingUser(NULL, username) == login_ok) {
              cprintf("+OK Password required for %s\r\n", username);
       }
       else {
              cprintf("-ERR No such user.\r\n");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function: