s3-spoolss: Removed the last free_a_printer() call in spoolss_nt.c.
[amitay/samba.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 typedef struct nt_printer_info_level_2
40 {
41         uint32 attributes;
42         uint32 priority;
43         uint32 default_priority;
44         uint32 starttime;
45         uint32 untiltime;
46         uint32 status;
47         uint32 cjobs;
48         uint32 averageppm;
49         fstring servername;
50         fstring printername;
51         fstring sharename;
52         fstring portname;
53         fstring drivername;
54         char comment[1024];
55         fstring location;
56         struct spoolss_DeviceMode *devmode;
57         fstring sepfile;
58         fstring printprocessor;
59         fstring datatype;
60         fstring parameters;
61         NT_PRINTER_DATA *data;
62         struct sec_desc_buf *secdesc_buf;
63         uint32 changeid;
64         uint32 c_setprinter;
65         uint32 setuptime;       
66 } NT_PRINTER_INFO_LEVEL_2;
67
68 typedef struct nt_printer_info_level
69 {
70         NT_PRINTER_INFO_LEVEL_2 *info_2;
71 } NT_PRINTER_INFO_LEVEL;
72
73 typedef struct
74 {
75         fstring name;
76         uint32 flag;
77         uint32 width;
78         uint32 length;
79         uint32 left;
80         uint32 top;
81         uint32 right;
82         uint32 bottom;
83 } nt_forms_struct;
84
85 #ifndef SAMBA_PRINTER_PORT_NAME
86 #define SAMBA_PRINTER_PORT_NAME "Samba Printer Port"
87 #endif
88
89 /* DOS header format */
90 #define DOS_HEADER_SIZE                 64
91 #define DOS_HEADER_MAGIC_OFFSET         0
92 #define DOS_HEADER_MAGIC                0x5A4D
93 #define DOS_HEADER_LFANEW_OFFSET        60
94
95 /* New Executable format (Win or OS/2 1.x segmented) */
96 #define NE_HEADER_SIZE                  64
97 #define NE_HEADER_SIGNATURE_OFFSET      0
98 #define NE_HEADER_SIGNATURE             0x454E
99 #define NE_HEADER_TARGET_OS_OFFSET      54
100 #define NE_HEADER_TARGOS_WIN            0x02
101 #define NE_HEADER_MINOR_VER_OFFSET      62
102 #define NE_HEADER_MAJOR_VER_OFFSET      63
103
104 /* Portable Executable format */
105 #define PE_HEADER_SIZE                  24
106 #define PE_HEADER_SIGNATURE_OFFSET      0
107 #define PE_HEADER_SIGNATURE             0x00004550
108 #define PE_HEADER_MACHINE_OFFSET        4
109 #define PE_HEADER_MACHINE_I386          0x14c
110 #define PE_HEADER_NUMBER_OF_SECTIONS    6
111 #define PE_HEADER_OPTIONAL_HEADER_SIZE  20
112 #define PE_HEADER_SECT_HEADER_SIZE      40
113 #define PE_HEADER_SECT_NAME_OFFSET      0
114 #define PE_HEADER_SECT_SIZE_DATA_OFFSET 16
115 #define PE_HEADER_SECT_PTR_DATA_OFFSET  20
116
117 /* Microsoft file version format */
118 #define VS_SIGNATURE                    "VS_VERSION_INFO"
119 #define VS_MAGIC_VALUE                  0xfeef04bd
120 #define VS_MAJOR_OFFSET                                 8
121 #define VS_MINOR_OFFSET                                 12
122 #define VS_VERSION_INFO_UNICODE_SIZE    (sizeof(VS_SIGNATURE)*2+4+VS_MINOR_OFFSET+4) /* not true size! */
123 #define VS_VERSION_INFO_SIZE            (sizeof(VS_SIGNATURE)+4+VS_MINOR_OFFSET+4)   /* not true size! */
124 #define VS_NE_BUF_SIZE                  4096  /* Must be > 2*VS_VERSION_INFO_SIZE */
125
126 /* Notify spoolss clients that something has changed.  The
127    notification data is either stored in two uint32 values or a
128    variable length array. */
129
130 #define SPOOLSS_NOTIFY_MSG_UNIX_JOBID 0x0001    /* Job id is unix  */
131
132 typedef struct spoolss_notify_msg {
133         fstring printer;        /* Name of printer notified */
134         uint32 type;            /* Printer or job notify */
135         uint32 field;           /* Notify field changed */
136         uint32 id;              /* Job id */
137         uint32 len;             /* Length of data, 0 for two uint32 value */
138         uint32 flags;
139         union {
140                 uint32 value[2];
141                 char *data;
142         } notify;
143 } SPOOLSS_NOTIFY_MSG;
144
145 typedef struct {
146         fstring                 printername;
147         uint32                  num_msgs;
148         SPOOLSS_NOTIFY_MSG      *msgs;
149 } SPOOLSS_NOTIFY_MSG_GROUP;
150
151 typedef struct {
152         TALLOC_CTX                      *ctx;
153         uint32                          num_groups;
154         SPOOLSS_NOTIFY_MSG_GROUP        *msg_groups;
155 } SPOOLSS_NOTIFY_MSG_CTR;
156
157 #define SPLHND_PRINTER          1
158 #define SPLHND_SERVER           2
159 #define SPLHND_PORTMON_TCP      3
160 #define SPLHND_PORTMON_LOCAL    4
161
162 /* structure to store the printer handles */
163 /* and a reference to what it's pointing to */
164 /* and the notify info asked about */
165 /* that's the central struct */
166 typedef struct _Printer{
167         struct _Printer *prev, *next;
168         bool document_started;
169         bool page_started;
170         uint32 jobid; /* jobid in printing backend */
171         int printer_type;
172         fstring servername;
173         fstring sharename;
174         uint32 type;
175         uint32 access_granted;
176         struct {
177                 uint32 flags;
178                 uint32 options;
179                 fstring localmachine;
180                 uint32 printerlocal;
181                 struct spoolss_NotifyOption *option;
182                 struct policy_handle client_hnd;
183                 bool client_connected;
184                 uint32 change;
185                 /* are we in a FindNextPrinterChangeNotify() call? */
186                 bool fnpcn;
187         } notify;
188         struct {
189                 fstring machine;
190                 fstring user;
191         } client;
192
193         /* devmode sent in the OpenPrinter() call */
194         struct spoolss_DeviceMode *devmode;
195
196         /* TODO cache the printer info2 structure */
197         struct spoolss_PrinterInfo2 *info2;
198         
199 } Printer_entry;
200
201 /*
202  * The printer attributes.
203  * I #defined all of them (grabbed form MSDN)
204  * I'm only using:
205  * ( SHARED | NETWORK | RAW_ONLY )
206  * RAW_ONLY _MUST_ be present otherwise NT will send an EMF file
207  */
208
209 #define PRINTER_ATTRIBUTE_SAMBA                 (PRINTER_ATTRIBUTE_RAW_ONLY|\
210                                                  PRINTER_ATTRIBUTE_SHARED|\
211                                                  PRINTER_ATTRIBUTE_LOCAL)
212 #define PRINTER_ATTRIBUTE_NOT_SAMBA             (PRINTER_ATTRIBUTE_NETWORK)
213
214 #define DRIVER_ANY_VERSION              0xffffffff
215 #define DRIVER_MAX_VERSION              4
216
217 struct print_architecture_table_node {
218         const char      *long_archi;
219         const char      *short_archi;
220         int     version;
221 };
222
223 #endif /* NT_PRINTING_H_ */