home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / texinfo-3.12 / info / dribble.c < prev    next >
C/C++ Source or Header  |  2000-01-15  |  2KB  |  78 lines

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