home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / U-Z / VideoToolBox Folder / VideoToolboxSources / ffprintf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-30  |  945 b   |  38 lines  |  [TEXT/KAHL]

  1. /*
  2. ffprintf.c
  3. fprintf(o,format,...);
  4. Prints to two output streams, o[0] and o[1], usually stdout and a file. 
  5. Any NULL stream is ignored.
  6. It also saves and restores the port and GDevice.
  7. Copyright (c) 1990 Denis G. Pelli
  8. HISTORY:
  9. 9/14/90    dgp    wrote it, based on my UserPrintf(), which it replaces
  10. 8/27/92    dgp    check for 8-bit quickdraw before using GDevices.
  11. */
  12. #include "VideoToolbox.h"
  13. #include <stdarg.h>      /* for variable-number-of-argument macros */
  14.  
  15. int ffprintf(FILE *stream[2],char *format,...)
  16. {
  17.     va_list args;
  18.     GDHandle oldDevice;
  19.     int i,j;
  20.     long value=0;
  21.   
  22.     Gestalt(gestaltQuickdrawVersion,&value);
  23.     if(value>=gestalt8BitQD){
  24.         oldDevice = GetGDevice();
  25.         SetGDevice(GetMainDevice());
  26.     }
  27.     
  28.     /* print copies to all non-NULL streams in stream[] */
  29.     for(i=0;i<2; i++){
  30.         va_start(args, format);
  31.         if(stream[i] != NULL) j=vfprintf(stream[i],format,args);
  32.     }
  33.     va_end(args);
  34.     
  35.     if(value>=gestalt8BitQD)SetGDevice(oldDevice);
  36.     return j;
  37. }
  38.