vfs_aio_fork: Use a shorter random delay
[Samba.git] / source3 / rpc_client / cli_winreg_spoolss.h
blob1bd2746e6f4236036540d425814e8a6856cd4c4f
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 _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_
23 #define _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_
25 struct dcerpc_binding_handle;
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 struct dcerpc_binding_handle *b,
77 const char *sharename);
79 /**
80 * @internal
82 * @brief Update the information of a printer in the registry.
84 * @param[in] mem_ctx The talloc memory context to use.
86 * @param[in] b The dcerpc binding handle
88 * @param[in] sharename The share name.
90 * @param[in] info2_mask A bitmask which defines which values should be set.
92 * @param[in] info2 A SetPrinterInfo2 structure with the data to set.
94 * @param[in] devmode A device mode structure with the data to set.
96 * @param[in] secdesc A security descriptor structure with the data to set.
98 * @return On success WERR_OK, a corresponding DOS error is
99 * something went wrong.
101 WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
102 struct dcerpc_binding_handle *b,
103 const char *sharename,
104 uint32_t info2_mask,
105 struct spoolss_SetPrinterInfo2 *info2,
106 struct spoolss_DeviceMode *devmode,
107 struct security_descriptor *secdesc);
111 * @brief Get the inforamtion of a printer stored in the registry.
113 * @param[in] mem_ctx The talloc memory context to use.
115 * @param[in] b The dcerpc binding handle
117 * @param[in] printer The name of the printer to get.
119 * @param[out] pinfo2 A pointer to store a PRINTER_INFO_2 structure.
121 * @return On success WERR_OK, a corresponding DOS error is
122 * something went wrong.
124 WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
125 struct dcerpc_binding_handle *b,
126 const char *printer,
127 struct spoolss_PrinterInfo2 **pinfo2);
130 * @brief Get the security descriptor for a printer.
132 * @param[in] mem_ctx The talloc memory context to use.
134 * @param[in] b The dcerpc binding handle
136 * @param[in] sharename The share name.
138 * @param[out] psecdesc A pointer to store the security descriptor.
140 * @return On success WERR_OK, a corresponding DOS error is
141 * something went wrong.
143 WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
144 struct dcerpc_binding_handle *b,
145 const char *sharename,
146 struct spoolss_security_descriptor **psecdesc);
149 * @brief Get the security descriptor for a printserver.
151 * @param[in] mem_ctx The talloc memory context to use.
153 * @param[in] b The dcerpc binding handle
155 * @param[out] psecdesc A pointer to store the security descriptor.
157 * @return On success WERR_OK, a corresponding DOS error is
158 * something went wrong.
161 WERROR winreg_get_printserver_secdesc(TALLOC_CTX *mem_ctx,
162 struct dcerpc_binding_handle *winreg_handle,
163 struct spoolss_security_descriptor **psecdesc);
166 * @brief Set the security descriptor for a printer.
168 * @param[in] mem_ctx The talloc memory context to use.
170 * @param[in] b The dcerpc binding handle
172 * @param[in] sharename The share name.
174 * @param[in] secdesc The security descriptor to save.
176 * @return On success WERR_OK, a corresponding DOS error is
177 * something went wrong.
179 WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
180 struct dcerpc_binding_handle *b,
181 const char *sharename,
182 const struct spoolss_security_descriptor *secdesc);
185 * @brief Set the security descriptor for a printserver.
187 * @param[in] mem_ctx The talloc memory context to use.
189 * @param[in] b The dcerpc binding handle
191 * @param[in] secdesc The security descriptor to save.
193 * @return On success WERR_OK, a corresponding DOS error is
194 * something went wrong.
196 WERROR winreg_set_printserver_secdesc(TALLOC_CTX *mem_ctx,
197 struct dcerpc_binding_handle *b,
198 const struct spoolss_security_descriptor *secdesc);
202 * @internal
204 * @brief Set printer data over the winreg pipe.
206 * @param[in] mem_ctx The talloc memory context to use.
208 * @param[in] b The dcerpc binding handle
210 * @param[in] printer The printer name.
212 * @param[in] key The key of the printer data to store the value.
214 * @param[in] value The value name to save.
216 * @param[in] type The type of the value to use.
218 * @param[in] data The data which sould be saved under the given value.
220 * @param[in] data_size The size of the data.
222 * @return On success WERR_OK, a corresponding DOS error is
223 * something went wrong.
225 WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
226 struct dcerpc_binding_handle *b,
227 const char *printer,
228 const char *key,
229 const char *value,
230 enum winreg_Type type,
231 uint8_t *data,
232 uint32_t data_size);
235 * @internal
237 * @brief Get printer data over a winreg pipe.
239 * @param[in] mem_ctx The talloc memory context to use.
241 * @param[in] b The dcerpc binding handle
243 * @param[in] printer The printer name.
245 * @param[in] key The key of the printer data to get the value.
247 * @param[in] value The name of the value to query.
249 * @param[in] type The type of the value to query.
251 * @param[out] data A pointer to store the data.
253 * @param[out] data_size A pointer to store the size of the data.
255 * @return On success WERR_OK, a corresponding DOS error is
256 * something went wrong.
258 WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
259 struct dcerpc_binding_handle *b,
260 const char *printer,
261 const char *key,
262 const char *value,
263 enum winreg_Type *type,
264 uint8_t **data,
265 uint32_t *data_size);
268 * @internal
270 * @brief Enumerate on the values of a given key and provide the data.
272 * @param[in] mem_ctx The talloc memory context to use.
274 * @param[in] b The dcerpc binding handle
276 * @param[in] printer The printer name.
278 * @param[in] key The key of the printer data to get the value.
280 * @param[out] pnum_values A pointer to store the number of values we found.
282 * @param[out] penum_values A pointer to store the values and its data.
284 * @return WERR_OK on success, the corresponding DOS error
285 * code if something gone wrong.
287 WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
288 struct dcerpc_binding_handle *b,
289 const char *printer,
290 const char *key,
291 uint32_t *pnum_values,
292 struct spoolss_PrinterEnumValues **penum_values);
295 * @internal
297 * @brief Delete printer data over a winreg pipe.
299 * @param[in] mem_ctx The talloc memory context to use.
301 * @param[in] b The dcerpc binding handle
303 * @param[in] printer The printer name.
305 * @param[in] key The key of the printer data to delete.
307 * @param[in] value The name of the value to delete.
309 * @return On success WERR_OK, a corresponding DOS error is
310 * something went wrong.
312 WERROR winreg_delete_printer_dataex(TALLOC_CTX *mem_ctx,
313 struct dcerpc_binding_handle *b,
314 const char *printer,
315 const char *key,
316 const char *value);
319 * @internal
321 * @brief Enumerate on the subkeys of a given key and provide the data.
323 * @param[in] mem_ctx The talloc memory context to use.
325 * @param[in] b The dcerpc binding handle
327 * @param[in] printer The printer name.
329 * @param[in] key The key of the printer data to get the value.
331 * @param[out] pnum_subkeys A pointer to store the number of subkeys found.
333 * @param[in] psubkeys A pointer to an array to store the names of the subkeys
334 * found.
336 * @return WERR_OK on success, the corresponding DOS error
337 * code if something gone wrong.
339 WERROR winreg_enum_printer_key(TALLOC_CTX *mem_ctx,
340 struct dcerpc_binding_handle *b,
341 const char *printer,
342 const char *key,
343 uint32_t *pnum_subkeys,
344 const char ***psubkeys);
347 * @internal
349 * @brief Delete a key with subkeys of a given printer.
351 * @param[in] mem_ctx The talloc memory context to use.
353 * @param[in] b The dcerpc binding handle
355 * @param[in] printer The printer name.
357 * @param[in] key The key of the printer to delete.
359 * @return On success WERR_OK, a corresponding DOS error is
360 * something went wrong.
362 WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
363 struct dcerpc_binding_handle *b,
364 const char *printer,
365 const char *key);
368 * @brief Update the ChangeID of a printer.
370 * The ChangeID **must** be increasing over the lifetime of client's spoolss
371 * service in order for the client's cache to show updates.
373 * If a form is updated of a printer, the we need to update the ChangeID of the
374 * pritner.
376 * @param[in] mem_ctx The talloc memory context to use.
378 * @param[in] b The dcerpc binding handle
380 * @param[in] printer The printer name.
382 * @return On success WERR_OK, a corresponding DOS error is
383 * something went wrong.
385 WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
386 struct dcerpc_binding_handle *b,
387 const char *printer);
390 * @brief Get the ChangeID of the given printer.
392 * @param[in] mem_ctx The talloc memory context to use.
394 * @param[in] b The dcerpc binding handle
396 * @param[in] printer The printer name.
398 * @param[in] changeid A pointer to store the changeid.
400 * @return On success WERR_OK, a corresponding DOS error is
401 * something went wrong.
403 WERROR winreg_printer_get_changeid(TALLOC_CTX *mem_ctx,
404 struct dcerpc_binding_handle *b,
405 const char *printer,
406 uint32_t *pchangeid);
409 * @internal
411 * @brief This function adds a form to the list of available forms that can be
412 * selected for the specified printer.
414 * @param[in] mem_ctx The talloc memory context to use.
416 * @param[in] b The dcerpc binding handle
418 * @param[in] form The form to add.
420 * @return WERR_OK on success.
421 * WERR_ALREADY_EXISTS if the form already exists or is a
422 * builtin form.
423 * A corresponding DOS error is something went wrong.
425 WERROR winreg_printer_addform1(TALLOC_CTX *mem_ctx,
426 struct dcerpc_binding_handle *b,
427 struct spoolss_AddFormInfo1 *form);
430 * @brief This function enumerates the forms supported by the specified printer.
432 * @param[in] mem_ctx The talloc memory context to use.
434 * @param[in] b The dcerpc binding handle
436 * @param[out] pnum_info A pointer to store the FormInfo count.
438 * @param[out] pinfo A pointer to store an array with FormInfo.
440 * @return On success WERR_OK, a corresponding DOS error is
441 * something went wrong.
443 WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
444 struct dcerpc_binding_handle *b,
445 uint32_t *pnum_info,
446 union spoolss_FormInfo **pinfo);
449 * @brief This function removes a form name from the list of supported forms.
451 * @param[in] mem_ctx The talloc memory context to use.
453 * @param[in] b The dcerpc binding handle
455 * @param[in] form_name The name of the form to delete.
457 * @return WERR_OK on success.
458 * WERR_INVALID_PARAMETER if the form is a builtin form.
459 * WERR_INVALID_FORM_NAME if the form or key doesn't exist.
460 * A corresponding DOS error is something went wrong.
462 WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
463 struct dcerpc_binding_handle *b,
464 const char *form_name);
467 * @brief This function sets the form information for the specified printer.
469 * If one provides both the name in the API call and inside the FormInfo
470 * structure, then the form gets renamed.
472 * @param[in] mem_ctx The talloc memory context to use.
474 * @param[in] b The dcerpc binding handle
476 * @param[in] form_name The name of the form to set or rename.
478 * @param[in] form The FormInfo structure to save.
480 * @return WERR_OK on success.
481 * WERR_INVALID_PARAMETER if the form is a builtin form.
482 * A corresponding DOS error is something went wrong.
484 WERROR winreg_printer_setform1(TALLOC_CTX *mem_ctx,
485 struct dcerpc_binding_handle *b,
486 const char *form_name,
487 struct spoolss_AddFormInfo1 *form);
490 * @brief This function retrieves information about a specified form.
492 * @param[in] mem_ctx The talloc memory context to use.
494 * @param[in] b The dcerpc binding handle
496 * @param[in] form_name The name of the form to query.
498 * @param[out] form A pointer to a form structure to fill out.
500 * @return On success WERR_OK, a corresponding DOS error is
501 * something went wrong.
503 WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
504 struct dcerpc_binding_handle *b,
505 const char *form_name,
506 struct spoolss_FormInfo1 *form);
509 * @brief This function adds a new spool driver
511 * @param[in] mem_ctx A talloc memory context.
513 * @param[in] b The dcerpc binding handle
515 * @param[in] r The structure containing the new driver data.
517 * @param[out] driver_name Returns the driver name.
519 * @param[out] driver_version Returns the driver version.
521 * @return On success WERR_OK, a corresponding DOS error is
522 * something went wrong.
524 WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
525 struct dcerpc_binding_handle *b,
526 struct spoolss_AddDriverInfoCtr *r,
527 const char **driver_name,
528 uint32_t *driver_version);
531 * @brief This function gets printer driver information
533 * @param[in] mem_ctx A talloc memory context.
535 * @param[in] b The dcerpc binding handle
537 * @param[in] architecture The architecture type.
539 * @param[in] driver_name The driver name.
541 * @param[in] driver_version The driver version.
543 * @param[out] _info8 The structure that holds the full driver information.
545 * @return On success WERR_OK, a corresponding DOS error is
546 * something went wrong.
549 WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
550 struct dcerpc_binding_handle *b,
551 const char *architecture,
552 const char *driver_name,
553 uint32_t driver_version,
554 struct spoolss_DriverInfo8 **_info8);
557 * @brief This function deletes a printer driver information
559 * @param[in] mem_ctx A talloc memory context.
561 * @param[in] b The dcerpc binding handle
563 * @param[out] info8 The structure that holds the full driver information.
565 * @param[in] version The driver type version.
567 * @return On success WERR_OK, a corresponding DOS error is
568 * something went wrong.
571 WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
572 struct dcerpc_binding_handle *b,
573 struct spoolss_DriverInfo8 *info8,
574 uint32_t version);
577 * @brief This function gets printer drivers list for the specified
578 * architecture and type version
580 * @param[in] mem_ctx A talloc memory context.
582 * @param[in] b The dcerpc binding handle
584 * @param[in] architecture The architecture type.
586 * @param[in] version The driver version.
588 * @param[out] num_drivers The number of drivers.
590 * @param[out] version The drivers names.
592 * @return On success WERR_OK, a corresponding DOS error is
593 * something went wrong.
596 WERROR winreg_get_driver_list(TALLOC_CTX *mem_ctx,
597 struct dcerpc_binding_handle *b,
598 const char *architecture,
599 uint32_t version,
600 uint32_t *num_drivers,
601 const char ***drivers);
603 * @brief This function gets a core printer driver
605 * @param[in] mem_ctx A talloc memory context.
607 * @param[in] b The dcerpc binding handle
609 * @param[in] architecture The architecture type.
611 * @param[in] core_driver_guid The core driver guid.
613 * @param[out] core_printer_driver The returned core printer driver definiton
615 * @return On success WERR_OK, a corresponding DOS error is
616 * something went wrong.
619 WERROR winreg_get_core_driver(TALLOC_CTX *mem_ctx,
620 struct dcerpc_binding_handle *winreg_handle,
621 const char *architecture,
622 const struct GUID *core_driver_guid,
623 struct spoolss_CorePrinterDriver **_core_printer_driver);
626 * @brief This function adds a core printer driver
628 * @param[in] mem_ctx A talloc memory context.
630 * @param[in] b The dcerpc binding handle
632 * @param[in] architecture The architecture type.
634 * @param[in] core_driver_driver The core driver.
636 * @return On success WERR_OK, a corresponding DOS error is
637 * something went wrong.
640 WERROR winreg_add_core_driver(TALLOC_CTX *mem_ctx,
641 struct dcerpc_binding_handle *winreg_handle,
642 const char *architecture,
643 const struct spoolss_CorePrinterDriver *r);
646 * @brief This function adds a driver package
648 * @param[in] mem_ctx A talloc memory context.
650 * @param[in] b The dcerpc binding handle
652 * @param[in] package_id The package ID.
654 * @param[in] architecture The architecture type.
656 * @param[in] driver_store_path The local DriverStorePath
658 * @param[in] cab_path The local CabFile path
660 * @return On success WERR_OK, a corresponding DOS error is
661 * something went wrong.
664 WERROR winreg_add_driver_package(TALLOC_CTX *mem_ctx,
665 struct dcerpc_binding_handle *winreg_handle,
666 const char *package_id,
667 const char *architecture,
668 const char *driver_store_path,
669 const char *cab_path);
672 * @brief This function gets a driver package
674 * @param[in] mem_ctx A talloc memory context.
676 * @param[in] b The dcerpc binding handle
678 * @param[in] package_id The package ID.
680 * @param[in] architecture The architecture type.
682 * @param[in] driver_store_path The pointer to a local DriverStorePath
684 * @param[in] cab_path The pointer to a local CabFile path
686 * @return On success WERR_OK, a corresponding DOS error is
687 * something went wrong.
690 WERROR winreg_get_driver_package(TALLOC_CTX *mem_ctx,
691 struct dcerpc_binding_handle *winreg_handle,
692 const char *package_id,
693 const char *architecture,
694 const char **driver_store_path,
695 const char **cab_path);
698 * @brief This function deletes a driver package
700 * @param[in] mem_ctx A talloc memory context.
702 * @param[in] b The dcerpc binding handle
704 * @param[in] package_id The package ID.
706 * @param[in] architecture The architecture type.
708 * @return On success WERR_OK, a corresponding DOS error is
709 * something went wrong.
712 WERROR winreg_del_driver_package(TALLOC_CTX *mem_ctx,
713 struct dcerpc_binding_handle *winreg_handle,
714 const char *package_id,
715 const char *architecture);
717 #endif /* _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_ */