home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / utilities / cli / gnuinfo / Source / c / dribble < prev    next >
Encoding:
Text File  |  1994-10-01  |  2.1 KB  |  73 lines

  1. #include "defines.h"
  2. /* dribble.c -- Dribble files for Info. */
  3.  
  4. /* This file is part of GNU Info, a program for reading online documentation
  5.    stored in Info format.
  6.  
  7.    Copyright (C) 1993 Free Software Foundation, Inc.
  8.  
  9.    This program is free software; you can redistribute it and/or modify
  10.    it under the terms of the GNU General Public License as published by
  11.    the Free Software Foundation; either version 2, or (at your option)
  12.    any later version.
  13.  
  14.    This program is distributed in the hope that it will be useful,
  15.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.    GNU General Public License for more details.
  18.  
  19.    You should have received a copy of the GNU General Public License
  20.    along with this program; if not, write to the Free Software
  21.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23.    Written by Brian Fox (bfox@ai.mit.edu). */
  24.  
  25. #include <stdio.h>
  26. #include "dribble.h"
  27.  
  28. /* When non-zero, it is a stream to write all input characters to for the
  29.    duration of this info session. */
  30. FILE *info_dribble_file = (FILE *)NULL;
  31.  
  32. /* Open a dribble file named NAME, perhaps closing an already open one.
  33.    This sets the global variable INFO_DRIBBLE_FILE to the open stream. */
  34. void
  35. open_dribble_file (name)
  36.      char *name;
  37. {
  38.   /* Perhaps close existing dribble file. */
  39.   close_dribble_file ();
  40.  
  41.   info_dribble_file = fopen (name, "w");
  42.  
  43. #if defined (HAVE_SETVBUF)
  44.   if (info_dribble_file)
  45. #  if defined (SETVBUF_REVERSED)
  46.     setvbuf (info_dribble_file, _IONBF, (char *)NULL, 1);
  47. #  else
  48.     setvbuf (info_dribble_file, (char *)NULL, _IONBF, 1);
  49. #  endif /* !SETVBUF_REVERSED */
  50. #endif /* HAVE_SETVBUF */
  51. }
  52.  
  53. /* If there is a dribble file already open, close it. */
  54. void
  55. close_dribble_file ()
  56. {
  57.   if (info_dribble_file)
  58.     {
  59.       fflush (info_dribble_file);
  60.       fclose (info_dribble_file);
  61.       info_dribble_file = (FILE *)NULL;
  62.     }
  63. }
  64.  
  65. /* Write some output to our existing dribble file. */
  66. void
  67. dribble (byte)
  68.      unsigned char byte;
  69. {
  70.   if (info_dribble_file)
  71.     fwrite (&byte, sizeof (unsigned char), 1, info_dribble_file);
  72. }
  73.