summaryrefslogtreecommitdiff
path: root/fpcsrc/rtl/inc/printer.inc
blob: f00527289f2b7ec97d632f73c5a9cde9eccd27c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 1999-2004 by the Free Pascal development team

    Common part of implementation for unit Printer.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

{$I-}

var
  Old_Exit: pointer;
  LstAvailable: boolean;

function IsLstAvailable: boolean;
begin
  IsLstAvailable := LstAvailable;
end;

procedure Printer_Exit;
begin
  if LstAvailable then
    Close (Lst);
  ExitProc := Old_Exit;
end;

procedure InitPrinter (const PrinterName: string);
var
  OldInOutRes: word;
begin
(* Avoid potential problems with previous InOutRes value... *)
  OldInOutRes := InOutRes;
  InOutRes := 0;
  Assign (Lst, PrinterName);
  Rewrite (Lst);
  LstAvailable := InOutRes = 0;
  InOutRes := OldInOutRes;
end;

procedure SetPrinterExit;
begin
  Old_Exit := ExitProc;
  ExitProc := @Printer_Exit;
end;

(* The default $I state is left for potential
   platform-specific part of implementation.  *)
{$I+}