import HEAD into svn+ssh://svn.samba.org/home/svn/samba/trunk
[metze/old/v3-2-winbind-ndr.git] / source / 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 2 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, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #ifndef NT_PRINTING_H_
24 #define NT_PRINTING_H_
25
26 #define ORIENTATION      0x00000001L
27 #define PAPERSIZE        0x00000002L
28 #define PAPERLENGTH      0x00000004L
29 #define PAPERWIDTH       0x00000008L
30 #define SCALE            0x00000010L
31 #define COPIES           0x00000100L
32 #define DEFAULTSOURCE    0x00000200L
33 #define PRINTQUALITY     0x00000400L
34 #define COLOR            0x00000800L
35 #define DUPLEX           0x00001000L
36 #define YRESOLUTION      0x00002000L
37 #define TTOPTION         0x00004000L
38 #define COLLATE          0x00008000L
39 #define FORMNAME         0x00010000L
40 #define LOGPIXELS        0x00020000L
41 #define BITSPERPEL       0x00040000L
42 #define PELSWIDTH        0x00080000L
43 #define PELSHEIGHT       0x00100000L
44 #define DISPLAYFLAGS     0x00200000L
45 #define DISPLAYFREQUENCY 0x00400000L
46 #define PANNINGWIDTH     0x00800000L
47 #define PANNINGHEIGHT    0x01000000L
48
49 #define ORIENT_PORTRAIT   1
50 #define ORIENT_LANDSCAPE  2
51
52 #define PAPER_FIRST                PAPER_LETTER
53 #define PAPER_LETTER               1  /* Letter 8 1/2 x 11 in               */
54 #define PAPER_LETTERSMALL          2  /* Letter Small 8 1/2 x 11 in         */
55 #define PAPER_TABLOID              3  /* Tabloid 11 x 17 in                 */
56 #define PAPER_LEDGER               4  /* Ledger 17 x 11 in                  */
57 #define PAPER_LEGAL                5  /* Legal 8 1/2 x 14 in                */
58 #define PAPER_STATEMENT            6  /* Statement 5 1/2 x 8 1/2 in         */
59 #define PAPER_EXECUTIVE            7  /* Executive 7 1/4 x 10 1/2 in        */
60 #define PAPER_A3                   8  /* A3 297 x 420 mm                    */
61 #define PAPER_A4                   9  /* A4 210 x 297 mm                    */
62 #define PAPER_A4SMALL             10  /* A4 Small 210 x 297 mm              */
63 #define PAPER_A5                  11  /* A5 148 x 210 mm                    */
64 #define PAPER_B4                  12  /* B4 (JIS) 250 x 354                 */
65 #define PAPER_B5                  13  /* B5 (JIS) 182 x 257 mm              */
66 #define PAPER_FOLIO               14  /* Folio 8 1/2 x 13 in                */
67 #define PAPER_QUARTO              15  /* Quarto 215 x 275 mm                */
68 #define PAPER_10X14               16  /* 10x14 in                           */
69 #define PAPER_11X17               17  /* 11x17 in                           */
70 #define PAPER_NOTE                18  /* Note 8 1/2 x 11 in                 */
71 #define PAPER_ENV_9               19  /* Envelope #9 3 7/8 x 8 7/8          */
72 #define PAPER_ENV_10              20  /* Envelope #10 4 1/8 x 9 1/2         */
73 #define PAPER_ENV_11              21  /* Envelope #11 4 1/2 x 10 3/8        */
74 #define PAPER_ENV_12              22  /* Envelope #12 4 \276 x 11           */
75 #define PAPER_ENV_14              23  /* Envelope #14 5 x 11 1/2            */
76 #define PAPER_CSHEET              24  /* C size sheet                       */
77 #define PAPER_DSHEET              25  /* D size sheet                       */
78 #define PAPER_ESHEET              26  /* E size sheet                       */
79 #define PAPER_ENV_DL              27  /* Envelope DL 110 x 220mm            */
80 #define PAPER_ENV_C5              28  /* Envelope C5 162 x 229 mm           */
81 #define PAPER_ENV_C3              29  /* Envelope C3  324 x 458 mm          */
82 #define PAPER_ENV_C4              30  /* Envelope C4  229 x 324 mm          */
83 #define PAPER_ENV_C6              31  /* Envelope C6  114 x 162 mm          */
84 #define PAPER_ENV_C65             32  /* Envelope C65 114 x 229 mm          */
85 #define PAPER_ENV_B4              33  /* Envelope B4  250 x 353 mm          */
86 #define PAPER_ENV_B5              34  /* Envelope B5  176 x 250 mm          */
87 #define PAPER_ENV_B6              35  /* Envelope B6  176 x 125 mm          */
88 #define PAPER_ENV_ITALY           36  /* Envelope 110 x 230 mm              */
89 #define PAPER_ENV_MONARCH         37  /* Envelope Monarch 3.875 x 7.5 in    */
90 #define PAPER_ENV_PERSONAL        38  /* 6 3/4 Envelope 3 5/8 x 6 1/2 in    */
91 #define PAPER_FANFOLD_US          39  /* US Std Fanfold 14 7/8 x 11 in      */
92 #define PAPER_FANFOLD_STD_GERMAN  40  /* German Std Fanfold 8 1/2 x 12 in   */
93 #define PAPER_FANFOLD_LGL_GERMAN  41  /* German Legal Fanfold 8 1/2 x 13 in */
94
95 #define PAPER_LAST                PAPER_FANFOLD_LGL_GERMAN
96 #define PAPER_USER                256
97
98 #define BIN_FIRST         BIN_UPPER
99 #define BIN_UPPER         1
100 #define BIN_ONLYONE       1
101 #define BIN_LOWER         2
102 #define BIN_MIDDLE        3
103 #define BIN_MANUAL        4
104 #define BIN_ENVELOPE      5
105 #define BIN_ENVMANUAL     6
106 #define BIN_AUTO          7
107 #define BIN_TRACTOR       8
108 #define BIN_SMALLFMT      9
109 #define BIN_LARGEFMT      10
110 #define BIN_LARGECAPACITY 11
111 #define BIN_CASSETTE      14
112 #define BIN_FORMSOURCE    15
113 #define BIN_LAST          BIN_FORMSOURCE
114
115 #define BIN_USER          256     /* device specific bins start here */
116
117 #define RES_DRAFT         (-1)
118 #define RES_LOW           (-2)
119 #define RES_MEDIUM        (-3)
120 #define RES_HIGH          (-4)
121
122 #define COLOR_MONOCHROME  1
123 #define COLOR_COLOR       2
124
125 #define DUP_SIMPLEX    1
126 #define DUP_VERTICAL   2
127 #define DUP_HORIZONTAL 3
128
129 #define TT_BITMAP     1       /* print TT fonts as graphics */
130 #define TT_DOWNLOAD   2       /* download TT fonts as soft fonts */
131 #define TT_SUBDEV     3       /* substitute device fonts for TT fonts */
132
133 #define COLLATE_FALSE  0
134 #define COLLATE_TRUE   1
135
136 typedef struct nt_printer_driver_info_level_3
137 {
138         uint32 cversion;
139
140         fstring name;
141         fstring environment;
142         fstring driverpath;
143         fstring datafile;
144         fstring configfile;
145         fstring helpfile;
146         fstring monitorname;
147         fstring defaultdatatype;
148         fstring *dependentfiles;
149 } NT_PRINTER_DRIVER_INFO_LEVEL_3;
150
151 /* SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure */
152 typedef struct {
153         uint32  version;
154         fstring name;
155         fstring environment;
156         fstring driverpath;
157         fstring datafile;
158         fstring configfile;
159         fstring helpfile;
160         fstring monitorname;
161         fstring defaultdatatype;
162         fstring mfgname;
163         fstring oemurl;
164         fstring hardwareid;
165         fstring provider;
166         fstring *dependentfiles;
167         fstring *previousnames;
168 } NT_PRINTER_DRIVER_INFO_LEVEL_6;
169
170
171 typedef struct nt_printer_driver_info_level
172 {
173         NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3;
174         NT_PRINTER_DRIVER_INFO_LEVEL_6 *info_6;
175 } NT_PRINTER_DRIVER_INFO_LEVEL;
176
177 /* predefined registry key names for printer data */
178
179 #define SPOOL_PRINTERDATA_KEY           "PrinterDriverData"
180 #define SPOOL_DSSPOOLER_KEY             "DsSpooler"
181 #define SPOOL_DSDRIVER_KEY              "DsDriver"
182 #define SPOOL_DSUSER_KEY                "DsUser"
183 #define SPOOL_PNPDATA_KEY               "PnPData"
184 #define SPOOL_OID_KEY                   "OID"
185
186 /* predefined value names for printer data */
187 #define SPOOL_REG_ASSETNUMBER           "assetNumber"
188 #define SPOOL_REG_BYTESPERMINUTE        "bytesPerMinute"
189 #define SPOOL_REG_DEFAULTPRIORITY       "defaultPriority"
190 #define SPOOL_REG_DESCRIPTION           "description"
191 #define SPOOL_REG_DRIVERNAME            "driverName"
192 #define SPOOL_REG_DRIVERVERSION         "driverVersion"
193 #define SPOOL_REG_FLAGS                 "flags"
194 #define SPOOL_REG_LOCATION              "location"
195 #define SPOOL_REG_OPERATINGSYSTEM       "operatingSystem"
196 #define SPOOL_REG_OPERATINGSYSTEMHOTFIX "operatingSystemHotfix"
197 #define SPOOL_REG_OPERATINGSYSTEMSERVICEPACK "operatingSystemServicePack"
198 #define SPOOL_REG_OPERATINGSYSTEMVERSION "operatingSystemVersion"
199 #define SPOOL_REG_PORTNAME              "portName"
200 #define SPOOL_REG_PRINTATTRIBUTES       "printAttributes"
201 #define SPOOL_REG_PRINTBINNAMES         "printBinNames"
202 #define SPOOL_REG_PRINTCOLLATE          "printCollate"
203 #define SPOOL_REG_PRINTCOLOR            "printColor"
204 #define SPOOL_REG_PRINTDUPLEXSUPPORTED  "printDuplexSupported"
205 #define SPOOL_REG_PRINTENDTIME          "printEndTime"
206 #define SPOOL_REG_PRINTERNAME           "printerName"
207 #define SPOOL_REG_PRINTFORMNAME         "printFormName"
208 #define SPOOL_REG_PRINTKEEPPRINTEDJOBS  "printKeepPrintedJobs"
209 #define SPOOL_REG_PRINTLANGUAGE         "printLanguage"
210 #define SPOOL_REG_PRINTMACADDRESS       "printMACAddress"
211 #define SPOOL_REG_PRINTMAXCOPIES        "printMaxCopies"
212 #define SPOOL_REG_PRINTMAXRESOLUTIONSUPPORTED "printMaxResolutionSupported"
213 #define SPOOL_REG_PRINTMAXXEXTENT       "printMaxXExtent"
214 #define SPOOL_REG_PRINTMAXYEXTENT       "printMaxYExtent"
215 #define SPOOL_REG_PRINTMEDIAREADY       "printMediaReady"
216 #define SPOOL_REG_PRINTMEDIASUPPORTED   "printMediaSupported"
217 #define SPOOL_REG_PRINTMEMORY           "printMemory"
218 #define SPOOL_REG_PRINTMINXEXTENT       "printMinXExtent"
219 #define SPOOL_REG_PRINTMINYEXTENT       "printMinYExtent"
220 #define SPOOL_REG_PRINTNETWORKADDRESS   "printNetworkAddress"
221 #define SPOOL_REG_PRINTNOTIFY           "printNotify"
222 #define SPOOL_REG_PRINTNUMBERUP         "printNumberUp"
223 #define SPOOL_REG_PRINTORIENTATIONSSUPPORTED "printOrientationsSupported"
224 #define SPOOL_REG_PRINTOWNER            "printOwner"
225 #define SPOOL_REG_PRINTPAGESPERMINUTE   "printPagesPerMinute"
226 #define SPOOL_REG_PRINTRATE             "printRate"
227 #define SPOOL_REG_PRINTRATEUNIT         "printRateUnit"
228 #define SPOOL_REG_PRINTSEPARATORFILE    "printSeparatorFile"
229 #define SPOOL_REG_PRINTSHARENAME        "printShareName"
230 #define SPOOL_REG_PRINTSPOOLING         "printSpooling"
231 #define SPOOL_REGVAL_PRINTWHILESPOOLING "PrintWhileSpooling"
232 #define SPOOL_REGVAL_PRINTAFTERSPOOLED  "PrintAfterSpooled"
233 #define SPOOL_REGVAL_PRINTDIRECT        "PrintDirect"
234 #define SPOOL_REG_PRINTSTAPLINGSUPPORTED "printStaplingSupported"
235 #define SPOOL_REG_PRINTSTARTTIME        "printStartTime"
236 #define SPOOL_REG_PRINTSTATUS           "printStatus"
237 #define SPOOL_REG_PRIORITY              "priority"
238 #define SPOOL_REG_SERVERNAME            "serverName"
239 #define SPOOL_REG_SHORTSERVERNAME       "shortServerName"
240 #define SPOOL_REG_UNCNAME               "uNCName"
241 #define SPOOL_REG_URL                   "url"
242 #define SPOOL_REG_VERSIONNUMBER         "versionNumber"
243
244 /* container for a single registry key */
245
246 typedef struct {
247         char            *name;
248         REGVAL_CTR      values;
249 } NT_PRINTER_KEY;
250
251 /* container for all printer data */
252
253 typedef struct {
254         int             num_keys;
255         NT_PRINTER_KEY  *keys;
256 } NT_PRINTER_DATA;
257
258 #define MAXDEVICENAME   32
259
260 typedef struct ntdevicemode
261 {
262         fstring devicename;
263         fstring formname;
264
265         uint16  specversion;
266         uint16  driverversion;
267         uint16  size;
268         uint16  driverextra;
269         uint16  orientation;
270         uint16  papersize;
271         uint16  paperlength;
272         uint16  paperwidth;
273         uint16  scale;
274         uint16  copies;
275         uint16  defaultsource;
276         uint16  printquality;
277         uint16  color;
278         uint16  duplex;
279         uint16  yresolution;
280         uint16  ttoption;
281         uint16  collate;
282         uint16  logpixels;
283
284         uint32  fields;
285         uint32  bitsperpel;
286         uint32  pelswidth;
287         uint32  pelsheight;
288         uint32  displayflags;
289         uint32  displayfrequency;
290         uint32  icmmethod;
291         uint32  icmintent;
292         uint32  mediatype;
293         uint32  dithertype;
294         uint32  reserved1;
295         uint32  reserved2;
296         uint32  panningwidth;
297         uint32  panningheight;
298         uint8   *private;
299 } NT_DEVICEMODE;
300
301 typedef struct nt_printer_info_level_2
302 {
303         uint32 attributes;
304         uint32 priority;
305         uint32 default_priority;
306         uint32 starttime;
307         uint32 untiltime;
308         uint32 status;
309         uint32 cjobs;
310         uint32 averageppm;
311         fstring servername;
312         fstring printername;
313         fstring sharename;
314         fstring portname;
315         fstring drivername;
316         pstring comment;
317         fstring location;
318         NT_DEVICEMODE *devmode;
319         fstring sepfile;
320         fstring printprocessor;
321         fstring datatype;
322         fstring parameters;
323         NT_PRINTER_DATA data;
324         SEC_DESC_BUF *secdesc_buf;
325         uint32 changeid;
326         uint32 c_setprinter;
327         uint32 setuptime;       
328 } NT_PRINTER_INFO_LEVEL_2;
329
330 typedef struct nt_printer_info_level
331 {
332         NT_PRINTER_INFO_LEVEL_2 *info_2;
333 } NT_PRINTER_INFO_LEVEL;
334
335 typedef struct
336 {
337         fstring name;
338         uint32 flag;
339         uint32 width;
340         uint32 length;
341         uint32 left;
342         uint32 top;
343         uint32 right;
344         uint32 bottom;
345 } nt_forms_struct;
346
347 /*
348 typedef struct _form
349 {
350        uint32 flags;
351        uint32 name_ptr;
352        uint32 size_x;
353        uint32 size_y;
354        uint32 left;
355        uint32 top;
356        uint32 right;
357        uint32 bottom;
358        UNISTR2 name;
359 } FORM;
360 */
361
362 #ifndef SAMBA_PRINTER_PORT_NAME
363 #define SAMBA_PRINTER_PORT_NAME "Samba Printer Port"
364 #endif
365
366 /* DOS header format */
367 #define DOS_HEADER_SIZE                 64
368 #define DOS_HEADER_MAGIC_OFFSET         0
369 #define DOS_HEADER_MAGIC                0x5A4D
370 #define DOS_HEADER_LFANEW_OFFSET        60
371
372 /* New Executable format (Win or OS/2 1.x segmented) */
373 #define NE_HEADER_SIZE                  64
374 #define NE_HEADER_SIGNATURE_OFFSET      0
375 #define NE_HEADER_SIGNATURE             0x454E
376 #define NE_HEADER_TARGET_OS_OFFSET      54
377 #define NE_HEADER_TARGOS_WIN            0x02
378 #define NE_HEADER_MINOR_VER_OFFSET      62
379 #define NE_HEADER_MAJOR_VER_OFFSET      63
380
381 /* Portable Executable format */
382 #define PE_HEADER_SIZE                  248
383 #define PE_HEADER_SIGNATURE_OFFSET      0
384 #define PE_HEADER_SIGNATURE             0x00004550
385 #define PE_HEADER_MACHINE_OFFSET        4
386 #define PE_HEADER_MACHINE_I386          0x14c
387 #define PE_HEADER_NUMBER_OF_SECTIONS    6
388 #define PE_HEADER_MAJOR_OS_VER_OFFSET   64
389 #define PE_HEADER_MINOR_OS_VER_OFFSET   66
390 #define PE_HEADER_MAJOR_IMG_VER_OFFSET  68
391 #define PE_HEADER_MINOR_IMG_VER_OFFSET  70
392 #define PE_HEADER_MAJOR_SS_VER_OFFSET   72
393 #define PE_HEADER_MINOR_SS_VER_OFFSET   74
394 #define PE_HEADER_SECT_HEADER_SIZE      40
395 #define PE_HEADER_SECT_NAME_OFFSET      0
396 #define PE_HEADER_SECT_SIZE_DATA_OFFSET 16
397 #define PE_HEADER_SECT_PTR_DATA_OFFSET  20
398
399 /* Microsoft file version format */
400 #define VS_SIGNATURE                    "VS_VERSION_INFO"
401 #define VS_MAGIC_VALUE                  0xfeef04bd
402 #define VS_MAJOR_OFFSET                                 8
403 #define VS_MINOR_OFFSET                                 12
404 #define VS_VERSION_INFO_UNICODE_SIZE    (sizeof(VS_SIGNATURE)*2+4+VS_MINOR_OFFSET+4) /* not true size! */
405 #define VS_VERSION_INFO_SIZE            (sizeof(VS_SIGNATURE)+4+VS_MINOR_OFFSET+4)   /* not true size! */
406 #define VS_NE_BUF_SIZE                  4096  /* Must be > 2*VS_VERSION_INFO_SIZE */
407
408 /* Notify spoolss clients that something has changed.  The
409    notification data is either stored in two uint32 values or a
410    variable length array. */
411
412 #define SPOOLSS_NOTIFY_MSG_UNIX_JOBID 0x0001    /* Job id is unix  */
413
414 typedef struct spoolss_notify_msg {
415         fstring printer;        /* Name of printer notified */
416         uint32 type;            /* Printer or job notify */
417         uint32 field;           /* Notify field changed */
418         uint32 id;              /* Job id */
419         uint32 len;             /* Length of data, 0 for two uint32 value */
420         uint32 flags;
421         union {
422                 uint32 value[2];
423                 char *data;
424         } notify;
425 } SPOOLSS_NOTIFY_MSG;
426
427 typedef struct {
428         fstring                 printername;
429         uint32                  num_msgs;
430         SPOOLSS_NOTIFY_MSG      *msgs;
431 } SPOOLSS_NOTIFY_MSG_GROUP;
432
433 typedef struct {
434         TALLOC_CTX                      *ctx;
435         uint32                          num_groups;
436         SPOOLSS_NOTIFY_MSG_GROUP        *msg_groups;
437 } SPOOLSS_NOTIFY_MSG_CTR;
438
439 #define PRINTER_HANDLE_IS_PRINTER       0
440 #define PRINTER_HANDLE_IS_PRINTSERVER   1
441
442 /* structure to store the printer handles */
443 /* and a reference to what it's pointing to */
444 /* and the notify info asked about */
445 /* that's the central struct */
446 typedef struct _Printer{
447         struct _Printer *prev, *next;
448         BOOL document_started;
449         BOOL page_started;
450         uint32 jobid; /* jobid in printing backend */
451         BOOL printer_type;
452         TALLOC_CTX *ctx;
453         union {
454                 fstring handlename;
455                 fstring printerservername;
456         } dev;
457         uint32 type;
458         uint32 access_granted;
459         struct {
460                 uint32 flags;
461                 uint32 options;
462                 fstring localmachine;
463                 uint32 printerlocal;
464                 SPOOL_NOTIFY_OPTION *option;
465                 POLICY_HND client_hnd;
466                 BOOL client_connected;
467                 uint32 change;
468                 /* are we in a FindNextPrinterChangeNotify() call? */
469                 BOOL fnpcn;
470         } notify;
471         struct {
472                 fstring machine;
473                 fstring user;
474         } client;
475         
476         /* devmode sent in the OpenPrinter() call */
477         NT_DEVICEMODE   *nt_devmode;
478         
479         /* cache the printer info */
480         NT_PRINTER_INFO_LEVEL *printer_info;
481         
482 } Printer_entry;
483
484 #endif /* NT_PRINTING_H_ */