1 /* dribble.c -- dribble files for Info.
3 Copyright (C) 1993, 98 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 = (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 (name)
34 /* Perhaps close existing dribble file. */
35 close_dribble_file ();
37 /* Keystrokes can be non-printable characters, so we need binary I/O. */
38 info_dribble_file = fopen (name, FOPEN_WBIN);
40 #if defined (HAVE_SETVBUF)
41 if (info_dribble_file)
42 # if defined (SETVBUF_REVERSED)
43 setvbuf (info_dribble_file, _IONBF, (char *)NULL, 1);
45 setvbuf (info_dribble_file, (char *)NULL, _IONBF, 1);
46 # endif /* !SETVBUF_REVERSED */
47 #endif /* HAVE_SETVBUF */
50 /* If there is a dribble file already open, close it. */
54 if (info_dribble_file)
56 fflush (info_dribble_file);
57 fclose (info_dribble_file);
58 info_dribble_file = (FILE *)NULL;
62 /* Write some output to our existing dribble file. */
67 if (info_dribble_file)
68 fwrite (&byte, sizeof (unsigned char), 1, info_dribble_file);