r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
[samba.git] / source3 / rpc_parse / parse_srv.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997,
7  *  Copyright (C) Jeremy Allison                    1999,
8  *  Copyright (C) Nigel Williams                    2001,
9  *  Copyright (C) Jim McDonough (jmcd@us.ibm.com)   2002.
10  *  Copyright (C) Gerald (Jerry) Carter             2006.
11  *  
12  *  This program is free software; you can redistribute it and/or modify
13  *  it under the terms of the GNU General Public License as published by
14  *  the Free Software Foundation; either version 2 of the License, or
15  *  (at your option) any later version.
16  *  
17  *  This program is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *  GNU General Public License for more details.
21  *  
22  *  You should have received a copy of the GNU General Public License
23  *  along with this program; if not, write to the Free Software
24  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  */
26
27 #include "includes.h"
28
29 #undef DBGC_CLASS
30 #define DBGC_CLASS DBGC_RPC_PARSE
31
32 /*******************************************************************
33  Inits a SH_INFO_0_STR structure
34 ********************************************************************/
35
36 void init_srv_share_info0_str(SH_INFO_0_STR *sh0, const char *net_name)
37 {
38         DEBUG(5,("init_srv_share_info0_str\n"));
39
40         init_unistr2(&sh0->uni_netname, net_name, UNI_STR_TERMINATE);
41 }
42
43 /*******************************************************************
44  Reads or writes a structure.
45 ********************************************************************/
46
47 static BOOL srv_io_share_info0_str(const char *desc, SH_INFO_0_STR *sh0, prs_struct *ps, int depth)
48 {
49         if (sh0 == NULL)
50                 return False;
51
52         prs_debug(ps, depth, desc, "srv_io_share_info0_str");
53         depth++;
54
55         if(!prs_align(ps))
56                 return False;
57         if(sh0->ptrs->ptr_netname)
58                 if(!smb_io_unistr2("", &sh0->uni_netname, True, ps, depth))
59                         return False;
60
61         return True;
62 }
63
64 /*******************************************************************
65  makes a SH_INFO_0 structure
66 ********************************************************************/
67
68 void init_srv_share_info0(SH_INFO_0 *sh0, const char *net_name)
69 {
70         DEBUG(5,("init_srv_share_info0: %s\n", net_name));
71
72         sh0->ptr_netname = (net_name != NULL) ? 1 : 0;
73 }
74
75 /*******************************************************************
76  Reads or writes a structure.
77 ********************************************************************/
78
79 static BOOL srv_io_share_info0(const char *desc, SH_INFO_0 *sh0, prs_struct *ps, int depth)
80 {
81         if (sh0 == NULL)
82                 return False;
83
84         prs_debug(ps, depth, desc, "srv_io_share_info0");
85         depth++;
86
87         if(!prs_align(ps))
88                 return False;
89
90         if(!prs_uint32("ptr_netname", ps, depth, &sh0->ptr_netname))
91                 return False;
92
93         return True;
94 }
95
96 /*******************************************************************
97  Inits a SH_INFO_1_STR structure
98 ********************************************************************/
99
100 void init_srv_share_info1_str(SH_INFO_1_STR *sh1, const char *net_name, const char *remark)
101 {
102         DEBUG(5,("init_srv_share_info1_str\n"));
103
104         init_unistr2(&sh1->uni_netname, net_name, UNI_STR_TERMINATE);
105         init_unistr2(&sh1->uni_remark, remark, UNI_STR_TERMINATE);
106 }
107
108 /*******************************************************************
109  Reads or writes a structure.
110 ********************************************************************/
111
112 static BOOL srv_io_share_info1_str(const char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth)
113 {
114         if (sh1 == NULL)
115                 return False;
116         
117         prs_debug(ps, depth, desc, "srv_io_share_info1_str");
118         depth++;
119         
120         if(!prs_align(ps))
121                 return False;
122
123         if(sh1->ptrs->ptr_netname)
124                 if(!smb_io_unistr2("", &sh1->uni_netname, True, ps, depth))
125                         return False;
126         
127         if(!prs_align(ps))
128                 return False;
129         
130         if(sh1->ptrs->ptr_remark)
131                 if(!smb_io_unistr2("", &sh1->uni_remark, True, ps, depth))
132                         return False;
133         
134         return True;
135 }
136
137 /*******************************************************************
138  makes a SH_INFO_1 structure
139 ********************************************************************/
140
141 void init_srv_share_info1(SH_INFO_1 *sh1, const char *net_name, uint32 type, const char *remark)
142 {
143         DEBUG(5,("init_srv_share_info1: %s %8x %s\n", net_name, type, remark));
144         
145         sh1->ptr_netname = (net_name != NULL) ? 1 : 0;
146         sh1->type        = type;
147         sh1->ptr_remark  = (remark != NULL) ? 1 : 0;
148 }
149
150 /*******************************************************************
151  Reads or writes a structure.
152 ********************************************************************/
153
154 static BOOL srv_io_share_info1(const char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth)
155 {
156         if (sh1 == NULL)
157                 return False;
158
159         prs_debug(ps, depth, desc, "srv_io_share_info1");
160         depth++;
161
162         if(!prs_align(ps))
163                 return False;
164
165         if(!prs_uint32("ptr_netname", ps, depth, &sh1->ptr_netname))
166                 return False;
167         if(!prs_uint32("type       ", ps, depth, &sh1->type))
168                 return False;
169         if(!prs_uint32("ptr_remark ", ps, depth, &sh1->ptr_remark))
170                 return False;
171
172         return True;
173 }
174
175 /*******************************************************************
176  Inits a SH_INFO_2_STR structure
177 ********************************************************************/
178
179 void init_srv_share_info2_str(SH_INFO_2_STR *sh2,
180                                 const char *net_name, const char *remark,
181                                 const char *path, const char *passwd)
182 {
183         DEBUG(5,("init_srv_share_info2_str\n"));
184
185         init_unistr2(&sh2->uni_netname, net_name, UNI_STR_TERMINATE);
186         init_unistr2(&sh2->uni_remark, remark, UNI_STR_TERMINATE);
187         init_unistr2(&sh2->uni_path, path, UNI_STR_TERMINATE);
188         init_unistr2(&sh2->uni_passwd, passwd, UNI_STR_TERMINATE);
189 }
190
191 /*******************************************************************
192  Reads or writes a structure.
193 ********************************************************************/
194
195 static BOOL srv_io_share_info2_str(const char *desc, SH_INFO_2 *sh, SH_INFO_2_STR *sh2, prs_struct *ps, int depth)
196 {
197         if (sh2 == NULL)
198                 return False;
199
200         if (UNMARSHALLING(ps))
201                 ZERO_STRUCTP(sh2);
202
203         prs_debug(ps, depth, desc, "srv_io_share_info2_str");
204         depth++;
205
206         if(!prs_align(ps))
207                 return False;
208
209         if (sh->ptr_netname)
210                 if(!smb_io_unistr2("", &sh2->uni_netname, True, ps, depth))
211                         return False;
212
213         if (sh->ptr_remark)
214                 if(!smb_io_unistr2("", &sh2->uni_remark, True, ps, depth))
215                         return False;
216
217         if (sh->ptr_netname)
218                 if(!smb_io_unistr2("", &sh2->uni_path, True, ps, depth))
219                         return False;
220
221         if (sh->ptr_passwd)
222                 if(!smb_io_unistr2("", &sh2->uni_passwd, True, ps, depth))
223                         return False;
224
225         return True;
226 }
227
228 /*******************************************************************
229  Inits a SH_INFO_2 structure
230 ********************************************************************/
231
232 void init_srv_share_info2(SH_INFO_2 *sh2,
233                                 const char *net_name, uint32 type, const char *remark,
234                                 uint32 perms, uint32 max_uses, uint32 num_uses,
235                                 const char *path, const char *passwd)
236 {
237         DEBUG(5,("init_srv_share_info2: %s %8x %s\n", net_name, type, remark));
238
239         sh2->ptr_netname = (net_name != NULL) ? 1 : 0;
240         sh2->type        = type;
241         sh2->ptr_remark  = (remark != NULL) ? 1 : 0;
242         sh2->perms       = perms;
243         sh2->max_uses    = max_uses;
244         sh2->num_uses    = num_uses;
245         sh2->ptr_path    = (path != NULL) ? 1 : 0;
246         sh2->ptr_passwd  = (passwd != NULL) ? 1 : 0;
247 }
248
249 /*******************************************************************
250  Reads or writes a structure.
251 ********************************************************************/
252
253 static BOOL srv_io_share_info2(const char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth)
254 {
255         if (sh2 == NULL)
256                 return False;
257
258         prs_debug(ps, depth, desc, "srv_io_share_info2");
259         depth++;
260
261         if(!prs_align(ps))
262                 return False;
263
264         if(!prs_uint32("ptr_netname", ps, depth, &sh2->ptr_netname))
265                 return False;
266         if(!prs_uint32("type       ", ps, depth, &sh2->type))
267                 return False;
268         if(!prs_uint32("ptr_remark ", ps, depth, &sh2->ptr_remark))
269                 return False;
270         if(!prs_uint32("perms      ", ps, depth, &sh2->perms))
271                 return False;
272         if(!prs_uint32("max_uses   ", ps, depth, &sh2->max_uses))
273                 return False;
274         if(!prs_uint32("num_uses   ", ps, depth, &sh2->num_uses))
275                 return False;
276         if(!prs_uint32("ptr_path   ", ps, depth, &sh2->ptr_path))
277                 return False;
278         if(!prs_uint32("ptr_passwd ", ps, depth, &sh2->ptr_passwd))
279                 return False;
280
281         return True;
282 }
283
284 /*******************************************************************
285  Inits a SH_INFO_501_STR structure
286 ********************************************************************/
287
288 void init_srv_share_info501_str(SH_INFO_501_STR *sh501,
289                                 const char *net_name, const char *remark)
290 {
291         DEBUG(5,("init_srv_share_info501_str\n"));
292
293         init_unistr2(&sh501->uni_netname, net_name, UNI_STR_TERMINATE);
294         init_unistr2(&sh501->uni_remark, remark, UNI_STR_TERMINATE);
295 }
296
297 /*******************************************************************
298  Inits a SH_INFO_2 structure
299 *******************************************************************/
300
301 void init_srv_share_info501(SH_INFO_501 *sh501, const char *net_name, uint32 type, const char *remark, uint32 csc_policy)
302 {
303         DEBUG(5,("init_srv_share_info501: %s %8x %s %08x\n", net_name, type,
304                 remark, csc_policy));
305
306         ZERO_STRUCTP(sh501);
307
308         sh501->ptr_netname = (net_name != NULL) ? 1 : 0;
309         sh501->type = type;
310         sh501->ptr_remark = (remark != NULL) ? 1 : 0;
311         sh501->csc_policy = csc_policy;
312 }
313
314 /*******************************************************************
315  Reads of writes a structure.
316 *******************************************************************/
317
318 static BOOL srv_io_share_info501(const char *desc, SH_INFO_501 *sh501, prs_struct *ps, int depth)
319 {
320         if (sh501 == NULL)
321                 return False;
322
323         prs_debug(ps, depth, desc, "srv_io_share_info501");
324         depth++;
325
326         if (!prs_align(ps))
327                 return False;
328
329         if (!prs_uint32("ptr_netname", ps, depth, &sh501->ptr_netname))
330                 return False;
331         if (!prs_uint32("type     ", ps, depth, &sh501->type))
332                 return False;
333         if (!prs_uint32("ptr_remark ", ps, depth, &sh501->ptr_remark))
334                 return False;
335         if (!prs_uint32("csc_policy ", ps, depth, &sh501->csc_policy))
336                 return False;
337
338         return True;
339 }
340
341 /*******************************************************************
342  Reads or writes a structure.
343 ********************************************************************/
344
345 static BOOL srv_io_share_info501_str(const char *desc, SH_INFO_501_STR *sh501, prs_struct *ps, int depth)
346 {
347         if (sh501 == NULL)
348                 return False;
349
350         prs_debug(ps, depth, desc, "srv_io_share_info501_str");
351         depth++;
352
353         if(!prs_align(ps))
354                 return False;
355         if(!smb_io_unistr2("", &sh501->uni_netname, True, ps, depth))
356                 return False;
357
358         if(!prs_align(ps))
359                 return False;
360         if(!smb_io_unistr2("", &sh501->uni_remark, True, ps, depth))
361                 return False;
362
363         return True;
364 }
365
366 /*******************************************************************
367  Inits a SH_INFO_502 structure
368 ********************************************************************/
369
370 void init_srv_share_info502(SH_INFO_502 *sh502,
371                                 const char *net_name, uint32 type, const char *remark,
372                                 uint32 perms, uint32 max_uses, uint32 num_uses,
373                                 const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size)
374 {
375         DEBUG(5,("init_srv_share_info502: %s %8x %s\n", net_name, type, remark));
376
377         ZERO_STRUCTP(sh502);
378
379         sh502->ptr_netname = (net_name != NULL) ? 1 : 0;
380         sh502->type        = type;
381         sh502->ptr_remark  = (remark != NULL) ? 1 : 0;
382         sh502->perms       = perms;
383         sh502->max_uses    = max_uses;
384         sh502->num_uses    = num_uses;
385         sh502->ptr_path    = (path != NULL) ? 1 : 0;
386         sh502->ptr_passwd  = (passwd != NULL) ? 1 : 0;
387         sh502->reserved    = 0;  /* actual size within rpc */
388         sh502->sd_size     = (uint32)sd_size;
389         sh502->ptr_sd      = (psd != NULL) ? 1 : 0;
390 }
391
392 /*******************************************************************
393  Reads or writes a structure.
394 ********************************************************************/
395
396 static BOOL srv_io_share_info502(const char *desc, SH_INFO_502 *sh502, prs_struct *ps, int depth)
397 {
398         if (sh502 == NULL)
399                 return False;
400
401         prs_debug(ps, depth, desc, "srv_io_share_info502");
402         depth++;
403
404         if(!prs_align(ps))
405                 return False;
406
407         if(!prs_uint32("ptr_netname", ps, depth, &sh502->ptr_netname))
408                 return False;
409         if(!prs_uint32("type       ", ps, depth, &sh502->type))
410                 return False;
411         if(!prs_uint32("ptr_remark ", ps, depth, &sh502->ptr_remark))
412                 return False;
413         if(!prs_uint32("perms      ", ps, depth, &sh502->perms))
414                 return False;
415         if(!prs_uint32("max_uses   ", ps, depth, &sh502->max_uses))
416                 return False;
417         if(!prs_uint32("num_uses   ", ps, depth, &sh502->num_uses))
418                 return False;
419         if(!prs_uint32("ptr_path   ", ps, depth, &sh502->ptr_path))
420                 return False;
421         if(!prs_uint32("ptr_passwd ", ps, depth, &sh502->ptr_passwd))
422                 return False;
423         if(!prs_uint32_pre("reserved   ", ps, depth, &sh502->reserved, &sh502->reserved_offset))
424                 return False;
425         if(!prs_uint32("ptr_sd     ", ps, depth, &sh502->ptr_sd))
426                 return False;
427
428         return True;
429 }
430
431 /*******************************************************************
432  Inits a SH_INFO_502_STR structure
433 ********************************************************************/
434
435 void init_srv_share_info502_str(SH_INFO_502_STR *sh502str,
436                                 const char *net_name, const char *remark,
437                                 const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size)
438 {
439         DEBUG(5,("init_srv_share_info502_str\n"));
440
441         init_unistr2(&sh502str->uni_netname, net_name, UNI_STR_TERMINATE);
442         init_unistr2(&sh502str->uni_remark, remark, UNI_STR_TERMINATE);
443         init_unistr2(&sh502str->uni_path, path, UNI_STR_TERMINATE);
444         init_unistr2(&sh502str->uni_passwd, passwd, UNI_STR_TERMINATE);
445         sh502str->sd = psd;
446         sh502str->reserved = 0;
447         sh502str->sd_size = sd_size;
448 }
449
450 /*******************************************************************
451  Reads or writes a structure.
452 ********************************************************************/
453
454 static BOOL srv_io_share_info502_str(const char *desc, SH_INFO_502_STR *sh502, prs_struct *ps, int depth)
455 {
456         if (sh502 == NULL)
457                 return False;
458
459         prs_debug(ps, depth, desc, "srv_io_share_info502_str");
460         depth++;
461
462         if(!prs_align(ps))
463                 return False;
464
465         if(sh502->ptrs->ptr_netname) {
466                 if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth))
467                         return False;
468         }
469
470         if(!prs_align(ps))
471                 return False;
472
473         if(sh502->ptrs->ptr_remark) {
474                 if(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth))
475                         return False;
476         }
477
478         if(!prs_align(ps))
479                 return False;
480
481         if(sh502->ptrs->ptr_path) {
482                 if(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth))
483                         return False;
484         }
485
486         if(!prs_align(ps))
487                 return False;
488
489         if(sh502->ptrs->ptr_passwd) {
490                 if(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth))
491                         return False;
492         }
493
494         if(!prs_align(ps))
495                 return False;
496
497         if(sh502->ptrs->ptr_sd) {
498                 uint32 old_offset;
499                 uint32 reserved_offset;
500
501                 if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &reserved_offset))
502                         return False;
503           
504                 old_offset = prs_offset(ps);
505           
506                 if (!sec_io_desc(desc, &sh502->sd, ps, depth))
507                         return False;
508
509                 if(UNMARSHALLING(ps)) {
510
511                         sh502->ptrs->sd_size = sh502->sd_size = sec_desc_size(sh502->sd);
512
513                         prs_set_offset(ps, old_offset + sh502->reserved);
514                 }
515
516                 prs_align(ps);
517
518                 if(MARSHALLING(ps)) {
519
520                         sh502->ptrs->reserved = sh502->reserved = prs_offset(ps) - old_offset;
521                 }
522             
523                 if(!prs_uint32_post("reserved ", ps, depth, 
524                                     &sh502->reserved, reserved_offset, sh502->reserved))
525                         return False;
526                 if(!prs_uint32_post("reserved ", ps, depth, 
527                                     &sh502->ptrs->reserved, sh502->ptrs->reserved_offset, sh502->ptrs->reserved))
528                         return False;
529         }
530
531         return True;
532 }
533
534 /*******************************************************************
535  Inits a SH_INFO_1004_STR structure
536 ********************************************************************/
537
538 void init_srv_share_info1004_str(SH_INFO_1004_STR *sh1004, const char *remark)
539 {
540         DEBUG(5,("init_srv_share_info1004_str\n"));
541
542         init_unistr2(&sh1004->uni_remark, remark, UNI_STR_TERMINATE);
543 }
544
545 /*******************************************************************
546  Reads or writes a structure.
547 ********************************************************************/
548
549 static BOOL srv_io_share_info1004_str(const char *desc, SH_INFO_1004_STR *sh1004, prs_struct *ps, int depth)
550 {
551         if (sh1004 == NULL)
552                 return False;
553
554         prs_debug(ps, depth, desc, "srv_io_share_info1004_str");
555         depth++;
556
557         if(!prs_align(ps))
558                 return False;
559         if(sh1004->ptrs->ptr_remark)
560                 if(!smb_io_unistr2("", &sh1004->uni_remark, True, ps, depth))
561                         return False;
562
563         return True;
564 }
565
566 /*******************************************************************
567  makes a SH_INFO_1004 structure
568 ********************************************************************/
569
570 void init_srv_share_info1004(SH_INFO_1004 *sh1004, const char *remark)
571 {
572         DEBUG(5,("init_srv_share_info1004: %s\n", remark));
573
574         sh1004->ptr_remark = (remark != NULL) ? 1 : 0;
575 }
576
577 /*******************************************************************
578  Reads or writes a structure.
579 ********************************************************************/
580
581 static BOOL srv_io_share_info1004(const char *desc, SH_INFO_1004 *sh1004, prs_struct *ps, int depth)
582 {
583         if (sh1004 == NULL)
584                 return False;
585
586         prs_debug(ps, depth, desc, "srv_io_share_info1004");
587         depth++;
588
589         if(!prs_align(ps))
590                 return False;
591
592         if(!prs_uint32("ptr_remark", ps, depth, &sh1004->ptr_remark))
593                 return False;
594
595         return True;
596 }
597
598 /*******************************************************************
599  Reads or writes a structure.
600 ********************************************************************/
601
602 static BOOL srv_io_share_info1005(const char* desc, SRV_SHARE_INFO_1005* sh1005, prs_struct* ps, int depth)
603 {
604         if(sh1005 == NULL)
605                 return False;
606
607         prs_debug(ps, depth, desc, "srv_io_share_info1005");
608                 depth++;
609
610         if(!prs_align(ps))
611                 return False;
612
613         if(!prs_uint32("share_info_flags", ps, depth, 
614                        &sh1005->share_info_flags))
615                 return False;
616
617         return True;
618 }   
619
620 /*******************************************************************
621  Reads or writes a structure.
622 ********************************************************************/
623
624 static BOOL srv_io_share_info1006(const char* desc, SRV_SHARE_INFO_1006* sh1006, prs_struct* ps, int depth)
625 {
626         if(sh1006 == NULL)
627                 return False;
628
629         prs_debug(ps, depth, desc, "srv_io_share_info1006");
630         depth++;
631
632         if(!prs_align(ps))
633                 return False;
634
635         if(!prs_uint32("max uses     ", ps, depth, &sh1006->max_uses))
636                 return False;
637
638         return True;
639 }   
640
641 /*******************************************************************
642  Inits a SH_INFO_1007_STR structure
643 ********************************************************************/
644
645 void init_srv_share_info1007_str(SH_INFO_1007_STR *sh1007, const char *alternate_directory_name)
646 {
647         DEBUG(5,("init_srv_share_info1007_str\n"));
648
649         init_unistr2(&sh1007->uni_AlternateDirectoryName, alternate_directory_name, UNI_STR_TERMINATE);
650 }
651
652 /*******************************************************************
653  Reads or writes a structure.
654 ********************************************************************/
655
656 static BOOL srv_io_share_info1007_str(const char *desc, SH_INFO_1007_STR *sh1007, prs_struct *ps, int depth)
657 {
658         if (sh1007 == NULL)
659                 return False;
660
661         prs_debug(ps, depth, desc, "srv_io_share_info1007_str");
662         depth++;
663
664         if(!prs_align(ps))
665                 return False;
666         if(sh1007->ptrs->ptr_AlternateDirectoryName)
667                 if(!smb_io_unistr2("", &sh1007->uni_AlternateDirectoryName, True, ps, depth))
668                         return False;
669
670         return True;
671 }
672
673 /*******************************************************************
674  makes a SH_INFO_1007 structure
675 ********************************************************************/
676
677 void init_srv_share_info1007(SH_INFO_1007 *sh1007, uint32 flags, const char *alternate_directory_name)
678 {
679         DEBUG(5,("init_srv_share_info1007: %s\n", alternate_directory_name));
680
681         sh1007->flags                      = flags;
682         sh1007->ptr_AlternateDirectoryName = (alternate_directory_name != NULL) ? 1 : 0;
683 }
684
685 /*******************************************************************
686  Reads or writes a structure.
687 ********************************************************************/
688
689 static BOOL srv_io_share_info1007(const char *desc, SH_INFO_1007 *sh1007, prs_struct *ps, int depth)
690 {
691         if (sh1007 == NULL)
692                 return False;
693
694         prs_debug(ps, depth, desc, "srv_io_share_info1007");
695         depth++;
696
697         if(!prs_align(ps))
698                 return False;
699
700         if(!prs_uint32("flags      ", ps, depth, &sh1007->flags))
701                 return False;
702         if(!prs_uint32("ptr_Alter..", ps, depth, &sh1007->ptr_AlternateDirectoryName))
703                 return False;
704
705         return True;
706 }
707
708 /*******************************************************************
709  Reads or writes a structure.
710 ********************************************************************/
711
712 static BOOL srv_io_share_info1501(const char* desc, SRV_SHARE_INFO_1501* sh1501,
713                                   prs_struct* ps, int depth)
714 {
715         if(sh1501 == NULL)
716                 return False;
717
718         prs_debug(ps, depth, desc, "srv_io_share_info1501");
719         depth++;
720
721         if(!prs_align(ps))
722                 return False;
723
724         if (!sec_io_desc_buf(desc, &sh1501->sdb, ps, depth))
725                 return False;
726
727         return True;
728 }   
729
730 /*******************************************************************
731  Reads or writes a structure.
732 ********************************************************************/
733
734 static BOOL srv_io_srv_share_ctr(const char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
735 {
736         if (ctr == NULL)
737                 return False;
738
739         prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
740         depth++;
741
742         if (UNMARSHALLING(ps)) {
743                 memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR));
744         }
745
746         if(!prs_align(ps))
747                 return False;
748
749         if(!prs_uint32("info_level", ps, depth, &ctr->info_level))
750                 return False;
751
752         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
753                 return False;
754         if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info))
755                 return False;
756
757         if (ctr->ptr_share_info == 0)
758                 return True;
759
760         if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
761                 return False;
762         if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
763                 return False;
764
765         if (ctr->ptr_entries == 0) {
766                 if (ctr->num_entries == 0)
767                         return True;
768                 else
769                         return False;
770         }
771
772         if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
773                 return False;
774
775         if (ctr->num_entries2 != ctr->num_entries)
776                 return False;
777
778         switch (ctr->switch_value) {
779
780         case 0:
781         {
782                 SRV_SHARE_INFO_0 *info0 = ctr->share.info0;
783                 int num_entries = ctr->num_entries;
784                 int i;
785
786                 if (UNMARSHALLING(ps)) {
787                         if (!(info0 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_0, num_entries)))
788                                 return False;
789                         ctr->share.info0 = info0;
790                 }
791
792                 for (i = 0; i < num_entries; i++) {
793                         if(!srv_io_share_info0("", &info0[i].info_0, ps, depth))
794                                 return False;
795                 }
796
797                 for (i = 0; i < num_entries; i++) {
798                         info0[i].info_0_str.ptrs = &info0[i].info_0;
799                         if(!srv_io_share_info0_str("", &info0[i].info_0_str, ps, depth))
800                                 return False;
801                 }
802
803                 break;
804         }
805
806         case 1:
807         {
808                 SRV_SHARE_INFO_1 *info1 = ctr->share.info1;
809                 int num_entries = ctr->num_entries;
810                 int i;
811
812                 if (UNMARSHALLING(ps)) {
813                         if (!(info1 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_1, num_entries)))
814                                 return False;
815                         ctr->share.info1 = info1;
816                 }
817
818                 for (i = 0; i < num_entries; i++) {
819                         if(!srv_io_share_info1("", &info1[i].info_1, ps, depth))
820                                 return False;
821                 }
822
823                 for (i = 0; i < num_entries; i++) {
824                         info1[i].info_1_str.ptrs = &info1[i].info_1;
825                         if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth))
826                                 return False;
827                 }
828
829                 break;
830         }
831
832         case 2:
833         {
834                 SRV_SHARE_INFO_2 *info2 = ctr->share.info2;
835                 int num_entries = ctr->num_entries;
836                 int i;
837
838                 if (UNMARSHALLING(ps)) {
839                         if (!(info2 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_2,num_entries)))
840                                 return False;
841                         ctr->share.info2 = info2;
842                 }
843
844                 for (i = 0; i < num_entries; i++) {
845                         if(!srv_io_share_info2("", &info2[i].info_2, ps, depth))
846                                 return False;
847                 }
848
849                 for (i = 0; i < num_entries; i++) {
850                         if(!srv_io_share_info2_str("", &info2[i].info_2, &info2[i].info_2_str, ps, depth))
851                                 return False;
852                 }
853
854                 break;
855         }
856
857         case 501:
858         {
859                 SRV_SHARE_INFO_501 *info501 = ctr->share.info501;
860                 int num_entries = ctr->num_entries;
861                 int i;
862
863                 if (UNMARSHALLING(ps)) {
864                         if (!(info501 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_501, num_entries)))
865                                 return False;
866                         ctr->share.info501 = info501;
867                 }
868
869                 for (i = 0; i < num_entries; i++) {
870                         if (!srv_io_share_info501("", &info501[i].info_501, ps, depth))
871                                 return False;
872                 }
873
874                 for (i = 0; i < num_entries; i++) {
875                         if (!srv_io_share_info501_str("", &info501[i].info_501_str, ps, depth))
876                                 return False;
877                 }
878
879                 break;
880         }
881
882         case 502:
883         {
884                 SRV_SHARE_INFO_502 *info502 = ctr->share.info502;
885                 int num_entries = ctr->num_entries;
886                 int i;
887
888                 if (UNMARSHALLING(ps)) {
889                         if (!(info502 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_502,num_entries)))
890                                 return False;
891                         ctr->share.info502 = info502;
892                 }
893
894                 for (i = 0; i < num_entries; i++) {
895                         if(!srv_io_share_info502("", &info502[i].info_502, ps, depth))
896                                 return False;
897         }
898                 
899                 for (i = 0; i < num_entries; i++) {
900                         info502[i].info_502_str.ptrs = &info502[i].info_502;
901                         if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth))
902                                 return False;
903                 }
904
905                 break;
906         }
907
908         case 1004:
909         {
910                 SRV_SHARE_INFO_1004 *info1004 = ctr->share.info1004;
911                 int num_entries = ctr->num_entries;
912                 int i;
913
914                 if (UNMARSHALLING(ps)) {
915                         if (!(info1004 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1004,num_entries)))
916                                 return False;
917                         ctr->share.info1004 = info1004;
918                 }
919
920                 for (i = 0; i < num_entries; i++) {
921                         if(!srv_io_share_info1004("", &info1004[i].info_1004, ps, depth))
922                                 return False;
923                 }
924
925                 for (i = 0; i < num_entries; i++) {
926                         info1004[i].info_1004_str.ptrs = &info1004[i].info_1004;
927                         if(!srv_io_share_info1004_str("", &info1004[i].info_1004_str, ps, depth))
928                                 return False;
929                 }
930
931                 break;
932         }
933
934         case 1005:
935         {
936                 SRV_SHARE_INFO_1005 *info1005 = ctr->share.info1005;
937                 int num_entries = ctr->num_entries;
938                 int i;
939
940                 if (UNMARSHALLING(ps)) {
941                         if (!(info1005 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1005,num_entries)))
942                                 return False;
943                         ctr->share.info1005 = info1005;
944                 }
945
946                 for (i = 0; i < num_entries; i++) {
947                         if(!srv_io_share_info1005("", &info1005[i], ps, depth))
948                                 return False;
949                 }
950
951                 break;
952         }
953
954         case 1006:
955         {
956                 SRV_SHARE_INFO_1006 *info1006 = ctr->share.info1006;
957                 int num_entries = ctr->num_entries;
958                 int i;
959
960                 if (UNMARSHALLING(ps)) {
961                         if (!(info1006 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1006,num_entries)))
962                                 return False;
963                         ctr->share.info1006 = info1006;
964                 }
965
966                 for (i = 0; i < num_entries; i++) {
967                         if(!srv_io_share_info1006("", &info1006[i], ps, depth))
968                                 return False;
969                 }
970
971                 break;
972         }
973
974         case 1007:
975         {
976                 SRV_SHARE_INFO_1007 *info1007 = ctr->share.info1007;
977                 int num_entries = ctr->num_entries;
978                 int i;
979
980                 if (UNMARSHALLING(ps)) {
981                         if (!(info1007 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1007,num_entries)))
982                                 return False;
983                         ctr->share.info1007 = info1007;
984                 }
985
986                 for (i = 0; i < num_entries; i++) {
987                         if(!srv_io_share_info1007("", &info1007[i].info_1007, ps, depth))
988                                 return False;
989                 }
990
991                 for (i = 0; i < num_entries; i++) {
992                         info1007[i].info_1007_str.ptrs = &info1007[i].info_1007;
993                         if(!srv_io_share_info1007_str("", &info1007[i].info_1007_str, ps, depth))
994                                 return False;
995                 }
996
997                 break;
998         }
999
1000         case 1501:
1001         {
1002                 SRV_SHARE_INFO_1501 *info1501 = ctr->share.info1501;
1003                 int num_entries = ctr->num_entries;
1004                 int i;
1005
1006                 if (UNMARSHALLING(ps)) {
1007                         if (!(info1501 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1501,num_entries)))
1008                                 return False;
1009                         ctr->share.info1501 = info1501;
1010                 }
1011
1012                 for (i = 0; i < num_entries; i++) {
1013                         if(!srv_io_share_info1501("", &info1501[i], ps, depth))
1014                                 return False;
1015                 }
1016
1017                 break;
1018         }
1019
1020         default:
1021                 DEBUG(5,("%s no share info at switch_value %d\n",
1022                          tab_depth(depth), ctr->switch_value));
1023                 break;
1024         }
1025
1026         return True;
1027 }
1028
1029 /*******************************************************************
1030  Inits a SRV_Q_NET_SHARE_ENUM structure.
1031 ********************************************************************/
1032
1033 void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, 
1034                                 const char *srv_name, uint32 info_level,
1035                                 uint32 preferred_len, ENUM_HND *hnd)
1036 {
1037
1038         DEBUG(5,("init_q_net_share_enum\n"));
1039
1040         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1041
1042         q_n->ctr.info_level = q_n->ctr.switch_value = info_level;
1043         q_n->ctr.ptr_share_info = 1;
1044         q_n->ctr.num_entries  = 0;
1045         q_n->ctr.ptr_entries  = 0;
1046         q_n->ctr.num_entries2 = 0;
1047         q_n->preferred_len = preferred_len;
1048
1049         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1050 }
1051
1052 /*******************************************************************
1053  Reads or writes a structure.
1054 ********************************************************************/
1055
1056 BOOL srv_io_q_net_share_enum(const char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
1057 {
1058         if (q_n == NULL)
1059                 return False;
1060
1061         prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
1062         depth++;
1063
1064         if(!prs_align(ps))
1065                 return False;
1066
1067         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1068                 return False;
1069         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1070                 return False;
1071
1072         if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth))
1073                 return False;
1074
1075         if(!prs_align(ps))
1076                 return False;
1077
1078         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1079                 return False;
1080
1081         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1082                 return False;
1083
1084         return True;
1085 }
1086
1087 /*******************************************************************
1088  Reads or writes a structure.
1089 ********************************************************************/
1090
1091 BOOL srv_io_r_net_share_enum(const char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
1092 {
1093         if (r_n == NULL)
1094                 return False;
1095
1096         prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
1097         depth++;
1098
1099         if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth))
1100                 return False;
1101
1102         if(!prs_align(ps))
1103                 return False;
1104
1105         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1106                 return False;
1107
1108         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1109                 return False;
1110
1111         if(!prs_werror("status", ps, depth, &r_n->status))
1112                 return False;
1113
1114         return True;
1115 }
1116
1117 /*******************************************************************
1118  initialises a structure.
1119 ********************************************************************/
1120
1121 BOOL init_srv_q_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n, const char *srv_name, const char *share_name, uint32 info_level)
1122 {
1123
1124         uint32 ptr_share_name;
1125
1126         DEBUG(5,("init_srv_q_net_share_get_info\n"));
1127
1128         init_buf_unistr2(&q_n->uni_srv_name,   &q_n->ptr_srv_name, srv_name);
1129         init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name,    share_name);
1130
1131         q_n->info_level = info_level;
1132
1133         return True;
1134 }
1135
1136 /*******************************************************************
1137  Reads or writes a structure.
1138 ********************************************************************/
1139
1140 BOOL srv_io_q_net_share_get_info(const char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
1141 {
1142         if (q_n == NULL)
1143                 return False;
1144
1145         prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
1146         depth++;
1147
1148         if(!prs_align(ps))
1149                 return False;
1150
1151         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1152                 return False;
1153         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1154                 return False;
1155
1156         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1157                 return False;
1158
1159         if(!prs_align(ps))
1160                 return False;
1161
1162         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1163                 return False;
1164
1165         return True;
1166 }
1167
1168 /*******************************************************************
1169  Reads or writes a structure.
1170 ********************************************************************/
1171
1172 static BOOL srv_io_srv_share_info(const char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n)
1173 {
1174         if (r_n == NULL)
1175                 return False;
1176
1177         prs_debug(ps, depth, desc, "srv_io_srv_share_info");
1178         depth++;
1179
1180         if(!prs_align(ps))
1181                 return False;
1182
1183         if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
1184                 return False;
1185
1186         if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
1187                 return False;
1188
1189         if (r_n->ptr_share_ctr != 0) {
1190                 switch (r_n->switch_value) {
1191                 case 0:
1192                         if(!srv_io_share_info0("", &r_n->share.info0.info_0, ps, depth))
1193                                 return False;
1194
1195                         /* allow access to pointers in the str part. */
1196                         r_n->share.info0.info_0_str.ptrs = &r_n->share.info0.info_0;
1197
1198                         if(!srv_io_share_info0_str("", &r_n->share.info0.info_0_str, ps, depth))
1199                                 return False;
1200
1201                         break;
1202                 case 1:
1203                         if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
1204                                 return False;
1205
1206                         /* allow access to pointers in the str part. */
1207                         r_n->share.info1.info_1_str.ptrs = &r_n->share.info1.info_1;
1208
1209                         if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
1210                                 return False;
1211
1212                         break;
1213                 case 2:
1214                         if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
1215                                 return False;
1216
1217                         if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth))
1218                                 return False;
1219
1220                         break;
1221                 case 501:
1222                         if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth))
1223                                 return False;
1224                         if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth))
1225                                 return False;
1226                         break;
1227
1228                 case 502:
1229                         if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth))
1230                                 return False;
1231
1232                         /* allow access to pointers in the str part. */
1233                         r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502;
1234
1235                         if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth))
1236                                 return False;
1237                         break;
1238                 case 1004:
1239                         if(!srv_io_share_info1004("", &r_n->share.info1004.info_1004, ps, depth))
1240                                 return False;
1241
1242                         /* allow access to pointers in the str part. */
1243                         r_n->share.info1004.info_1004_str.ptrs = &r_n->share.info1004.info_1004;
1244
1245                         if(!srv_io_share_info1004_str("", &r_n->share.info1004.info_1004_str, ps, depth))
1246                                 return False;
1247                         break;
1248                 case 1005:
1249                         if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth))
1250                                 return False;           
1251                         break;
1252                 case 1006:
1253                         if(!srv_io_share_info1006("", &r_n->share.info1006, ps, depth))
1254                                 return False;           
1255                         break;
1256                 case 1007:
1257                         if(!srv_io_share_info1007("", &r_n->share.info1007.info_1007, ps, depth))
1258                                 return False;
1259
1260                         /* allow access to pointers in the str part. */
1261                         r_n->share.info1007.info_1007_str.ptrs = &r_n->share.info1007.info_1007;
1262
1263                         if(!srv_io_share_info1007_str("", &r_n->share.info1007.info_1007_str, ps, depth))
1264                                 return False;
1265                         break;
1266                 case 1501:
1267                         if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth))
1268                                 return False;
1269                 default:
1270                         DEBUG(5,("%s no share info at switch_value %d\n",
1271                                  tab_depth(depth), r_n->switch_value));
1272                         break;
1273                 }
1274         }
1275
1276         return True;
1277 }
1278
1279 /*******************************************************************
1280  Reads or writes a structure.
1281 ********************************************************************/
1282
1283 BOOL srv_io_r_net_share_get_info(const char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
1284 {
1285         if (r_n == NULL)
1286                 return False;
1287
1288         prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
1289         depth++;
1290
1291         if(!prs_align(ps))
1292                 return False;
1293
1294         if(!srv_io_srv_share_info("info  ", ps, depth, &r_n->info))
1295                 return False;
1296
1297         if(!prs_align(ps))
1298                 return False;
1299
1300         if(!prs_werror("status", ps, depth, &r_n->status))
1301                 return False;
1302
1303         return True;
1304 }
1305
1306 /*******************************************************************
1307  intialises a structure.
1308 ********************************************************************/
1309
1310 BOOL init_srv_q_net_share_set_info(SRV_Q_NET_SHARE_SET_INFO *q_n, 
1311                                    const char *srv_name, 
1312                                    const char *share_name, 
1313                                    uint32 info_level, 
1314                                    const SRV_SHARE_INFO *info) 
1315 {
1316
1317         uint32 ptr_share_name;
1318
1319         DEBUG(5,("init_srv_q_net_share_set_info\n"));
1320
1321         init_buf_unistr2(&q_n->uni_srv_name,   &q_n->ptr_srv_name, srv_name);
1322         init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name,    share_name);
1323
1324         q_n->info_level = info_level;
1325   
1326         q_n->info = *info;
1327
1328         q_n->ptr_parm_error = 1;
1329         q_n->parm_error     = 0;
1330
1331         return True;
1332 }
1333
1334 /*******************************************************************
1335  Reads or writes a structure.
1336 ********************************************************************/
1337
1338 BOOL srv_io_q_net_share_set_info(const char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
1339 {
1340         if (q_n == NULL)
1341                 return False;
1342
1343         prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info");
1344         depth++;
1345
1346         if(!prs_align(ps))
1347                 return False;
1348
1349         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1350                 return False;
1351         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1352                 return False;
1353
1354         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1355                 return False;
1356
1357         if(!prs_align(ps))
1358                 return False;
1359
1360         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1361                 return False;
1362
1363         if(!prs_align(ps))
1364                 return False;
1365
1366         if(!srv_io_srv_share_info("info  ", ps, depth, &q_n->info))
1367                 return False;
1368
1369         if(!prs_align(ps))
1370                 return False;
1371         if(!prs_uint32("ptr_parm_error", ps, depth, &q_n->ptr_parm_error))
1372                 return False;
1373         if(q_n->ptr_parm_error!=0) {
1374                 if(!prs_uint32("parm_error", ps, depth, &q_n->parm_error))
1375                         return False;
1376         }
1377
1378         return True;
1379 }
1380
1381 /*******************************************************************
1382  Reads or writes a structure.
1383 ********************************************************************/
1384
1385 BOOL srv_io_r_net_share_set_info(const char *desc, SRV_R_NET_SHARE_SET_INFO *r_n, prs_struct *ps, int depth)
1386 {
1387         if (r_n == NULL)
1388                 return False;
1389
1390         prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info");
1391         depth++;
1392
1393         if(!prs_align(ps))
1394                 return False;
1395
1396         if(!prs_uint32("ptr_parm_error  ", ps, depth, &r_n->ptr_parm_error))
1397                 return False;
1398
1399         if(r_n->ptr_parm_error) {
1400
1401                 if(!prs_uint32("parm_error  ", ps, depth, &r_n->parm_error))
1402                         return False;
1403         }
1404
1405         if(!prs_werror("status", ps, depth, &r_n->status))
1406                 return False;
1407
1408         return True;
1409 }       
1410
1411
1412 /*******************************************************************
1413  Reads or writes a structure.
1414 ********************************************************************/
1415
1416 BOOL srv_io_q_net_share_add(const char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
1417 {
1418         if (q_n == NULL)
1419                 return False;
1420
1421         prs_debug(ps, depth, desc, "srv_io_q_net_share_add");
1422         depth++;
1423
1424         if(!prs_align(ps))
1425                 return False;
1426
1427         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1428                 return False;
1429         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1430                 return False;
1431
1432         if(!prs_align(ps))
1433                 return False;
1434
1435         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1436                 return False;
1437
1438         if(!prs_align(ps))
1439                 return False;
1440
1441         if(!srv_io_srv_share_info("info  ", ps, depth, &q_n->info))
1442                 return False;
1443
1444         if(!prs_align(ps))
1445                 return False;
1446
1447         if(!prs_uint32("ptr_err_index", ps, depth, &q_n->ptr_err_index))
1448                 return False;
1449         if (q_n->ptr_err_index)
1450                 if (!prs_uint32("err_index", ps, depth, &q_n->err_index))
1451                         return False;
1452
1453         return True;
1454 }
1455
1456 void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, const char *srvname,
1457                               const char *netname, uint32 type, const char *remark, 
1458                               uint32 perms, uint32 max_uses, uint32 num_uses,
1459                               const char *path, const char *passwd, 
1460                               int level, SEC_DESC *sd)
1461 {
1462         switch(level) {
1463         case 502: {
1464                 size_t sd_size = sec_desc_size(sd);
1465                 q->ptr_srv_name = 1;
1466                 init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
1467                 q->info.switch_value = q->info_level = level;
1468                 q->info.ptr_share_ctr = 1;
1469                 init_srv_share_info502(&q->info.share.info502.info_502, netname, type,
1470                                      remark, perms, max_uses, num_uses, path, passwd, sd, sd_size);
1471                 init_srv_share_info502_str(&q->info.share.info502.info_502_str, netname,
1472                                          remark, path, passwd, sd, sd_size);
1473                 q->ptr_err_index = 1;
1474                 q->err_index = 0;
1475                 }
1476                 break;
1477         case 2:
1478         default:
1479                 q->ptr_srv_name = 1;
1480                 init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
1481                 q->info.switch_value = q->info_level = level;
1482                 q->info.ptr_share_ctr = 1;
1483                 init_srv_share_info2(&q->info.share.info2.info_2, netname, type,
1484                                      remark, perms, max_uses, num_uses, path, passwd);
1485                 init_srv_share_info2_str(&q->info.share.info2.info_2_str, netname,
1486                                          remark, path, passwd);
1487                 q->ptr_err_index = 1;
1488                 q->err_index = 0;
1489                 break;
1490         }
1491 }
1492
1493
1494 /*******************************************************************
1495  Reads or writes a structure.
1496 ********************************************************************/
1497
1498 BOOL srv_io_r_net_share_add(const char *desc, SRV_R_NET_SHARE_ADD *r_n, prs_struct *ps, int depth)
1499 {
1500         if (r_n == NULL)
1501                 return False;
1502
1503         prs_debug(ps, depth, desc, "srv_io_r_net_share_add");
1504         depth++;
1505
1506         if(!prs_align(ps))
1507                 return False;
1508
1509         if(!prs_uint32("ptr_parm_error", ps, depth, &r_n->ptr_parm_error))
1510                 return False;
1511
1512         if(r_n->ptr_parm_error) {
1513           
1514                 if(!prs_uint32("parm_error", ps, depth, &r_n->parm_error))
1515                         return False;
1516         }
1517
1518         if(!prs_werror("status", ps, depth, &r_n->status))
1519                 return False;
1520
1521         return True;
1522 }       
1523
1524 /*******************************************************************
1525  initialises a structure.
1526 ********************************************************************/
1527
1528 void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname,
1529                               const char *sharename)
1530 {
1531         del->ptr_srv_name = 1;
1532         init_unistr2(&del->uni_srv_name, srvname, UNI_STR_TERMINATE);
1533         init_unistr2(&del->uni_share_name, sharename, UNI_STR_TERMINATE);
1534 }
1535
1536 /*******************************************************************
1537  Reads or writes a structure.
1538 ********************************************************************/
1539
1540 BOOL srv_io_q_net_share_del(const char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1541 {
1542         if (q_n == NULL)
1543                 return False;
1544
1545         prs_debug(ps, depth, desc, "srv_io_q_net_share_del");
1546         depth++;
1547
1548         if(!prs_align(ps))
1549                 return False;
1550
1551         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1552                 return False;
1553         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1554                 return False;
1555
1556         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1557                 return False;
1558
1559         if(!prs_align(ps))
1560                 return False;
1561         if(!prs_uint32("reserved", ps, depth, &q_n->reserved))
1562                 return False;
1563
1564         return True;
1565 }
1566
1567 /*******************************************************************
1568  Reads or writes a structure.
1569 ********************************************************************/
1570
1571 BOOL srv_io_r_net_share_del(const char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1572 {
1573         if (q_n == NULL)
1574                 return False;
1575
1576         prs_debug(ps, depth, desc, "srv_io_r_net_share_del");
1577         depth++;
1578
1579         if(!prs_align(ps))
1580                 return False;
1581
1582         if(!prs_werror("status", ps, depth, &q_n->status))
1583                 return False;
1584
1585         return True;
1586 }       
1587
1588 /*******************************************************************
1589  Inits a SESS_INFO_0_STR structure
1590 ********************************************************************/
1591
1592 void init_srv_sess_info0( SESS_INFO_0 *ss0, const char *name )
1593 {
1594         ZERO_STRUCTP( ss0 );
1595
1596         if ( name ) {
1597                 if ( (ss0->sharename = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) {
1598                         DEBUG(0,("init_srv_sess_info0: talloc failed!\n"));
1599                         return;
1600                 }
1601                 init_unistr2( ss0->sharename, name, UNI_STR_TERMINATE );
1602         }
1603 }
1604
1605 /*******************************************************************
1606  Reads or writes a structure.
1607 ********************************************************************/
1608
1609 static BOOL srv_io_srv_sess_info_0(const char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1610 {
1611         if (ss0 == NULL)
1612                 return False;
1613
1614         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
1615         depth++;
1616
1617         if(!prs_align(ps))
1618                 return False;
1619
1620         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1621                 return False;
1622         if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
1623                 return False;
1624
1625         if (ss0->ptr_sess_info != 0) {
1626                 uint32 i;
1627                 uint32 num_entries = ss0->num_entries_read;
1628
1629                 if (num_entries > MAX_SESS_ENTRIES) {
1630                         num_entries = MAX_SESS_ENTRIES; /* report this! */
1631                 }
1632
1633                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1634                         return False;
1635
1636                 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
1637
1638                 /* first the pointers */
1639                 for (i = 0; i < num_entries; i++) {
1640                         if ( !prs_io_unistr2_p("", ps, depth, &ss0->info_0[i].sharename ) )
1641                                 return False;
1642                 }
1643
1644                 /* now the strings */
1645                 for (i = 0; i < num_entries; i++) {
1646                         if ( !prs_io_unistr2("sharename", ps, depth, ss0->info_0[i].sharename ))
1647                                 return False;
1648                 }
1649
1650                 if(!prs_align(ps))
1651                         return False;
1652         }
1653
1654         return True;
1655 }
1656
1657 /*******************************************************************
1658  Inits a SESS_INFO_1 structure
1659 ********************************************************************/
1660
1661 void init_srv_sess_info1( SESS_INFO_1 *ss1, const char *name, const char *user,
1662                           uint32 num_opens, uint32 open_time, uint32 idle_time,
1663                           uint32 user_flags)
1664 {
1665         DEBUG(5,("init_srv_sess_info1: %s\n", name));
1666
1667         ZERO_STRUCTP( ss1 );
1668
1669         if ( name ) {
1670                 if ( (ss1->sharename = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) {
1671                         DEBUG(0,("init_srv_sess_info0: talloc failed!\n"));
1672                         return;
1673                 }
1674                 init_unistr2( ss1->sharename, name, UNI_STR_TERMINATE );
1675         }
1676
1677         if ( user ) {
1678                 if ( (ss1->username = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) {
1679                         DEBUG(0,("init_srv_sess_info0: talloc failed!\n"));
1680                         return;
1681                 }
1682                 init_unistr2( ss1->username, user, UNI_STR_TERMINATE );
1683         }
1684
1685         ss1->num_opens  = num_opens;
1686         ss1->open_time  = open_time;
1687         ss1->idle_time  = idle_time;
1688         ss1->user_flags = user_flags;
1689 }
1690
1691
1692 /*******************************************************************
1693  Reads or writes a structure.
1694 ********************************************************************/
1695
1696 static BOOL srv_io_srv_sess_info_1(const char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1697 {
1698         if (ss1 == NULL)
1699                 return False;
1700
1701         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
1702         depth++;
1703
1704         if(!prs_align(ps))
1705                 return False;
1706
1707         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1708                 return False;
1709         if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
1710                 return False;
1711
1712         if (ss1->ptr_sess_info != 0) {
1713                 uint32 i;
1714                 uint32 num_entries = ss1->num_entries_read;
1715
1716                 if (num_entries > MAX_SESS_ENTRIES) {
1717                         num_entries = MAX_SESS_ENTRIES; /* report this! */
1718                 }
1719
1720                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1721                         return False;
1722
1723                 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
1724
1725                 /* first the pointers and flags */
1726
1727                 for (i = 0; i < num_entries; i++) {
1728
1729                         if ( !prs_io_unistr2_p("", ps, depth, &ss1->info_1[i].sharename ))
1730                                 return False;
1731                         if ( !prs_io_unistr2_p("", ps, depth, &ss1->info_1[i].username ))
1732                                 return False;
1733
1734                         if(!prs_uint32("num_opens ", ps, depth, &ss1->info_1[i].num_opens))
1735                                 return False;
1736                         if(!prs_uint32("open_time ", ps, depth, &ss1->info_1[i].open_time))
1737                                 return False;
1738                         if(!prs_uint32("idle_time ", ps, depth, &ss1->info_1[i].idle_time))
1739                                 return False;
1740                         if(!prs_uint32("user_flags", ps, depth, &ss1->info_1[i].user_flags))
1741                                 return False;
1742                 }
1743
1744                 /* now the strings */
1745
1746                 for (i = 0; i < num_entries; i++) {
1747                         if ( !prs_io_unistr2("", ps, depth, ss1->info_1[i].sharename ))
1748                                 return False;
1749                         if ( !prs_io_unistr2("", ps, depth, ss1->info_1[i].username ))
1750                                 return False;
1751                 }
1752
1753                 if(!prs_align(ps))
1754                         return False;
1755         }
1756
1757         return True;
1758 }
1759
1760 /*******************************************************************
1761  Reads or writes a structure.
1762 ********************************************************************/
1763
1764 static BOOL srv_io_srv_sess_ctr(const char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1765 {
1766         SRV_SESS_INFO_CTR *ctr = *pp_ctr;
1767
1768         prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
1769         depth++;
1770
1771         if(UNMARSHALLING(ps)) {
1772                 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_SESS_INFO_CTR, 1);
1773                 if (ctr == NULL)
1774                         return False;
1775         }
1776
1777         if (ctr == NULL)
1778                 return False;
1779
1780         if(!prs_align(ps))
1781                 return False;
1782
1783         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1784                 return False;
1785         if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
1786                 return False;
1787
1788         if (ctr->ptr_sess_ctr != 0) {
1789                 switch (ctr->switch_value) {
1790                 case 0:
1791                         if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
1792                                 return False;
1793                         break;
1794                 case 1:
1795                         if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
1796                                 return False;
1797                         break;
1798                 default:
1799                         DEBUG(5,("%s no session info at switch_value %d\n",
1800                                  tab_depth(depth), ctr->switch_value));
1801                         break;
1802                 }
1803         }
1804
1805         return True;
1806 }
1807
1808 /*******************************************************************
1809  Reads or writes a structure.
1810 ********************************************************************/
1811
1812 BOOL srv_io_q_net_sess_enum(const char *desc, SRV_Q_NET_SESS_ENUM *q_u, prs_struct *ps, int depth)
1813 {
1814         if (q_u == NULL)
1815                 return False;
1816
1817         prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
1818         depth++;
1819
1820         if(!prs_align(ps))
1821                 return False;
1822
1823         if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
1824                 return False;
1825
1826         if(!prs_align(ps))
1827                 return False;
1828
1829         if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
1830                 return False;
1831
1832         if(!prs_align(ps))
1833                 return False;
1834
1835         if(!prs_pointer("username", ps, depth, (void*)&q_u->username, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
1836                 return False;
1837
1838         if(!prs_align(ps))
1839                 return False;
1840
1841         if(!prs_uint32("sess_level", ps, depth, &q_u->sess_level))
1842                 return False;
1843         
1844         if (q_u->sess_level != (uint32)-1) {
1845                 if(!srv_io_srv_sess_ctr("sess_ctr", &q_u->ctr, ps, depth))
1846                         return False;
1847         }
1848
1849         if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len))
1850                 return False;
1851
1852         if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth))
1853                 return False;
1854
1855         return True;
1856 }
1857
1858 /*******************************************************************
1859  Reads or writes a structure.
1860 ********************************************************************/
1861
1862 BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
1863 {
1864         if (r_n == NULL)
1865                 return False;
1866
1867         prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
1868         depth++;
1869
1870         if(!prs_align(ps))
1871                 return False;
1872
1873         if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
1874                 return False;
1875
1876         if (r_n->sess_level != (uint32)-1) {
1877                 if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
1878                         return False;
1879         }
1880
1881         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1882                 return False;
1883         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1884                 return False;
1885         if(!prs_werror("status", ps, depth, &r_n->status))
1886                 return False;
1887
1888         return True;
1889 }
1890
1891 /*******************************************************************
1892  Inits a SRV_Q_NET_SESS_DEL structure.
1893 ********************************************************************/
1894
1895 void init_srv_q_net_sess_del(SRV_Q_NET_SESS_DEL *q_n, const char *srv_name,
1896                               const char *cli_name, const char *user_name)
1897 {
1898         DEBUG(5,("init_q_net_sess_enum\n"));
1899
1900         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1901         init_buf_unistr2(&q_n->uni_cli_name, &q_n->ptr_cli_name, cli_name);
1902         init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
1903 }
1904
1905 /*******************************************************************
1906  Reads or writes a structure.
1907 ********************************************************************/
1908
1909 BOOL srv_io_q_net_sess_del(const char *desc, SRV_Q_NET_SESS_DEL *q_n, prs_struct *ps, int depth)
1910 {
1911         if (q_n == NULL)
1912                 return False;
1913
1914         prs_debug(ps, depth, desc, "srv_io_q_net_sess_del");
1915         depth++;
1916
1917         if(!prs_align(ps))
1918                 return False;
1919
1920         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1921                 return False;
1922         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1923                 return False;
1924
1925         if(!prs_align(ps))
1926                 return False;
1927
1928         if(!prs_uint32("ptr_cli_name", ps, depth, &q_n->ptr_cli_name))
1929                 return False;
1930         if(!smb_io_unistr2("", &q_n->uni_cli_name, q_n->ptr_cli_name, ps, depth))
1931                 return False;
1932
1933         if(!prs_align(ps))
1934                 return False;
1935         if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
1936                 return False;
1937         if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
1938                 return False;
1939
1940         return True;
1941 }
1942
1943 /*******************************************************************
1944  Reads or writes a structure.
1945 ********************************************************************/
1946
1947 BOOL srv_io_r_net_sess_del(const char *desc, SRV_R_NET_SESS_DEL *r_n, prs_struct *ps, int depth)
1948 {
1949         if (r_n == NULL)
1950                 return False;
1951
1952         prs_debug(ps, depth, desc, "srv_io_r_net_sess_del");
1953         depth++;
1954
1955         if(!prs_align(ps))
1956                 return False;
1957
1958         if(!prs_werror("status", ps, depth, &r_n->status))
1959                 return False;
1960
1961         return True;
1962 }
1963
1964 /*******************************************************************
1965  Inits a CONN_INFO_0 structure
1966 ********************************************************************/
1967
1968 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
1969 {
1970         DEBUG(5,("init_srv_conn_info0\n"));
1971
1972         ss0->id = id;
1973 }
1974
1975 /*******************************************************************
1976  Reads or writes a structure.
1977 ********************************************************************/
1978
1979 static BOOL srv_io_conn_info0(const char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1980 {
1981         if (ss0 == NULL)
1982                 return False;
1983
1984         prs_debug(ps, depth, desc, "srv_io_conn_info0");
1985         depth++;
1986
1987         if(!prs_align(ps))
1988                 return False;
1989
1990         if(!prs_uint32("id", ps, depth, &ss0->id))
1991                 return False;
1992
1993         return True;
1994 }
1995
1996 /*******************************************************************
1997  Reads or writes a structure.
1998 ********************************************************************/
1999
2000 static BOOL srv_io_srv_conn_info_0(const char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
2001 {
2002         if (ss0 == NULL)
2003                 return False;
2004
2005         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
2006         depth++;
2007
2008         if(!prs_align(ps))
2009                 return False;
2010
2011         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
2012                 return False;
2013         if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
2014                 return False;
2015
2016         if (ss0->ptr_conn_info != 0) {
2017                 int i;
2018                 int num_entries = ss0->num_entries_read;
2019
2020                 if (num_entries > MAX_CONN_ENTRIES) {
2021                         num_entries = MAX_CONN_ENTRIES; /* report this! */
2022                 }
2023
2024                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
2025                         return False;
2026
2027                 for (i = 0; i < num_entries; i++) {
2028                         if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
2029                                 return False;
2030                 }
2031
2032                 if(!prs_align(ps))
2033                         return False;
2034         }
2035
2036         return True;
2037 }
2038
2039 /*******************************************************************
2040  Inits a CONN_INFO_1_STR structure
2041 ********************************************************************/
2042
2043 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const char *net_name)
2044 {
2045         DEBUG(5,("init_srv_conn_info1_str\n"));
2046
2047         init_unistr2(&ss1->uni_usr_name, usr_name, UNI_STR_TERMINATE);
2048         init_unistr2(&ss1->uni_net_name, net_name, UNI_STR_TERMINATE);
2049 }
2050
2051 /*******************************************************************
2052  Reads or writes a structure.
2053 ********************************************************************/
2054
2055 static BOOL srv_io_conn_info1_str(const char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
2056 {
2057         if (ss1 == NULL)
2058                 return False;
2059
2060         prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
2061         depth++;
2062
2063         if(!prs_align(ps))
2064                 return False;
2065
2066         if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
2067                 return False;
2068         if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
2069                 return False;
2070
2071         return True;
2072 }
2073
2074 /*******************************************************************
2075  Inits a CONN_INFO_1 structure
2076 ********************************************************************/
2077
2078 void init_srv_conn_info1(CONN_INFO_1 *ss1, 
2079                                 uint32 id, uint32 type,
2080                                 uint32 num_opens, uint32 num_users, uint32 open_time,
2081                                 const char *usr_name, const char *net_name)
2082 {
2083         DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
2084
2085         ss1->id        = id       ;
2086         ss1->type      = type     ;
2087         ss1->num_opens = num_opens ;
2088         ss1->num_users = num_users;
2089         ss1->open_time = open_time;
2090
2091         ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
2092         ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
2093 }
2094
2095 /*******************************************************************
2096  Reads or writes a structure.
2097 ********************************************************************/
2098
2099 static BOOL srv_io_conn_info1(const char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2100 {
2101         if (ss1 == NULL)
2102                 return False;
2103
2104         prs_debug(ps, depth, desc, "srv_io_conn_info1");
2105         depth++;
2106
2107         if(!prs_align(ps))
2108                 return False;
2109
2110         if(!prs_uint32("id          ", ps, depth, &ss1->id))
2111                 return False;
2112         if(!prs_uint32("type        ", ps, depth, &ss1->type))
2113                 return False;
2114         if(!prs_uint32("num_opens   ", ps, depth, &ss1->num_opens))
2115                 return False;
2116         if(!prs_uint32("num_users   ", ps, depth, &ss1->num_users))
2117                 return False;
2118         if(!prs_uint32("open_time   ", ps, depth, &ss1->open_time))
2119                 return False;
2120
2121         if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
2122                 return False;
2123         if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
2124                 return False;
2125
2126         return True;
2127 }
2128
2129 /*******************************************************************
2130  Reads or writes a structure.
2131 ********************************************************************/
2132
2133 static BOOL srv_io_srv_conn_info_1(const char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2134 {
2135         if (ss1 == NULL)
2136                 return False;
2137
2138         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
2139         depth++;
2140
2141         if(!prs_align(ps))
2142                 return False;
2143
2144         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
2145                 return False;
2146         if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
2147                 return False;
2148
2149         if (ss1->ptr_conn_info != 0) {
2150                 int i;
2151                 int num_entries = ss1->num_entries_read;
2152
2153                 if (num_entries > MAX_CONN_ENTRIES) {
2154                         num_entries = MAX_CONN_ENTRIES; /* report this! */
2155                 }
2156
2157                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
2158                         return False;
2159
2160                 for (i = 0; i < num_entries; i++) {
2161                         if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
2162                                 return False;
2163                 }
2164
2165                 for (i = 0; i < num_entries; i++) {
2166                         if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
2167                                 return False;
2168                 }
2169
2170                 if(!prs_align(ps))
2171                         return False;
2172         }
2173
2174         return True;
2175 }
2176
2177 /*******************************************************************
2178  Reads or writes a structure.
2179 ********************************************************************/
2180
2181 static BOOL srv_io_srv_conn_ctr(const char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
2182 {
2183         SRV_CONN_INFO_CTR *ctr = *pp_ctr;
2184
2185         prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
2186         depth++;
2187
2188         if (UNMARSHALLING(ps)) {
2189                 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_CONN_INFO_CTR, 1);
2190                 if (ctr == NULL)
2191                         return False;
2192         }
2193                 
2194         if (ctr == NULL)
2195                 return False;
2196
2197         if(!prs_align(ps))
2198                 return False;
2199
2200         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2201                 return False;
2202         if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
2203                 return False;
2204
2205         if (ctr->ptr_conn_ctr != 0) {
2206                 switch (ctr->switch_value) {
2207                 case 0:
2208                         if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
2209                                 return False;
2210                         break;
2211                 case 1:
2212                         if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
2213                                 return False;
2214                         break;
2215                 default:
2216                         DEBUG(5,("%s no connection info at switch_value %d\n",
2217                                  tab_depth(depth), ctr->switch_value));
2218                         break;
2219                 }
2220         }
2221
2222         return True;
2223 }
2224
2225 /*******************************************************************
2226   Reads or writes a structure.
2227 ********************************************************************/
2228
2229 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, 
2230                                 const char *srv_name, const char *qual_name,
2231                                 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
2232                                 uint32 preferred_len,
2233                                 ENUM_HND *hnd)
2234 {
2235         DEBUG(5,("init_q_net_conn_enum\n"));
2236
2237         q_n->ctr = ctr;
2238
2239         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
2240         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2241
2242         q_n->conn_level    = conn_level;
2243         q_n->preferred_len = preferred_len;
2244
2245         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2246 }
2247
2248 /*******************************************************************
2249  Reads or writes a structure.
2250 ********************************************************************/
2251
2252 BOOL srv_io_q_net_conn_enum(const char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
2253 {
2254         if (q_n == NULL)
2255                 return False;
2256
2257         prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
2258         depth++;
2259
2260         if(!prs_align(ps))
2261                 return False;
2262
2263         if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2264                 return False;
2265         if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
2266                 return False;
2267
2268         if(!prs_align(ps))
2269                 return False;
2270
2271         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2272                 return False;
2273         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2274                 return False;
2275
2276         if(!prs_align(ps))
2277                 return False;
2278
2279         if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
2280                 return False;
2281         
2282         if (q_n->conn_level != (uint32)-1) {
2283                 if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
2284                         return False;
2285         }
2286
2287         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2288                 return False;
2289
2290         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2291                 return False;
2292
2293         return True;
2294 }
2295
2296 /*******************************************************************
2297  Reads or writes a structure.
2298 ********************************************************************/
2299
2300 BOOL srv_io_r_net_conn_enum(const char *desc,  SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
2301 {
2302         if (r_n == NULL)
2303                 return False;
2304
2305         prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
2306         depth++;
2307
2308         if(!prs_align(ps))
2309                 return False;
2310
2311         if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
2312                 return False;
2313
2314         if (r_n->conn_level != (uint32)-1) {
2315                 if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
2316                         return False;
2317         }
2318
2319         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2320                 return False;
2321         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2322                 return False;
2323         if(!prs_werror("status", ps, depth, &r_n->status))
2324                 return False;
2325
2326         return True;
2327 }
2328
2329 /*******************************************************************
2330  Reads or writes a structure.
2331 ********************************************************************/
2332
2333 static BOOL srv_io_file_info3_str(const char *desc, FILE_INFO_3 *sh1, prs_struct *ps, int depth)
2334 {
2335         if (sh1 == NULL)
2336                 return False;
2337
2338         prs_debug(ps, depth, desc, "srv_io_file_info3_str");
2339         depth++;
2340
2341         if(!prs_align(ps))
2342                 return False;
2343
2344         if ( sh1->path ) {
2345                 if(!smb_io_unistr2("", sh1->path, True, ps, depth))
2346                         return False;
2347         }
2348
2349         if ( sh1->user ) {
2350                 if(!smb_io_unistr2("", sh1->user, True, ps, depth))
2351                         return False;
2352         }
2353
2354         return True;
2355 }
2356
2357 /*******************************************************************
2358  Inits a FILE_INFO_3 structure
2359 ********************************************************************/
2360
2361 void init_srv_file_info3( FILE_INFO_3 *fl3, uint32 id, uint32 perms, uint32 num_locks,
2362                           const char *user_name, const char *path_name )
2363 {
2364         fl3->id        = id;    
2365         fl3->perms     = perms;
2366         fl3->num_locks = num_locks;
2367
2368         if ( path_name ) {
2369                 if ( (fl3->path = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL )
2370                         return;
2371                 init_unistr2(fl3->path, path_name, UNI_STR_TERMINATE);
2372         }
2373
2374         if ( user_name ) {
2375                 if ( (fl3->user = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL )
2376                         return;
2377                 init_unistr2(fl3->user, user_name, UNI_STR_TERMINATE);
2378         }
2379
2380         return;
2381 }
2382
2383 /*******************************************************************
2384  Reads or writes a structure.
2385 ********************************************************************/
2386
2387 static BOOL srv_io_file_info3(const char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
2388 {
2389         uint32 uni_p;
2390
2391         if (fl3 == NULL)
2392                 return False;
2393
2394         prs_debug(ps, depth, desc, "srv_io_file_info3");
2395         depth++;
2396
2397         if(!prs_align(ps))
2398                 return False;
2399
2400         if(!prs_uint32("id           ", ps, depth, &fl3->id))
2401                 return False;
2402         if(!prs_uint32("perms        ", ps, depth, &fl3->perms))
2403                 return False;
2404         if(!prs_uint32("num_locks    ", ps, depth, &fl3->num_locks))
2405                 return False;
2406
2407         uni_p = fl3->path ? 1 : 0;
2408         if(!prs_uint32("ptr", ps, depth, &uni_p))
2409                 return False;
2410         if (UNMARSHALLING(ps)) {
2411                 if ( (fl3->path = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) {
2412                         return False;
2413                 }
2414         }
2415
2416         uni_p = fl3->user ? 1 : 0;
2417         if(!prs_uint32("ptr", ps, depth, &uni_p))
2418                 return False;
2419         if (UNMARSHALLING(ps)) {
2420                 if ( (fl3->user = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) {
2421                         return False;
2422                 }
2423         }
2424
2425         return True;
2426 }
2427
2428 /*******************************************************************
2429  Reads or writes a structure.
2430 ********************************************************************/
2431
2432 static BOOL srv_io_srv_file_ctr(const char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
2433 {
2434         if (ctr == NULL)
2435                 return False;
2436
2437         prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
2438         depth++;
2439
2440         if (UNMARSHALLING(ps)) {
2441                 ZERO_STRUCTP(ctr);
2442         }
2443
2444         if(!prs_align(ps))
2445                 return False;
2446
2447         if(!prs_uint32("level", ps, depth, &ctr->level))
2448                 return False;
2449
2450         if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info))
2451                 return False;
2452         if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
2453                 return False;
2454         if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
2455                 return False;
2456
2457         if (ctr->ptr_entries == 0)
2458                 return True;
2459
2460         if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
2461                 return False;
2462
2463         switch (ctr->level) {
2464         case 3: {
2465                 FILE_INFO_3 *info3 = ctr->file.info3;
2466                 int num_entries = ctr->num_entries;
2467                 int i;
2468
2469                 if (UNMARSHALLING(ps)) {
2470                         if (!(info3 = PRS_ALLOC_MEM(ps, FILE_INFO_3, num_entries)))
2471                                 return False;
2472                         ctr->file.info3 = info3;
2473                 }
2474
2475                 for (i = 0; i < num_entries; i++) {
2476                         if(!srv_io_file_info3("", &ctr->file.info3[i], ps, depth)) 
2477                                 return False;
2478                 }
2479
2480                 for (i = 0; i < num_entries; i++) {
2481                         if(!srv_io_file_info3_str("", &ctr->file.info3[i], ps, depth))
2482                                 return False;
2483                 }
2484                 break;
2485         }
2486         default:
2487                 DEBUG(5,("%s no file info at switch_value %d\n", tab_depth(depth), ctr->level));
2488                 break;
2489         }
2490                         
2491         return True;
2492 }
2493
2494 /*******************************************************************
2495  Inits a SRV_Q_NET_FILE_ENUM structure.
2496 ********************************************************************/
2497
2498 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, 
2499                               const char *srv_name, const char *qual_name, 
2500                               const char *user_name,
2501                               uint32 file_level, SRV_FILE_INFO_CTR *ctr,
2502                               uint32 preferred_len,
2503                               ENUM_HND *hnd)
2504 {
2505         uint32 ptr;
2506
2507         if ( srv_name ) {
2508                 if ( (q_n->servername = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL )
2509                         return;
2510                 init_buf_unistr2(q_n->servername, &ptr, srv_name);
2511         }
2512
2513         if ( qual_name ) {
2514                 if ( (q_n->qualifier = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL )
2515                         return;
2516                 init_buf_unistr2(q_n->qualifier,  &ptr, qual_name);
2517         }
2518
2519         if ( user_name ) {
2520                 if ( (q_n->username = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL )
2521                         return;
2522                 init_buf_unistr2(q_n->username,   &ptr, user_name);
2523         }
2524
2525         q_n->level = q_n->ctr.level = file_level;
2526
2527         q_n->preferred_len = preferred_len;
2528         q_n->ctr.ptr_file_info = 1;
2529         q_n->ctr.num_entries = 0;
2530         q_n->ctr.num_entries2 = 0;
2531
2532         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2533 }
2534
2535 /*******************************************************************
2536  Reads or writes a structure.
2537 ********************************************************************/
2538
2539 BOOL srv_io_q_net_file_enum(const char *desc, SRV_Q_NET_FILE_ENUM *q_u, prs_struct *ps, int depth)
2540 {
2541         if (q_u == NULL)
2542                 return False;
2543
2544         prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
2545         depth++;
2546
2547         if(!prs_align(ps))
2548                 return False;
2549
2550         if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
2551                 return False;
2552         if(!prs_align(ps))
2553                 return False;
2554
2555         if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
2556                 return False;
2557         if(!prs_align(ps))
2558                 return False;
2559
2560         if(!prs_pointer("username", ps, depth, (void*)&q_u->username, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
2561                 return False;
2562         if(!prs_align(ps))
2563                 return False;
2564
2565         if(!prs_uint32("level", ps, depth, &q_u->level))
2566                 return False;
2567
2568         if (q_u->level != (uint32)-1) {
2569                 if(!srv_io_srv_file_ctr("file_ctr", &q_u->ctr, ps, depth))
2570                         return False;
2571         }
2572
2573         if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len))
2574                 return False;
2575
2576         if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth))
2577                 return False;
2578
2579         return True;
2580 }
2581
2582 /*******************************************************************
2583  Reads or writes a structure.
2584 ********************************************************************/
2585
2586 BOOL srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
2587 {
2588         if (r_n == NULL)
2589                 return False;
2590
2591         prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
2592         depth++;
2593
2594         if(!prs_align(ps))
2595                 return False;
2596
2597         if(!prs_uint32("level", ps, depth, &r_n->level))
2598                 return False;
2599
2600         if (r_n->level != 0) {
2601                 if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
2602                         return False;
2603         }
2604
2605         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2606                 return False;
2607         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2608                 return False;
2609         if(!prs_werror("status", ps, depth, &r_n->status))
2610                 return False;
2611
2612         return True;
2613 }
2614
2615 /*******************************************************************
2616  Initialize a net file close request
2617 ********************************************************************/
2618 void init_srv_q_net_file_close(SRV_Q_NET_FILE_CLOSE *q_n, const char *server,
2619                                uint32 file_id)
2620 {
2621         if ( server ) {
2622                 if ( (q_n->servername = TALLOC_P( get_talloc_ctx(), UNISTR2 )) == NULL ) {
2623                         return;
2624                 }
2625                 init_unistr2(q_n->servername, server, UNI_STR_TERMINATE);
2626         }
2627
2628         q_n->file_id = file_id;
2629 }
2630
2631 /*******************************************************************
2632  Inits a SRV_INFO_100 structure.
2633  ********************************************************************/
2634
2635 void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name)
2636 {
2637         DEBUG(5,("init_srv_info_100\n"));
2638
2639         sv100->platform_id  = platform_id;
2640         init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
2641 }
2642
2643 /*******************************************************************
2644  Reads or writes a SRV_INFO_101 structure.
2645  ********************************************************************/
2646
2647 static BOOL srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
2648 {
2649         if (sv100 == NULL)
2650                 return False;
2651
2652         prs_debug(ps, depth, desc, "srv_io_info_100");
2653         depth++;
2654
2655         if(!prs_align(ps))
2656                 return False;
2657
2658         if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
2659                 return False;
2660         if(!prs_uint32("ptr_name    ", ps, depth, &sv100->ptr_name))
2661                 return False;
2662
2663         if(!smb_io_unistr2("uni_name    ", &sv100->uni_name, True, ps, depth))
2664                 return False;
2665
2666         return True;
2667 }
2668
2669
2670 /*******************************************************************
2671  Inits a SRV_INFO_101 structure.
2672  ********************************************************************/
2673
2674 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name,
2675                                 uint32 ver_major, uint32 ver_minor,
2676                                 uint32 srv_type, const char *comment)
2677 {
2678         DEBUG(5,("init_srv_info_101\n"));
2679
2680         sv101->platform_id  = platform_id;
2681         init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
2682         sv101->ver_major    = ver_major;
2683         sv101->ver_minor    = ver_minor;
2684         sv101->srv_type     = srv_type;
2685         init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
2686 }
2687
2688 /*******************************************************************
2689  Reads or writes a SRV_INFO_101 structure.
2690  ********************************************************************/
2691
2692 static BOOL srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
2693 {
2694         if (sv101 == NULL)
2695                 return False;
2696
2697         prs_debug(ps, depth, desc, "srv_io_info_101");
2698         depth++;
2699
2700         if(!prs_align(ps))
2701                 return False;
2702
2703         if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
2704                 return False;
2705         if(!prs_uint32("ptr_name    ", ps, depth, &sv101->ptr_name))
2706                 return False;
2707         if(!prs_uint32("ver_major   ", ps, depth, &sv101->ver_major))
2708                 return False;
2709         if(!prs_uint32("ver_minor   ", ps, depth, &sv101->ver_minor))
2710                 return False;
2711         if(!prs_uint32("srv_type    ", ps, depth, &sv101->srv_type))
2712                 return False;
2713         if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
2714                 return False;
2715
2716         if(!prs_align(ps))
2717                 return False;
2718
2719         if(!smb_io_unistr2("uni_name    ", &sv101->uni_name, True, ps, depth))
2720                 return False;
2721         if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
2722                 return False;
2723
2724         return True;
2725 }
2726
2727 /*******************************************************************
2728  Inits a SRV_INFO_102 structure.
2729  ********************************************************************/
2730
2731 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name,
2732                                 const char *comment, uint32 ver_major, uint32 ver_minor,
2733                                 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
2734                                 uint32 announce, uint32 ann_delta, uint32 licenses,
2735                                 const char *usr_path)
2736 {
2737         DEBUG(5,("init_srv_info_102\n"));
2738
2739         sv102->platform_id  = platform_id;
2740         init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
2741         sv102->ver_major    = ver_major;
2742         sv102->ver_minor    = ver_minor;
2743         sv102->srv_type     = srv_type;
2744         init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
2745
2746         /* same as 101 up to here */
2747
2748         sv102->users        = users;
2749         sv102->disc         = disc;
2750         sv102->hidden       = hidden;
2751         sv102->announce     = announce;
2752         sv102->ann_delta    = ann_delta;
2753         sv102->licenses     = licenses;
2754         init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
2755 }
2756
2757
2758 /*******************************************************************
2759  Reads or writes a SRV_INFO_102 structure.
2760  ********************************************************************/
2761
2762 static BOOL srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
2763 {
2764         if (sv102 == NULL)
2765                 return False;
2766
2767         prs_debug(ps, depth, desc, "srv_io_info102");
2768         depth++;
2769
2770         if(!prs_align(ps))
2771                 return False;
2772
2773         if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
2774                 return False;
2775         if(!prs_uint32("ptr_name    ", ps, depth, &sv102->ptr_name))
2776                 return False;
2777         if(!prs_uint32("ver_major   ", ps, depth, &sv102->ver_major))
2778                 return False;
2779         if(!prs_uint32("ver_minor   ", ps, depth, &sv102->ver_minor))
2780                 return False;
2781         if(!prs_uint32("srv_type    ", ps, depth, &sv102->srv_type))
2782                 return False;
2783         if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
2784                 return False;
2785
2786         /* same as 101 up to here */
2787
2788         if(!prs_uint32("users       ", ps, depth, &sv102->users))
2789                 return False;
2790         if(!prs_uint32("disc        ", ps, depth, &sv102->disc))
2791                 return False;
2792         if(!prs_uint32("hidden      ", ps, depth, &sv102->hidden))
2793                 return False;
2794         if(!prs_uint32("announce    ", ps, depth, &sv102->announce))
2795                 return False;
2796         if(!prs_uint32("ann_delta   ", ps, depth, &sv102->ann_delta))
2797                 return False;
2798         if(!prs_uint32("licenses    ", ps, depth, &sv102->licenses))
2799                 return False;
2800         if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
2801                 return False;
2802
2803         if(!smb_io_unistr2("uni_name    ", &sv102->uni_name, True, ps, depth))
2804                 return False;
2805         if(!prs_align(ps))
2806                 return False;
2807         if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
2808                 return False;
2809         if(!prs_align(ps))
2810                 return False;
2811         if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
2812                 return False;
2813
2814         return True;
2815 }
2816
2817 /*******************************************************************
2818  Reads or writes a SRV_INFO_102 structure.
2819  ********************************************************************/
2820
2821 static BOOL srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
2822 {
2823         if (ctr == NULL)
2824                 return False;
2825
2826         prs_debug(ps, depth, desc, "srv_io_info_ctr");
2827         depth++;
2828
2829         if(!prs_align(ps))
2830                 return False;
2831
2832         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2833                 return False;
2834         if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
2835                 return False;
2836
2837         if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
2838                 switch (ctr->switch_value) {
2839                 case 100:
2840                         if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
2841                                 return False;
2842                         break;
2843                 case 101:
2844                         if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
2845                                 return False;
2846                         break;
2847                 case 102:
2848                         if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
2849                                 return False;
2850                         break;
2851                 default:
2852                         DEBUG(5,("%s no server info at switch_value %d\n",
2853                                          tab_depth(depth), ctr->switch_value));
2854                         break;
2855                 }
2856                 if(!prs_align(ps))
2857                         return False;
2858         }
2859
2860         return True;
2861 }
2862
2863 /*******************************************************************
2864  Inits a SRV_Q_NET_SRV_GET_INFO structure.
2865  ********************************************************************/
2866
2867 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
2868                                 const char *server_name, uint32 switch_value)
2869 {
2870         DEBUG(5,("init_srv_q_net_srv_get_info\n"));
2871
2872         init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
2873
2874         srv->switch_value = switch_value;
2875 }
2876
2877 /*******************************************************************
2878  Reads or writes a structure.
2879 ********************************************************************/
2880
2881 BOOL srv_io_q_net_srv_get_info(const char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
2882 {
2883         if (q_n == NULL)
2884                 return False;
2885
2886         prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
2887         depth++;
2888
2889         if(!prs_align(ps))
2890                 return False;
2891
2892         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2893                 return False;
2894         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2895                 return False;
2896
2897         if(!prs_align(ps))
2898                 return False;
2899
2900         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2901                 return False;
2902
2903         return True;
2904 }
2905
2906 /*******************************************************************
2907  Inits a SRV_R_NET_SRV_GET_INFO structure.
2908  ********************************************************************/
2909
2910 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
2911                                 uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status)
2912 {
2913         DEBUG(5,("init_srv_r_net_srv_get_info\n"));
2914
2915         srv->ctr = ctr;
2916
2917         if (W_ERROR_IS_OK(status)) {
2918                 srv->ctr->switch_value = switch_value;
2919                 srv->ctr->ptr_srv_ctr  = 1;
2920         } else {
2921                 srv->ctr->switch_value = 0;
2922                 srv->ctr->ptr_srv_ctr  = 0;
2923         }
2924
2925         srv->status = status;
2926 }
2927
2928 /*******************************************************************
2929  Inits a SRV_R_NET_SRV_SET_INFO structure.
2930  ********************************************************************/
2931
2932 void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
2933                                  uint32 switch_value, WERROR status)
2934 {
2935         DEBUG(5,("init_srv_r_net_srv_set_info\n"));
2936
2937         srv->switch_value = switch_value;
2938         srv->status = status;
2939 }
2940
2941 /*******************************************************************
2942  Reads or writes a structure.
2943 ********************************************************************/
2944
2945 BOOL srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, 
2946                                prs_struct *ps, int depth)
2947 {
2948         prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
2949         depth++;
2950
2951         if(!prs_align(ps))
2952                 return False;
2953
2954         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2955                 return False;
2956         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2957                 return False;
2958
2959         if(!prs_align(ps))
2960                 return False;
2961
2962         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2963                 return False;
2964
2965         if (UNMARSHALLING(ps)) {
2966                 q_n->ctr = PRS_ALLOC_MEM(ps, SRV_INFO_CTR, 1);
2967
2968                 if (!q_n->ctr)
2969                         return False;
2970         }
2971
2972         if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth))
2973                 return False;
2974
2975         return True;
2976 }
2977
2978 /*******************************************************************
2979  Reads or writes a structure.
2980  ********************************************************************/
2981
2982 BOOL srv_io_r_net_srv_get_info(const char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
2983 {
2984         if (r_n == NULL)
2985                 return False;
2986
2987         prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
2988         depth++;
2989
2990         if(!prs_align(ps))
2991                 return False;
2992
2993         if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
2994                 return False;
2995
2996         if(!prs_werror("status", ps, depth, &r_n->status))
2997                 return False;
2998
2999         return True;
3000 }
3001
3002 /*******************************************************************
3003  Reads or writes a structure.
3004  ********************************************************************/
3005
3006 BOOL srv_io_r_net_srv_set_info(const char *desc, SRV_R_NET_SRV_SET_INFO *r_n, 
3007                                prs_struct *ps, int depth)
3008 {
3009         prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info");
3010         depth++;
3011
3012         if(!prs_align(ps))
3013                 return False;
3014
3015         if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value))
3016                 return False;
3017
3018         if(!prs_werror("status", ps, depth, &r_n->status))
3019                 return False;
3020
3021         return True;
3022 }
3023
3024 /*******************************************************************
3025  Reads or writes a structure.
3026  ********************************************************************/
3027
3028 BOOL srv_io_q_net_remote_tod(const char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
3029 {
3030         if (q_n == NULL)
3031                 return False;
3032
3033         prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
3034         depth++;
3035
3036         if(!prs_align(ps))
3037                 return False;
3038
3039         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
3040                 return False;
3041         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3042                 return False;
3043
3044         return True;
3045 }
3046
3047 /*******************************************************************
3048  Reads or writes a TIME_OF_DAY_INFO structure.
3049  ********************************************************************/
3050
3051 static BOOL srv_io_time_of_day_info(const char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
3052 {
3053         if (tod == NULL)
3054                 return False;
3055
3056         prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
3057         depth++;
3058
3059         if(!prs_align(ps))
3060                 return False;
3061         
3062         if(!prs_uint32("elapsedt   ", ps, depth, &tod->elapsedt))
3063                 return False;
3064         if(!prs_uint32("msecs      ", ps, depth, &tod->msecs))
3065                 return False;
3066         if(!prs_uint32("hours      ", ps, depth, &tod->hours))
3067                 return False;
3068         if(!prs_uint32("mins       ", ps, depth, &tod->mins))
3069                 return False;
3070         if(!prs_uint32("secs       ", ps, depth, &tod->secs))
3071                 return False;
3072         if(!prs_uint32("hunds      ", ps, depth, &tod->hunds))
3073                 return False;
3074         if(!prs_uint32("timezone   ", ps, depth, &tod->zone))
3075                 return False;
3076         if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
3077                 return False;
3078         if(!prs_uint32("day        ", ps, depth, &tod->day))
3079                 return False;
3080         if(!prs_uint32("month      ", ps, depth, &tod->month))
3081                 return False;
3082         if(!prs_uint32("year       ", ps, depth, &tod->year))
3083                 return False;
3084         if(!prs_uint32("weekday    ", ps, depth, &tod->weekday))
3085                 return False;
3086
3087         return True;
3088 }
3089
3090 /*******************************************************************
3091  Inits a TIME_OF_DAY_INFO structure.
3092  ********************************************************************/
3093
3094 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
3095                            uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
3096                            uint32 zone, uint32 tintervals, uint32 day,
3097                            uint32 month, uint32 year, uint32 weekday)
3098 {
3099         DEBUG(5,("init_time_of_day_info\n"));
3100
3101         tod->elapsedt   = elapsedt;
3102         tod->msecs      = msecs;
3103         tod->hours      = hours;
3104         tod->mins       = mins;
3105         tod->secs       = secs;
3106         tod->hunds      = hunds;
3107         tod->zone       = zone;
3108         tod->tintervals = tintervals;
3109         tod->day        = day;
3110         tod->month      = month;
3111         tod->year       = year;
3112         tod->weekday    = weekday;
3113 }
3114
3115
3116 /*******************************************************************
3117  Reads or writes a structure.
3118  ********************************************************************/
3119
3120 BOOL srv_io_r_net_remote_tod(const char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
3121 {
3122         if (r_n == NULL)
3123                 return False;
3124
3125         prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
3126         depth++;
3127
3128         if(!prs_align(ps))
3129                 return False;
3130         
3131         if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
3132                 return False;
3133
3134         if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
3135                 return False;
3136
3137         if(!prs_werror("status", ps, depth, &r_n->status))
3138                 return False;
3139
3140         return True;
3141 }
3142
3143 /*******************************************************************
3144  initialises a structure.
3145  ********************************************************************/
3146
3147 BOOL init_srv_q_net_disk_enum(SRV_Q_NET_DISK_ENUM *q_n,
3148                               const char *srv_name,
3149                               uint32 preferred_len,
3150                               ENUM_HND *enum_hnd
3151         ) 
3152 {
3153   
3154
3155         DEBUG(5,("init_srv_q_net_srv_disk_enum\n"));
3156
3157         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
3158
3159         q_n->disk_enum_ctr.level = 0;
3160         q_n->disk_enum_ctr.disk_info_ptr   = 0;
3161   
3162         q_n->preferred_len = preferred_len;
3163         memcpy(&q_n->enum_hnd, enum_hnd, sizeof(*enum_hnd));
3164
3165         return True;
3166 }
3167
3168 /*******************************************************************
3169  Reads or writes a structure.
3170  ********************************************************************/
3171
3172 BOOL srv_io_q_net_disk_enum(const char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth)
3173 {
3174         if (q_n == NULL)
3175                 return False;
3176
3177         prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum");
3178         depth++;
3179
3180         if(!prs_align(ps))
3181                 return False;
3182
3183         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3184                 return False;
3185
3186         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3187                 return False;
3188
3189         if(!prs_align(ps))
3190                 return False;
3191
3192         if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level))
3193                 return False;
3194
3195         if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read))
3196                 return False;
3197
3198         if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr))
3199                 return False;
3200
3201         if(!prs_align(ps))
3202                 return False;
3203
3204         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
3205                 return False;
3206         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
3207                 return False;
3208
3209         return True;
3210 }
3211
3212 /*******************************************************************
3213  Reads or writes a structure.
3214  ********************************************************************/
3215
3216 BOOL srv_io_r_net_disk_enum(const char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth)
3217 {
3218
3219         unsigned int i;
3220         uint32 entries_read, entries_read2, entries_read3;
3221
3222         if (r_n == NULL)
3223                 return False;
3224
3225         prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum");
3226         depth++;
3227
3228         entries_read = entries_read2 = entries_read3 = r_n->disk_enum_ctr.entries_read;
3229
3230         if(!prs_align(ps))
3231                 return False;
3232
3233         if(!prs_uint32("entries_read", ps, depth, &entries_read))
3234                 return False;
3235         if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr))
3236                 return False;
3237
3238         /*this may be max, unknown, actual?*/
3239
3240         if(!prs_uint32("max_elements", ps, depth, &entries_read2))
3241                 return False;
3242         if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown))
3243                 return False;
3244         if(!prs_uint32("actual_elements", ps, depth, &entries_read3))
3245                 return False;
3246
3247         r_n->disk_enum_ctr.entries_read = entries_read3;
3248
3249         if(UNMARSHALLING(ps)) {
3250
3251                 DISK_INFO *dinfo;
3252
3253                 if(!(dinfo = PRS_ALLOC_MEM(ps, DISK_INFO, entries_read3)))
3254                         return False;
3255                 r_n->disk_enum_ctr.disk_info = dinfo;
3256         }
3257
3258         for(i=0; i < r_n->disk_enum_ctr.entries_read; i++) {
3259
3260                 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown))
3261                         return False;
3262    
3263                 if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth))
3264                         return False;
3265
3266                 if(!prs_align(ps))
3267                         return False;
3268         }
3269
3270         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
3271                 return False;
3272
3273         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
3274                 return False;
3275
3276         if(!prs_werror("status", ps, depth, &r_n->status))
3277                 return False;
3278
3279         return True;
3280 }
3281
3282 /*******************************************************************
3283  Reads or writes a structure.
3284  ********************************************************************/
3285
3286 BOOL srv_io_q_net_name_validate(const char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth)
3287 {
3288         if (q_n == NULL)
3289                 return False;
3290
3291         prs_debug(ps, depth, desc, "srv_io_q_net_name_validate");
3292         depth++;
3293
3294         if(!prs_align(ps))
3295                 return False;
3296
3297         if(!prs_pointer("servername", ps, depth, (void*)&q_n->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
3298                 return False;
3299
3300         if(!prs_align(ps))
3301                 return False;
3302
3303         if(!smb_io_unistr2("", &q_n->sharename, True, ps, depth))
3304                 return False;
3305
3306         if(!prs_align(ps))
3307                 return False;
3308
3309         if(!prs_uint32("type", ps, depth, &q_n->type))
3310                 return False;
3311
3312         if(!prs_uint32("flags", ps, depth, &q_n->flags))
3313                 return False;
3314
3315         return True;
3316 }
3317
3318 /*******************************************************************
3319  Reads or writes a structure.
3320  ********************************************************************/
3321
3322 BOOL srv_io_r_net_name_validate(const char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth)
3323 {
3324         if (r_n == NULL)
3325                 return False;
3326
3327         prs_debug(ps, depth, desc, "srv_io_r_net_name_validate");
3328         depth++;
3329
3330         if(!prs_align(ps))
3331                 return False;
3332
3333         if(!prs_werror("status", ps, depth, &r_n->status))
3334                 return False;
3335
3336         return True;
3337 }
3338
3339 /*******************************************************************
3340  Reads or writes a structure.
3341 ********************************************************************/
3342
3343 BOOL srv_io_q_net_file_query_secdesc(const char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth)
3344 {
3345         if (q_n == NULL)
3346                 return False;
3347
3348         prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc");
3349         depth++;
3350
3351         if(!prs_align(ps))
3352                 return False;
3353
3354         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3355                 return False;
3356
3357         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3358                 return False;
3359
3360         if(!prs_align(ps))
3361                 return False;
3362
3363         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3364                 return False;
3365
3366         if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3367                 return False;
3368
3369         if(!prs_align(ps))
3370                 return False;
3371
3372         if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3373                 return False;
3374
3375         if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1))
3376                 return False;
3377
3378         if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2))
3379                 return False;
3380
3381         if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3))
3382                 return False;
3383
3384         return True;
3385 }
3386
3387 /*******************************************************************
3388  Reads or writes a structure.
3389 ********************************************************************/
3390
3391 BOOL srv_io_r_net_file_query_secdesc(const char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth)
3392 {
3393         if (r_n == NULL)
3394                 return False;
3395
3396         prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc");
3397         depth++;
3398
3399         if(!prs_align(ps))
3400                 return False;
3401
3402         if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response))
3403                 return False;
3404
3405         if(!prs_uint32("size_response", ps, depth, &r_n->size_response))
3406                 return False;
3407
3408         if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc))
3409                 return False;
3410
3411         if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc))
3412                 return False;
3413
3414         if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth))
3415                 return False;
3416
3417         if(!prs_align(ps))
3418                 return False;
3419
3420         if(!prs_werror("status", ps, depth, &r_n->status))
3421                 return False;
3422
3423         return True;
3424 }
3425
3426 /*******************************************************************
3427  Reads or writes a structure.
3428 ********************************************************************/
3429
3430 BOOL srv_io_q_net_file_set_secdesc(const char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth)
3431 {
3432         if (q_n == NULL)
3433                 return False;
3434
3435         prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc");
3436         depth++;
3437
3438         if(!prs_align(ps))
3439                 return False;
3440
3441         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3442                 return False;
3443
3444         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3445                 return False;
3446
3447         if(!prs_align(ps))
3448                 return False;
3449
3450         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3451                 return False;
3452
3453         if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3454                 return False;
3455
3456         if(!prs_align(ps))
3457                 return False;
3458
3459         if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3460                 return False;
3461
3462         if(!prs_align(ps))
3463                 return False;
3464
3465         if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info))
3466                 return False;
3467
3468         if(!prs_uint32("size_set", ps, depth, &q_n->size_set))
3469                 return False;
3470
3471         if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc))
3472                 return False;
3473
3474         if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc))
3475                 return False;
3476
3477         if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth))
3478                 return False;
3479
3480         return True;
3481 }
3482
3483 /*******************************************************************
3484  Reads or writes a structure.
3485 ********************************************************************/
3486
3487 BOOL srv_io_r_net_file_set_secdesc(const char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth)
3488 {
3489         if (r_n == NULL)
3490                 return False;
3491
3492         prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc");
3493         depth++;
3494
3495         if(!prs_align(ps))
3496                 return False;
3497
3498         if(!prs_werror("status", ps, depth, &r_n->status))
3499                 return False;
3500
3501         return True;
3502 }
3503
3504 /*******************************************************************
3505  Inits a structure
3506 ********************************************************************/
3507
3508 void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, const char *server)
3509 {
3510         q_u->ptr_srv_name = 1;
3511         init_unistr2(&q_u->uni_srv_name, server, UNI_STR_TERMINATE);
3512 }
3513
3514
3515 /*******************************************************************
3516  Reads or writes a structure.
3517 ********************************************************************/
3518
3519 BOOL srv_io_q_net_file_close(const char *desc, SRV_Q_NET_FILE_CLOSE *q_u, prs_struct *ps, int depth)
3520 {
3521         if (q_u == NULL)
3522                 return False;
3523
3524         prs_debug(ps, depth, desc, "srv_io_q_net_file_close");
3525         depth++;
3526
3527         if(!prs_align(ps))
3528                 return False;
3529
3530         if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
3531                 return False;
3532         if(!prs_align(ps))
3533                 return False;
3534
3535         if(!prs_uint32("file_id", ps, depth, &q_u->file_id))
3536                 return False;
3537                 
3538         return True;
3539 }
3540
3541 /*******************************************************************
3542  ********************************************************************/
3543
3544 BOOL srv_io_r_net_file_close(const char *desc, SRV_R_NET_FILE_CLOSE *r_n, 
3545                                prs_struct *ps, int depth)
3546 {
3547         prs_debug(ps, depth, desc, "srv_io_r_net_file_close");
3548         depth++;
3549
3550         if(!prs_align(ps))
3551                 return False;
3552
3553         if(!prs_werror("status", ps, depth, &r_n->status))
3554                 return False;
3555
3556         return True;
3557 }