printer.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2004 by the Free Pascal development team
  5. Common part of implementation for unit Printer.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$I-}
  13. var
  14. Old_Exit: pointer;
  15. LstAvailable: boolean;
  16. function IsLstAvailable: boolean;
  17. begin
  18. IsLstAvailable := LstAvailable;
  19. end;
  20. procedure Printer_Exit;
  21. begin
  22. if LstAvailable then
  23. Close (Lst);
  24. ExitProc := Old_Exit;
  25. end;
  26. procedure InitPrinter (const PrinterName: string);
  27. var
  28. OldInOutRes: word;
  29. begin
  30. (* Avoid potential problems with previous InOutRes value... *)
  31. OldInOutRes := InOutRes;
  32. InOutRes := 0;
  33. Assign (Lst, PrinterName);
  34. Rewrite (Lst);
  35. LstAvailable := InOutRes = 0;
  36. InOutRes := OldInOutRes;
  37. end;
  38. procedure SetPrinterExit;
  39. begin
  40. Old_Exit := ExitProc;
  41. ExitProc := @Printer_Exit;
  42. end;
  43. (* The default $I state is left for potential
  44. platform-specific part of implementation. *)
  45. {$I+}
  46. {
  47. $Log$
  48. Revision 1.1 2004-12-05 11:21:46 hajny
  49. * common implementation of unit printer - fix for bug 3421
  50. }