s3-spoolss: Added a winreg_create_printer function.
[Samba/ekacnet.git] / source3 / rpc_server / srv_spoolss_util.h
blob1590db2c641d559cb76c32485c7a8e1a15142a83
1 /*
2 * Unix SMB/CIFS implementation.
4 * SPOOLSS RPC Pipe server / winreg client routines
6 * Copyright (c) 2010 Andreas Schneider <asn@samba.org>
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 _SRV_SPOOLSS_UITL_H
23 #define _SRV_SPOOLSS_UITL_H
26 enum spoolss_PrinterInfo2Mask {
27 SPOOLSS_PRINTER_INFO_ATTRIBUTES = (int)(0x00000001),
28 SPOOLSS_PRINTER_INFO_AVERAGEPPM = (int)(0x00000002),
29 SPOOLSS_PRINTER_INFO_CJOBS = (int)(0x00000004),
30 SPOOLSS_PRINTER_INFO_COMMENT = (int)(0x00000008),
31 SPOOLSS_PRINTER_INFO_DATATYPE = (int)(0x00000010),
32 SPOOLSS_PRINTER_INFO_DEFAULTPRIORITY = (int)(0x00000020),
33 SPOOLSS_PRINTER_INFO_DEVMODE = (int)(0x00000040),
34 SPOOLSS_PRINTER_INFO_DRIVERNAME = (int)(0x00000080),
35 SPOOLSS_PRINTER_INFO_LOCATION = (int)(0x00000100),
36 SPOOLSS_PRINTER_INFO_NAME = (int)(0x00000200),
37 SPOOLSS_PRINTER_INFO_PARAMETERS = (int)(0x00000400),
38 SPOOLSS_PRINTER_INFO_PORTNAME = (int)(0x00000800),
39 SPOOLSS_PRINTER_INFO_PRINTERNAME = (int)(0x00001000),
40 SPOOLSS_PRINTER_INFO_PRINTPROCESSOR = (int)(0x00002000),
41 SPOOLSS_PRINTER_INFO_PRIORITY = (int)(0x00004000),
42 SPOOLSS_PRINTER_INFO_SECDESC = (int)(0x00008000),
43 SPOOLSS_PRINTER_INFO_SEPFILE = (int)(0x00010000),
44 SPOOLSS_PRINTER_INFO_SERVERNAME = (int)(0x00020000),
45 SPOOLSS_PRINTER_INFO_SHARENAME = (int)(0x00040000),
46 SPOOLSS_PRINTER_INFO_STARTTIME = (int)(0x00080000),
47 SPOOLSS_PRINTER_INFO_STATUS = (int)(0x00100000),
48 SPOOLSS_PRINTER_INFO_UNTILTIME = (int)(0x00200000)
51 #define SPOOLSS_PRINTER_INFO_ALL SPOOLSS_PRINTER_INFO_ATTRIBUTES | \
52 SPOOLSS_PRINTER_INFO_AVERAGEPPM | \
53 SPOOLSS_PRINTER_INFO_CJOBS | \
54 SPOOLSS_PRINTER_INFO_COMMENT | \
55 SPOOLSS_PRINTER_INFO_DATATYPE | \
56 SPOOLSS_PRINTER_INFO_DEFAULTPRIORITY | \
57 SPOOLSS_PRINTER_INFO_DEVMODE | \
58 SPOOLSS_PRINTER_INFO_DRIVERNAME | \
59 SPOOLSS_PRINTER_INFO_LOCATION | \
60 SPOOLSS_PRINTER_INFO_NAME | \
61 SPOOLSS_PRINTER_INFO_PARAMETERS | \
62 SPOOLSS_PRINTER_INFO_PORTNAME | \
63 SPOOLSS_PRINTER_INFO_PRINTERNAME | \
64 SPOOLSS_PRINTER_INFO_PRINTPROCESSOR | \
65 SPOOLSS_PRINTER_INFO_PRIORITY | \
66 SPOOLSS_PRINTER_INFO_SECDESC | \
67 SPOOLSS_PRINTER_INFO_SEPFILE | \
68 SPOOLSS_PRINTER_INFO_SERVERNAME | \
69 SPOOLSS_PRINTER_INFO_SHARENAME | \
70 SPOOLSS_PRINTER_INFO_STARTTIME | \
71 SPOOLSS_PRINTER_INFO_STATUS | \
72 SPOOLSS_PRINTER_INFO_UNTILTIME
74 WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
75 struct auth_serversupplied_info *server_info,
76 const char *sharename);
78 /**
79 * @internal
81 * @brief Update the information of a printer in the registry.
83 * @param[in] mem_ctx The talloc memory context to use.
85 * @param[in] server_info The server supplied session info.
87 * @param[in] info2_mask A bitmask which defines which values should be set.
89 * @param[in] info2 A SetPrinterInfo2 structure with the data to set.
91 * @param[in] devmode A device mode structure with the data to set.
93 * @param[in] secdesc A security descriptor structure with the data to set.
95 * @return On success WERR_OK, a corresponding DOS error is
96 * something went wrong.
98 WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
99 struct auth_serversupplied_info *server_info,
100 uint32_t info2_mask,
101 struct spoolss_SetPrinterInfo2 *info2,
102 struct spoolss_DeviceMode *devmode,
103 struct security_descriptor *secdesc);
106 * @internal
108 * @brief Set printer data over the winreg pipe.
110 * @param[in] mem_ctx The talloc memory context to use.
112 * @param[in] server_info The server supplied session info.
114 * @param[in] printer The printer name.
116 * @param[in] key The key of the printer data to store the value.
118 * @param[in] value The value name to save.
120 * @param[in] type The type of the value to use.
122 * @param[in] data The data which sould be saved under the given value.
124 * @param[in] data_size The size of the data.
126 * @return On success WERR_OK, a corresponding DOS error is
127 * something went wrong.
129 WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
130 struct auth_serversupplied_info *server_info,
131 const char *printer,
132 const char *key,
133 const char *value,
134 enum winreg_Type type,
135 uint8_t *data,
136 uint32_t data_size);
139 * @internal
141 * @brief Get printer data over a winreg pipe.
143 * @param[in] mem_ctx The talloc memory context to use.
145 * @param[in] server_info The server supplied session info.
147 * @param[in] printer The printer name.
149 * @param[in] key The key of the printer data to get the value.
151 * @param[in] value The name of the value to query.
153 * @param[in] type The type of the value to query.
155 * @param[out] data A pointer to store the data.
157 * @param[out] data_size A pointer to store the size of the data.
159 * @return On success WERR_OK, a corresponding DOS error is
160 * something went wrong.
162 WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
163 struct auth_serversupplied_info *server_info,
164 const char *printer,
165 const char *key,
166 const char *value,
167 enum winreg_Type *type,
168 uint8_t **data,
169 uint32_t *data_size);
172 * @internal
174 * @brief Enumerate on the values of a given key and provide the data.
176 * @param[in] mem_ctx The talloc memory context to use.
178 * @param[in] server_info The server supplied session info.
180 * @param[in] printer The printer name.
182 * @param[in] key The key of the printer data to get the value.
184 * @param[out] pnum_values A pointer to store the number of values we found.
186 * @param[out] penum_values A pointer to store the values and its data.
188 * @return WERR_OK on success, the corresponding DOS error
189 * code if something gone wrong.
191 WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
192 struct auth_serversupplied_info *server_info,
193 const char *printer,
194 const char *key,
195 uint32_t *pnum_values,
196 struct spoolss_PrinterEnumValues **penum_values);
199 * @internal
201 * @brief Delete printer data over a winreg pipe.
203 * @param[in] mem_ctx The talloc memory context to use.
205 * @param[in] server_info The server supplied session info.
207 * @param[in] printer The printer name.
209 * @param[in] key The key of the printer data to delete.
211 * @param[in] value The name of the value to delete.
213 * @return On success WERR_OK, a corresponding DOS error is
214 * something went wrong.
216 WERROR winreg_delete_printer_dataex(TALLOC_CTX *mem_ctx,
217 struct auth_serversupplied_info *server_info,
218 const char *printer,
219 const char *key,
220 const char *value);
223 * @internal
225 * @brief Enumerate on the subkeys of a given key and provide the data.
227 * @param[in] mem_ctx The talloc memory context to use.
229 * @param[in] server_info The server supplied session info.
231 * @param[in] printer The printer name.
233 * @param[in] key The key of the printer data to get the value.
235 * @param[out] pnum_subkeys A pointer to store the number of subkeys found.
237 * @param[in] psubkeys A pointer to an array to store the names of the subkeys
238 * found.
240 * @return WERR_OK on success, the corresponding DOS error
241 * code if something gone wrong.
243 WERROR winreg_enum_printer_key(TALLOC_CTX *mem_ctx,
244 struct auth_serversupplied_info *server_info,
245 const char *printer,
246 const char *key,
247 uint32_t *pnum_subkeys,
248 const char ***psubkeys);
251 * @internal
253 * @brief Delete a key with subkeys of a given printer.
255 * @param[in] mem_ctx The talloc memory context to use.
257 * @param[in] server_info The server supplied session info.
259 * @param[in] printer The printer name.
261 * @param[in] key The key of the printer to delete.
263 * @return On success WERR_OK, a corresponding DOS error is
264 * something went wrong.
266 WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
267 struct auth_serversupplied_info *server_info,
268 const char *printer,
269 const char *key);
272 * @brief Update the ChangeID of a printer.
274 * The ChangeID **must** be increasing over the lifetime of client's spoolss
275 * service in order for the client's cache to show updates.
277 * If a form is updated of a printer, the we need to update the ChangeID of the
278 * pritner.
280 * @param[in] mem_ctx The talloc memory context to use.
282 * @param[in] server_info The server supplied session info.
284 * @param[in] printer The printer name.
286 * @return On success WERR_OK, a corresponding DOS error is
287 * something went wrong.
289 WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
290 struct auth_serversupplied_info *server_info,
291 const char *printer);
294 * @brief Get the ChangeID of the given printer.
296 * @param[in] mem_ctx The talloc memory context to use.
298 * @param[in] server_info The server supplied session info.
300 * @param[in] printer The printer name.
302 * @param[in] changeid A pointer to store the changeid.
304 * @return On success WERR_OK, a corresponding DOS error is
305 * something went wrong.
307 WERROR winreg_printer_get_changeid(TALLOC_CTX *mem_ctx,
308 struct auth_serversupplied_info *server_info,
309 const char *printer,
310 uint32_t *pchangeid);
313 * @internal
315 * @brief This function adds a form to the list of available forms that can be
316 * selected for the specified printer.
318 * @param[in] mem_ctx The talloc memory context to use.
320 * @param[in] server_info The server supplied session info.
322 * @param[in] form The form to add.
324 * @return WERR_OK on success.
325 * WERR_ALREADY_EXISTS if the form already exists or is a
326 * builtin form.
327 * A corresponding DOS error is something went wrong.
329 WERROR winreg_printer_addform1(TALLOC_CTX *mem_ctx,
330 struct auth_serversupplied_info *server_info,
331 struct spoolss_AddFormInfo1 *form);
334 * @brief This function enumerates the forms supported by the specified printer.
336 * @param[in] mem_ctx The talloc memory context to use.
338 * @param[in] server_info The server supplied session info.
340 * @param[out] pnum_info A pointer to store the FormInfo count.
342 * @param[out] pinfo A pointer to store an array with FormInfo.
344 * @return On success WERR_OK, a corresponding DOS error is
345 * something went wrong.
347 WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
348 struct auth_serversupplied_info *server_info,
349 uint32_t *pnum_info,
350 union spoolss_FormInfo **pinfo);
353 * @brief This function removes a form name from the list of supported forms.
355 * @param[in] mem_ctx The talloc memory context to use.
357 * @param[in] server_info The server supplied session info.
359 * @param[in] form_name The name of the form to delete.
361 * @return WERR_OK on success.
362 * WERR_INVALID_PARAM if the form is a builtin form.
363 * WERR_INVALID_FORM_NAME if the form or key doesn't exist.
364 * A corresponding DOS error is something went wrong.
366 WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
367 struct auth_serversupplied_info *server_info,
368 const char *form_name);
371 * @brief This function sets the form information for the specified printer.
373 * If one provides both the name in the API call and inside the FormInfo
374 * structure, then the form gets renamed.
376 * @param[in] mem_ctx The talloc memory context to use.
378 * @param[in] server_info The server supplied session info.
380 * @param[in] form_name The name of the form to set or rename.
382 * @param[in] form The FormInfo structure to save.
384 * @return WERR_OK on success.
385 * WERR_INVALID_PARAM if the form is a builtin form.
386 * A corresponding DOS error is something went wrong.
388 WERROR winreg_printer_setform1(TALLOC_CTX *mem_ctx,
389 struct auth_serversupplied_info *server_info,
390 const char *form_name,
391 struct spoolss_AddFormInfo1 *form);
394 * @brief This function retrieves information about a specified form.
396 * @param[in] mem_ctx The talloc memory context to use.
398 * @param[in] server_info The server supplied session info.
400 * @param[in] form_name The name of the form to query.
402 * @param[out] form A pointer to a form structure to fill out.
404 * @return On success WERR_OK, a corresponding DOS error is
405 * something went wrong.
407 WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
408 struct auth_serversupplied_info *server_info,
409 const char *form_name,
410 struct spoolss_FormInfo1 *form);
413 * @brief This function adds a new spool driver
415 * @param[in] mem_ctx A talloc memory context.
417 * @param[in] server_info Auth info to open the pipe.
419 * @param[in] r The structure containing the new driver data.
421 * @param[out] driver_name Returns the driver name.
423 * @param[out] driver_version Returns the driver version.
425 * @return On success WERR_OK, a corresponding DOS error is
426 * something went wrong.
428 WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
429 struct auth_serversupplied_info *server_info,
430 struct spoolss_AddDriverInfoCtr *r,
431 const char **driver_name,
432 uint32_t *driver_version);
435 * @brief This function gets printer driver information
437 * @param[in] mem_ctx A talloc memory context.
439 * @param[in] server_info Auth info to open the pipe.
441 * @param[in] architecture The architecture type.
443 * @param[in] driver_name The driver name.
445 * @param[in] driver_version The driver version.
447 * @param[out] _info8 The structure that holds the full driver information.
449 * @return On success WERR_OK, a corresponding DOS error is
450 * something went wrong.
453 WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
454 struct auth_serversupplied_info *server_info,
455 const char *architecture,
456 const char *driver_name,
457 uint32_t driver_version,
458 struct spoolss_DriverInfo8 **_info8);
461 * @brief This function deletes a printer driver information
463 * @param[in] mem_ctx A talloc memory context.
465 * @param[in] server_info Auth info to open the pipe.
467 * @param[out] info8 The structure that holds the full driver information.
469 * @param[in] version The driver type version.
471 * @return On success WERR_OK, a corresponding DOS error is
472 * something went wrong.
475 WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
476 struct auth_serversupplied_info *server_info,
477 struct spoolss_DriverInfo8 *info8,
478 uint32_t version);
481 * @brief This function gets printer drivers list for the specified
482 * architecture and type version
484 * @param[in] mem_ctx A talloc memory context.
486 * @param[in] server_info Auth info to open the pipe.
488 * @param[in] architecture The architecture type.
490 * @param[in] version The driver version.
492 * @param[out] num_drivers The number of drivers.
494 * @param[out] version The drivers names.
496 * @return On success WERR_OK, a corresponding DOS error is
497 * something went wrong.
500 WERROR winreg_get_driver_list(TALLOC_CTX *mem_ctx,
501 struct auth_serversupplied_info *server_info,
502 const char *architecture,
503 uint32_t version,
504 uint32_t *num_drivers,
505 const char ***drivers);
507 #endif /* _SRV_SPOOLSS_UITL_H */