smbXsrv_session: Remove a "can't happen" NULL check
[Samba.git] / source3 / include / nt_printing.h
blobb89c3bd60e52b95367c0a41a157117fe0ceaad55
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.
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.
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.
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/>.
22 #ifndef NT_PRINTING_H_
23 #define NT_PRINTING_H_
25 #include "../librpc/gen_ndr/spoolss.h"
27 #ifndef SAMBA_PRINTER_PORT_NAME
28 #define SAMBA_PRINTER_PORT_NAME "Samba Printer Port"
29 #endif
31 /* DOS header format */
32 #define DOS_HEADER_SIZE 64
33 #define DOS_HEADER_MAGIC_OFFSET 0
34 #define DOS_HEADER_MAGIC 0x5A4D
35 #define DOS_HEADER_LFANEW_OFFSET 60
37 /* New Executable format (Win or OS/2 1.x segmented) */
38 #define NE_HEADER_SIZE 64
39 #define NE_HEADER_SIGNATURE_OFFSET 0
40 #define NE_HEADER_SIGNATURE 0x454E
41 #define NE_HEADER_TARGET_OS_OFFSET 54
42 #define NE_HEADER_TARGOS_WIN 0x02
43 #define NE_HEADER_MINOR_VER_OFFSET 62
44 #define NE_HEADER_MAJOR_VER_OFFSET 63
46 /* Portable Executable format */
47 #define PE_HEADER_SIZE 24
48 #define PE_HEADER_SIGNATURE_OFFSET 0
49 #define PE_HEADER_SIGNATURE 0x00004550
50 #define PE_HEADER_MACHINE_OFFSET 4
51 #define PE_HEADER_MACHINE_I386 0x14c
52 #define PE_HEADER_NUMBER_OF_SECTIONS 6
53 #define PE_HEADER_OPTIONAL_HEADER_SIZE 20
54 #define PE_HEADER_SECT_HEADER_SIZE 40
55 #define PE_HEADER_SECT_NAME_OFFSET 0
56 #define PE_HEADER_SECT_SIZE_DATA_OFFSET 16
57 #define PE_HEADER_SECT_PTR_DATA_OFFSET 20
59 /* Microsoft file version format */
60 #define VS_SIGNATURE "VS_VERSION_INFO"
61 #define VS_MAGIC_VALUE 0xfeef04bd
62 #define VS_MAJOR_OFFSET 8
63 #define VS_MINOR_OFFSET 12
64 #define VS_VERSION_INFO_UNICODE_SIZE (sizeof(VS_SIGNATURE)*2+4+VS_MINOR_OFFSET+4) /* not true size! */
65 #define VS_VERSION_INFO_SIZE (sizeof(VS_SIGNATURE)+4+VS_MINOR_OFFSET+4) /* not true size! */
66 #define VS_NE_BUF_SIZE 4096 /* Must be > 2*VS_VERSION_INFO_SIZE */
68 /* Notify spoolss clients that something has changed. The
69 notification data is either stored in two uint32_t values or a
70 variable length array. */
72 #define SPOOLSS_NOTIFY_MSG_UNIX_JOBID 0x0001 /* Job id is unix */
74 typedef struct spoolss_notify_msg {
75 fstring printer; /* Name of printer notified */
76 uint32_t type; /* Printer or job notify */
77 uint32_t field; /* Notify field changed */
78 uint32_t id; /* Job id */
79 uint32_t len; /* Length of data, 0 for two uint32_t value */
80 uint32_t flags;
81 union {
82 uint32_t value[2];
83 char *data;
84 } notify;
85 } SPOOLSS_NOTIFY_MSG;
87 typedef struct {
88 fstring printername;
89 uint32_t num_msgs;
90 SPOOLSS_NOTIFY_MSG *msgs;
91 } SPOOLSS_NOTIFY_MSG_GROUP;
93 typedef struct {
94 TALLOC_CTX *ctx;
95 uint32_t num_groups;
96 SPOOLSS_NOTIFY_MSG_GROUP *msg_groups;
97 } SPOOLSS_NOTIFY_MSG_CTR;
100 * The printer attributes.
101 * I #defined all of them (grabbed form MSDN)
102 * I'm only using:
103 * ( SHARED | NETWORK | RAW_ONLY )
104 * RAW_ONLY _MUST_ be present otherwise NT will send an EMF file
107 #define PRINTER_ATTRIBUTE_SAMBA (PRINTER_ATTRIBUTE_RAW_ONLY|\
108 PRINTER_ATTRIBUTE_SHARED|\
109 PRINTER_ATTRIBUTE_LOCAL)
110 #define PRINTER_ATTRIBUTE_NOT_SAMBA (PRINTER_ATTRIBUTE_NETWORK)
112 #define DRIVER_ANY_VERSION 0xffffffff
113 #define DRIVER_MAX_VERSION 4
115 struct print_architecture_table_node {
116 const char *long_archi;
117 const char *short_archi;
118 int version;
121 bool nt_printing_init(struct messaging_context *msg_ctx);
123 const char *get_short_archi(const char *long_archi);
125 WERROR print_access_check(const struct auth_session_info *server_info,
126 struct messaging_context *msg_ctx, int snum,
127 int access_type);
129 WERROR nt_printer_guid_retrieve(TALLOC_CTX *mem_ctx, const char *printer,
130 struct GUID *pguid);
132 WERROR nt_printer_guid_store(struct messaging_context *msg_ctx,
133 const char *printer, struct GUID guid);
135 WERROR nt_printer_guid_get(TALLOC_CTX *mem_ctx,
136 const struct auth_session_info *session_info,
137 struct messaging_context *msg_ctx,
138 const char *printer, struct GUID *guid);
140 WERROR nt_printer_publish(TALLOC_CTX *mem_ctx,
141 const struct auth_session_info *server_info,
142 struct messaging_context *msg_ctx,
143 struct spoolss_PrinterInfo2 *pinfo2,
144 int action);
146 bool is_printer_published(TALLOC_CTX *mem_ctx,
147 const struct auth_session_info *server_info,
148 struct messaging_context *msg_ctx,
149 const char *servername,
150 const char *printer,
151 struct spoolss_PrinterInfo2 **info2);
153 WERROR check_published_printers(struct messaging_context *msg_ctx);
155 struct dcerpc_binding_handle;
157 bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
158 struct dcerpc_binding_handle *b,
159 const struct spoolss_DriverInfo8 *r);
160 bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
161 struct dcerpc_binding_handle *b,
162 struct spoolss_DriverInfo8 *r);
163 bool delete_driver_files(const struct auth_session_info *server_info,
164 const struct spoolss_DriverInfo8 *r);
166 WERROR move_driver_to_download_area(const struct auth_session_info *session_info,
167 const struct spoolss_AddDriverInfoCtr *r,
168 const char *driver_directory);
170 WERROR clean_up_driver_struct(TALLOC_CTX *mem_ctx,
171 const struct auth_session_info *session_info,
172 const struct spoolss_AddDriverInfoCtr *r,
173 uint32_t flags,
174 const char **driver_directory);
176 void map_printer_permissions(struct security_descriptor *sd);
178 void map_job_permissions(struct security_descriptor *sd);
180 bool print_time_access_check(const struct auth_session_info *server_info,
181 struct messaging_context *msg_ctx,
182 const char *servicename);
184 void nt_printer_remove(TALLOC_CTX *mem_ctx,
185 const struct auth_session_info *server_info,
186 struct messaging_context *msg_ctx,
187 const char *printer);
188 void nt_printer_add(TALLOC_CTX *mem_ctx,
189 const struct auth_session_info *server_info,
190 struct messaging_context *msg_ctx,
191 const char *printer);
193 /* The version int is used by getdrivers. Note that
194 all architecture strings that support multiple
195 versions must be grouped together since enumdrivers
196 uses this property to prevent issuing multiple
197 enumdriver calls for the same arch */
198 static const struct print_architecture_table_node archi_table[]= {
199 {SPOOLSS_ARCHITECTURE_4_0, SPL_ARCH_WIN40, 0 },
200 {SPOOLSS_ARCHITECTURE_NT_X86, SPL_ARCH_W32X86, 2 },
201 {SPOOLSS_ARCHITECTURE_NT_X86, SPL_ARCH_W32X86, 3 },
202 {SPOOLSS_ARCHITECTURE_W32MIPS, SPL_ARCH_W32MIPS, 2 },
203 {SPOOLSS_ARCHITECTURE_W32ALPHA, SPL_ARCH_W32ALPHA, 2 },
204 {SPOOLSS_ARCHITECTURE_W32PPC, SPL_ARCH_W32PPC, 2 },
205 {SPOOLSS_ARCHITECTURE_IA_64, SPL_ARCH_IA64, 3 },
206 {SPOOLSS_ARCHITECTURE_x64, SPL_ARCH_X64, 3 },
207 {SPOOLSS_ARCHITECTURE_ARM64, SPL_ARCH_ARM64, 3 },
208 {NULL, "", -1 }
211 #endif /* NT_PRINTING_H_ */