printer.inc 1.2 KB

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