home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 21 / macformat_21.iso / Shareware / Programación / VideoToolbox / VideoToolboxSources / ffprintf.c < prev    next >
Text File  |  1995-07-19  |  1KB  |  46 lines

  1. /*
  2. ffprintf.c
  3. ffprintf(o,format,...);
  4. Uses fprintf to print 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. 7/19/95 dgp made compatible with Standard C.
  12. */
  13. #include "VideoToolbox.h"
  14. #include <stdarg.h>      /* for variable-number-of-argument macros */
  15.  
  16. int ffprintf(FILE *stream[2],char *format,...)
  17. {
  18.     va_list args;
  19.     int i,j;
  20.     #if MAC_C
  21.         GDHandle oldDevice;
  22.         long qD=0;
  23.     #endif
  24.   
  25.     #if MAC_C
  26.         Gestalt(gestaltQuickdrawVersion,&qD);
  27.         if(qD>=gestalt8BitQD){
  28.             oldDevice = GetGDevice();
  29.             SetGDevice(GetMainDevice());
  30.         }
  31.     #endif
  32.     
  33.     /* print copies to all non-NULL streams in stream[] */
  34.     for(i=0;i<2; i++){
  35.         va_start(args, format);
  36.         if(stream[i] != NULL) j=vfprintf(stream[i],format,args);
  37.     }
  38.     va_end(args);
  39.     
  40.     #if MAC_C
  41.         if(qD>=gestalt8BitQD)SetGDevice(oldDevice);
  42.     #endif
  43.  
  44.     return j;
  45. }
  46.