s3-rpc_cli: add winreg_add_core_driver()
[vlendec/samba-autobuild/.git] / source3 / rpc_client / cli_winreg_spoolss.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *
4  *  SPOOLSS RPC Pipe server / winreg client routines
5  *
6  *  Copyright (c) 2010      Andreas Schneider <asn@samba.org>
7  *
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.
12  *
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.
17  *
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/>.
20  */
21
22 #ifndef _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_
23 #define _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_
24
25 struct dcerpc_binding_handle;
26
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)
50 };
51
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
74
75 WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
76                              struct dcerpc_binding_handle *b,
77                              const char *sharename);
78
79 /**
80  * @internal
81  *
82  * @brief Update the information of a printer in the registry.
83  *
84  * @param[in]  mem_ctx  The talloc memory context to use.
85  *
86  * @param[in]  b The dcerpc binding handle
87  *
88  * @param[in]  sharename  The share name.
89  *
90  * @param[in]  info2_mask A bitmask which defines which values should be set.
91  *
92  * @param[in]  info2    A SetPrinterInfo2 structure with the data to set.
93  *
94  * @param[in]  devmode  A device mode structure with the data to set.
95  *
96  * @param[in]  secdesc  A security descriptor structure with the data to set.
97  *
98  * @return              On success WERR_OK, a corresponding DOS error is
99  *                      something went wrong.
100  */
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);
108
109
110 /**
111  * @brief Get the inforamtion of a printer stored in the registry.
112  *
113  * @param[in]  mem_ctx  The talloc memory context to use.
114  *
115  * @param[in]  b The dcerpc binding handle
116  *
117  * @param[in]  printer  The name of the printer to get.
118  *
119  * @param[out] pinfo2   A pointer to store a PRINTER_INFO_2 structure.
120  *
121  * @return              On success WERR_OK, a corresponding DOS error is
122  *                      something went wrong.
123  */
124 WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
125                           struct dcerpc_binding_handle *b,
126                           const char *printer,
127                           struct spoolss_PrinterInfo2 **pinfo2);
128
129 /**
130  * @brief Get the security descriptor for a printer.
131  *
132  * @param[in]  mem_ctx  The talloc memory context to use.
133  *
134  * @param[in]  b The dcerpc binding handle
135  *
136  * @param[in]  sharename  The share name.
137  *
138  * @param[out] psecdesc   A pointer to store the security descriptor.
139  *
140  * @return              On success WERR_OK, a corresponding DOS error is
141  *                      something went wrong.
142  */
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);
147
148 /**
149  * @brief Get the security descriptor for a printserver.
150  *
151  * @param[in]  mem_ctx  The talloc memory context to use.
152  *
153  * @param[in]  b The dcerpc binding handle
154  *
155  * @param[out] psecdesc   A pointer to store the security descriptor.
156  *
157  * @return              On success WERR_OK, a corresponding DOS error is
158  *                      something went wrong.
159  */
160
161 WERROR winreg_get_printserver_secdesc(TALLOC_CTX *mem_ctx,
162                                       struct dcerpc_binding_handle *winreg_handle,
163                                       struct spoolss_security_descriptor **psecdesc);
164
165 /**
166  * @brief Set the security descriptor for a printer.
167  *
168  * @param[in]  mem_ctx  The talloc memory context to use.
169  *
170  * @param[in]  b The dcerpc binding handle
171  *
172  * @param[in]  sharename  The share name.
173  *
174  * @param[in]  secdesc  The security descriptor to save.
175  *
176  * @return              On success WERR_OK, a corresponding DOS error is
177  *                      something went wrong.
178  */
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);
183
184 /**
185  * @brief Set the security descriptor for a printserver.
186  *
187  * @param[in]  mem_ctx  The talloc memory context to use.
188  *
189  * @param[in]  b The dcerpc binding handle
190  *
191  * @param[in]  secdesc  The security descriptor to save.
192  *
193  * @return              On success WERR_OK, a corresponding DOS error is
194  *                      something went wrong.
195  */
196 WERROR winreg_set_printserver_secdesc(TALLOC_CTX *mem_ctx,
197                                       struct dcerpc_binding_handle *b,
198                                       const struct spoolss_security_descriptor *secdesc);
199
200
201 /**
202  * @internal
203  *
204  * @brief Set printer data over the winreg pipe.
205  *
206  * @param[in]  mem_ctx  The talloc memory context to use.
207  *
208  * @param[in]  b The dcerpc binding handle
209  *
210  * @param[in]  printer  The printer name.
211  *
212  * @param[in]  key      The key of the printer data to store the value.
213  *
214  * @param[in]  value    The value name to save.
215  *
216  * @param[in]  type     The type of the value to use.
217  *
218  * @param[in]  data     The data which sould be saved under the given value.
219  *
220  * @param[in]  data_size The size of the data.
221  *
222  * @return              On success WERR_OK, a corresponding DOS error is
223  *                      something went wrong.
224  */
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);
233
234 /**
235  * @internal
236  *
237  * @brief Get printer data over a winreg pipe.
238  *
239  * @param[in]  mem_ctx  The talloc memory context to use.
240  *
241  * @param[in]  b The dcerpc binding handle
242  *
243  * @param[in]  printer  The printer name.
244  *
245  * @param[in]  key      The key of the printer data to get the value.
246  *
247  * @param[in]  value    The name of the value to query.
248  *
249  * @param[in]  type     The type of the value to query.
250  *
251  * @param[out] data     A pointer to store the data.
252  *
253  * @param[out] data_size A pointer to store the size of the data.
254  *
255  * @return              On success WERR_OK, a corresponding DOS error is
256  *                      something went wrong.
257  */
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);
266
267 /**
268  * @internal
269  *
270  * @brief Enumerate on the values of a given key and provide the data.
271  *
272  * @param[in]  mem_ctx  The talloc memory context to use.
273  *
274  * @param[in]  b The dcerpc binding handle
275  *
276  * @param[in]  printer  The printer name.
277  *
278  * @param[in]  key      The key of the printer data to get the value.
279  *
280  * @param[out] pnum_values A pointer to store the number of values we found.
281  *
282  * @param[out] penum_values A pointer to store the values and its data.
283  *
284  * @return                   WERR_OK on success, the corresponding DOS error
285  *                           code if something gone wrong.
286  */
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);
293
294 /**
295  * @internal
296  *
297  * @brief Delete printer data over a winreg pipe.
298  *
299  * @param[in]  mem_ctx  The talloc memory context to use.
300  *
301  * @param[in]  b The dcerpc binding handle
302  *
303  * @param[in]  printer  The printer name.
304  *
305  * @param[in]  key      The key of the printer data to delete.
306  *
307  * @param[in]  value    The name of the value to delete.
308  *
309  * @return              On success WERR_OK, a corresponding DOS error is
310  *                      something went wrong.
311  */
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);
317
318 /**
319  * @internal
320  *
321  * @brief Enumerate on the subkeys of a given key and provide the data.
322  *
323  * @param[in]  mem_ctx  The talloc memory context to use.
324  *
325  * @param[in]  b The dcerpc binding handle
326  *
327  * @param[in]  printer  The printer name.
328  *
329  * @param[in]  key      The key of the printer data to get the value.
330  *
331  * @param[out] pnum_subkeys A pointer to store the number of subkeys found.
332  *
333  * @param[in]  psubkeys A pointer to an array to store the names of the subkeys
334  *                      found.
335  *
336  * @return              WERR_OK on success, the corresponding DOS error
337  *                      code if something gone wrong.
338  */
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);
345
346 /**
347  * @internal
348  *
349  * @brief Delete a key with subkeys of a given printer.
350  *
351  * @param[in]  mem_ctx  The talloc memory context to use.
352  *
353  * @param[in]  b The dcerpc binding handle
354  *
355  * @param[in]  printer  The printer name.
356  *
357  * @param[in]  key      The key of the printer to delete.
358  *
359  * @return              On success WERR_OK, a corresponding DOS error is
360  *                      something went wrong.
361  */
362 WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
363                                  struct dcerpc_binding_handle *b,
364                                  const char *printer,
365                                  const char *key);
366
367 /**
368  * @brief Update the ChangeID of a printer.
369  *
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.
372  *
373  * If a form is updated of a printer, the we need to update the ChangeID of the
374  * pritner.
375  *
376  * @param[in]  mem_ctx  The talloc memory context to use.
377  *
378  * @param[in]  b The dcerpc binding handle
379  *
380  * @param[in]  printer  The printer name.
381  *
382  * @return              On success WERR_OK, a corresponding DOS error is
383  *                      something went wrong.
384  */
385 WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
386                                       struct dcerpc_binding_handle *b,
387                                       const char *printer);
388
389 /**
390  * @brief Get the ChangeID of the given printer.
391  *
392  * @param[in]  mem_ctx  The talloc memory context to use.
393  *
394  * @param[in]  b The dcerpc binding handle
395  *
396  * @param[in]  printer  The printer name.
397  *
398  * @param[in]  changeid A pointer to store the changeid.
399  *
400  * @return              On success WERR_OK, a corresponding DOS error is
401  *                      something went wrong.
402  */
403 WERROR winreg_printer_get_changeid(TALLOC_CTX *mem_ctx,
404                                    struct dcerpc_binding_handle *b,
405                                    const char *printer,
406                                    uint32_t *pchangeid);
407
408 /**
409  * @internal
410  *
411  * @brief This function adds a form to the list of available forms that can be
412  * selected for the specified printer.
413  *
414  * @param[in]  mem_ctx  The talloc memory context to use.
415  *
416  * @param[in]  b The dcerpc binding handle
417  *
418  * @param[in]  form     The form to add.
419  *
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.
424  */
425 WERROR winreg_printer_addform1(TALLOC_CTX *mem_ctx,
426                                struct dcerpc_binding_handle *b,
427                                struct spoolss_AddFormInfo1 *form);
428
429 /*
430  * @brief This function enumerates the forms supported by the specified printer.
431  *
432  * @param[in]  mem_ctx  The talloc memory context to use.
433  *
434  * @param[in]  b The dcerpc binding handle
435  *
436  * @param[out] pnum_info A pointer to store the FormInfo count.
437  *
438  * @param[out] pinfo     A pointer to store an array with FormInfo.
439  *
440  * @return              On success WERR_OK, a corresponding DOS error is
441  *                      something went wrong.
442  */
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);
447
448 /**
449  * @brief This function removes a form name from the list of supported forms.
450  *
451  * @param[in]  mem_ctx  The talloc memory context to use.
452  *
453  * @param[in]  b The dcerpc binding handle
454  *
455  * @param[in]  form_name The name of the form to delete.
456  *
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.
461  */
462 WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
463                                   struct dcerpc_binding_handle *b,
464                                   const char *form_name);
465
466 /**
467  * @brief This function sets the form information for the specified printer.
468  *
469  * If one provides both the name in the API call and inside the FormInfo
470  * structure, then the form gets renamed.
471  *
472  * @param[in]  mem_ctx  The talloc memory context to use.
473  *
474  * @param[in]  b The dcerpc binding handle
475  *
476  * @param[in]  form_name The name of the form to set or rename.
477  *
478  * @param[in]  form     The FormInfo structure to save.
479  *
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.
483  */
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);
488
489 /**
490  * @brief This function retrieves information about a specified form.
491  *
492  * @param[in]  mem_ctx  The talloc memory context to use.
493  *
494  * @param[in]  b The dcerpc binding handle
495  *
496  * @param[in]  form_name The name of the form to query.
497  *
498  * @param[out] form     A pointer to a form structure to fill out.
499  *
500  * @return              On success WERR_OK, a corresponding DOS error is
501  *                      something went wrong.
502  */
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);
507
508 /**
509  * @brief This function adds a new spool driver
510  *
511  * @param[in]  mem_ctx         A talloc memory context.
512  *
513  * @param[in]  b The dcerpc binding handle
514  *
515  * @param[in]  r               The structure containing the new driver data.
516  *
517  * @param[out] driver_name     Returns the driver name.
518  *
519  * @param[out] driver_version  Returns the driver version.
520  *
521  * @return              On success WERR_OK, a corresponding DOS error is
522  *                      something went wrong.
523  */
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);
529
530 /**
531  * @brief This function gets printer driver information
532  *
533  * @param[in]  mem_ctx         A talloc memory context.
534  *
535  * @param[in]  b The dcerpc binding handle
536  *
537  * @param[in]  architecture    The architecture type.
538  *
539  * @param[in]  driver_name     The driver name.
540  *
541  * @param[in]  driver_version  The driver version.
542  *
543  * @param[out] _info8   The structure that holds the full driver information.
544  *
545  * @return              On success WERR_OK, a corresponding DOS error is
546  *                      something went wrong.
547  */
548
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);
555
556 /**
557  * @brief This function deletes a printer driver information
558  *
559  * @param[in]  mem_ctx         A talloc memory context.
560  *
561  * @param[in]  b The dcerpc binding handle
562  *
563  * @param[out] info8    The structure that holds the full driver information.
564  *
565  * @param[in]  version  The driver type version.
566  *
567  * @return              On success WERR_OK, a corresponding DOS error is
568  *                      something went wrong.
569  */
570
571 WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
572                          struct dcerpc_binding_handle *b,
573                          struct spoolss_DriverInfo8 *info8,
574                          uint32_t version);
575
576 /**
577  * @brief This function gets printer drivers list for the specified
578  *        architecture and type version
579  *
580  * @param[in]  mem_ctx         A talloc memory context.
581  *
582  * @param[in]  b The dcerpc binding handle
583  *
584  * @param[in]  architecture    The architecture type.
585  *
586  * @param[in]  version         The driver version.
587  *
588  * @param[out] num_drivers     The number of drivers.
589  *
590  * @param[out] version         The drivers names.
591  *
592  * @return              On success WERR_OK, a corresponding DOS error is
593  *                      something went wrong.
594  */
595
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);
602 /**
603  * @brief This function gets a core printer driver
604  *
605  * @param[in]  mem_ctx         A talloc memory context.
606  *
607  * @param[in]  b The dcerpc binding handle
608  *
609  * @param[in]  architecture    The architecture type.
610  *
611  * @param[in]  core_driver_guid The core driver guid.
612  *
613  * @param[out] core_printer_driver The returned core printer driver definiton
614  *
615  * @return              On success WERR_OK, a corresponding DOS error is
616  *                      something went wrong.
617  */
618
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);
624
625 /**
626  * @brief This function adds a core printer driver
627  *
628  * @param[in]  mem_ctx         A talloc memory context.
629  *
630  * @param[in]  b The dcerpc binding handle
631  *
632  * @param[in]  architecture    The architecture type.
633  *
634  * @param[in]  core_driver_driver The core driver.
635  *
636  * @return              On success WERR_OK, a corresponding DOS error is
637  *                      something went wrong.
638  */
639
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);
644
645 #endif /* _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_ */