/*
* (POP3Lite) HomeBox - 3lite POP3 Daemon (~/mbox support)
* 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>
#ifdef DEBUG
# include <syslog.h>
#endif
static const char rcsid[]="$Id: homebox.c,v 1.4 2001/01/12 15:58:59 algernon Exp $";
int homebox_LTX_module_done ( P3LControl *control );
int homebox_LTX_module_init ( P3LControl *control );
static P3LHook_get_mailbox B_homebox_get_mailbox;
static char *homebox_get_mailbox ( P3LControl *control );
/**
* homebox_get_mailbox: determine mailbox filename
* @control: the usual control struct
*
* Alternative way of determining the mailbox path.
*
* Returns: path to the mailbox.
**/
static char *
homebox_get_mailbox ( P3LControl *control )
{
char *user, *mb_name;
UserInfo *ui;
#ifdef DEBUG
control->system->log ( control, LOG_DEBUG, "%s:%d: get mailbox (%s)",
__FILE__, __LINE__, P3L_GET_DATA ("USER" ) );
#endif
/*
* Look up the userinfo...
*/
user = P3L_GET_DATA ( "USER" );
ui = control->system->getuinam ( control, user );
/*
* In the unlikely (impossible?) case when the
* requested user is not found, we return NULL.
*/
if ( ui == NULL )
return NULL;
/*
* Get options
*/
mb_name = P3L_GET_FIRST_OPTION ( "HOMEBOX.MAILBOX" );
if ( mb_name == NULL )
mb_name = "mbox";
/*
* Return mailbox path
*/
return g_strdup_printf ( "%s/%s", ui->home, mb_name );
}
int
homebox_LTX_module_init ( P3LControl *control )
{
#ifdef DEBUG
control->system->log ( control, LOG_DEBUG, "%s:%d: init mod-HomeBox",
__FILE__, __LINE__ );
#endif
B_homebox_get_mailbox = (P3LHook_get_mailbox)
p3l_command_replace ( control->hooks, "GET-MAILBOX",
(gpointer) homebox_get_mailbox );
return 0;
}
int
homebox_LTX_module_done ( P3LControl *control )
{
#ifdef DEBUG
control->system->log ( control, LOG_DEBUG, "%s:%d: done mod-HomeBox",
__FILE__, __LINE__ );
#endif
g_hash_table_insert ( control->hooks, "GET-MAILBOX",
(gpointer) B_homebox_get_mailbox );
return 0;
}
syntax highlighted by Code2HTML, v. 0.9.1