]>
Commit | Line | Data |
---|---|---|
21006e63 CW |
1 | /* |
2 | * lpr for cygwin/windows | |
3 | * | |
4 | * Copyright (C) 2000-2003 Rick Rankin | |
5 | * http://www.cygwin.com/ml/cygwin/2000-07/msg00320.html | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation in version 2 of the License. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | */ | |
20 | ||
21 | #if !defined(Printer_hh) | |
22 | #define Printer_hh | |
23 | ||
24 | #if HAVE_CONFIG_H | |
25 | # include "config.h" | |
26 | #endif | |
27 | #include "common.h" | |
28 | ||
29 | #include <string> | |
30 | #include <memory> | |
31 | #include <vector> | |
32 | ||
33 | #include "src/lpr/PrinterException.hh" | |
34 | ||
35 | using namespace std; | |
36 | ||
37 | class Printer | |
38 | { | |
39 | public: | |
40 | Printer(const string &name, bool debugFlag) | |
41 | throw(PrinterException); | |
42 | ~Printer(); | |
43 | ||
44 | void close(); | |
45 | void endDoc() | |
46 | throw(PrinterException); | |
47 | void endPage() | |
48 | throw(PrinterException); | |
49 | void flush() | |
50 | throw(PrinterException); | |
a18d2869 | 51 | bool getRawFlag() const; |
21006e63 CW |
52 | void print(istream & in, const string & docName) |
53 | throw(PrinterException); | |
54 | void put(unsigned char ch) | |
55 | throw(PrinterException); | |
a18d2869 | 56 | void setRawFlag(bool flag); |
21006e63 CW |
57 | void startDoc(const string & docName) |
58 | throw(PrinterException); | |
59 | void startPage() | |
60 | throw(PrinterException); | |
61 | void write(unsigned char *buf, unsigned int size) | |
62 | throw(PrinterException); | |
63 | ||
64 | private: | |
65 | ||
66 | typedef vector<PRINTER_INFO_5> PrinterList; | |
67 | ||
68 | // Don't want copy construction or assignment. | |
69 | Printer(const Printer & rhs); | |
70 | Printer & operator = (const Printer & rhs); | |
71 | ||
72 | // Enumerate the existing printers. | |
73 | PrinterList enumPrinters(DWORD flags, LPTSTR name) | |
74 | throw(PrinterException); | |
75 | ||
76 | // Map a port name (lpt1, etc) to a device name. | |
77 | void mapPortName() | |
78 | throw(PrinterException); | |
79 | ||
80 | // Open the printer if it's not already open. | |
81 | void open() | |
82 | throw(PrinterException); | |
83 | ||
84 | string m_devName; | |
85 | bool m_debugFlag; | |
86 | HANDLE m_devHandle; | |
87 | DEVMODE * m_devMode; | |
88 | unsigned char * m_buffer; | |
89 | unsigned int m_bufferSize; | |
90 | unsigned int m_bufferIndex; | |
a18d2869 | 91 | bool m_rawFlag; |
21006e63 CW |
92 | }; |
93 | ||
94 | #endif /* Printer_hh */ |