/*
* 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 <stdlib.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include "local.h"
/*
** SM_SUBMORE_X -- expand ungetc buffer
**
** Expand the ungetc buffer `in place'. That is, adjust fp->f_p when
** the buffer moves, so that it points the same distance from the end,
** and move the bytes in the buffer around as necessary so that they
** are all at the end (stack-style).
**
** Parameters:
** fp -- the file pointer
**
** Results:
** none.
**
** Exceptions:
** F:sm_heap -- out of memory
*/
static void
{
register int i;
register unsigned char *p;
{
/* Get a buffer; f_ubuf is fixed size. */
return;
}
/* no overlap (hence can use memcpy) because we doubled the size */
}
/*
** SM_IO_UNGETC -- place a character back into the buffer just read
**
** Parameters:
** fp -- the file pointer affected
** timeout -- time to complete ungetc
** c -- the character to place back
**
** Results:
** On success, returns value of character placed back, 0-255.
** Returns SM_IO_EOF if c == SM_IO_EOF or if last operation
** was a write and flush failed.
**
** Exceptions:
** F:sm_heap -- out of memory
*/
int
int timeout;
int c;
{
if (c == SM_IO_EOF)
return SM_IO_EOF;
if (timeout == SM_TIME_IMMEDIATE)
{
/*
** Ungetting the buffer will take time and we are wanted to
** return immediately. So...
*/
return SM_IO_EOF;
}
if (!Sm_IO_DidInit)
sm_init();
{
/*
** Not already reading: no good unless reading-and-writing.
** Otherwise, flush any current write stuff.
*/
return SM_IO_EOF;
{
return SM_IO_EOF;
}
}
c = (unsigned char) c;
/*
** If we are in the middle of ungetc'ing, just continue.
** This may require expanding the current ungetc buffer.
*/
{
return c;
}
/*
** If we can handle this by simply backing up, do so,
** but never replace the original character.
** (This makes sscanf() work when scanning `const' data.)
*/
{
return c;
}
/*
** Create an ungetc buffer.
** Initially, we will use the `reserve' buffer.
*/
return c;
}