fclose.c revision 49218d4f8e4d84d1c08aeb267bcf6e451f2056dc
/*
* Copyright (c) 2000-2002, 2004 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <errno.h>
#include <stdlib.h>
#include <setjmp.h>
#include "local.h"
static jmp_buf CloseTimeOut;
/*
** CLOSEALRM -- handler when timeout activated for sm_io_close()
**
** Returns flow of control to where setjmp(CloseTimeOut) was set.
**
** Parameters:
** sig -- unused
**
** Returns:
** does not return
**
** Side Effects:
** returns flow of control to setjmp(CloseTimeOut).
**
** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
** DOING.
*/
/* ARGSUSED0 */
static void
int sig;
{
}
/*
**
** Parameters:
** fp -- file pointer to be closed
** timeout -- maximum time allowed to perform the close (millisecs)
**
** Returns:
** 0 on success
** -1 on failure and sets errno
**
** Side Effects:
** file pointer 'fp' will no longer be valid.
*/
int
int SM_NONVOLATILE timeout;
{
register int SM_NONVOLATILE r;
{
return SM_IO_EOF;
}
/* XXX this won't be reached if above macro is active */
{
/* not open! */
return SM_IO_EOF;
}
{
/* no close function! */
return SM_IO_EOF;
}
{
/* decrement file pointer open count */
return 0;
}
/* Okay, this is where we set the timeout. */
if (timeout == SM_TIME_DEFAULT)
if (timeout == SM_TIME_IMMEDIATE)
{
return -1;
}
/* No more duplicates of file pointer. Flush buffer and close */
/* sm_flush() has updated to.it_value for the time it's used */
if (timeout != SM_TIME_FOREVER)
{
if (setjmp(CloseTimeOut) != 0)
{
return SM_IO_EOF;
}
}
r = SM_IO_EOF;
/* We're back. So undo our timeout and handler */
{
}
return r;
}