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);
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
+);
#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))
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.
*/
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);
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");
+/*
+ * list available msgs
+ */
+void pop3_list(char *argbuf) {
+ cprintf("-ERR oops, not finished\r\n");
+}
+
+
+
+
/*
* Main command loop for POP3 sessions.
*/
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");
}
CtdlRegisterServiceHook(POP3_PORT,
pop3_greeting,
pop3_command_loop);
+ CtdlRegisterSessionHook(pop3_cleanup_function, EVT_STOP);
return "$Id$";
}