fpos.c revision 49218d4f8e4d84d1c08aeb267bcf6e451f2056dc
/*
* Copyright (c) 2000-2001, 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 <setjmp.h>
#include "local.h"
static jmp_buf TellTimeOut;
/*
** TELLALRM -- handler when timeout activated for sm_io_tell()
**
** Returns flow of control to where setjmp(TellTimeOut) was set.
**
** Parameters:
** sig -- unused
**
** Returns:
** does not return
**
** Side Effects:
** returns flow of control to setjmp(TellTimeOut).
**
** 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;
{
}
/*
** SM_IO_TELL -- position the file pointer
**
** Paramters:
** fp -- the file pointer to get repositioned
** timeout -- time to complete the tell (milliseconds)
**
** Returns:
** Success -- the repositioned location.
** Failure -- -1 (minus 1) and sets errno
*/
long
int SM_NONVOLATILE timeout;
{
{
return -1L;
}
if (timeout == SM_TIME_DEFAULT)
if (timeout == SM_TIME_IMMEDIATE)
{
/*
** Filling the buffer will take time and we are wanted to
** return immediately. So...
*/
return -1L;
}
/*
** Find offset of underlying I/O object, then adjust byte position
** may adjust seek offset on append stream
*/
/* This is where we start the timeout */
if (timeout != SM_TIME_FOREVER)
{
if (setjmp(TellTimeOut) != 0)
{
return -1L;
}
}
else
{
/* XXX only set the timeout here? */
if (pos == -1L)
goto clean;
}
{
/*
** Reading. Any unread characters (including
** those from ungetc) cause the position to be
** smaller than that in the underlying object.
*/
}
{
/*
** Writing. Any buffered characters cause the
** position to be greater than that in the
** underlying object.
*/
}
/* We're back. So undo our timeout and handler */
return pos;
}