/*
* (POP3Lite) MailBox - 3lite POP3 Daemon (mailbox driver)
* Copyright (C) 2000, 2001 Gergely Nagy <8@free.bsd.hu>
*
* This file is part of POP3Lite.
*
* POP3Lite 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 2 of the License, or
* (at your option) any later version.
*
* POP3Lite 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
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <pop3lite.h>
#include <glib.h>
#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_LOCKFILE
# include <lockfile.h>
# include "mailbox-p.h"
#endif
#include "mailbox-trans.h"
#include "mailbox-upd.h"
#ifdef DEBUG
# include <syslog.h>
#endif
static const char rcsid[]="$Id: mailbox.c,v 1.6.2.1 2001/05/30 12:37:55 algernon Exp $";
int mailbox_LTX_module_init ( P3LControl *control );
int mailbox_LTX_module_done ( P3LControl *control );
#ifdef HAVE_LOCKFILE
int
mailbox_alarm_handler ( P3LControl *control )
{
lockfile_touch ( g_strdup_printf ( "%s.lock", P3L_GET_DATA ( "MAILBOX" ) ) );
return 0;
}
#endif
int
mailbox_LTX_module_init ( P3LControl *control )
{
#ifdef DEBUG
control->system->log ( control, LOG_DEBUG, "%s:%d: init mod-Mailbox",
__FILE__, __LINE__ );
#endif
control->trans_init = mailbox_trans_init;
control->update = mailbox_update;
/*
* We don't make backups. Why ? Because only one
* mailbox/maildir whatever is supported.
*/
g_hash_table_insert ( control->trans_commands, "DELE",
(gpointer) mailbox_cmd_trans_dele );
g_hash_table_insert ( control->trans_commands, "RETR",
(gpointer) mailbox_cmd_trans_retr );
g_hash_table_insert ( control->trans_commands, "TOP",
(gpointer) mailbox_cmd_trans_top );
return 0;
}
int
mailbox_LTX_module_done ( P3LControl *control )
{
int mailboxfd;
char *mailbox = P3L_GET_DATA ( "MAILBOX" );
#ifdef DEBUG
control->system->log ( control, LOG_DEBUG, "%s:%d: done mod-Mailbox",
__FILE__, __LINE__ );
#endif
/*
* We unlock the mailbox unconditionally, and don't
* care if it fails, for if it does, it is probably unlocked
* already.
*/
mailboxfd = GPOINTER_TO_INT ( g_hash_table_lookup ( control->data, "MAILBOXFD" ) );
p3l_unlock_fd ( mailboxfd, mailbox );
close ( mailboxfd );
g_hash_table_remove ( control->trans_commands, "DELE" );
g_hash_table_remove ( control->trans_commands, "RETR" );
g_hash_table_remove ( control->trans_commands, "TOP" );
control->trans_init = NULL;
control->update = NULL;
return 0;
}
syntax highlighted by Code2HTML, v. 0.9.1