Fairly large change to printing code.
[Samba.git] / source / rpc_server / srv_reg.c
blobd0aaf0199bd8e3280f293639c412b73a70b4633a
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6 * Copyright (C) Paul Ashton 1997.
7 * Copyright (C) Marc Jacobsen 2000.
8 * Copyright (C) Jeremy Allison 2001.
9 * Copyright (C) Gerald Carter 2002.
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 /* This is the interface for the registry functions. */
28 #include "includes.h"
30 #undef DBGC_CLASS
31 #define DBGC_CLASS DBGC_RPC_SRV
33 /*******************************************************************
34 api_reg_close
35 ********************************************************************/
37 static BOOL api_reg_close(pipes_struct *p)
39 REG_Q_CLOSE q_u;
40 REG_R_CLOSE r_u;
41 prs_struct *data = &p->in_data.data;
42 prs_struct *rdata = &p->out_data.rdata;
44 ZERO_STRUCT(q_u);
45 ZERO_STRUCT(r_u);
47 /* grab the reg unknown 1 */
48 if(!reg_io_q_close("", &q_u, data, 0))
49 return False;
51 r_u.status = _reg_close(p, &q_u, &r_u);
53 if(!reg_io_r_close("", &r_u, rdata, 0))
54 return False;
56 return True;
59 /*******************************************************************
60 api_reg_open_khlm
61 ********************************************************************/
63 static BOOL api_reg_open_hklm(pipes_struct *p)
65 REG_Q_OPEN_HKLM q_u;
66 REG_R_OPEN_HKLM r_u;
67 prs_struct *data = &p->in_data.data;
68 prs_struct *rdata = &p->out_data.rdata;
70 ZERO_STRUCT(q_u);
71 ZERO_STRUCT(r_u);
73 /* grab the reg open */
74 if(!reg_io_q_open_hklm("", &q_u, data, 0))
75 return False;
77 r_u.status = _reg_open_hklm(p, &q_u, &r_u);
79 if(!reg_io_r_open_hklm("", &r_u, rdata, 0))
80 return False;
82 return True;
85 /*******************************************************************
86 api_reg_open_khu
87 ********************************************************************/
89 static BOOL api_reg_open_hku(pipes_struct *p)
91 REG_Q_OPEN_HKU q_u;
92 REG_R_OPEN_HKU r_u;
93 prs_struct *data = &p->in_data.data;
94 prs_struct *rdata = &p->out_data.rdata;
96 ZERO_STRUCT(q_u);
97 ZERO_STRUCT(r_u);
99 /* grab the reg open */
100 if(!reg_io_q_open_hku("", &q_u, data, 0))
101 return False;
103 r_u.status = _reg_open_hku(p, &q_u, &r_u);
105 if(!reg_io_r_open_hku("", &r_u, rdata, 0))
106 return False;
108 return True;
111 /*******************************************************************
112 api_reg_open_khcr
113 ********************************************************************/
115 static BOOL api_reg_open_hkcr(pipes_struct *p)
117 REG_Q_OPEN_HKCR q_u;
118 REG_R_OPEN_HKCR r_u;
119 prs_struct *data = &p->in_data.data;
120 prs_struct *rdata = &p->out_data.rdata;
122 ZERO_STRUCT(q_u);
123 ZERO_STRUCT(r_u);
125 /* grab the reg open */
126 if(!reg_io_q_open_hkcr("", &q_u, data, 0))
127 return False;
129 r_u.status = _reg_open_hkcr(p, &q_u, &r_u);
131 if(!reg_io_r_open_hkcr("", &r_u, rdata, 0))
132 return False;
134 return True;
138 /*******************************************************************
139 api_reg_open_entry
140 ********************************************************************/
142 static BOOL api_reg_open_entry(pipes_struct *p)
144 REG_Q_OPEN_ENTRY q_u;
145 REG_R_OPEN_ENTRY r_u;
146 prs_struct *data = &p->in_data.data;
147 prs_struct *rdata = &p->out_data.rdata;
149 ZERO_STRUCT(q_u);
150 ZERO_STRUCT(r_u);
152 /* grab the reg open entry */
153 if(!reg_io_q_open_entry("", &q_u, data, 0))
154 return False;
156 /* construct reply. */
157 r_u.status = _reg_open_entry(p, &q_u, &r_u);
159 if(!reg_io_r_open_entry("", &r_u, rdata, 0))
160 return False;
162 return True;
165 /*******************************************************************
166 api_reg_info
167 ********************************************************************/
169 static BOOL api_reg_info(pipes_struct *p)
171 REG_Q_INFO q_u;
172 REG_R_INFO r_u;
173 prs_struct *data = &p->in_data.data;
174 prs_struct *rdata = &p->out_data.rdata;
176 ZERO_STRUCT(q_u);
177 ZERO_STRUCT(r_u);
179 /* grab the reg unknown 0x11*/
180 if(!reg_io_q_info("", &q_u, data, 0))
181 return False;
183 r_u.status = _reg_info(p, &q_u, &r_u);
185 if(!reg_io_r_info("", &r_u, rdata, 0))
186 return False;
188 return True;
191 /*******************************************************************
192 api_reg_shutdown
193 ********************************************************************/
195 static BOOL api_reg_shutdown(pipes_struct *p)
197 REG_Q_SHUTDOWN q_u;
198 REG_R_SHUTDOWN r_u;
199 prs_struct *data = &p->in_data.data;
200 prs_struct *rdata = &p->out_data.rdata;
202 ZERO_STRUCT(q_u);
203 ZERO_STRUCT(r_u);
205 /* grab the reg shutdown */
206 if(!reg_io_q_shutdown("", &q_u, data, 0))
207 return False;
209 r_u.status = _reg_shutdown(p, &q_u, &r_u);
211 if(!reg_io_r_shutdown("", &r_u, rdata, 0))
212 return False;
214 return True;
217 /*******************************************************************
218 api_reg_abort_shutdown
219 ********************************************************************/
221 static BOOL api_reg_abort_shutdown(pipes_struct *p)
223 REG_Q_ABORT_SHUTDOWN q_u;
224 REG_R_ABORT_SHUTDOWN r_u;
225 prs_struct *data = &p->in_data.data;
226 prs_struct *rdata = &p->out_data.rdata;
228 ZERO_STRUCT(q_u);
229 ZERO_STRUCT(r_u);
231 /* grab the reg shutdown */
232 if(!reg_io_q_abort_shutdown("", &q_u, data, 0))
233 return False;
235 r_u.status = _reg_abort_shutdown(p, &q_u, &r_u);
237 if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0))
238 return False;
240 return True;
244 /*******************************************************************
245 api_reg_query_key
246 ********************************************************************/
248 static BOOL api_reg_query_key(pipes_struct *p)
250 REG_Q_QUERY_KEY q_u;
251 REG_R_QUERY_KEY r_u;
252 prs_struct *data = &p->in_data.data;
253 prs_struct *rdata = &p->out_data.rdata;
255 ZERO_STRUCT(q_u);
256 ZERO_STRUCT(r_u);
258 if(!reg_io_q_query_key("", &q_u, data, 0))
259 return False;
261 r_u.status = _reg_query_key(p, &q_u, &r_u);
263 if(!reg_io_r_query_key("", &r_u, rdata, 0))
264 return False;
266 return True;
269 /*******************************************************************
270 api_reg_unknown_1a
271 ********************************************************************/
273 static BOOL api_reg_unknown_1a(pipes_struct *p)
275 REG_Q_UNKNOWN_1A q_u;
276 REG_R_UNKNOWN_1A r_u;
277 prs_struct *data = &p->in_data.data;
278 prs_struct *rdata = &p->out_data.rdata;
280 ZERO_STRUCT(q_u);
281 ZERO_STRUCT(r_u);
283 if(!reg_io_q_unknown_1a("", &q_u, data, 0))
284 return False;
286 r_u.status = _reg_unknown_1a(p, &q_u, &r_u);
288 if(!reg_io_r_unknown_1a("", &r_u, rdata, 0))
289 return False;
291 return True;
294 /*******************************************************************
295 api_reg_enum_key
296 ********************************************************************/
298 static BOOL api_reg_enum_key(pipes_struct *p)
300 REG_Q_ENUM_KEY q_u;
301 REG_R_ENUM_KEY r_u;
302 prs_struct *data = &p->in_data.data;
303 prs_struct *rdata = &p->out_data.rdata;
305 ZERO_STRUCT(q_u);
306 ZERO_STRUCT(r_u);
308 if(!reg_io_q_enum_key("", &q_u, data, 0))
309 return False;
311 r_u.status = _reg_enum_key(p, &q_u, &r_u);
313 if(!reg_io_r_enum_key("", &r_u, rdata, 0))
314 return False;
316 return True;
319 /*******************************************************************
320 api_reg_enum_value
321 ********************************************************************/
323 static BOOL api_reg_enum_value(pipes_struct *p)
325 REG_Q_ENUM_VALUE q_u;
326 REG_R_ENUM_VALUE r_u;
327 prs_struct *data = &p->in_data.data;
328 prs_struct *rdata = &p->out_data.rdata;
330 ZERO_STRUCT(q_u);
331 ZERO_STRUCT(r_u);
333 if(!reg_io_q_enum_val("", &q_u, data, 0))
334 return False;
336 r_u.status = _reg_enum_value(p, &q_u, &r_u);
338 if(!reg_io_r_enum_val("", &r_u, rdata, 0))
339 return False;
341 return True;
344 /*******************************************************************
345 api_reg_save_key
346 ********************************************************************/
348 static BOOL api_reg_save_key(pipes_struct *p)
350 REG_Q_SAVE_KEY q_u;
351 REG_R_SAVE_KEY r_u;
352 prs_struct *data = &p->in_data.data;
353 prs_struct *rdata = &p->out_data.rdata;
355 ZERO_STRUCT(q_u);
356 ZERO_STRUCT(r_u);
358 if(!reg_io_q_save_key("", &q_u, data, 0))
359 return False;
361 r_u.status = _reg_save_key(p, &q_u, &r_u);
363 if(!reg_io_r_save_key("", &r_u, rdata, 0))
364 return False;
366 return True;
371 /*******************************************************************
372 array of \PIPE\reg operations
373 ********************************************************************/
374 static struct api_struct api_reg_cmds[] =
376 { "REG_CLOSE" , REG_CLOSE , api_reg_close },
377 { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry },
378 { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr },
379 { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm },
380 { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku },
381 { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key },
382 { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value },
383 { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key },
384 { "REG_INFO" , REG_INFO , api_reg_info },
385 { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown },
386 { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown },
387 { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a },
388 { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key },
389 { NULL , 0 , NULL }
392 /*******************************************************************
393 receives a reg pipe and responds.
394 ********************************************************************/
396 BOOL api_reg_rpc(pipes_struct *p)
398 return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds);