/* * Copyright (c) 1999 Ian Freislich * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: mailbox.c,v 1.41 2003/01/24 09:35:19 ianf Exp $ */ #include #include #include #include #include #ifdef SOLARIS #include "/usr/ucbinclude/fcntl.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include "poputil.h" #include "private.h" /* * Public Interface */ int mbox_op(struct connection *cxn, int cmd, char *arg1, char *arg2) { int num1 = 0, num2 = 0; if (cxn->flags & MAILBOX_F_CMD_LOG) syslog(LOG_NOTICE, "CLIENT: '%s' '%s' '%s'", ntocmd(cmd), arg1, arg2); if (arg1) { num1 = atoi(arg1); if (num1 < 1) { message(OUTOFRANGE); return(FALSE); } } else num1 = -1; if (arg2) { num2 = atoi(arg2); if (num2 < 0) { message(OUTOFRANGE); return(FALSE); } } else num2 = -1; switch (cxn->flags & MAILBOX_F_MAILMASK) { case MAILBOX_F_MAILDIRCOMPAT: case MAILBOX_F_MAILDIR: return(maildir_mbox_op(cxn, cmd, num1, num2)); break; case MAILBOX_F_MAILBOX: return(mbf_mbox_op(cxn, cmd, num1, num2)); break; case MAILBOX_F_MAILIDX: return(mailidx_mbox_op(cxn, cmd, num1, num2)); break; default: exit_error(EX_CONFIG, "mailbox type %0X not supported", cxn->flags & MAILBOX_F_MAILMASK); } return(TRUE); }