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 struct messaging_context *msg_ctx,
77 const char *servername,
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] server_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 struct auth_serversupplied_info *server_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] server_info The server supplied session info.
119 * @param[in] printer The servername to use.
121 * @param[in] printer The name of the printer to get.
123 * @param[out] pinfo2 A pointer to store a PRINTER_INFO_2 structure.
125 * @return On success WERR_OK, a corresponding DOS error is
126 * something went wrong.
128 WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
129 struct auth_serversupplied_info *server_info,
130 struct messaging_context *msg_ctx,
131 const char *servername,
133 struct spoolss_PrinterInfo2 **pinfo2);
136 * @brief Get the security descriptor for a printer.
138 * @param[in] mem_ctx The talloc memory context to use.
140 * @param[in] server_info The server supplied session info.
142 * @param[in] sharename The share name.
144 * @param[out] psecdesc A pointer to store the security descriptor.
146 * @return On success WERR_OK, a corresponding DOS error is
147 * something went wrong.
149 WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
150 struct auth_serversupplied_info *server_info,
151 struct messaging_context *msg_ctx,
152 const char *sharename,
153 struct spoolss_security_descriptor **psecdesc);
156 * @brief Set the security descriptor for a printer.
158 * @param[in] mem_ctx The talloc memory context to use.
160 * @param[in] server_info The server supplied session info.
162 * @param[in] sharename The share name.
164 * @param[in] secdesc The security descriptor to save.
166 * @return On success WERR_OK, a corresponding DOS error is
167 * something went wrong.
169 WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
170 struct auth_serversupplied_info *server_info,
171 struct messaging_context *msg_ctx,
172 const char *sharename,
173 const struct spoolss_security_descriptor *secdesc);
178 * @brief Set printer data over the winreg pipe.
180 * @param[in] mem_ctx The talloc memory context to use.
182 * @param[in] server_info The server supplied session info.
184 * @param[in] printer The printer name.
186 * @param[in] key The key of the printer data to store the value.
188 * @param[in] value The value name to save.
190 * @param[in] type The type of the value to use.
192 * @param[in] data The data which sould be saved under the given value.
194 * @param[in] data_size The size of the data.
196 * @return On success WERR_OK, a corresponding DOS error is
197 * something went wrong.
199 WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
200 struct auth_serversupplied_info *server_info,
204 enum winreg_Type type,
211 * @brief Get printer data over a winreg pipe.
213 * @param[in] mem_ctx The talloc memory context to use.
215 * @param[in] server_info The server supplied session info.
217 * @param[in] printer The printer name.
219 * @param[in] key The key of the printer data to get the value.
221 * @param[in] value The name of the value to query.
223 * @param[in] type The type of the value to query.
225 * @param[out] data A pointer to store the data.
227 * @param[out] data_size A pointer to store the size of the data.
229 * @return On success WERR_OK, a corresponding DOS error is
230 * something went wrong.
232 WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
233 struct auth_serversupplied_info *server_info,
237 enum winreg_Type *type,
239 uint32_t *data_size);
244 * @brief Enumerate on the values of a given key and provide the data.
246 * @param[in] mem_ctx The talloc memory context to use.
248 * @param[in] server_info The server supplied session info.
250 * @param[in] printer The printer name.
252 * @param[in] key The key of the printer data to get the value.
254 * @param[out] pnum_values A pointer to store the number of values we found.
256 * @param[out] penum_values A pointer to store the values and its data.
258 * @return WERR_OK on success, the corresponding DOS error
259 * code if something gone wrong.
261 WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
262 struct auth_serversupplied_info *server_info,
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] server_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 struct auth_serversupplied_info *server_info,
295 * @brief Enumerate on the subkeys of a given key and provide the data.
297 * @param[in] mem_ctx The talloc memory context to use.
299 * @param[in] server_info The server supplied session info.
301 * @param[in] printer The printer name.
303 * @param[in] key The key of the printer data to get the value.
305 * @param[out] pnum_subkeys A pointer to store the number of subkeys found.
307 * @param[in] psubkeys A pointer to an array to store the names of the subkeys
310 * @return WERR_OK on success, the corresponding DOS error
311 * code if something gone wrong.
313 WERROR winreg_enum_printer_key(TALLOC_CTX *mem_ctx,
314 struct auth_serversupplied_info *server_info,
317 uint32_t *pnum_subkeys,
318 const char ***psubkeys);
323 * @brief Delete a key with subkeys of a given printer.
325 * @param[in] mem_ctx The talloc memory context to use.
327 * @param[in] server_info The server supplied session info.
329 * @param[in] printer The printer name.
331 * @param[in] key The key of the printer to delete.
333 * @return On success WERR_OK, a corresponding DOS error is
334 * something went wrong.
336 WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
337 struct auth_serversupplied_info *server_info,
342 * @brief Update the ChangeID of a printer.
344 * The ChangeID **must** be increasing over the lifetime of client's spoolss
345 * service in order for the client's cache to show updates.
347 * If a form is updated of a printer, the we need to update the ChangeID of the
350 * @param[in] mem_ctx The talloc memory context to use.
352 * @param[in] server_info The server supplied session info.
354 * @param[in] printer The printer name.
356 * @return On success WERR_OK, a corresponding DOS error is
357 * something went wrong.
359 WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
360 struct auth_serversupplied_info *server_info,
361 const char *printer);
364 * @brief Get the ChangeID of the given printer.
366 * @param[in] mem_ctx The talloc memory context to use.
368 * @param[in] server_info The server supplied session info.
370 * @param[in] printer The printer name.
372 * @param[in] changeid A pointer to store the changeid.
374 * @return On success WERR_OK, a corresponding DOS error is
375 * something went wrong.
377 WERROR winreg_printer_get_changeid(TALLOC_CTX *mem_ctx,
378 struct auth_serversupplied_info *server_info,
380 uint32_t *pchangeid);
385 * @brief This function adds a form to the list of available forms that can be
386 * selected for the specified printer.
388 * @param[in] mem_ctx The talloc memory context to use.
390 * @param[in] server_info The server supplied session info.
392 * @param[in] form The form to add.
394 * @return WERR_OK on success.
395 * WERR_ALREADY_EXISTS if the form already exists or is a
397 * A corresponding DOS error is something went wrong.
399 WERROR winreg_printer_addform1(TALLOC_CTX *mem_ctx,
400 struct auth_serversupplied_info *server_info,
401 struct spoolss_AddFormInfo1 *form);
404 * @brief This function enumerates the forms supported by the specified printer.
406 * @param[in] mem_ctx The talloc memory context to use.
408 * @param[in] server_info The server supplied session info.
410 * @param[out] pnum_info A pointer to store the FormInfo count.
412 * @param[out] pinfo A pointer to store an array with FormInfo.
414 * @return On success WERR_OK, a corresponding DOS error is
415 * something went wrong.
417 WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
418 struct auth_serversupplied_info *server_info,
420 union spoolss_FormInfo **pinfo);
423 * @brief This function removes a form name from the list of supported forms.
425 * @param[in] mem_ctx The talloc memory context to use.
427 * @param[in] server_info The server supplied session info.
429 * @param[in] form_name The name of the form to delete.
431 * @return WERR_OK on success.
432 * WERR_INVALID_PARAM if the form is a builtin form.
433 * WERR_INVALID_FORM_NAME if the form or key doesn't exist.
434 * A corresponding DOS error is something went wrong.
436 WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
437 struct auth_serversupplied_info *server_info,
438 const char *form_name);
441 * @brief This function sets the form information for the specified printer.
443 * If one provides both the name in the API call and inside the FormInfo
444 * structure, then the form gets renamed.
446 * @param[in] mem_ctx The talloc memory context to use.
448 * @param[in] server_info The server supplied session info.
450 * @param[in] form_name The name of the form to set or rename.
452 * @param[in] form The FormInfo structure to save.
454 * @return WERR_OK on success.
455 * WERR_INVALID_PARAM if the form is a builtin form.
456 * A corresponding DOS error is something went wrong.
458 WERROR winreg_printer_setform1(TALLOC_CTX *mem_ctx,
459 struct auth_serversupplied_info *server_info,
460 const char *form_name,
461 struct spoolss_AddFormInfo1 *form);
464 * @brief This function retrieves information about a specified form.
466 * @param[in] mem_ctx The talloc memory context to use.
468 * @param[in] server_info The server supplied session info.
470 * @param[in] form_name The name of the form to query.
472 * @param[out] form A pointer to a form structure to fill out.
474 * @return On success WERR_OK, a corresponding DOS error is
475 * something went wrong.
477 WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
478 struct auth_serversupplied_info *server_info,
479 const char *form_name,
480 struct spoolss_FormInfo1 *form);
483 * @brief This function adds a new spool driver
485 * @param[in] mem_ctx A talloc memory context.
487 * @param[in] server_info Auth info to open the pipe.
489 * @param[in] r The structure containing the new driver data.
491 * @param[out] driver_name Returns the driver name.
493 * @param[out] driver_version Returns the driver version.
495 * @return On success WERR_OK, a corresponding DOS error is
496 * something went wrong.
498 WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
499 struct auth_serversupplied_info *server_info,
500 struct spoolss_AddDriverInfoCtr *r,
501 const char **driver_name,
502 uint32_t *driver_version);
505 * @brief This function gets printer driver information
507 * @param[in] mem_ctx A talloc memory context.
509 * @param[in] server_info Auth info to open the pipe.
511 * @param[in] architecture The architecture type.
513 * @param[in] driver_name The driver name.
515 * @param[in] driver_version The driver version.
517 * @param[out] _info8 The structure that holds the full driver information.
519 * @return On success WERR_OK, a corresponding DOS error is
520 * something went wrong.
523 WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
524 struct auth_serversupplied_info *server_info,
525 const char *architecture,
526 const char *driver_name,
527 uint32_t driver_version,
528 struct spoolss_DriverInfo8 **_info8);
531 * @brief This function deletes a printer driver information
533 * @param[in] mem_ctx A talloc memory context.
535 * @param[in] server_info Auth info to open the pipe.
537 * @param[out] info8 The structure that holds the full driver information.
539 * @param[in] version The driver type version.
541 * @return On success WERR_OK, a corresponding DOS error is
542 * something went wrong.
545 WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
546 struct auth_serversupplied_info *server_info,
547 struct spoolss_DriverInfo8 *info8,
551 * @brief This function gets printer drivers list for the specified
552 * architecture and type version
554 * @param[in] mem_ctx A talloc memory context.
556 * @param[in] server_info Auth info to open the pipe.
558 * @param[in] architecture The architecture type.
560 * @param[in] version The driver version.
562 * @param[out] num_drivers The number of drivers.
564 * @param[out] version The drivers names.
566 * @return On success WERR_OK, a corresponding DOS error is
567 * something went wrong.
570 WERROR winreg_get_driver_list(TALLOC_CTX *mem_ctx,
571 struct auth_serversupplied_info *server_info,
572 const char *architecture,
574 uint32_t *num_drivers,
575 const char ***drivers);
577 #endif /* _SRV_SPOOLSS_UITL_H */