[GLUE] Rsync SAMBA_3_0 SVN r25598 in order to create the v3-0-test branch.
[Samba.git] / source / rpc_parse / parse_shutdown.c
blobda3380773337b4576d057d657557dafeb5f8a898
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
5 * Copyright (C) Gerald (Jerry) Carter 2002-2005.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
24 #undef DBGC_CLASS
25 #define DBGC_CLASS DBGC_RPC_PARSE
27 /*******************************************************************
28 Inits a structure.
29 ********************************************************************/
31 void init_shutdown_q_init(SHUTDOWN_Q_INIT *q_s, const char *msg,
32 uint32 timeout, BOOL do_reboot, BOOL force)
34 q_s->server = TALLOC_P( get_talloc_ctx(), uint16 );
35 if (!q_s->server) {
36 smb_panic("init_shutdown_q_init: talloc fail.\n");
37 return;
40 *q_s->server = 0x1;
42 q_s->message = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 );
43 if (!q_s->message) {
44 smb_panic("init_shutdown_q_init: talloc fail.\n");
45 return;
48 if ( msg && *msg ) {
49 init_unistr4( q_s->message, msg, UNI_FLAGS_NONE );
51 /* Win2000 is apparently very sensitive to these lengths */
52 /* do a special case here */
54 q_s->message->string->uni_max_len++;
55 q_s->message->size += 2;
58 q_s->timeout = timeout;
60 q_s->reboot = do_reboot ? 1 : 0;
61 q_s->force = force ? 1 : 0;
64 /*******************************************************************
65 ********************************************************************/
67 void init_shutdown_q_init_ex(SHUTDOWN_Q_INIT_EX * q_u_ex, const char *msg,
68 uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason)
70 SHUTDOWN_Q_INIT q_u;
72 ZERO_STRUCT( q_u );
74 init_shutdown_q_init( &q_u, msg, timeout, do_reboot, force );
76 /* steal memory */
78 q_u_ex->server = q_u.server;
79 q_u_ex->message = q_u.message;
81 q_u_ex->reboot = q_u.reboot;
82 q_u_ex->force = q_u.force;
84 q_u_ex->reason = reason;
87 /*******************************************************************
88 reads or writes a structure.
89 ********************************************************************/
91 BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps,
92 int depth)
94 if (q_s == NULL)
95 return False;
97 prs_debug(ps, depth, desc, "shutdown_io_q_init");
98 depth++;
100 if (!prs_align(ps))
101 return False;
103 if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
104 return False;
105 if (!prs_align(ps))
106 return False;
108 if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
109 return False;
111 if (!prs_align(ps))
112 return False;
114 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
115 return False;
117 if (!prs_uint8("force ", ps, depth, &(q_s->force)))
118 return False;
119 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
120 return False;
122 return True;
125 /*******************************************************************
126 reads or writes a structure.
127 ********************************************************************/
128 BOOL shutdown_io_r_init(const char *desc, SHUTDOWN_R_INIT* r_s, prs_struct *ps,
129 int depth)
131 if (r_s == NULL)
132 return False;
134 prs_debug(ps, depth, desc, "shutdown_io_r_init");
135 depth++;
137 if(!prs_align(ps))
138 return False;
140 if(!prs_werror("status", ps, depth, &r_s->status))
141 return False;
143 return True;
146 /*******************************************************************
147 reads or writes a REG_Q_SHUTDOWN_EX structure.
148 ********************************************************************/
150 BOOL shutdown_io_q_init_ex(const char *desc, SHUTDOWN_Q_INIT_EX * q_s, prs_struct *ps,
151 int depth)
153 if (q_s == NULL)
154 return False;
156 prs_debug(ps, depth, desc, "shutdown_io_q_init_ex");
157 depth++;
159 if (!prs_align(ps))
160 return False;
162 if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
163 return False;
164 if (!prs_align(ps))
165 return False;
167 if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
168 return False;
170 if (!prs_align(ps))
171 return False;
173 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
174 return False;
176 if (!prs_uint8("force ", ps, depth, &(q_s->force)))
177 return False;
178 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
179 return False;
181 if (!prs_align(ps))
182 return False;
183 if (!prs_uint32("reason", ps, depth, &(q_s->reason)))
184 return False;
187 return True;
190 /*******************************************************************
191 reads or writes a REG_R_SHUTDOWN_EX structure.
192 ********************************************************************/
193 BOOL shutdown_io_r_init_ex(const char *desc, SHUTDOWN_R_INIT_EX * r_s, prs_struct *ps,
194 int depth)
196 if (r_s == NULL)
197 return False;
199 prs_debug(ps, depth, desc, "shutdown_io_r_init_ex");
200 depth++;
202 if(!prs_align(ps))
203 return False;
205 if(!prs_werror("status", ps, depth, &r_s->status))
206 return False;
208 return True;
212 /*******************************************************************
213 Inits a structure.
214 ********************************************************************/
215 void init_shutdown_q_abort(SHUTDOWN_Q_ABORT *q_s)
217 q_s->server = TALLOC_P( get_talloc_ctx(), uint16 );
218 if (!q_s->server) {
219 smb_panic("init_shutdown_q_abort: talloc fail.\n");
220 return;
223 *q_s->server = 0x1;
226 /*******************************************************************
227 reads or writes a structure.
228 ********************************************************************/
229 BOOL shutdown_io_q_abort(const char *desc, SHUTDOWN_Q_ABORT *q_s,
230 prs_struct *ps, int depth)
232 if (q_s == NULL)
233 return False;
235 prs_debug(ps, depth, desc, "shutdown_io_q_abort");
236 depth++;
238 if (!prs_align(ps))
239 return False;
241 if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
242 return False;
243 if (!prs_align(ps))
244 return False;
246 return True;
249 /*******************************************************************
250 reads or writes a structure.
251 ********************************************************************/
252 BOOL shutdown_io_r_abort(const char *desc, SHUTDOWN_R_ABORT *r_s,
253 prs_struct *ps, int depth)
255 if (r_s == NULL)
256 return False;
258 prs_debug(ps, depth, desc, "shutdown_io_r_abort");
259 depth++;
261 if (!prs_align(ps))
262 return False;
264 if (!prs_werror("status", ps, depth, &r_s->status))
265 return False;
267 return True;