home *** CD-ROM | disk | FTP | other *** search
- /*
- ** prtoggle()
- **
- ** Tee's all standard output to the printer.
- **
- ** Parameters: None
- **
- ** Returns: 0 if operation was successful.
- ** -1 if stdout or stdin is redirected.
- **
- ** Side effects: Flushes the keyboard buffer
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <io.h>
- #ifdef __ZTC__ /* Zortech C/C++ doesn't support ungetch() */
- #include <mflsys.h> /* Part of the MFLZT shareware library */
- #endif
-
- int cdecl prtoggle(void)
- {
- if (!isatty(fileno(stdin)) || !isatty(fileno(stdout)))
- return -1;
- while (kbhit()) /* Flush the keyboard buffer */
- getch();
- ungetch('P' - 64); /* Stuff a Ctrl-P into the buffer */
- system(""); /* Let COMMAND.COM do the work */
- return 0;
- }
-