r238: Fix memleak
[Samba/gebeck_regimport.git] / source3 / rpc_parse / parse_shutdown.c
blobad2d6e1a028aa10ff2740d8b415a8a013be48156
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "includes.h"
23 #undef DBGC_CLASS
24 #define DBGC_CLASS DBGC_RPC_PARSE
26 /*******************************************************************
27 Inits a structure.
28 ********************************************************************/
30 void init_shutdown_q_init(SHUTDOWN_Q_INIT *q_s, const char *msg,
31 uint32 timeout, BOOL do_reboot, BOOL force)
33 q_s->ptr_server = 1;
34 q_s->server = 1;
35 q_s->ptr_msg = 1;
37 init_unistr2(&q_s->uni_msg, msg, UNI_FLAGS_NONE);
38 init_uni_hdr(&q_s->hdr_msg, &q_s->uni_msg);
40 q_s->timeout = timeout;
42 q_s->reboot = do_reboot ? 1 : 0;
43 q_s->force = force ? 1 : 0;
46 /*******************************************************************
47 reads or writes a structure.
48 ********************************************************************/
50 BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps,
51 int depth)
53 if (q_s == NULL)
54 return False;
56 prs_debug(ps, depth, desc, "shutdown_io_q_init");
57 depth++;
59 if (!prs_align(ps))
60 return False;
62 if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server)))
63 return False;
64 if (!prs_uint16("server", ps, depth, &(q_s->server)))
65 return False;
67 if (!prs_align(ps))
68 return False;
69 if (!prs_uint32("ptr_msg", ps, depth, &(q_s->ptr_msg)))
70 return False;
72 if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth))
73 return False;
74 if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth))
75 return False;
76 if (!prs_align(ps))
77 return False;
79 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
80 return False;
81 if (!prs_uint8("force ", ps, depth, &(q_s->force)))
82 return False;
83 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
84 return False;
86 return True;
89 /*******************************************************************
90 reads or writes a structure.
91 ********************************************************************/
92 BOOL shutdown_io_r_init(const char *desc, SHUTDOWN_R_INIT* r_s, prs_struct *ps,
93 int depth)
95 if (r_s == NULL)
96 return False;
98 prs_debug(ps, depth, desc, "shutdown_io_r_init");
99 depth++;
101 if(!prs_align(ps))
102 return False;
104 if(!prs_ntstatus("status", ps, depth, &r_s->status))
105 return False;
107 return True;
110 /*******************************************************************
111 Inits a structure.
112 ********************************************************************/
113 void init_shutdown_q_abort(SHUTDOWN_Q_ABORT *q_s)
116 q_s->ptr_server = 0;
120 /*******************************************************************
121 reads or writes a structure.
122 ********************************************************************/
123 BOOL shutdown_io_q_abort(const char *desc, SHUTDOWN_Q_ABORT *q_s,
124 prs_struct *ps, int depth)
126 if (q_s == NULL)
127 return False;
129 prs_debug(ps, depth, desc, "shutdown_io_q_abort");
130 depth++;
132 if (!prs_align(ps))
133 return False;
135 if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server)))
136 return False;
137 if (q_s->ptr_server != 0)
138 if (!prs_uint16("server", ps, depth, &(q_s->server)))
139 return False;
141 return True;
144 /*******************************************************************
145 reads or writes a structure.
146 ********************************************************************/
147 BOOL shutdown_io_r_abort(const char *desc, SHUTDOWN_R_ABORT *r_s,
148 prs_struct *ps, int depth)
150 if (r_s == NULL)
151 return False;
153 prs_debug(ps, depth, desc, "shutdown_io_r_abort");
154 depth++;
156 if (!prs_align(ps))
157 return False;
159 if (!prs_ntstatus("status", ps, depth, &r_s->status))
160 return False;
162 return True;