Clean up a comment noticed by Jonathan Shao@Panasas.com and remove an
[Samba/gebeck_regimport.git] / source3 / rpc_client / cli_spoolss_notify.c
blobf4eda332bb10a09d52d88f03a15e6a1828577d19
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) Gerald Carter 2001-2002,
6 Copyright (C) Tim Potter 2000-2002,
7 Copyright (C) Andrew Tridgell 1994-2000,
8 Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
9 Copyright (C) Jean-Francois Micouleau 1999-2000.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "includes.h"
29 * SPOOLSS Client RPC's used by servers as the notification
30 * back channel.
33 /* Send a ReplyOpenPrinter request. This rpc is made by the printer
34 server to the printer client in response to a rffpcnex request.
35 The rrfpcnex request names a printer and a handle (the printerlocal
36 value) and this rpc establishes a back-channel over which printer
37 notifications are performed. */
39 WERROR cli_spoolss_reply_open_printer(struct cli_state *cli, TALLOC_CTX *mem_ctx,
40 const char *printer, uint32 printerlocal, uint32 type,
41 POLICY_HND *handle)
43 prs_struct qbuf, rbuf;
44 SPOOL_Q_REPLYOPENPRINTER q;
45 SPOOL_R_REPLYOPENPRINTER r;
46 WERROR result = W_ERROR(ERRgeneral);
48 /* Initialise input parameters */
50 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
51 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
53 make_spoolss_q_replyopenprinter(&q, printer, printerlocal, type);
55 /* Marshall data and send request */
57 if (!spoolss_io_q_replyopenprinter("", &q, &qbuf, 0) ||
58 !rpc_api_pipe_req (cli, SPOOLSS_REPLYOPENPRINTER, &qbuf, &rbuf))
59 goto done;
61 /* Unmarshall response */
63 if (!spoolss_io_r_replyopenprinter("", &r, &rbuf, 0))
64 goto done;
66 /* Return result */
68 memcpy(handle, &r.handle, sizeof(r.handle));
69 result = r.status;
71 done:
72 prs_mem_free(&qbuf);
73 prs_mem_free(&rbuf);
75 return result;
78 /* Close a back-channel notification connection */
80 WERROR cli_spoolss_reply_close_printer(struct cli_state *cli, TALLOC_CTX *mem_ctx,
81 POLICY_HND *handle)
83 prs_struct qbuf, rbuf;
84 SPOOL_Q_REPLYCLOSEPRINTER q;
85 SPOOL_R_REPLYCLOSEPRINTER r;
86 WERROR result = W_ERROR(ERRgeneral);
88 /* Initialise input parameters */
90 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
91 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
93 make_spoolss_q_reply_closeprinter(&q, handle);
95 /* Marshall data and send request */
97 if (!spoolss_io_q_replycloseprinter("", &q, &qbuf, 0) ||
98 !rpc_api_pipe_req (cli, SPOOLSS_REPLYCLOSEPRINTER, &qbuf, &rbuf))
99 goto done;
101 /* Unmarshall response */
103 if (!spoolss_io_r_replycloseprinter("", &r, &rbuf, 0))
104 goto done;
106 /* Return result */
108 result = r.status;
110 done:
111 prs_mem_free(&qbuf);
112 prs_mem_free(&rbuf);
114 return result;
117 /*********************************************************************
118 This SPOOLSS_ROUTERREPLYPRINTER function is used to send a change
119 notification event when the registration **did not** use
120 SPOOL_NOTIFY_OPTION_TYPE structure to specify the events to monitor.
121 Also see cli_spolss_reply_rrpcn()
122 *********************************************************************/
124 WERROR cli_spoolss_routerreplyprinter(struct cli_state *cli, TALLOC_CTX *mem_ctx,
125 POLICY_HND *pol, uint32 condition, uint32 change_id)
127 prs_struct qbuf, rbuf;
128 SPOOL_Q_ROUTERREPLYPRINTER q;
129 SPOOL_R_ROUTERREPLYPRINTER r;
130 WERROR result = W_ERROR(ERRgeneral);
132 /* Initialise input parameters */
134 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
135 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
137 make_spoolss_q_routerreplyprinter(&q, pol, condition, change_id);
139 /* Marshall data and send request */
141 if (!spoolss_io_q_routerreplyprinter("", &q, &qbuf, 0) ||
142 !rpc_api_pipe_req (cli, SPOOLSS_ROUTERREPLYPRINTER, &qbuf, &rbuf))
143 goto done;
145 /* Unmarshall response */
147 if (!spoolss_io_r_routerreplyprinter("", &r, &rbuf, 0))
148 goto done;
150 /* Return output parameters */
152 result = r.status;
154 done:
155 prs_mem_free(&qbuf);
156 prs_mem_free(&rbuf);
158 return result;
161 /*********************************************************************
162 This SPOOLSS_REPLY_RRPCN function is used to send a change
163 notification event when the registration **did** use
164 SPOOL_NOTIFY_OPTION_TYPE structure to specify the events to monitor
165 Also see cli_spoolss_routereplyprinter()
166 *********************************************************************/
168 WERROR cli_spoolss_rrpcn(struct cli_state *cli, TALLOC_CTX *mem_ctx,
169 POLICY_HND *pol, uint32 notify_data_len,
170 SPOOL_NOTIFY_INFO_DATA *notify_data,
171 uint32 change_low, uint32 change_high)
173 prs_struct qbuf, rbuf;
174 SPOOL_Q_REPLY_RRPCN q;
175 SPOOL_R_REPLY_RRPCN r;
176 WERROR result = W_ERROR(ERRgeneral);
177 SPOOL_NOTIFY_INFO notify_info;
179 ZERO_STRUCT(q);
180 ZERO_STRUCT(r);
182 /* Initialise parse structures */
184 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
185 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
187 ZERO_STRUCT(notify_info);
189 /* Initialise input parameters */
191 notify_info.version = 0x2;
192 notify_info.flags = 0x00020000; /* ?? */
193 notify_info.count = notify_data_len;
194 notify_info.data = notify_data;
196 /* create and send a MSRPC command with api */
197 /* store the parameters */
199 make_spoolss_q_reply_rrpcn(&q, pol, change_low, change_high,
200 &notify_info);
202 /* Marshall data and send request */
204 if(!spoolss_io_q_reply_rrpcn("", &q, &qbuf, 0) ||
205 !rpc_api_pipe_req(cli, SPOOLSS_RRPCN, &qbuf, &rbuf))
206 goto done;
208 /* Unmarshall response */
210 if(!spoolss_io_r_reply_rrpcn("", &r, &rbuf, 0))
211 goto done;
213 if (r.unknown0 == 0x00080000)
214 DEBUG(8,("cli_spoolss_reply_rrpcn: I think the spooler resonded that the notification was ignored.\n"));
215 else if ( r.unknown0 != 0x0 )
216 DEBUG(8,("cli_spoolss_reply_rrpcn: unknown0 is non-zero [0x%x]\n", r.unknown0));
218 result = r.status;
220 done:
221 prs_mem_free(&qbuf);
222 prs_mem_free(&rbuf);
224 return result;
227 /*********************************************************************
228 *********************************************************************/
230 WERROR cli_spoolss_rffpcnex(struct cli_state *cli, TALLOC_CTX *mem_ctx,
231 POLICY_HND *pol, uint32 flags, uint32 options,
232 const char *localmachine, uint32 printerlocal,
233 SPOOL_NOTIFY_OPTION *option)
235 prs_struct qbuf, rbuf;
236 SPOOL_Q_RFFPCNEX q;
237 SPOOL_R_RFFPCNEX r;
238 WERROR result = W_ERROR(ERRgeneral);
240 ZERO_STRUCT(q);
241 ZERO_STRUCT(r);
243 /* Initialise parse structures */
245 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
246 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
248 /* Initialise input parameters */
250 make_spoolss_q_rffpcnex(
251 &q, pol, flags, options, localmachine, printerlocal,
252 option);
254 /* Marshall data and send request */
256 if(!spoolss_io_q_rffpcnex("", &q, &qbuf, 0) ||
257 !rpc_api_pipe_req(cli, SPOOLSS_RFFPCNEX, &qbuf, &rbuf))
258 goto done;
260 /* Unmarshall response */
262 if(!spoolss_io_r_rffpcnex("", &r, &rbuf, 0))
263 goto done;
265 result = r.status;
267 done:
268 prs_mem_free(&qbuf);
269 prs_mem_free(&rbuf);
271 return result;