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 _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_
23 #define _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_
26 #include "librpc/gen_ndr/spoolss.h"
28 struct dcerpc_binding_handle
;
30 enum spoolss_PrinterInfo2Mask
{
31 SPOOLSS_PRINTER_INFO_ATTRIBUTES
= (int)(0x00000001),
32 SPOOLSS_PRINTER_INFO_AVERAGEPPM
= (int)(0x00000002),
33 SPOOLSS_PRINTER_INFO_CJOBS
= (int)(0x00000004),
34 SPOOLSS_PRINTER_INFO_COMMENT
= (int)(0x00000008),
35 SPOOLSS_PRINTER_INFO_DATATYPE
= (int)(0x00000010),
36 SPOOLSS_PRINTER_INFO_DEFAULTPRIORITY
= (int)(0x00000020),
37 SPOOLSS_PRINTER_INFO_DEVMODE
= (int)(0x00000040),
38 SPOOLSS_PRINTER_INFO_DRIVERNAME
= (int)(0x00000080),
39 SPOOLSS_PRINTER_INFO_LOCATION
= (int)(0x00000100),
40 SPOOLSS_PRINTER_INFO_NAME
= (int)(0x00000200),
41 SPOOLSS_PRINTER_INFO_PARAMETERS
= (int)(0x00000400),
42 SPOOLSS_PRINTER_INFO_PORTNAME
= (int)(0x00000800),
43 SPOOLSS_PRINTER_INFO_PRINTERNAME
= (int)(0x00001000),
44 SPOOLSS_PRINTER_INFO_PRINTPROCESSOR
= (int)(0x00002000),
45 SPOOLSS_PRINTER_INFO_PRIORITY
= (int)(0x00004000),
46 SPOOLSS_PRINTER_INFO_SECDESC
= (int)(0x00008000),
47 SPOOLSS_PRINTER_INFO_SEPFILE
= (int)(0x00010000),
48 SPOOLSS_PRINTER_INFO_SERVERNAME
= (int)(0x00020000),
49 SPOOLSS_PRINTER_INFO_SHARENAME
= (int)(0x00040000),
50 SPOOLSS_PRINTER_INFO_STARTTIME
= (int)(0x00080000),
51 SPOOLSS_PRINTER_INFO_STATUS
= (int)(0x00100000),
52 SPOOLSS_PRINTER_INFO_UNTILTIME
= (int)(0x00200000)
55 #define SPOOLSS_PRINTER_INFO_ALL SPOOLSS_PRINTER_INFO_ATTRIBUTES | \
56 SPOOLSS_PRINTER_INFO_AVERAGEPPM | \
57 SPOOLSS_PRINTER_INFO_CJOBS | \
58 SPOOLSS_PRINTER_INFO_COMMENT | \
59 SPOOLSS_PRINTER_INFO_DATATYPE | \
60 SPOOLSS_PRINTER_INFO_DEFAULTPRIORITY | \
61 SPOOLSS_PRINTER_INFO_DEVMODE | \
62 SPOOLSS_PRINTER_INFO_DRIVERNAME | \
63 SPOOLSS_PRINTER_INFO_LOCATION | \
64 SPOOLSS_PRINTER_INFO_NAME | \
65 SPOOLSS_PRINTER_INFO_PARAMETERS | \
66 SPOOLSS_PRINTER_INFO_PORTNAME | \
67 SPOOLSS_PRINTER_INFO_PRINTERNAME | \
68 SPOOLSS_PRINTER_INFO_PRINTPROCESSOR | \
69 SPOOLSS_PRINTER_INFO_PRIORITY | \
70 SPOOLSS_PRINTER_INFO_SECDESC | \
71 SPOOLSS_PRINTER_INFO_SEPFILE | \
72 SPOOLSS_PRINTER_INFO_SERVERNAME | \
73 SPOOLSS_PRINTER_INFO_SHARENAME | \
74 SPOOLSS_PRINTER_INFO_STARTTIME | \
75 SPOOLSS_PRINTER_INFO_STATUS | \
76 SPOOLSS_PRINTER_INFO_UNTILTIME
78 WERROR
winreg_create_printer(TALLOC_CTX
*mem_ctx
,
79 struct dcerpc_binding_handle
*b
,
80 const char *sharename
);
85 * @brief Update the information of a printer in the registry.
87 * @param[in] mem_ctx The talloc memory context to use.
89 * @param[in] b The dcerpc binding handle
91 * @param[in] sharename The share name.
93 * @param[in] info2_mask A bitmask which defines which values should be set.
95 * @param[in] info2 A SetPrinterInfo2 structure with the data to set.
97 * @param[in] devmode A device mode structure with the data to set.
99 * @param[in] secdesc A security descriptor structure with the data to set.
101 * @return On success WERR_OK, a corresponding DOS error is
102 * something went wrong.
104 WERROR
winreg_update_printer(TALLOC_CTX
*mem_ctx
,
105 struct dcerpc_binding_handle
*b
,
106 const char *sharename
,
108 struct spoolss_SetPrinterInfo2
*info2
,
109 struct spoolss_DeviceMode
*devmode
,
110 struct security_descriptor
*secdesc
);
114 * @brief Get the information of a printer stored in the registry.
116 * @param[in] mem_ctx The talloc memory context to use.
118 * @param[in] b The dcerpc binding handle
120 * @param[in] printer The name of the printer to get.
122 * @param[out] pinfo2 A pointer to store a PRINTER_INFO_2 structure.
124 * @return On success WERR_OK, a corresponding DOS error is
125 * something went wrong.
127 WERROR
winreg_get_printer(TALLOC_CTX
*mem_ctx
,
128 struct dcerpc_binding_handle
*b
,
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] b The dcerpc binding handle
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 struct dcerpc_binding_handle
*b
,
148 const char *sharename
,
149 struct spoolss_security_descriptor
**psecdesc
);
152 * @brief Get the security descriptor for a printserver.
154 * @param[in] mem_ctx The talloc memory context to use.
156 * @param[in] b The dcerpc binding handle
158 * @param[out] psecdesc A pointer to store the security descriptor.
160 * @return On success WERR_OK, a corresponding DOS error is
161 * something went wrong.
164 WERROR
winreg_get_printserver_secdesc(TALLOC_CTX
*mem_ctx
,
165 struct dcerpc_binding_handle
*winreg_handle
,
166 struct spoolss_security_descriptor
**psecdesc
);
169 * @brief Set the security descriptor for a printer.
171 * @param[in] mem_ctx The talloc memory context to use.
173 * @param[in] b The dcerpc binding handle
175 * @param[in] sharename The share name.
177 * @param[in] secdesc The security descriptor to save.
179 * @return On success WERR_OK, a corresponding DOS error is
180 * something went wrong.
182 WERROR
winreg_set_printer_secdesc(TALLOC_CTX
*mem_ctx
,
183 struct dcerpc_binding_handle
*b
,
184 const char *sharename
,
185 const struct spoolss_security_descriptor
*secdesc
);
188 * @brief Set the security descriptor for a printserver.
190 * @param[in] mem_ctx The talloc memory context to use.
192 * @param[in] b The dcerpc binding handle
194 * @param[in] secdesc The security descriptor to save.
196 * @return On success WERR_OK, a corresponding DOS error is
197 * something went wrong.
199 WERROR
winreg_set_printserver_secdesc(TALLOC_CTX
*mem_ctx
,
200 struct dcerpc_binding_handle
*b
,
201 const struct spoolss_security_descriptor
*secdesc
);
207 * @brief Set printer data over the winreg pipe.
209 * @param[in] mem_ctx The talloc memory context to use.
211 * @param[in] b The dcerpc binding handle
213 * @param[in] printer The printer name.
215 * @param[in] key The key of the printer data to store the value.
217 * @param[in] value The value name to save.
219 * @param[in] type The type of the value to use.
221 o @param[in] data The data which should be saved under the given value.
223 * @param[in] data_size The size of the data.
225 * @return On success WERR_OK, a corresponding DOS error is
226 * something went wrong.
228 WERROR
winreg_set_printer_dataex(TALLOC_CTX
*mem_ctx
,
229 struct dcerpc_binding_handle
*b
,
233 enum winreg_Type type
,
240 * @brief Get printer data over a winreg pipe.
242 * @param[in] mem_ctx The talloc memory context to use.
244 * @param[in] b The dcerpc binding handle
246 * @param[in] printer The printer name.
248 * @param[in] key The key of the printer data to get the value.
250 * @param[in] value The name of the value to query.
252 * @param[in] type The type of the value to query.
254 * @param[out] data A pointer to store the data.
256 * @param[out] data_size A pointer to store the size of the data.
258 * @return On success WERR_OK, a corresponding DOS error is
259 * something went wrong.
261 WERROR
winreg_get_printer_dataex(TALLOC_CTX
*mem_ctx
,
262 struct dcerpc_binding_handle
*b
,
266 enum winreg_Type
*type
,
268 uint32_t *data_size
);
273 * @brief Enumerate on the values of a given key and provide the data.
275 * @param[in] mem_ctx The talloc memory context to use.
277 * @param[in] b The dcerpc binding handle
279 * @param[in] printer The printer name.
281 * @param[in] key The key of the printer data to get the value.
283 * @param[out] pnum_values A pointer to store the number of values we found.
285 * @param[out] penum_values A pointer to store the values and its data.
287 * @return WERR_OK on success, the corresponding DOS error
288 * code if something gone wrong.
290 WERROR
winreg_enum_printer_dataex(TALLOC_CTX
*mem_ctx
,
291 struct dcerpc_binding_handle
*b
,
294 uint32_t *pnum_values
,
295 struct spoolss_PrinterEnumValues
**penum_values
);
300 * @brief Delete printer data over a winreg pipe.
302 * @param[in] mem_ctx The talloc memory context to use.
304 * @param[in] b The dcerpc binding handle
306 * @param[in] printer The printer name.
308 * @param[in] key The key of the printer data to delete.
310 * @param[in] value The name of the value to delete.
312 * @return On success WERR_OK, a corresponding DOS error is
313 * something went wrong.
315 WERROR
winreg_delete_printer_dataex(TALLOC_CTX
*mem_ctx
,
316 struct dcerpc_binding_handle
*b
,
324 * @brief Enumerate on the subkeys of a given key and provide the data.
326 * @param[in] mem_ctx The talloc memory context to use.
328 * @param[in] b The dcerpc binding handle
330 * @param[in] printer The printer name.
332 * @param[in] key The key of the printer data to get the value.
334 * @param[out] pnum_subkeys A pointer to store the number of subkeys found.
336 * @param[in] psubkeys A pointer to an array to store the names of the subkeys
339 * @return WERR_OK on success, the corresponding DOS error
340 * code if something gone wrong.
342 WERROR
winreg_enum_printer_key(TALLOC_CTX
*mem_ctx
,
343 struct dcerpc_binding_handle
*b
,
346 uint32_t *pnum_subkeys
,
347 const char ***psubkeys
);
352 * @brief Delete a key with subkeys of a given printer.
354 * @param[in] mem_ctx The talloc memory context to use.
356 * @param[in] b The dcerpc binding handle
358 * @param[in] printer The printer name.
360 * @param[in] key The key of the printer to delete.
362 * @return On success WERR_OK, a corresponding DOS error is
363 * something went wrong.
365 WERROR
winreg_delete_printer_key(TALLOC_CTX
*mem_ctx
,
366 struct dcerpc_binding_handle
*b
,
371 * @brief Update the ChangeID of a printer.
373 * The ChangeID **must** be increasing over the lifetime of client's spoolss
374 * service in order for the client's cache to show updates.
376 * If a form is updated of a printer, the we need to update the ChangeID of the
379 * @param[in] mem_ctx The talloc memory context to use.
381 * @param[in] b The dcerpc binding handle
383 * @param[in] printer The printer name.
385 * @return On success WERR_OK, a corresponding DOS error is
386 * something went wrong.
388 WERROR
winreg_printer_update_changeid(TALLOC_CTX
*mem_ctx
,
389 struct dcerpc_binding_handle
*b
,
390 const char *printer
);
393 * @brief Get the ChangeID of the given printer.
395 * @param[in] mem_ctx The talloc memory context to use.
397 * @param[in] b The dcerpc binding handle
399 * @param[in] printer The printer name.
401 * @param[in] changeid A pointer to store the changeid.
403 * @return On success WERR_OK, a corresponding DOS error is
404 * something went wrong.
406 WERROR
winreg_printer_get_changeid(TALLOC_CTX
*mem_ctx
,
407 struct dcerpc_binding_handle
*b
,
409 uint32_t *pchangeid
);
414 * @brief This function adds a form to the list of available forms that can be
415 * selected for the specified printer.
417 * @param[in] mem_ctx The talloc memory context to use.
419 * @param[in] b The dcerpc binding handle
421 * @param[in] form The form to add.
423 * @return WERR_OK on success.
424 * WERR_ALREADY_EXISTS if the form already exists or is a
426 * A corresponding DOS error is something went wrong.
428 WERROR
winreg_printer_addform1(TALLOC_CTX
*mem_ctx
,
429 struct dcerpc_binding_handle
*b
,
430 struct spoolss_AddFormInfo1
*form
);
433 * @brief This function enumerates the forms supported by the specified printer.
435 * @param[in] mem_ctx The talloc memory context to use.
437 * @param[in] b The dcerpc binding handle
439 * @param[out] pnum_info A pointer to store the FormInfo count.
441 * @param[out] pinfo A pointer to store an array with FormInfo.
443 * @return On success WERR_OK, a corresponding DOS error is
444 * something went wrong.
446 WERROR
winreg_printer_enumforms1(TALLOC_CTX
*mem_ctx
,
447 struct dcerpc_binding_handle
*b
,
449 union spoolss_FormInfo
**pinfo
);
452 * @brief This function removes a form name from the list of supported forms.
454 * @param[in] mem_ctx The talloc memory context to use.
456 * @param[in] b The dcerpc binding handle
458 * @param[in] form_name The name of the form to delete.
460 * @return WERR_OK on success.
461 * WERR_INVALID_PARAMETER if the form is a builtin form.
462 * WERR_INVALID_FORM_NAME if the form or key doesn't exist.
463 * A corresponding DOS error is something went wrong.
465 WERROR
winreg_printer_deleteform1(TALLOC_CTX
*mem_ctx
,
466 struct dcerpc_binding_handle
*b
,
467 const char *form_name
);
470 * @brief This function sets the form information for the specified printer.
472 * If one provides both the name in the API call and inside the FormInfo
473 * structure, then the form gets renamed.
475 * @param[in] mem_ctx The talloc memory context to use.
477 * @param[in] b The dcerpc binding handle
479 * @param[in] form_name The name of the form to set or rename.
481 * @param[in] form The FormInfo structure to save.
483 * @return WERR_OK on success.
484 * WERR_INVALID_PARAMETER if the form is a builtin form.
485 * A corresponding DOS error is something went wrong.
487 WERROR
winreg_printer_setform1(TALLOC_CTX
*mem_ctx
,
488 struct dcerpc_binding_handle
*b
,
489 const char *form_name
,
490 struct spoolss_AddFormInfo1
*form
);
493 * @brief This function retrieves information about a specified form.
495 * @param[in] mem_ctx The talloc memory context to use.
497 * @param[in] b The dcerpc binding handle
499 * @param[in] form_name The name of the form to query.
501 * @param[out] form A pointer to a form structure to fill out.
503 * @return On success WERR_OK, a corresponding DOS error is
504 * something went wrong.
506 WERROR
winreg_printer_getform1(TALLOC_CTX
*mem_ctx
,
507 struct dcerpc_binding_handle
*b
,
508 const char *form_name
,
509 struct spoolss_FormInfo1
*form
);
512 * @brief This function adds a new spool driver
514 * @param[in] mem_ctx A talloc memory context.
516 * @param[in] b The dcerpc binding handle
518 * @param[in] r The structure containing the new driver data.
520 * @param[out] driver_name Returns the driver name.
522 * @param[out] driver_version Returns the driver version.
524 * @return On success WERR_OK, a corresponding DOS error is
525 * something went wrong.
527 WERROR
winreg_add_driver(TALLOC_CTX
*mem_ctx
,
528 struct dcerpc_binding_handle
*b
,
529 struct spoolss_AddDriverInfoCtr
*r
,
530 const char **driver_name
,
531 uint32_t *driver_version
);
534 * @brief This function gets printer driver information
536 * @param[in] mem_ctx A talloc memory context.
538 * @param[in] b The dcerpc binding handle
540 * @param[in] architecture The architecture type.
542 * @param[in] driver_name The driver name.
544 * @param[in] driver_version The driver version.
546 * @param[out] _info8 The structure that holds the full driver information.
548 * @return On success WERR_OK, a corresponding DOS error is
549 * something went wrong.
552 WERROR
winreg_get_driver(TALLOC_CTX
*mem_ctx
,
553 struct dcerpc_binding_handle
*b
,
554 const char *architecture
,
555 const char *driver_name
,
556 uint32_t driver_version
,
557 struct spoolss_DriverInfo8
**_info8
);
560 * @brief This function deletes a printer driver information
562 * @param[in] mem_ctx A talloc memory context.
564 * @param[in] b The dcerpc binding handle
566 * @param[out] info8 The structure that holds the full driver information.
568 * @param[in] version The driver type version.
570 * @return On success WERR_OK, a corresponding DOS error is
571 * something went wrong.
574 WERROR
winreg_del_driver(TALLOC_CTX
*mem_ctx
,
575 struct dcerpc_binding_handle
*b
,
576 struct spoolss_DriverInfo8
*info8
,
580 * @brief This function gets printer drivers list for the specified
581 * architecture and type version
583 * @param[in] mem_ctx A talloc memory context.
585 * @param[in] b The dcerpc binding handle
587 * @param[in] architecture The architecture type.
589 * @param[in] version The driver version.
591 * @param[out] num_drivers The number of drivers.
593 * @param[out] version The drivers names.
595 * @return On success WERR_OK, a corresponding DOS error is
596 * something went wrong.
599 WERROR
winreg_get_driver_list(TALLOC_CTX
*mem_ctx
,
600 struct dcerpc_binding_handle
*b
,
601 const char *architecture
,
603 uint32_t *num_drivers
,
604 const char ***drivers
);
606 * @brief This function gets a core printer driver
608 * @param[in] mem_ctx A talloc memory context.
610 * @param[in] b The dcerpc binding handle
612 * @param[in] architecture The architecture type.
614 * @param[in] core_driver_guid The core driver guid.
616 * @param[out] core_printer_driver The returned core printer driver definition
618 * @return On success WERR_OK, a corresponding DOS error is
619 * something went wrong.
622 WERROR
winreg_get_core_driver(TALLOC_CTX
*mem_ctx
,
623 struct dcerpc_binding_handle
*winreg_handle
,
624 const char *architecture
,
625 const struct GUID
*core_driver_guid
,
626 struct spoolss_CorePrinterDriver
**_core_printer_driver
);
629 * @brief This function adds a core printer driver
631 * @param[in] mem_ctx A talloc memory context.
633 * @param[in] b The dcerpc binding handle
635 * @param[in] architecture The architecture type.
637 * @param[in] core_driver_driver The core driver.
639 * @return On success WERR_OK, a corresponding DOS error is
640 * something went wrong.
643 WERROR
winreg_add_core_driver(TALLOC_CTX
*mem_ctx
,
644 struct dcerpc_binding_handle
*winreg_handle
,
645 const char *architecture
,
646 const struct spoolss_CorePrinterDriver
*r
);
649 * @brief This function adds a driver package
651 * @param[in] mem_ctx A talloc memory context.
653 * @param[in] b The dcerpc binding handle
655 * @param[in] package_id The package ID.
657 * @param[in] architecture The architecture type.
659 * @param[in] driver_store_path The local DriverStorePath
661 * @param[in] cab_path The local CabFile path
663 * @return On success WERR_OK, a corresponding DOS error is
664 * something went wrong.
667 WERROR
winreg_add_driver_package(TALLOC_CTX
*mem_ctx
,
668 struct dcerpc_binding_handle
*winreg_handle
,
669 const char *package_id
,
670 const char *architecture
,
671 const char *driver_store_path
,
672 const char *cab_path
);
675 * @brief This function gets a driver package
677 * @param[in] mem_ctx A talloc memory context.
679 * @param[in] b The dcerpc binding handle
681 * @param[in] package_id The package ID.
683 * @param[in] architecture The architecture type.
685 * @param[in] driver_store_path The pointer to a local DriverStorePath
687 * @param[in] cab_path The pointer to a local CabFile path
689 * @return On success WERR_OK, a corresponding DOS error is
690 * something went wrong.
693 WERROR
winreg_get_driver_package(TALLOC_CTX
*mem_ctx
,
694 struct dcerpc_binding_handle
*winreg_handle
,
695 const char *package_id
,
696 const char *architecture
,
697 const char **driver_store_path
,
698 const char **cab_path
);
701 * @brief This function deletes a driver package
703 * @param[in] mem_ctx A talloc memory context.
705 * @param[in] b The dcerpc binding handle
707 * @param[in] package_id The package ID.
709 * @param[in] architecture The architecture type.
711 * @return On success WERR_OK, a corresponding DOS error is
712 * something went wrong.
715 WERROR
winreg_del_driver_package(TALLOC_CTX
*mem_ctx
,
716 struct dcerpc_binding_handle
*winreg_handle
,
717 const char *package_id
,
718 const char *architecture
);
720 #endif /* _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_ */