s4 dns: Update prerequisite checking conforming to RFC
[mat/samba.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 Set the security descriptor for a printer.
150  *
151  * @param[in]  mem_ctx  The talloc memory context to use.
152  *
153  * @param[in]  b The dcerpc binding handle
154  *
155  * @param[in]  sharename  The share name.
156  *
157  * @param[in]  secdesc  The security descriptor to save.
158  *
159  * @return              On success WERR_OK, a corresponding DOS error is
160  *                      something went wrong.
161  */
162 WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
163                                   struct dcerpc_binding_handle *b,
164                                   const char *sharename,
165                                   const struct spoolss_security_descriptor *secdesc);
166
167 /**
168  * @internal
169  *
170  * @brief Set printer data over the winreg pipe.
171  *
172  * @param[in]  mem_ctx  The talloc memory context to use.
173  *
174  * @param[in]  b The dcerpc binding handle
175  *
176  * @param[in]  printer  The printer name.
177  *
178  * @param[in]  key      The key of the printer data to store the value.
179  *
180  * @param[in]  value    The value name to save.
181  *
182  * @param[in]  type     The type of the value to use.
183  *
184  * @param[in]  data     The data which sould be saved under the given value.
185  *
186  * @param[in]  data_size The size of the data.
187  *
188  * @return              On success WERR_OK, a corresponding DOS error is
189  *                      something went wrong.
190  */
191 WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
192                                  struct dcerpc_binding_handle *b,
193                                  const char *printer,
194                                  const char *key,
195                                  const char *value,
196                                  enum winreg_Type type,
197                                  uint8_t *data,
198                                  uint32_t data_size);
199
200 /**
201  * @internal
202  *
203  * @brief Get printer data over a winreg pipe.
204  *
205  * @param[in]  mem_ctx  The talloc memory context to use.
206  *
207  * @param[in]  b The dcerpc binding handle
208  *
209  * @param[in]  printer  The printer name.
210  *
211  * @param[in]  key      The key of the printer data to get the value.
212  *
213  * @param[in]  value    The name of the value to query.
214  *
215  * @param[in]  type     The type of the value to query.
216  *
217  * @param[out] data     A pointer to store the data.
218  *
219  * @param[out] data_size A pointer to store the size of the data.
220  *
221  * @return              On success WERR_OK, a corresponding DOS error is
222  *                      something went wrong.
223  */
224 WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
225                                  struct dcerpc_binding_handle *b,
226                                  const char *printer,
227                                  const char *key,
228                                  const char *value,
229                                  enum winreg_Type *type,
230                                  uint8_t **data,
231                                  uint32_t *data_size);
232
233 /**
234  * @internal
235  *
236  * @brief Enumerate on the values of a given key and provide the data.
237  *
238  * @param[in]  mem_ctx  The talloc memory context to use.
239  *
240  * @param[in]  b The dcerpc binding handle
241  *
242  * @param[in]  printer  The printer name.
243  *
244  * @param[in]  key      The key of the printer data to get the value.
245  *
246  * @param[out] pnum_values A pointer to store the number of values we found.
247  *
248  * @param[out] penum_values A pointer to store the values and its data.
249  *
250  * @return                   WERR_OK on success, the corresponding DOS error
251  *                           code if something gone wrong.
252  */
253 WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
254                                   struct dcerpc_binding_handle *b,
255                                   const char *printer,
256                                   const char *key,
257                                   uint32_t *pnum_values,
258                                   struct spoolss_PrinterEnumValues **penum_values);
259
260 /**
261  * @internal
262  *
263  * @brief Delete printer data over a winreg pipe.
264  *
265  * @param[in]  mem_ctx  The talloc memory context to use.
266  *
267  * @param[in]  b The dcerpc binding handle
268  *
269  * @param[in]  printer  The printer name.
270  *
271  * @param[in]  key      The key of the printer data to delete.
272  *
273  * @param[in]  value    The name of the value to delete.
274  *
275  * @return              On success WERR_OK, a corresponding DOS error is
276  *                      something went wrong.
277  */
278 WERROR winreg_delete_printer_dataex(TALLOC_CTX *mem_ctx,
279                                     struct dcerpc_binding_handle *b,
280                                     const char *printer,
281                                     const char *key,
282                                     const char *value);
283
284 /**
285  * @internal
286  *
287  * @brief Enumerate on the subkeys of a given key and provide the data.
288  *
289  * @param[in]  mem_ctx  The talloc memory context to use.
290  *
291  * @param[in]  b The dcerpc binding handle
292  *
293  * @param[in]  printer  The printer name.
294  *
295  * @param[in]  key      The key of the printer data to get the value.
296  *
297  * @param[out] pnum_subkeys A pointer to store the number of subkeys found.
298  *
299  * @param[in]  psubkeys A pointer to an array to store the names of the subkeys
300  *                      found.
301  *
302  * @return              WERR_OK on success, the corresponding DOS error
303  *                      code if something gone wrong.
304  */
305 WERROR winreg_enum_printer_key(TALLOC_CTX *mem_ctx,
306                                struct dcerpc_binding_handle *b,
307                                const char *printer,
308                                const char *key,
309                                uint32_t *pnum_subkeys,
310                                const char ***psubkeys);
311
312 /**
313  * @internal
314  *
315  * @brief Delete a key with subkeys of a given printer.
316  *
317  * @param[in]  mem_ctx  The talloc memory context to use.
318  *
319  * @param[in]  b The dcerpc binding handle
320  *
321  * @param[in]  printer  The printer name.
322  *
323  * @param[in]  key      The key of the printer to delete.
324  *
325  * @return              On success WERR_OK, a corresponding DOS error is
326  *                      something went wrong.
327  */
328 WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
329                                  struct dcerpc_binding_handle *b,
330                                  const char *printer,
331                                  const char *key);
332
333 /**
334  * @brief Update the ChangeID of a printer.
335  *
336  * The ChangeID **must** be increasing over the lifetime of client's spoolss
337  * service in order for the client's cache to show updates.
338  *
339  * If a form is updated of a printer, the we need to update the ChangeID of the
340  * pritner.
341  *
342  * @param[in]  mem_ctx  The talloc memory context to use.
343  *
344  * @param[in]  b The dcerpc binding handle
345  *
346  * @param[in]  printer  The printer name.
347  *
348  * @return              On success WERR_OK, a corresponding DOS error is
349  *                      something went wrong.
350  */
351 WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
352                                       struct dcerpc_binding_handle *b,
353                                       const char *printer);
354
355 /**
356  * @brief Get the ChangeID of the given printer.
357  *
358  * @param[in]  mem_ctx  The talloc memory context to use.
359  *
360  * @param[in]  b The dcerpc binding handle
361  *
362  * @param[in]  printer  The printer name.
363  *
364  * @param[in]  changeid A pointer to store the changeid.
365  *
366  * @return              On success WERR_OK, a corresponding DOS error is
367  *                      something went wrong.
368  */
369 WERROR winreg_printer_get_changeid(TALLOC_CTX *mem_ctx,
370                                    struct dcerpc_binding_handle *b,
371                                    const char *printer,
372                                    uint32_t *pchangeid);
373
374 /**
375  * @internal
376  *
377  * @brief This function adds a form to the list of available forms that can be
378  * selected for the specified printer.
379  *
380  * @param[in]  mem_ctx  The talloc memory context to use.
381  *
382  * @param[in]  b The dcerpc binding handle
383  *
384  * @param[in]  form     The form to add.
385  *
386  * @return              WERR_OK on success.
387  *                      WERR_ALREADY_EXISTS if the form already exists or is a
388  *                                          builtin form.
389  *                      A corresponding DOS error is something went wrong.
390  */
391 WERROR winreg_printer_addform1(TALLOC_CTX *mem_ctx,
392                                struct dcerpc_binding_handle *b,
393                                struct spoolss_AddFormInfo1 *form);
394
395 /*
396  * @brief This function enumerates the forms supported by the specified printer.
397  *
398  * @param[in]  mem_ctx  The talloc memory context to use.
399  *
400  * @param[in]  b The dcerpc binding handle
401  *
402  * @param[out] pnum_info A pointer to store the FormInfo count.
403  *
404  * @param[out] pinfo     A pointer to store an array with FormInfo.
405  *
406  * @return              On success WERR_OK, a corresponding DOS error is
407  *                      something went wrong.
408  */
409 WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
410                                  struct dcerpc_binding_handle *b,
411                                  uint32_t *pnum_info,
412                                  union spoolss_FormInfo **pinfo);
413
414 /**
415  * @brief This function removes a form name from the list of supported forms.
416  *
417  * @param[in]  mem_ctx  The talloc memory context to use.
418  *
419  * @param[in]  b The dcerpc binding handle
420  *
421  * @param[in]  form_name The name of the form to delete.
422  *
423  * @return              WERR_OK on success.
424  *                      WERR_INVALID_PARAM if the form is a builtin form.
425  *                      WERR_INVALID_FORM_NAME if the form or key doesn't exist.
426  *                      A corresponding DOS error is something went wrong.
427  */
428 WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
429                                   struct dcerpc_binding_handle *b,
430                                   const char *form_name);
431
432 /**
433  * @brief This function sets the form information for the specified printer.
434  *
435  * If one provides both the name in the API call and inside the FormInfo
436  * structure, then the form gets renamed.
437  *
438  * @param[in]  mem_ctx  The talloc memory context to use.
439  *
440  * @param[in]  b The dcerpc binding handle
441  *
442  * @param[in]  form_name The name of the form to set or rename.
443  *
444  * @param[in]  form     The FormInfo structure to save.
445  *
446  * @return              WERR_OK on success.
447  *                      WERR_INVALID_PARAM if the form is a builtin form.
448  *                      A corresponding DOS error is something went wrong.
449  */
450 WERROR winreg_printer_setform1(TALLOC_CTX *mem_ctx,
451                                struct dcerpc_binding_handle *b,
452                                const char *form_name,
453                                struct spoolss_AddFormInfo1 *form);
454
455 /**
456  * @brief This function retrieves information about a specified form.
457  *
458  * @param[in]  mem_ctx  The talloc memory context to use.
459  *
460  * @param[in]  b The dcerpc binding handle
461  *
462  * @param[in]  form_name The name of the form to query.
463  *
464  * @param[out] form     A pointer to a form structure to fill out.
465  *
466  * @return              On success WERR_OK, a corresponding DOS error is
467  *                      something went wrong.
468  */
469 WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
470                                struct dcerpc_binding_handle *b,
471                                const char *form_name,
472                                struct spoolss_FormInfo1 *form);
473
474 /**
475  * @brief This function adds a new spool driver
476  *
477  * @param[in]  mem_ctx         A talloc memory context.
478  *
479  * @param[in]  b The dcerpc binding handle
480  *
481  * @param[in]  r               The structure containing the new driver data.
482  *
483  * @param[out] driver_name     Returns the driver name.
484  *
485  * @param[out] driver_version  Returns the driver version.
486  *
487  * @return              On success WERR_OK, a corresponding DOS error is
488  *                      something went wrong.
489  */
490 WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
491                          struct dcerpc_binding_handle *b,
492                          struct spoolss_AddDriverInfoCtr *r,
493                          const char **driver_name,
494                          uint32_t *driver_version);
495
496 /**
497  * @brief This function gets printer driver information
498  *
499  * @param[in]  mem_ctx         A talloc memory context.
500  *
501  * @param[in]  b The dcerpc binding handle
502  *
503  * @param[in]  architecture    The architecture type.
504  *
505  * @param[in]  driver_name     The driver name.
506  *
507  * @param[in]  driver_version  The driver version.
508  *
509  * @param[out] _info8   The structure that holds the full driver information.
510  *
511  * @return              On success WERR_OK, a corresponding DOS error is
512  *                      something went wrong.
513  */
514
515 WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
516                          struct dcerpc_binding_handle *b,
517                          const char *architecture,
518                          const char *driver_name,
519                          uint32_t driver_version,
520                          struct spoolss_DriverInfo8 **_info8);
521
522 /**
523  * @brief This function deletes a printer driver information
524  *
525  * @param[in]  mem_ctx         A talloc memory context.
526  *
527  * @param[in]  b The dcerpc binding handle
528  *
529  * @param[out] info8    The structure that holds the full driver information.
530  *
531  * @param[in]  version  The driver type version.
532  *
533  * @return              On success WERR_OK, a corresponding DOS error is
534  *                      something went wrong.
535  */
536
537 WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
538                          struct dcerpc_binding_handle *b,
539                          struct spoolss_DriverInfo8 *info8,
540                          uint32_t version);
541
542 /**
543  * @brief This function gets printer drivers list for the specified
544  *        architecture and type version
545  *
546  * @param[in]  mem_ctx         A talloc memory context.
547  *
548  * @param[in]  b The dcerpc binding handle
549  *
550  * @param[in]  architecture    The architecture type.
551  *
552  * @param[in]  version         The driver version.
553  *
554  * @param[out] num_drivers     The number of drivers.
555  *
556  * @param[out] version         The drivers names.
557  *
558  * @return              On success WERR_OK, a corresponding DOS error is
559  *                      something went wrong.
560  */
561
562 WERROR winreg_get_driver_list(TALLOC_CTX *mem_ctx,
563                               struct dcerpc_binding_handle *b,
564                               const char *architecture,
565                               uint32_t version,
566                               uint32_t *num_drivers,
567                               const char ***drivers);
568
569 #endif /* _RPC_CLIENT_CLI_WINREG_SPOOLSS_H_ */