1 /* dribble.c -- dribble files for Info.
2 $Id: dribble.c,v 1.3 2004/04/11 17:56:45 karl Exp $
4 Copyright (C) 1993, 1998, 2004 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 2, or (at your option)
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, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 Written by Brian Fox (bfox@ai.mit.edu). */
25 /* When non-zero, it is a stream to write all input characters to for the
26 duration of this info session. */
27 FILE *info_dribble_file
= (FILE *)NULL
;
29 /* Open a dribble file named NAME, perhaps closing an already open one.
30 This sets the global variable INFO_DRIBBLE_FILE to the open stream. */
32 open_dribble_file (char *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. */
52 close_dribble_file (void)
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. */
64 dribble (unsigned char byte
)
66 if (info_dribble_file
)
67 fwrite (&byte
, sizeof (unsigned char), 1, info_dribble_file
);