2 Unix SMB/CIFS implementation.
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.
29 * SPOOLSS Client RPC's used by servers as the notification
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 char *printer
, uint32 printerlocal
, uint32 type
,
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
))
61 /* Unmarshall response */
63 if (!spoolss_io_r_replyopenprinter("", &r
, &rbuf
, 0))
68 memcpy(handle
, &r
.handle
, sizeof(r
.handle
));
78 /* Close a back-channel notification connection */
80 WERROR
cli_spoolss_reply_close_printer(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
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
))
101 /* Unmarshall response */
103 if (!spoolss_io_r_replycloseprinter("", &r
, &rbuf
, 0))
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
))
145 /* Unmarshall response */
147 if (!spoolss_io_r_routerreplyprinter("", &r
, &rbuf
, 0))
150 /* Return output parameters */
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
;
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
,
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
))
208 /* Unmarshall response */
210 if(!spoolss_io_r_reply_rrpcn("", &r
, &rbuf
, 0))
213 if (r
.unknown0
== 0x00080000)
214 DEBUG(8,("cli_spoolss_reply_rrpcn: I think the spooler resonded that the notification was ignored.\n"));
225 /*********************************************************************
226 *********************************************************************/
228 WERROR
cli_spoolss_rffpcnex(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
229 POLICY_HND
*pol
, uint32 flags
, uint32 options
,
230 char *localmachine
, uint32 printerlocal
,
231 SPOOL_NOTIFY_OPTION
*option
)
233 prs_struct qbuf
, rbuf
;
236 WERROR result
= W_ERROR(ERRgeneral
);
241 /* Initialise parse structures */
243 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
244 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
246 /* Initialise input parameters */
248 make_spoolss_q_rffpcnex(
249 &q
, pol
, flags
, options
, localmachine
, printerlocal
,
252 /* Marshall data and send request */
254 if(!spoolss_io_q_rffpcnex("", &q
, &qbuf
, 0) ||
255 !rpc_api_pipe_req(cli
, SPOOLSS_RFFPCNEX
, &qbuf
, &rbuf
))
258 /* Unmarshall response */
260 if(!spoolss_io_r_rffpcnex("", &r
, &rbuf
, 0))