r10909: Give better shutdown messages
[Samba/nascimento.git] / source3 / rpc_parse / parse_shutdown.c
blobde850ca4cc8876ce168663eb615f0a079802e7fc
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 q_s->message = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 );
39 if ( msg && *msg ) {
40 init_unistr4( q_s->message, msg, UNI_FLAGS_NONE );
42 /* Win2000 is apparently very sensitive to these lengths */
43 /* do a special case here */
45 q_s->message->string->uni_max_len++;
46 q_s->message->size += 2;
49 q_s->timeout = timeout;
51 q_s->reboot = do_reboot ? 1 : 0;
52 q_s->force = force ? 1 : 0;
55 /*******************************************************************
56 ********************************************************************/
58 void init_shutdown_q_init_ex(SHUTDOWN_Q_INIT_EX * q_u_ex, const char *msg,
59 uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason)
61 SHUTDOWN_Q_INIT q_u;
63 ZERO_STRUCT( q_u );
65 init_shutdown_q_init( &q_u, msg, timeout, do_reboot, force );
67 /* steal memory */
69 q_u_ex->server = q_u.server;
70 q_u_ex->message = q_u.message;
72 q_u_ex->reboot = q_u.reboot;
73 q_u_ex->force = q_u.force;
75 q_u_ex->reason = reason;
78 /*******************************************************************
79 reads or writes a structure.
80 ********************************************************************/
82 BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps,
83 int depth)
85 if (q_s == NULL)
86 return False;
88 prs_debug(ps, depth, desc, "shutdown_io_q_init");
89 depth++;
91 if (!prs_align(ps))
92 return False;
94 if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
95 return False;
96 if (!prs_align(ps))
97 return False;
99 if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
100 return False;
102 if (!prs_align(ps))
103 return False;
105 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
106 return False;
108 if (!prs_uint8("force ", ps, depth, &(q_s->force)))
109 return False;
110 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
111 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;