1 /* dribble.c -- dribble files for Info.
2 $Id: dribble.c,v 1.7 2008/06/11 09:55:41 gray Exp $
4 Copyright (C) 1993, 1998, 2004, 2007, 2008 Free Software Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Written by Brian Fox (bfox@ai.mit.edu). */
24 /* When non-zero, it is a stream to write all input characters to for the
25 duration of this info session. */
26 FILE *info_dribble_file = NULL;
28 /* Open a dribble file named NAME, perhaps closing an already open one.
29 This sets the global variable INFO_DRIBBLE_FILE to the open stream. */
31 open_dribble_file (char *name)
33 /* Perhaps close existing dribble file. */
34 close_dribble_file ();
36 /* Keystrokes can be non-printable characters, so we need binary I/O. */
37 info_dribble_file = fopen (name, FOPEN_WBIN);
39 #if defined (HAVE_SETVBUF)
40 if (info_dribble_file)
41 # if defined (SETVBUF_REVERSED)
42 setvbuf (info_dribble_file, _IONBF, NULL, 1);
44 setvbuf (info_dribble_file, NULL, _IONBF, 1);
45 # endif /* !SETVBUF_REVERSED */
46 #endif /* HAVE_SETVBUF */
49 /* If there is a dribble file already open, close it. */
51 close_dribble_file (void)
53 if (info_dribble_file)
55 fflush (info_dribble_file);
56 fclose (info_dribble_file);
57 info_dribble_file = NULL;
61 /* Write some output to our existing dribble file. */
63 dribble (unsigned char byte)
65 if (info_dribble_file)
66 fwrite (&byte, sizeof (unsigned char), 1, info_dribble_file);