aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sh/setlinebuf.c
blob: 05f95793b5d51b7599c48b2244ab2e9a86020575 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* setlinebuf.c - line-buffer a stdio stream. */

/* Copyright (C) 1997 Free Software Foundation, Inc.

   This file is part of GNU Bash, the Bourne Again SHell.

   Bash is free software; you can redistribute it and/or modify it under
   the terms of the GNU General Public License as published by the Free
   Software Foundation; either version 2, or (at your option) any later
   version.

   Bash is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   for more details.

   You should have received a copy of the GNU General Public License along
   with Bash; see the file COPYING.  If not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */

#include <config.h>

#if !defined (HAVE_SETLINEBUF)

#include <stdio.h>

/* Cause STREAM to buffer lines as opposed to characters or blocks. */
int
setlinebuf (stream)
     FILE *stream;
{
#if defined (_IOLBF)
#  if defined (SETVBUF_REVERSED)
  setvbuf (stream, _IOLBF, (char *)NULL, BUFSIZ);
#  else /* !SETVBUF_REVERSED */
  setvbuf (stream, (char *)NULL, _IOLBF, BUFSIZ);
#  endif /* !SETVBUF_REVERSED */
#endif /* _IOLBF */
  return (0);
}
#endif /* !HAVE_SETLINEBUF */