3a509a243a29cf9c583132f1593d7e368ee02943
[ira/wip.git] / source3 / include / nt_printing.h
1 /*
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    SMB parameters and setup
5    Copyright (C) Andrew Tridgell              1992-2000,
6    Copyright (C) Jean Francois Micouleau      1998-2000.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef NT_PRINTING_H_
23 #define NT_PRINTING_H_
24
25 /* container for a single registry key */
26
27 typedef struct {
28         char                    *name;
29         struct regval_ctr       *values;
30 } NT_PRINTER_KEY;
31
32 /* container for all printer data */
33
34 typedef struct {
35         int             num_keys;
36         NT_PRINTER_KEY  *keys;
37 } NT_PRINTER_DATA;
38
39 #define MAXDEVICENAME   32
40
41 typedef struct ntdevicemode
42 {
43         fstring devicename;
44         fstring formname;
45
46         uint16  specversion;
47         uint16  driverversion;
48         uint16  size;
49         uint16  driverextra;
50         uint16  orientation;
51         uint16  papersize;
52         uint16  paperlength;
53         uint16  paperwidth;
54         uint16  scale;
55         uint16  copies;
56         uint16  defaultsource;
57         uint16  printquality;
58         uint16  color;
59         uint16  duplex;
60         uint16  yresolution;
61         uint16  ttoption;
62         uint16  collate;
63         uint16  logpixels;
64
65         uint32  fields;
66         uint32  bitsperpel;
67         uint32  pelswidth;
68         uint32  pelsheight;
69         uint32  displayflags;
70         uint32  displayfrequency;
71         uint32  icmmethod;
72         uint32  icmintent;
73         uint32  mediatype;
74         uint32  dithertype;
75         uint32  reserved1;
76         uint32  reserved2;
77         uint32  panningwidth;
78         uint32  panningheight;
79         uint8   *nt_dev_private;
80 } NT_DEVICEMODE;
81
82 typedef struct nt_printer_info_level_2
83 {
84         uint32 attributes;
85         uint32 priority;
86         uint32 default_priority;
87         uint32 starttime;
88         uint32 untiltime;
89         uint32 status;
90         uint32 cjobs;
91         uint32 averageppm;
92         fstring servername;
93         fstring printername;
94         fstring sharename;
95         fstring portname;
96         fstring drivername;
97         char comment[1024];
98         fstring location;
99         NT_DEVICEMODE *devmode;
100         fstring sepfile;
101         fstring printprocessor;
102         fstring datatype;
103         fstring parameters;
104         NT_PRINTER_DATA *data;
105         SEC_DESC_BUF *secdesc_buf;
106         uint32 changeid;
107         uint32 c_setprinter;
108         uint32 setuptime;       
109 } NT_PRINTER_INFO_LEVEL_2;
110
111 typedef struct nt_printer_info_level
112 {
113         NT_PRINTER_INFO_LEVEL_2 *info_2;
114 } NT_PRINTER_INFO_LEVEL;
115
116 typedef struct
117 {
118         fstring name;
119         uint32 flag;
120         uint32 width;
121         uint32 length;
122         uint32 left;
123         uint32 top;
124         uint32 right;
125         uint32 bottom;
126 } nt_forms_struct;
127
128 #ifndef SAMBA_PRINTER_PORT_NAME
129 #define SAMBA_PRINTER_PORT_NAME "Samba Printer Port"
130 #endif
131
132 /* DOS header format */
133 #define DOS_HEADER_SIZE                 64
134 #define DOS_HEADER_MAGIC_OFFSET         0
135 #define DOS_HEADER_MAGIC                0x5A4D
136 #define DOS_HEADER_LFANEW_OFFSET        60
137
138 /* New Executable format (Win or OS/2 1.x segmented) */
139 #define NE_HEADER_SIZE                  64
140 #define NE_HEADER_SIGNATURE_OFFSET      0
141 #define NE_HEADER_SIGNATURE             0x454E
142 #define NE_HEADER_TARGET_OS_OFFSET      54
143 #define NE_HEADER_TARGOS_WIN            0x02
144 #define NE_HEADER_MINOR_VER_OFFSET      62
145 #define NE_HEADER_MAJOR_VER_OFFSET      63
146
147 /* Portable Executable format */
148 #define PE_HEADER_SIZE                  24
149 #define PE_HEADER_SIGNATURE_OFFSET      0
150 #define PE_HEADER_SIGNATURE             0x00004550
151 #define PE_HEADER_MACHINE_OFFSET        4
152 #define PE_HEADER_MACHINE_I386          0x14c
153 #define PE_HEADER_NUMBER_OF_SECTIONS    6
154 #define PE_HEADER_OPTIONAL_HEADER_SIZE  20
155 #define PE_HEADER_SECT_HEADER_SIZE      40
156 #define PE_HEADER_SECT_NAME_OFFSET      0
157 #define PE_HEADER_SECT_SIZE_DATA_OFFSET 16
158 #define PE_HEADER_SECT_PTR_DATA_OFFSET  20
159
160 /* Microsoft file version format */
161 #define VS_SIGNATURE                    "VS_VERSION_INFO"
162 #define VS_MAGIC_VALUE                  0xfeef04bd
163 #define VS_MAJOR_OFFSET                                 8
164 #define VS_MINOR_OFFSET                                 12
165 #define VS_VERSION_INFO_UNICODE_SIZE    (sizeof(VS_SIGNATURE)*2+4+VS_MINOR_OFFSET+4) /* not true size! */
166 #define VS_VERSION_INFO_SIZE            (sizeof(VS_SIGNATURE)+4+VS_MINOR_OFFSET+4)   /* not true size! */
167 #define VS_NE_BUF_SIZE                  4096  /* Must be > 2*VS_VERSION_INFO_SIZE */
168
169 /* Notify spoolss clients that something has changed.  The
170    notification data is either stored in two uint32 values or a
171    variable length array. */
172
173 #define SPOOLSS_NOTIFY_MSG_UNIX_JOBID 0x0001    /* Job id is unix  */
174
175 typedef struct spoolss_notify_msg {
176         fstring printer;        /* Name of printer notified */
177         uint32 type;            /* Printer or job notify */
178         uint32 field;           /* Notify field changed */
179         uint32 id;              /* Job id */
180         uint32 len;             /* Length of data, 0 for two uint32 value */
181         uint32 flags;
182         union {
183                 uint32 value[2];
184                 char *data;
185         } notify;
186 } SPOOLSS_NOTIFY_MSG;
187
188 typedef struct {
189         fstring                 printername;
190         uint32                  num_msgs;
191         SPOOLSS_NOTIFY_MSG      *msgs;
192 } SPOOLSS_NOTIFY_MSG_GROUP;
193
194 typedef struct {
195         TALLOC_CTX                      *ctx;
196         uint32                          num_groups;
197         SPOOLSS_NOTIFY_MSG_GROUP        *msg_groups;
198 } SPOOLSS_NOTIFY_MSG_CTR;
199
200 #define SPLHND_PRINTER          1
201 #define SPLHND_SERVER           2
202 #define SPLHND_PORTMON_TCP      3
203 #define SPLHND_PORTMON_LOCAL    4
204
205 /* structure to store the printer handles */
206 /* and a reference to what it's pointing to */
207 /* and the notify info asked about */
208 /* that's the central struct */
209 typedef struct _Printer{
210         struct _Printer *prev, *next;
211         bool document_started;
212         bool page_started;
213         uint32 jobid; /* jobid in printing backend */
214         int printer_type;
215         fstring servername;
216         fstring sharename;
217         uint32 type;
218         uint32 access_granted;
219         struct {
220                 uint32 flags;
221                 uint32 options;
222                 fstring localmachine;
223                 uint32 printerlocal;
224                 struct spoolss_NotifyOption *option;
225                 struct policy_handle client_hnd;
226                 bool client_connected;
227                 uint32 change;
228                 /* are we in a FindNextPrinterChangeNotify() call? */
229                 bool fnpcn;
230         } notify;
231         struct {
232                 fstring machine;
233                 fstring user;
234         } client;
235         
236         /* devmode sent in the OpenPrinter() call */
237         NT_DEVICEMODE   *nt_devmode;
238         
239         /* cache the printer info */
240         NT_PRINTER_INFO_LEVEL *printer_info;
241         
242 } Printer_entry;
243
244 /*
245  * The printer attributes.
246  * I #defined all of them (grabbed form MSDN)
247  * I'm only using:
248  * ( SHARED | NETWORK | RAW_ONLY )
249  * RAW_ONLY _MUST_ be present otherwise NT will send an EMF file
250  */
251
252 #define PRINTER_ATTRIBUTE_SAMBA                 (PRINTER_ATTRIBUTE_RAW_ONLY|\
253                                                  PRINTER_ATTRIBUTE_SHARED|\
254                                                  PRINTER_ATTRIBUTE_LOCAL)
255 #define PRINTER_ATTRIBUTE_NOT_SAMBA             (PRINTER_ATTRIBUTE_NETWORK)
256
257 #define DRIVER_ANY_VERSION              0xffffffff
258 #define DRIVER_MAX_VERSION              4
259
260 struct print_architecture_table_node {
261         const char      *long_archi;
262         const char      *short_archi;
263         int     version;
264 };
265
266 #endif /* NT_PRINTING_H_ */