1 /* $OpenBSD: wsetup.c,v 1.7 2005/08/08 08:05:36 espie Exp $ */
3 * SPDX-License-Identifier: BSD-3-Clause
5 * Copyright (C) 1990, 1993
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
18 * Various output routines call wsetup to be sure it is safe to write,
19 * because either _flags does not include __SWR, or _buf is NULL.
20 * _wsetup returns 0 if OK to write, nonzero otherwise.
23 __swsetup(LTTNG_UST_LFILE
*fp
)
25 /* make sure stdio is set up */
30 * If we are not writing, we had better be reading and writing.
32 if ((fp
->_flags
& __SWR
) == 0) {
33 if ((fp
->_flags
& __SRW
) == 0)
35 if (fp
->_flags
& __SRD
) {
36 /* clobber any ungetc data */
39 fp
->_flags
&= ~(__SRD
|__SEOF
);
41 fp
->_p
= fp
->_bf
._base
;
47 * Make a buffer if necessary, then set _w.
49 if (fp
->_bf
._base
== NULL
) {
50 // if ((fp->_flags & (__SSTR | __SALC)) == __SSTR)
55 if (fp
->_flags
& __SLBF
) {
57 * It is line buffered, so make _lbfsize be -_bufsize
58 * for the putc() macro. We will change _lbfsize back
59 * to 0 whenever we turn off __SWR.
62 fp
->_lbfsize
= -fp
->_bf
._size
;
64 fp
->_w
= fp
->_flags
& __SNBF
? 0 : fp
->_bf
._size
;
This page took 0.030506 seconds and 4 git commands to generate.