r10391: * setting version to 3.0.20a
[Samba.git] / source / rpc_parse / parse_shutdown.c
blob62c23a243c63d4cf45b49be34c98ed8ac884708f
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 *q_s->server = 0x1;
37 if ( msg && *msg ) {
38 q_s->message = TALLOC_P( get_talloc_ctx(), UNISTR4 );
39 init_unistr4( q_s->message, msg, UNI_FLAGS_NONE );
41 /* Win2000 is apparently very sensitive to these lengths */
42 /* do a special case here */
44 q_s->message->string->uni_max_len++;
45 q_s->message->size += 2;
48 q_s->timeout = timeout;
50 q_s->reboot = do_reboot ? 1 : 0;
51 q_s->force = force ? 1 : 0;
54 /*******************************************************************
55 ********************************************************************/
57 void init_shutdown_q_init_ex(SHUTDOWN_Q_INIT_EX * q_u_ex, const char *msg,
58 uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason)
60 SHUTDOWN_Q_INIT q_u;
62 ZERO_STRUCT( q_u );
64 init_shutdown_q_init( &q_u, msg, timeout, do_reboot, force );
66 /* steal memory */
68 q_u_ex->server = q_u.server;
69 q_u_ex->message = q_u.message;
71 q_u_ex->reboot = q_u.reboot;
72 q_u_ex->force = q_u.force;
74 q_u_ex->reason = reason;
77 /*******************************************************************
78 reads or writes a structure.
79 ********************************************************************/
81 BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps,
82 int depth)
84 if (q_s == NULL)
85 return False;
87 prs_debug(ps, depth, desc, "shutdown_io_q_init");
88 depth++;
90 if (!prs_align(ps))
91 return False;
93 if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
94 return False;
95 if (!prs_align(ps))
96 return False;
98 if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
99 return False;
101 if (!prs_align(ps))
102 return False;
104 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
105 return False;
107 if (!prs_uint8("force ", ps, depth, &(q_s->force)))
108 return False;
109 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
110 return False;
113 return True;
116 /*******************************************************************
117 reads or writes a structure.
118 ********************************************************************/
119 BOOL shutdown_io_r_init(const char *desc, SHUTDOWN_R_INIT* r_s, prs_struct *ps,
120 int depth)
122 if (r_s == NULL)
123 return False;
125 prs_debug(ps, depth, desc, "shutdown_io_r_init");
126 depth++;
128 if(!prs_align(ps))
129 return False;
131 if(!prs_werror("status", ps, depth, &r_s->status))
132 return False;
134 return True;
137 /*******************************************************************
138 reads or writes a REG_Q_SHUTDOWN_EX structure.
139 ********************************************************************/
141 BOOL shutdown_io_q_init_ex(const char *desc, SHUTDOWN_Q_INIT_EX * q_s, prs_struct *ps,
142 int depth)
144 if (q_s == NULL)
145 return False;
147 prs_debug(ps, depth, desc, "shutdown_io_q_init_ex");
148 depth++;
150 if (!prs_align(ps))
151 return False;
153 if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
154 return False;
155 if (!prs_align(ps))
156 return False;
158 if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
159 return False;
161 if (!prs_align(ps))
162 return False;
164 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
165 return False;
167 if (!prs_uint8("force ", ps, depth, &(q_s->force)))
168 return False;
169 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
170 return False;
172 if (!prs_align(ps))
173 return False;
174 if (!prs_uint32("reason", ps, depth, &(q_s->reason)))
175 return False;
178 return True;
181 /*******************************************************************
182 reads or writes a REG_R_SHUTDOWN_EX structure.
183 ********************************************************************/
184 BOOL shutdown_io_r_init_ex(const char *desc, SHUTDOWN_R_INIT_EX * r_s, prs_struct *ps,
185 int depth)
187 if (r_s == NULL)
188 return False;
190 prs_debug(ps, depth, desc, "shutdown_io_r_init_ex");
191 depth++;
193 if(!prs_align(ps))
194 return False;
196 if(!prs_werror("status", ps, depth, &r_s->status))
197 return False;
199 return True;
203 /*******************************************************************
204 Inits a structure.
205 ********************************************************************/
206 void init_shutdown_q_abort(SHUTDOWN_Q_ABORT *q_s)
208 q_s->server = TALLOC_P( get_talloc_ctx(), uint16 );
209 *q_s->server = 0x1;
212 /*******************************************************************
213 reads or writes a structure.
214 ********************************************************************/
215 BOOL shutdown_io_q_abort(const char *desc, SHUTDOWN_Q_ABORT *q_s,
216 prs_struct *ps, int depth)
218 if (q_s == NULL)
219 return False;
221 prs_debug(ps, depth, desc, "shutdown_io_q_abort");
222 depth++;
224 if (!prs_align(ps))
225 return False;
227 if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
228 return False;
229 if (!prs_align(ps))
230 return False;
232 return True;
235 /*******************************************************************
236 reads or writes a structure.
237 ********************************************************************/
238 BOOL shutdown_io_r_abort(const char *desc, SHUTDOWN_R_ABORT *r_s,
239 prs_struct *ps, int depth)
241 if (r_s == NULL)
242 return False;
244 prs_debug(ps, depth, desc, "shutdown_io_r_abort");
245 depth++;
247 if (!prs_align(ps))
248 return False;
250 if (!prs_werror("status", ps, depth, &r_s->status))
251 return False;
253 return True;