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