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