/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1989 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <malloc.h>
extern int fclose();
/*
* Flush buffers on exit
*/
void
_cleanup(void)
{
}
/*
* fclose() will flush (output) buffers for a buffered open
* FILE and then issue a system close on the _fileno. The
* _base field will be reset to NULL for any but stdin and
* stdout, the _ptr field will be set the same as the _base
* field. The _flags and the _cnt field will be zeroed.
* If buffers had been obtained via malloc(), the space will
* be free()'d. In case the FILE was not open, or fflush()
* or close() failed, an EOF will be returned, otherwise the
* return value is 0.
*/
int
{
return(rtn);
}
}
return(rtn);
}
/*
* The fflush() routine must take care because of the
* possibility for recursion. The calling program might
* do IO in an interupt catching routine that is likely
* to interupt the write() call within fflush()
*/
int
{
}
return(0);
}
}
/*
* The routine _flsbuf may or may not actually flush the output buffer. If
* the file is line-buffered, the fact that iop->_cnt has run below zero
* is meaningless: it is always kept below zero so that invocations of putc
* will consistently give control to _flsbuf, even if the buffer is far from
* full. _flsbuf, on seeing the "line-buffered" flag, determines whether the
* buffer is actually full by comparing iop->_ptr to the end of the buffer
* iop->_base + iop->_bufsiz. If it is full, or if an output line is
* completed (with a newline), the buffer is flushed. (Note: the character
* argument to _flsbuf is not flushed with the current buffer if the buffer
* is actually full -- it goes into the buffer after flushing.)
*/
int
{
unsigned char c1;
do {
/* check for linebuffered with write perm, but no EOF */
break; /* exit do-while, and flush buf. */
return(c);
}
/* write out an unbuffered file, if have write perm, but no EOF */
c1 = c;
return(c);
return(EOF);
}
/* The _wrtchk call is here rather than at the top of _flsbuf to re- */
/* duce overhead for line-buffered I/O under normal circumstances. */
return(EOF);
/* (which, because of signals, may NOT be empty) */
}
/*
* The function _xflsbuf writes out the current contents of the output
* buffer delimited by iop->_base and iop->_ptr.
* iop->_cnt is reset appropriately, but its value on entry to _xflsbuf
* is ignored.
*
* The following code is not strictly correct. If a signal is raised,
* invoking a signal-handler which generates output into the same buffer
* being flushed, a peculiar output sequence may result (for example,
* the output generated by the signal-handler may appear twice). At
* present no means has been found to guarantee correct behavior without
* resorting to the disabling of signals, a means considered too expensive.
* For now the code has been written with the intent of reducing the
* probability of strange effects and, when they do occur, of confining
* the damage. Except under extremely pathological circumstances, this
* code should be expected to respect buffer boundaries even in the face
* of interrupts and other signals.
*/
int
{
unsigned char *base;
int n;
return(EOF);
}
return(0);
}
/*
* The function _wrtchk checks to see whether it is legitimate to write
* to the specified device. If it is, _wrtchk sets flags in iop->_flag for
* writing, assures presence of a buffer, and returns 0. If writing is not
* legitimate, EOF is returned.
*/
int
{
return(EOF); /* bogus call--read-only file */
}
return(0); /* not our business to monkey with buffers or counts */
}
return(0);
}
/*
* _findbuf, called only when iop->_base == NULL, locates a predefined buffer
* or allocates a buffer using malloc. If a buffer is obtained from malloc,
* the _IOMYBUF flag is set in iop->_flag.
*/
void
{
int size;
/* allocate a small block for unbuffered, large for buffered */
} else {
size = 128;
} else {
else {
}
}
/* if we got a buffer */
} else {
/* if no room for buffer, use small buffer */
}
}
}
/*
* The function _bufsync is called because interrupts and other signals
* which occur in between the decrementing of iop->_cnt and the incrementing
* of iop->_ptr, or in other contexts as well, may upset the synchronization
* of iop->_cnt and iop->ptr. If this happens, calling _bufsync should
* resynchronize the two quantities (this is not always possible). Resyn-
* chronization guarantees that putc invocations will not write beyond
* the end of the buffer. Note that signals during _bufsync can cause
* _bufsync to do the wrong thing, but usually with benign effects.
*/
void
{
int spaceleft;
}