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
25 struct auth_serversupplied_info;
27 enum spoolss_PrinterInfo2Mask {
28 SPOOLSS_PRINTER_INFO_ATTRIBUTES = (int)(0x00000001),
29 SPOOLSS_PRINTER_INFO_AVERAGEPPM = (int)(0x00000002),
30 SPOOLSS_PRINTER_INFO_CJOBS = (int)(0x00000004),
31 SPOOLSS_PRINTER_INFO_COMMENT = (int)(0x00000008),
32 SPOOLSS_PRINTER_INFO_DATATYPE = (int)(0x00000010),
33 SPOOLSS_PRINTER_INFO_DEFAULTPRIORITY = (int)(0x00000020),
34 SPOOLSS_PRINTER_INFO_DEVMODE = (int)(0x00000040),
35 SPOOLSS_PRINTER_INFO_DRIVERNAME = (int)(0x00000080),
36 SPOOLSS_PRINTER_INFO_LOCATION = (int)(0x00000100),
37 SPOOLSS_PRINTER_INFO_NAME = (int)(0x00000200),
38 SPOOLSS_PRINTER_INFO_PARAMETERS = (int)(0x00000400),
39 SPOOLSS_PRINTER_INFO_PORTNAME = (int)(0x00000800),
40 SPOOLSS_PRINTER_INFO_PRINTERNAME = (int)(0x00001000),
41 SPOOLSS_PRINTER_INFO_PRINTPROCESSOR = (int)(0x00002000),
42 SPOOLSS_PRINTER_INFO_PRIORITY = (int)(0x00004000),
43 SPOOLSS_PRINTER_INFO_SECDESC = (int)(0x00008000),
44 SPOOLSS_PRINTER_INFO_SEPFILE = (int)(0x00010000),
45 SPOOLSS_PRINTER_INFO_SERVERNAME = (int)(0x00020000),
46 SPOOLSS_PRINTER_INFO_SHARENAME = (int)(0x00040000),
47 SPOOLSS_PRINTER_INFO_STARTTIME = (int)(0x00080000),
48 SPOOLSS_PRINTER_INFO_STATUS = (int)(0x00100000),
49 SPOOLSS_PRINTER_INFO_UNTILTIME = (int)(0x00200000)
52 #define SPOOLSS_PRINTER_INFO_ALL SPOOLSS_PRINTER_INFO_ATTRIBUTES | \
53 SPOOLSS_PRINTER_INFO_AVERAGEPPM | \
54 SPOOLSS_PRINTER_INFO_CJOBS | \
55 SPOOLSS_PRINTER_INFO_COMMENT | \
56 SPOOLSS_PRINTER_INFO_DATATYPE | \
57 SPOOLSS_PRINTER_INFO_DEFAULTPRIORITY | \
58 SPOOLSS_PRINTER_INFO_DEVMODE | \
59 SPOOLSS_PRINTER_INFO_DRIVERNAME | \
60 SPOOLSS_PRINTER_INFO_LOCATION | \
61 SPOOLSS_PRINTER_INFO_NAME | \
62 SPOOLSS_PRINTER_INFO_PARAMETERS | \
63 SPOOLSS_PRINTER_INFO_PORTNAME | \
64 SPOOLSS_PRINTER_INFO_PRINTERNAME | \
65 SPOOLSS_PRINTER_INFO_PRINTPROCESSOR | \
66 SPOOLSS_PRINTER_INFO_PRIORITY | \
67 SPOOLSS_PRINTER_INFO_SECDESC | \
68 SPOOLSS_PRINTER_INFO_SEPFILE | \
69 SPOOLSS_PRINTER_INFO_SERVERNAME | \
70 SPOOLSS_PRINTER_INFO_SHARENAME | \
71 SPOOLSS_PRINTER_INFO_STARTTIME | \
72 SPOOLSS_PRINTER_INFO_STATUS | \
73 SPOOLSS_PRINTER_INFO_UNTILTIME
75 WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
76 const struct auth_serversupplied_info *session_info,
77 struct messaging_context *msg_ctx,
78 const char *sharename);
83 * @brief Update the information of a printer in the registry.
85 * @param[in] mem_ctx The talloc memory context to use.
87 * @param[in] session_info The server supplied session info.
89 * @param[in] sharename The share name.
91 * @param[in] info2_mask A bitmask which defines which values should be set.
93 * @param[in] info2 A SetPrinterInfo2 structure with the data to set.
95 * @param[in] devmode A device mode structure with the data to set.
97 * @param[in] secdesc A security descriptor structure with the data to set.
99 * @return On success WERR_OK, a corresponding DOS error is
100 * something went wrong.
102 WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
103 const struct auth_serversupplied_info *session_info,
104 struct messaging_context *msg_ctx,
105 const char *sharename,
107 struct spoolss_SetPrinterInfo2 *info2,
108 struct spoolss_DeviceMode *devmode,
109 struct security_descriptor *secdesc);
113 * @brief Get the inforamtion of a printer stored in the registry.
115 * @param[in] mem_ctx The talloc memory context to use.
117 * @param[in] session_info The server supplied session info.
119 * @param[in] printer The name of the printer to get.
121 * @param[out] pinfo2 A pointer to store a PRINTER_INFO_2 structure.
123 * @return On success WERR_OK, a corresponding DOS error is
124 * something went wrong.
126 WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
127 const struct auth_serversupplied_info *session_info,
128 struct messaging_context *msg_ctx,
130 struct spoolss_PrinterInfo2 **pinfo2);
133 * @brief Get the security descriptor for a printer.
135 * @param[in] mem_ctx The talloc memory context to use.
137 * @param[in] session_info The server supplied session info.
139 * @param[in] sharename The share name.
141 * @param[out] psecdesc A pointer to store the security descriptor.
143 * @return On success WERR_OK, a corresponding DOS error is
144 * something went wrong.
146 WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
147 const struct auth_serversupplied_info *session_info,
148 struct messaging_context *msg_ctx,
149 const char *sharename,
150 struct spoolss_security_descriptor **psecdesc);
153 * @brief Set the security descriptor for a printer.
155 * @param[in] mem_ctx The talloc memory context to use.
157 * @param[in] session_info The server supplied session info.
159 * @param[in] sharename The share name.
161 * @param[in] secdesc The security descriptor to save.
163 * @return On success WERR_OK, a corresponding DOS error is
164 * something went wrong.
166 WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
167 const struct auth_serversupplied_info *session_info,
168 struct messaging_context *msg_ctx,
169 const char *sharename,
170 const struct spoolss_security_descriptor *secdesc);
175 * @brief Set printer data over the winreg pipe.
177 * @param[in] mem_ctx The talloc memory context to use.
179 * @param[in] session_info The server supplied session info.
181 * @param[in] printer The printer name.
183 * @param[in] key The key of the printer data to store the value.
185 * @param[in] value The value name to save.
187 * @param[in] type The type of the value to use.
189 * @param[in] data The data which sould be saved under the given value.
191 * @param[in] data_size The size of the data.
193 * @return On success WERR_OK, a corresponding DOS error is
194 * something went wrong.
196 WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
197 const struct auth_serversupplied_info *session_info,
198 struct messaging_context *msg_ctx,
202 enum winreg_Type type,
209 * @brief Get printer data over a winreg pipe.
211 * @param[in] mem_ctx The talloc memory context to use.
213 * @param[in] session_info The server supplied session info.
215 * @param[in] printer The printer name.
217 * @param[in] key The key of the printer data to get the value.
219 * @param[in] value The name of the value to query.
221 * @param[in] type The type of the value to query.
223 * @param[out] data A pointer to store the data.
225 * @param[out] data_size A pointer to store the size of the data.
227 * @return On success WERR_OK, a corresponding DOS error is
228 * something went wrong.
230 WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
231 const struct auth_serversupplied_info *session_info,
232 struct messaging_context *msg_ctx,
236 enum winreg_Type *type,
238 uint32_t *data_size);
243 * @brief Enumerate on the values of a given key and provide the data.
245 * @param[in] mem_ctx The talloc memory context to use.
247 * @param[in] session_info The server supplied session info.
249 * @param[in] printer The printer name.
251 * @param[in] key The key of the printer data to get the value.
253 * @param[out] pnum_values A pointer to store the number of values we found.
255 * @param[out] penum_values A pointer to store the values and its data.
257 * @return WERR_OK on success, the corresponding DOS error
258 * code if something gone wrong.
260 WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
261 const struct auth_serversupplied_info *session_info,
262 struct messaging_context *msg_ctx,
265 uint32_t *pnum_values,
266 struct spoolss_PrinterEnumValues **penum_values);
271 * @brief Delete printer data over a winreg pipe.
273 * @param[in] mem_ctx The talloc memory context to use.
275 * @param[in] session_info The server supplied session info.
277 * @param[in] printer The printer name.
279 * @param[in] key The key of the printer data to delete.
281 * @param[in] value The name of the value to delete.
283 * @return On success WERR_OK, a corresponding DOS error is
284 * something went wrong.
286 WERROR winreg_delete_printer_dataex(TALLOC_CTX *mem_ctx,
287 const struct auth_serversupplied_info *session_info,
288 struct messaging_context *msg_ctx,
296 * @brief Enumerate on the subkeys of a given key and provide the data.
298 * @param[in] mem_ctx The talloc memory context to use.
300 * @param[in] session_info The server supplied session info.
302 * @param[in] printer The printer name.
304 * @param[in] key The key of the printer data to get the value.
306 * @param[out] pnum_subkeys A pointer to store the number of subkeys found.
308 * @param[in] psubkeys A pointer to an array to store the names of the subkeys
311 * @return WERR_OK on success, the corresponding DOS error
312 * code if something gone wrong.
314 WERROR winreg_enum_printer_key(TALLOC_CTX *mem_ctx,
315 const struct auth_serversupplied_info *session_info,
316 struct messaging_context *msg_ctx,
319 uint32_t *pnum_subkeys,
320 const char ***psubkeys);
325 * @brief Delete a key with subkeys of a given printer.
327 * @param[in] mem_ctx The talloc memory context to use.
329 * @param[in] session_info The server supplied session info.
331 * @param[in] printer The printer name.
333 * @param[in] key The key of the printer to delete.
335 * @return On success WERR_OK, a corresponding DOS error is
336 * something went wrong.
338 WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
339 const struct auth_serversupplied_info *session_info,
340 struct messaging_context *msg_ctx,
345 * @brief Update the ChangeID of a printer.
347 * The ChangeID **must** be increasing over the lifetime of client's spoolss
348 * service in order for the client's cache to show updates.
350 * If a form is updated of a printer, the we need to update the ChangeID of the
353 * @param[in] mem_ctx The talloc memory context to use.
355 * @param[in] session_info The server supplied session info.
357 * @param[in] printer The printer name.
359 * @return On success WERR_OK, a corresponding DOS error is
360 * something went wrong.
362 WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
363 const struct auth_serversupplied_info *session_info,
364 struct messaging_context *msg_ctx,
365 const char *printer);
368 * @brief Get the ChangeID of the given printer.
370 * @param[in] mem_ctx The talloc memory context to use.
372 * @param[in] session_info The server supplied session info.
374 * @param[in] printer The printer name.
376 * @param[in] changeid A pointer to store the changeid.
378 * @return On success WERR_OK, a corresponding DOS error is
379 * something went wrong.
381 WERROR winreg_printer_get_changeid(TALLOC_CTX *mem_ctx,
382 const struct auth_serversupplied_info *session_info,
383 struct messaging_context *msg_ctx,
385 uint32_t *pchangeid);
390 * @brief This function adds a form to the list of available forms that can be
391 * selected for the specified printer.
393 * @param[in] mem_ctx The talloc memory context to use.
395 * @param[in] session_info The server supplied session info.
397 * @param[in] form The form to add.
399 * @return WERR_OK on success.
400 * WERR_ALREADY_EXISTS if the form already exists or is a
402 * A corresponding DOS error is something went wrong.
404 WERROR winreg_printer_addform1(TALLOC_CTX *mem_ctx,
405 const struct auth_serversupplied_info *session_info,
406 struct messaging_context *msg_ctx,
407 struct spoolss_AddFormInfo1 *form);
410 * @brief This function enumerates the forms supported by the specified printer.
412 * @param[in] mem_ctx The talloc memory context to use.
414 * @param[in] session_info The server supplied session info.
416 * @param[out] pnum_info A pointer to store the FormInfo count.
418 * @param[out] pinfo A pointer to store an array with FormInfo.
420 * @return On success WERR_OK, a corresponding DOS error is
421 * something went wrong.
423 WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
424 const struct auth_serversupplied_info *session_info,
425 struct messaging_context *msg_ctx,
427 union spoolss_FormInfo **pinfo);
430 * @brief This function removes a form name from the list of supported forms.
432 * @param[in] mem_ctx The talloc memory context to use.
434 * @param[in] session_info The server supplied session info.
436 * @param[in] form_name The name of the form to delete.
438 * @return WERR_OK on success.
439 * WERR_INVALID_PARAM if the form is a builtin form.
440 * WERR_INVALID_FORM_NAME if the form or key doesn't exist.
441 * A corresponding DOS error is something went wrong.
443 WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
444 const struct auth_serversupplied_info *session_info,
445 struct messaging_context *msg_ctx,
446 const char *form_name);
449 * @brief This function sets the form information for the specified printer.
451 * If one provides both the name in the API call and inside the FormInfo
452 * structure, then the form gets renamed.
454 * @param[in] mem_ctx The talloc memory context to use.
456 * @param[in] session_info The server supplied session info.
458 * @param[in] form_name The name of the form to set or rename.
460 * @param[in] form The FormInfo structure to save.
462 * @return WERR_OK on success.
463 * WERR_INVALID_PARAM if the form is a builtin form.
464 * A corresponding DOS error is something went wrong.
466 WERROR winreg_printer_setform1(TALLOC_CTX *mem_ctx,
467 const struct auth_serversupplied_info *session_info,
468 struct messaging_context *msg_ctx,
469 const char *form_name,
470 struct spoolss_AddFormInfo1 *form);
473 * @brief This function retrieves information about a specified form.
475 * @param[in] mem_ctx The talloc memory context to use.
477 * @param[in] session_info The server supplied session info.
479 * @param[in] form_name The name of the form to query.
481 * @param[out] form A pointer to a form structure to fill out.
483 * @return On success WERR_OK, a corresponding DOS error is
484 * something went wrong.
486 WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
487 const struct auth_serversupplied_info *session_info,
488 struct messaging_context *msg_ctx,
489 const char *form_name,
490 struct spoolss_FormInfo1 *form);
493 * @brief This function adds a new spool driver
495 * @param[in] mem_ctx A talloc memory context.
497 * @param[in] session_info Auth info to open the pipe.
499 * @param[in] r The structure containing the new driver data.
501 * @param[out] driver_name Returns the driver name.
503 * @param[out] driver_version Returns the driver version.
505 * @return On success WERR_OK, a corresponding DOS error is
506 * something went wrong.
508 WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
509 const struct auth_serversupplied_info *session_info,
510 struct messaging_context *msg_ctx,
511 struct spoolss_AddDriverInfoCtr *r,
512 const char **driver_name,
513 uint32_t *driver_version);
516 * @brief This function gets printer driver information
518 * @param[in] mem_ctx A talloc memory context.
520 * @param[in] session_info Auth info to open the pipe.
522 * @param[in] architecture The architecture type.
524 * @param[in] driver_name The driver name.
526 * @param[in] driver_version The driver version.
528 * @param[out] _info8 The structure that holds the full driver information.
530 * @return On success WERR_OK, a corresponding DOS error is
531 * something went wrong.
534 WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
535 const struct auth_serversupplied_info *session_info,
536 struct messaging_context *msg_ctx,
537 const char *architecture,
538 const char *driver_name,
539 uint32_t driver_version,
540 struct spoolss_DriverInfo8 **_info8);
543 * @brief This function deletes a printer driver information
545 * @param[in] mem_ctx A talloc memory context.
547 * @param[in] session_info Auth info to open the pipe.
549 * @param[out] info8 The structure that holds the full driver information.
551 * @param[in] version The driver type version.
553 * @return On success WERR_OK, a corresponding DOS error is
554 * something went wrong.
557 WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
558 const struct auth_serversupplied_info *session_info,
559 struct messaging_context *msg_ctx,
560 struct spoolss_DriverInfo8 *info8,
564 * @brief This function gets printer drivers list for the specified
565 * architecture and type version
567 * @param[in] mem_ctx A talloc memory context.
569 * @param[in] session_info Auth info to open the pipe.
571 * @param[in] architecture The architecture type.
573 * @param[in] version The driver version.
575 * @param[out] num_drivers The number of drivers.
577 * @param[out] version The drivers names.
579 * @return On success WERR_OK, a corresponding DOS error is
580 * something went wrong.
583 WERROR winreg_get_driver_list(TALLOC_CTX *mem_ctx,
584 const struct auth_serversupplied_info *session_info,
585 struct messaging_context *msg_ctx,
586 const char *architecture,
588 uint32_t *num_drivers,
589 const char ***drivers);
591 #endif /* _SRV_SPOOLSS_UITL_H */