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

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  change_prn()
  5. **
  6. **  A function to change the standard printer device for the duration
  7. **  of a program. Valid new device codes are:
  8. **
  9. **      0 - LPT1
  10. **      1 - LPT2
  11. **      2 - LPT3
  12. **      3 - COM1
  13. **      4 - COM2
  14. **      5 - CON
  15. **
  16. **  Original Copyright 1988-1991 by Bob Stout as part of
  17. **  the MicroFirm Function Library (MFL)
  18. **
  19. **  The user is granted a free limited license to use this source file
  20. **  to create royalty-free programs, subject to the terms of the
  21. **  license restrictions specified in the LICENSE.MFL file.
  22. */
  23.  
  24. #include "sniprint.h"               /* Includes PrintDevice typedef     */
  25.  
  26. int change_prn(PrintDevice device)
  27. {
  28.       char *newdev;
  29.  
  30.       switch (device)
  31.       {
  32.       case LPT1:
  33.             newdev = "LPT1";
  34.             break;
  35.       case LPT2:
  36.             newdev = "LPT2";
  37.             break;
  38.       case LPT3:
  39.             newdev = "LPT3";
  40.             break;
  41.       case COM1:
  42.             newdev = "COM1";
  43.             break;
  44.       case COM2:
  45.             newdev = "COM2";
  46.             break;
  47.       case CON:
  48.             newdev = "CON";
  49.             break;
  50.       default:
  51.             return -1;
  52.       }
  53.       return (NULL == freopen(newdev, "w", stdprn));
  54. }
  55.