home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / PRTOGGLE.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  41 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  prtoggle()
  5. **
  6. **  Tee's all standard output to the printer.
  7. **
  8. **  Parameters: None
  9. **
  10. **  Returns:  0 if operation was successful.
  11. **           -1 if stdout or stdin is redirected.
  12. **
  13. **  Side effects: Flushes the keyboard buffer
  14. **
  15. **  Original Copyright 1988-1991 by Bob Stout as part of
  16. **  the MicroFirm Function Library (MFL)
  17. **
  18. **  The user is granted a free limited license to use this source file
  19. **  to create royalty-free programs, subject to the terms of the
  20. **  license restrictions specified in the LICENSE.MFL file.
  21. */
  22.  
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <conio.h>
  26. #include <io.h>
  27. #include "sniptype.h"
  28. #include "sniprint.h"
  29. #include "snipkbio.h"
  30.  
  31. int prtoggle(void)
  32. {
  33.       if (!isatty(fileno(stdin)) || !isatty(fileno(stdout)))
  34.             return -1;
  35.       while (kbhit())           /* Flush the keyboard buffer            */
  36.             getch();
  37.       ungetkey('P' - 64);       /* Stuff a Ctrl-P into the buffer       */
  38.       system("");               /* Let COMMAND.COM do the work          */
  39.       return 0;
  40. }
  41.