6b464645e51ba4f7b7db871a706f69b49fe9cc35
[samba.git] / source3 / rpc_parse / parse_reg.c
1 /* 
2  *  Unix SMB/Netbios implementation.
3  *  Version 1.9.
4  *  RPC Pipe client / server routines
5  *  Copyright (C) Andrew Tridgell              1992-1997,
6  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7  *  Copyright (C) Paul Ashton                       1997.
8  *  
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *  
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *  
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24
25 #include "includes.h"
26
27 extern int DEBUGLEVEL;
28
29
30 /*******************************************************************
31 reads or writes a structure.
32 ********************************************************************/
33 void reg_io_q_open_policy(char *desc,  REG_Q_OPEN_POLICY *r_q, prs_struct *ps, int depth)
34 {
35         if (r_q == NULL) return;
36
37         prs_debug(ps, depth, desc, "reg_io_q_open_policy");
38         depth++;
39
40         prs_align(ps);
41         
42         prs_uint32("ptr      ", ps, depth, &(r_q->ptr      ));
43         if (r_q->ptr != 0)
44         {
45                 prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0));
46                 prs_uint32("level    ", ps, depth, &(r_q->level    ));
47                 prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
48         }
49 }
50
51
52 /*******************************************************************
53 reads or writes a structure.
54 ********************************************************************/
55 void reg_io_r_open_policy(char *desc,  REG_R_OPEN_POLICY *r_r, prs_struct *ps, int depth)
56 {
57         if (r_r == NULL) return;
58
59         prs_debug(ps, depth, desc, "reg_io_r_open_policy");
60         depth++;
61
62         prs_align(ps);
63         
64         smb_io_pol_hnd("", &(r_r->pol), ps, depth);
65
66         prs_uint32("status", ps, depth, &(r_r->status));
67 }
68
69
70 /*******************************************************************
71 reads or writes a structure.
72 ********************************************************************/
73 void reg_io_q_close(char *desc,  REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
74 {
75         if (q_u == NULL) return;
76
77         prs_debug(ps, depth, desc, "reg_io_q_unknown_1");
78         depth++;
79
80         prs_align(ps);
81
82         smb_io_pol_hnd("", &(q_u->pol), ps, depth); 
83         prs_align(ps);
84 }
85
86 /*******************************************************************
87 reads or writes a structure.
88 ********************************************************************/
89 void reg_io_r_close(char *desc,  REG_R_CLOSE *r_u, prs_struct *ps, int depth)
90 {
91         if (r_u == NULL) return;
92
93         prs_debug(ps, depth, desc, "reg_io_r_unknown_1");
94         depth++;
95
96         prs_align(ps);
97
98         smb_io_pol_hnd("", &(r_u->pol), ps, depth); 
99         prs_align(ps);
100
101         prs_uint32("status", ps, depth, &(r_u->status));
102 }
103
104 /*******************************************************************
105 reads or writes a structure.
106 ********************************************************************/
107 void reg_io_q_info(char *desc,  REG_Q_INFO *r_q, prs_struct *ps, int depth)
108 {
109         if (r_q == NULL) return;
110
111         prs_debug(ps, depth, desc, "reg_io_q_info");
112         depth++;
113
114         prs_align(ps);
115         
116         smb_io_pol_hnd("", &(r_q->pol), ps, depth); 
117         smb_io_unihdr ("", &(r_q->hdr_type), ps, depth);
118         smb_io_unistr2("", &(r_q->uni_type), r_q->hdr_type.buffer, ps, depth);
119
120         prs_uint32("ptr1", ps, depth, &(r_q->ptr1));
121
122         if (r_q->ptr1 != 0)
123         {
124                 smb_io_time("", &(r_q->time), ps, depth);
125                 prs_uint8 ("major_version1", ps, depth, &(r_q->major_version1));
126                 prs_uint8 ("minor_version1", ps, depth, &(r_q->minor_version1));
127                 prs_uint8s(False, "pad1", ps, depth, r_q->pad1, sizeof(r_q->pad1));
128         }
129
130         prs_uint32("ptr2", ps, depth, &(r_q->ptr2));
131
132         if (r_q->ptr2 != 0)
133         {
134                 prs_uint8 ("major_version2", ps, depth, &(r_q->major_version2));
135                 prs_uint8 ("minor_version2", ps, depth, &(r_q->minor_version2));
136                 prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2));
137         }
138
139         prs_uint32("ptr3", ps, depth, &(r_q->ptr3));
140
141         if (r_q->ptr3 != 0)
142         {
143                 prs_uint32("unknown", ps, depth, &(r_q->unknown));
144         }
145 }
146
147
148 /*******************************************************************
149 creates a structure.
150 ********************************************************************/
151 void make_reg_r_info(REG_R_INFO *r_r,
152                                 uint32 level, char *os_type,
153                                 uint32 unknown_0, uint32 unknown_1,
154                                 uint32 status)
155 {
156         int type_len = strlen(os_type);
157
158         r_r->ptr1 = 1;
159         r_r->level = level;
160
161         r_r->ptr_type = 1;
162         make_uninotstr2(&(r_r->uni_type), os_type, type_len);
163
164         r_r->ptr2 = 1;
165         r_r->unknown_0 = unknown_0;
166
167         r_r->ptr3 = 1;
168         r_r->unknown_1 = unknown_1;
169
170         r_r->status = status;
171 }
172
173 /*******************************************************************
174 reads or writes a structure.
175 ********************************************************************/
176 void reg_io_r_info(char *desc,  REG_R_INFO *r_r, prs_struct *ps, int depth)
177 {
178         if (r_r == NULL) return;
179
180         prs_debug(ps, depth, desc, "reg_io_r_info");
181         depth++;
182
183         prs_align(ps);
184         
185         prs_uint32("ptr1", ps, depth, &(r_r->ptr1));
186
187         if (r_r->ptr1 != 0)
188         {
189                 prs_uint32("level", ps, depth, &(r_r->level));
190
191                 prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type));
192                 smb_io_uninotstr2("", &(r_r->uni_type), r_r->ptr_type, ps, depth);
193                 prs_align(ps);
194
195                 prs_uint32("ptr2", ps, depth, &(r_r->ptr2));
196
197                 if (r_r->ptr2 != 0)
198                 {
199                         prs_uint32("unknown_0", ps, depth, &(r_r->unknown_0));
200                 }
201
202                 prs_uint32("ptr3", ps, depth, &(r_r->ptr3));
203
204                 if (r_r->ptr3 != 0)
205                 {
206                         prs_uint32("unknown_1", ps, depth, &(r_r->unknown_1));
207                 }
208         }
209
210         prs_uint32("status", ps, depth, &(r_r->status));
211 }
212
213
214 /*******************************************************************
215 reads or writes a structure.
216 ********************************************************************/
217 void reg_io_q_open_entry(char *desc,  REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
218 {
219         if (r_q == NULL) return;
220
221         prs_debug(ps, depth, desc, "reg_io_q_entry");
222         depth++;
223
224         prs_align(ps);
225         
226         smb_io_pol_hnd("", &(r_q->pol), ps, depth);
227         smb_io_unihdr ("", &(r_q->hdr_name), ps, depth);
228         smb_io_unistr2("", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth);
229
230         prs_uint32("unknown_0", ps, depth, &(r_q->unknown_0));
231         prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
232         prs_uint16("unknown_2", ps, depth, &(r_q->unknown_2));
233 }
234
235
236 /*******************************************************************
237 creates a structure.
238 ********************************************************************/
239 void make_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
240                                 POLICY_HND *pol, uint32 status)
241 {
242         if (r_r == NULL) return;
243
244         memcpy(&(r_r->pol), pol, sizeof(r_r->pol));
245         r_r->status = status;
246 }
247
248 /*******************************************************************
249 reads or writes a structure.
250 ********************************************************************/
251 void reg_io_r_open_entry(char *desc,  REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
252 {
253         if (r_r == NULL) return;
254
255         prs_debug(ps, depth, desc, "reg_io_r_open_entry");
256         depth++;
257
258         prs_align(ps);
259         
260         smb_io_pol_hnd("", &(r_r->pol), ps, depth);
261
262         prs_uint32("status", ps, depth, &(r_r->status));
263 }
264