Remove tiny code duplication
[bbaumbach/samba-autobuild/.git] / source / 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 3 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, see <http://www.gnu.org/licenses/>.
24  */
25
26 #include "includes.h"
27
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_PARSE
30
31 /*******************************************************************
32  Inits a SH_INFO_0_STR structure
33 ********************************************************************/
34
35 void init_srv_share_info0_str(SH_INFO_0_STR *sh0, const char *net_name)
36 {
37         DEBUG(5,("init_srv_share_info0_str\n"));
38
39         init_unistr2(&sh0->uni_netname, net_name, UNI_STR_TERMINATE);
40 }
41
42 /*******************************************************************
43  Reads or writes a structure.
44 ********************************************************************/
45
46 static bool srv_io_share_info0_str(const char *desc, SH_INFO_0_STR *sh0, prs_struct *ps, int depth)
47 {
48         if (sh0 == NULL)
49                 return False;
50
51         prs_debug(ps, depth, desc, "srv_io_share_info0_str");
52         depth++;
53
54         if(!prs_align(ps))
55                 return False;
56         if(sh0->ptrs->ptr_netname)
57                 if(!smb_io_unistr2("", &sh0->uni_netname, True, ps, depth))
58                         return False;
59
60         return True;
61 }
62
63 /*******************************************************************
64  makes a SH_INFO_0 structure
65 ********************************************************************/
66
67 void init_srv_share_info0(SH_INFO_0 *sh0, const char *net_name)
68 {
69         DEBUG(5,("init_srv_share_info0: %s\n", net_name));
70
71         sh0->ptr_netname = (net_name != NULL) ? 1 : 0;
72 }
73
74 /*******************************************************************
75  Reads or writes a structure.
76 ********************************************************************/
77
78 static bool srv_io_share_info0(const char *desc, SH_INFO_0 *sh0, prs_struct *ps, int depth)
79 {
80         if (sh0 == NULL)
81                 return False;
82
83         prs_debug(ps, depth, desc, "srv_io_share_info0");
84         depth++;
85
86         if(!prs_align(ps))
87                 return False;
88
89         if(!prs_uint32("ptr_netname", ps, depth, &sh0->ptr_netname))
90                 return False;
91
92         return True;
93 }
94
95 /*******************************************************************
96  Inits a SH_INFO_1_STR structure
97 ********************************************************************/
98
99 void init_srv_share_info1_str(SH_INFO_1_STR *sh1, const char *net_name, const char *remark)
100 {
101         DEBUG(5,("init_srv_share_info1_str\n"));
102
103         init_unistr2(&sh1->uni_netname, net_name, UNI_STR_TERMINATE);
104         init_unistr2(&sh1->uni_remark, remark, UNI_STR_TERMINATE);
105 }
106
107 /*******************************************************************
108  Reads or writes a structure.
109 ********************************************************************/
110
111 static bool srv_io_share_info1_str(const char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth)
112 {
113         if (sh1 == NULL)
114                 return False;
115         
116         prs_debug(ps, depth, desc, "srv_io_share_info1_str");
117         depth++;
118         
119         if(!prs_align(ps))
120                 return False;
121
122         if(sh1->ptrs->ptr_netname)
123                 if(!smb_io_unistr2("", &sh1->uni_netname, True, ps, depth))
124                         return False;
125         
126         if(!prs_align(ps))
127                 return False;
128         
129         if(sh1->ptrs->ptr_remark)
130                 if(!smb_io_unistr2("", &sh1->uni_remark, True, ps, depth))
131                         return False;
132         
133         return True;
134 }
135
136 /*******************************************************************
137  makes a SH_INFO_1 structure
138 ********************************************************************/
139
140 void init_srv_share_info1(SH_INFO_1 *sh1, const char *net_name, uint32 type, const char *remark)
141 {
142         DEBUG(5,("init_srv_share_info1: %s %8x %s\n", net_name, type, remark));
143         
144         sh1->ptr_netname = (net_name != NULL) ? 1 : 0;
145         sh1->type        = type;
146         sh1->ptr_remark  = (remark != NULL) ? 1 : 0;
147 }
148
149 /*******************************************************************
150  Reads or writes a structure.
151 ********************************************************************/
152
153 static bool srv_io_share_info1(const char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth)
154 {
155         if (sh1 == NULL)
156                 return False;
157
158         prs_debug(ps, depth, desc, "srv_io_share_info1");
159         depth++;
160
161         if(!prs_align(ps))
162                 return False;
163
164         if(!prs_uint32("ptr_netname", ps, depth, &sh1->ptr_netname))
165                 return False;
166         if(!prs_uint32("type       ", ps, depth, &sh1->type))
167                 return False;
168         if(!prs_uint32("ptr_remark ", ps, depth, &sh1->ptr_remark))
169                 return False;
170
171         return True;
172 }
173
174 /*******************************************************************
175  Inits a SH_INFO_2_STR structure
176 ********************************************************************/
177
178 void init_srv_share_info2_str(SH_INFO_2_STR *sh2,
179                                 const char *net_name, const char *remark,
180                                 const char *path, const char *passwd)
181 {
182         DEBUG(5,("init_srv_share_info2_str\n"));
183
184         init_unistr2(&sh2->uni_netname, net_name, UNI_STR_TERMINATE);
185         init_unistr2(&sh2->uni_remark, remark, UNI_STR_TERMINATE);
186         init_unistr2(&sh2->uni_path, path, UNI_STR_TERMINATE);
187         init_unistr2(&sh2->uni_passwd, passwd, UNI_STR_TERMINATE);
188 }
189
190 /*******************************************************************
191  Reads or writes a structure.
192 ********************************************************************/
193
194 static bool srv_io_share_info2_str(const char *desc, SH_INFO_2 *sh, SH_INFO_2_STR *sh2, prs_struct *ps, int depth)
195 {
196         if (sh2 == NULL)
197                 return False;
198
199         if (UNMARSHALLING(ps))
200                 ZERO_STRUCTP(sh2);
201
202         prs_debug(ps, depth, desc, "srv_io_share_info2_str");
203         depth++;
204
205         if(!prs_align(ps))
206                 return False;
207
208         if (sh->ptr_netname)
209                 if(!smb_io_unistr2("", &sh2->uni_netname, True, ps, depth))
210                         return False;
211
212         if (sh->ptr_remark)
213                 if(!smb_io_unistr2("", &sh2->uni_remark, True, ps, depth))
214                         return False;
215
216         if (sh->ptr_netname)
217                 if(!smb_io_unistr2("", &sh2->uni_path, True, ps, depth))
218                         return False;
219
220         if (sh->ptr_passwd)
221                 if(!smb_io_unistr2("", &sh2->uni_passwd, True, ps, depth))
222                         return False;
223
224         return True;
225 }
226
227 /*******************************************************************
228  Inits a SH_INFO_2 structure
229 ********************************************************************/
230
231 void init_srv_share_info2(SH_INFO_2 *sh2,
232                                 const char *net_name, uint32 type, const char *remark,
233                                 uint32 perms, uint32 max_uses, uint32 num_uses,
234                                 const char *path, const char *passwd)
235 {
236         DEBUG(5,("init_srv_share_info2: %s %8x %s\n", net_name, type, remark));
237
238         sh2->ptr_netname = (net_name != NULL) ? 1 : 0;
239         sh2->type        = type;
240         sh2->ptr_remark  = (remark != NULL) ? 1 : 0;
241         sh2->perms       = perms;
242         sh2->max_uses    = max_uses;
243         sh2->num_uses    = num_uses;
244         sh2->ptr_path    = (path != NULL) ? 1 : 0;
245         sh2->ptr_passwd  = (passwd != NULL) ? 1 : 0;
246 }
247
248 /*******************************************************************
249  Reads or writes a structure.
250 ********************************************************************/
251
252 static bool srv_io_share_info2(const char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth)
253 {
254         if (sh2 == NULL)
255                 return False;
256
257         prs_debug(ps, depth, desc, "srv_io_share_info2");
258         depth++;
259
260         if(!prs_align(ps))
261                 return False;
262
263         if(!prs_uint32("ptr_netname", ps, depth, &sh2->ptr_netname))
264                 return False;
265         if(!prs_uint32("type       ", ps, depth, &sh2->type))
266                 return False;
267         if(!prs_uint32("ptr_remark ", ps, depth, &sh2->ptr_remark))
268                 return False;
269         if(!prs_uint32("perms      ", ps, depth, &sh2->perms))
270                 return False;
271         if(!prs_uint32("max_uses   ", ps, depth, &sh2->max_uses))
272                 return False;
273         if(!prs_uint32("num_uses   ", ps, depth, &sh2->num_uses))
274                 return False;
275         if(!prs_uint32("ptr_path   ", ps, depth, &sh2->ptr_path))
276                 return False;
277         if(!prs_uint32("ptr_passwd ", ps, depth, &sh2->ptr_passwd))
278                 return False;
279
280         return True;
281 }
282
283 /*******************************************************************
284  Inits a SH_INFO_501_STR structure
285 ********************************************************************/
286
287 void init_srv_share_info501_str(SH_INFO_501_STR *sh501,
288                                 const char *net_name, const char *remark)
289 {
290         DEBUG(5,("init_srv_share_info501_str\n"));
291
292         init_unistr2(&sh501->uni_netname, net_name, UNI_STR_TERMINATE);
293         init_unistr2(&sh501->uni_remark, remark, UNI_STR_TERMINATE);
294 }
295
296 /*******************************************************************
297  Inits a SH_INFO_2 structure
298 *******************************************************************/
299
300 void init_srv_share_info501(SH_INFO_501 *sh501, const char *net_name, uint32 type, const char *remark, uint32 csc_policy)
301 {
302         DEBUG(5,("init_srv_share_info501: %s %8x %s %08x\n", net_name, type,
303                 remark, csc_policy));
304
305         ZERO_STRUCTP(sh501);
306
307         sh501->ptr_netname = (net_name != NULL) ? 1 : 0;
308         sh501->type = type;
309         sh501->ptr_remark = (remark != NULL) ? 1 : 0;
310         sh501->csc_policy = csc_policy;
311 }
312
313 /*******************************************************************
314  Reads of writes a structure.
315 *******************************************************************/
316
317 static bool srv_io_share_info501(const char *desc, SH_INFO_501 *sh501, prs_struct *ps, int depth)
318 {
319         if (sh501 == NULL)
320                 return False;
321
322         prs_debug(ps, depth, desc, "srv_io_share_info501");
323         depth++;
324
325         if (!prs_align(ps))
326                 return False;
327
328         if (!prs_uint32("ptr_netname", ps, depth, &sh501->ptr_netname))
329                 return False;
330         if (!prs_uint32("type     ", ps, depth, &sh501->type))
331                 return False;
332         if (!prs_uint32("ptr_remark ", ps, depth, &sh501->ptr_remark))
333                 return False;
334         if (!prs_uint32("csc_policy ", ps, depth, &sh501->csc_policy))
335                 return False;
336
337         return True;
338 }
339
340 /*******************************************************************
341  Reads or writes a structure.
342 ********************************************************************/
343
344 static bool srv_io_share_info501_str(const char *desc, SH_INFO_501_STR *sh501, prs_struct *ps, int depth)
345 {
346         if (sh501 == NULL)
347                 return False;
348
349         prs_debug(ps, depth, desc, "srv_io_share_info501_str");
350         depth++;
351
352         if(!prs_align(ps))
353                 return False;
354         if(!smb_io_unistr2("", &sh501->uni_netname, True, ps, depth))
355                 return False;
356
357         if(!prs_align(ps))
358                 return False;
359         if(!smb_io_unistr2("", &sh501->uni_remark, True, ps, depth))
360                 return False;
361
362         return True;
363 }
364
365 /*******************************************************************
366  Inits a SH_INFO_502 structure
367 ********************************************************************/
368
369 void init_srv_share_info502(SH_INFO_502 *sh502,
370                                 const char *net_name, uint32 type, const char *remark,
371                                 uint32 perms, uint32 max_uses, uint32 num_uses,
372                                 const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size)
373 {
374         DEBUG(5,("init_srv_share_info502: %s %8x %s\n", net_name, type, remark));
375
376         ZERO_STRUCTP(sh502);
377
378         sh502->ptr_netname = (net_name != NULL) ? 1 : 0;
379         sh502->type        = type;
380         sh502->ptr_remark  = (remark != NULL) ? 1 : 0;
381         sh502->perms       = perms;
382         sh502->max_uses    = max_uses;
383         sh502->num_uses    = num_uses;
384         sh502->ptr_path    = (path != NULL) ? 1 : 0;
385         sh502->ptr_passwd  = (passwd != NULL) ? 1 : 0;
386         sh502->reserved    = 0;  /* actual size within rpc */
387         sh502->sd_size     = (uint32)sd_size;
388         sh502->ptr_sd      = (psd != NULL) ? 1 : 0;
389 }
390
391 /*******************************************************************
392  Reads or writes a structure.
393 ********************************************************************/
394
395 static bool srv_io_share_info502(const char *desc, SH_INFO_502 *sh502, prs_struct *ps, int depth)
396 {
397         if (sh502 == NULL)
398                 return False;
399
400         prs_debug(ps, depth, desc, "srv_io_share_info502");
401         depth++;
402
403         if(!prs_align(ps))
404                 return False;
405
406         if(!prs_uint32("ptr_netname", ps, depth, &sh502->ptr_netname))
407                 return False;
408         if(!prs_uint32("type       ", ps, depth, &sh502->type))
409                 return False;
410         if(!prs_uint32("ptr_remark ", ps, depth, &sh502->ptr_remark))
411                 return False;
412         if(!prs_uint32("perms      ", ps, depth, &sh502->perms))
413                 return False;
414         if(!prs_uint32("max_uses   ", ps, depth, &sh502->max_uses))
415                 return False;
416         if(!prs_uint32("num_uses   ", ps, depth, &sh502->num_uses))
417                 return False;
418         if(!prs_uint32("ptr_path   ", ps, depth, &sh502->ptr_path))
419                 return False;
420         if(!prs_uint32("ptr_passwd ", ps, depth, &sh502->ptr_passwd))
421                 return False;
422         if(!prs_uint32_pre("reserved   ", ps, depth, &sh502->reserved, &sh502->reserved_offset))
423                 return False;
424         if(!prs_uint32("ptr_sd     ", ps, depth, &sh502->ptr_sd))
425                 return False;
426
427         return True;
428 }
429
430 /*******************************************************************
431  Inits a SH_INFO_502_STR structure
432 ********************************************************************/
433
434 void init_srv_share_info502_str(SH_INFO_502_STR *sh502str,
435                                 const char *net_name, const char *remark,
436                                 const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size)
437 {
438         DEBUG(5,("init_srv_share_info502_str\n"));
439
440         init_unistr2(&sh502str->uni_netname, net_name, UNI_STR_TERMINATE);
441         init_unistr2(&sh502str->uni_remark, remark, UNI_STR_TERMINATE);
442         init_unistr2(&sh502str->uni_path, path, UNI_STR_TERMINATE);
443         init_unistr2(&sh502str->uni_passwd, passwd, UNI_STR_TERMINATE);
444         sh502str->sd = psd;
445         sh502str->reserved = 0;
446         sh502str->sd_size = sd_size;
447 }
448
449 /*******************************************************************
450  Reads or writes a structure.
451 ********************************************************************/
452
453 static bool srv_io_share_info502_str(const char *desc, SH_INFO_502_STR *sh502, prs_struct *ps, int depth)
454 {
455         if (sh502 == NULL)
456                 return False;
457
458         prs_debug(ps, depth, desc, "srv_io_share_info502_str");
459         depth++;
460
461         if(!prs_align(ps))
462                 return False;
463
464         if(sh502->ptrs->ptr_netname) {
465                 if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth))
466                         return False;
467         }
468
469         if(!prs_align(ps))
470                 return False;
471
472         if(sh502->ptrs->ptr_remark) {
473                 if(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth))
474                         return False;
475         }
476
477         if(!prs_align(ps))
478                 return False;
479
480         if(sh502->ptrs->ptr_path) {
481                 if(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth))
482                         return False;
483         }
484
485         if(!prs_align(ps))
486                 return False;
487
488         if(sh502->ptrs->ptr_passwd) {
489                 if(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth))
490                         return False;
491         }
492
493         if(!prs_align(ps))
494                 return False;
495
496         if(sh502->ptrs->ptr_sd) {
497                 uint32 old_offset;
498                 uint32 reserved_offset;
499
500                 if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &reserved_offset))
501                         return False;
502           
503                 old_offset = prs_offset(ps);
504           
505                 if (!sec_io_desc(desc, &sh502->sd, ps, depth))
506                         return False;
507
508                 if(UNMARSHALLING(ps)) {
509
510                         sh502->ptrs->sd_size = sh502->sd_size =
511                                 ndr_size_security_descriptor(sh502->sd, 0);
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) && num_entries) {
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) && num_entries) {
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) && num_entries) {
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) && num_entries) {
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) && num_entries) {
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) && num_entries) {
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) && num_entries) {
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) && num_entries) {
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) && num_entries) {
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) && num_entries) {
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(5,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(5,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 = ndr_size_security_descriptor(sd, 0);
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( talloc_tos(), 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( talloc_tos(), 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( talloc_tos(), 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(5,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,
1824                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
1825                 return False;
1826
1827         if(!prs_align(ps))
1828                 return False;
1829
1830         if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier,
1831                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
1832                 return False;
1833
1834         if(!prs_align(ps))
1835                 return False;
1836
1837         if(!prs_pointer("username", ps, depth, (void*)&q_u->username,
1838                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
1839                 return False;
1840
1841         if(!prs_align(ps))
1842                 return False;
1843
1844         if(!prs_uint32("sess_level", ps, depth, &q_u->sess_level))
1845                 return False;
1846         
1847         if (q_u->sess_level != (uint32)-1) {
1848                 if(!srv_io_srv_sess_ctr("sess_ctr", &q_u->ctr, ps, depth))
1849                         return False;
1850         }
1851
1852         if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len))
1853                 return False;
1854
1855         if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth))
1856                 return False;
1857
1858         return True;
1859 }
1860
1861 /*******************************************************************
1862  Reads or writes a structure.
1863 ********************************************************************/
1864
1865 bool srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
1866 {
1867         if (r_n == NULL)
1868                 return False;
1869
1870         prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
1871         depth++;
1872
1873         if(!prs_align(ps))
1874                 return False;
1875
1876         if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
1877                 return False;
1878
1879         if (r_n->sess_level != (uint32)-1) {
1880                 if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
1881                         return False;
1882         }
1883
1884         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1885                 return False;
1886         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1887                 return False;
1888         if(!prs_werror("status", ps, depth, &r_n->status))
1889                 return False;
1890
1891         return True;
1892 }
1893
1894 /*******************************************************************
1895  Inits a SRV_Q_NET_SESS_DEL structure.
1896 ********************************************************************/
1897
1898 void init_srv_q_net_sess_del(SRV_Q_NET_SESS_DEL *q_n, const char *srv_name,
1899                               const char *cli_name, const char *user_name)
1900 {
1901         DEBUG(5,("init_q_net_sess_enum\n"));
1902
1903         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1904         init_buf_unistr2(&q_n->uni_cli_name, &q_n->ptr_cli_name, cli_name);
1905         init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
1906 }
1907
1908 /*******************************************************************
1909  Reads or writes a structure.
1910 ********************************************************************/
1911
1912 bool srv_io_q_net_sess_del(const char *desc, SRV_Q_NET_SESS_DEL *q_n, prs_struct *ps, int depth)
1913 {
1914         if (q_n == NULL)
1915                 return False;
1916
1917         prs_debug(ps, depth, desc, "srv_io_q_net_sess_del");
1918         depth++;
1919
1920         if(!prs_align(ps))
1921                 return False;
1922
1923         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1924                 return False;
1925         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1926                 return False;
1927
1928         if(!prs_align(ps))
1929                 return False;
1930
1931         if(!prs_uint32("ptr_cli_name", ps, depth, &q_n->ptr_cli_name))
1932                 return False;
1933         if(!smb_io_unistr2("", &q_n->uni_cli_name, q_n->ptr_cli_name, ps, depth))
1934                 return False;
1935
1936         if(!prs_align(ps))
1937                 return False;
1938         if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
1939                 return False;
1940         if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
1941                 return False;
1942
1943         return True;
1944 }
1945
1946 /*******************************************************************
1947  Reads or writes a structure.
1948 ********************************************************************/
1949
1950 bool srv_io_r_net_sess_del(const char *desc, SRV_R_NET_SESS_DEL *r_n, prs_struct *ps, int depth)
1951 {
1952         if (r_n == NULL)
1953                 return False;
1954
1955         prs_debug(ps, depth, desc, "srv_io_r_net_sess_del");
1956         depth++;
1957
1958         if(!prs_align(ps))
1959                 return False;
1960
1961         if(!prs_werror("status", ps, depth, &r_n->status))
1962                 return False;
1963
1964         return True;
1965 }
1966
1967 /*******************************************************************
1968  Inits a CONN_INFO_0 structure
1969 ********************************************************************/
1970
1971 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
1972 {
1973         DEBUG(5,("init_srv_conn_info0\n"));
1974
1975         ss0->id = id;
1976 }
1977
1978 /*******************************************************************
1979  Reads or writes a structure.
1980 ********************************************************************/
1981
1982 static bool srv_io_conn_info0(const char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1983 {
1984         if (ss0 == NULL)
1985                 return False;
1986
1987         prs_debug(ps, depth, desc, "srv_io_conn_info0");
1988         depth++;
1989
1990         if(!prs_align(ps))
1991                 return False;
1992
1993         if(!prs_uint32("id", ps, depth, &ss0->id))
1994                 return False;
1995
1996         return True;
1997 }
1998
1999 /*******************************************************************
2000  Reads or writes a structure.
2001 ********************************************************************/
2002
2003 static bool srv_io_srv_conn_info_0(const char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
2004 {
2005         if (ss0 == NULL)
2006                 return False;
2007
2008         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
2009         depth++;
2010
2011         if(!prs_align(ps))
2012                 return False;
2013
2014         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
2015                 return False;
2016         if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
2017                 return False;
2018
2019         if (ss0->ptr_conn_info != 0) {
2020                 int i;
2021                 int num_entries = ss0->num_entries_read;
2022
2023                 if (num_entries > MAX_CONN_ENTRIES) {
2024                         num_entries = MAX_CONN_ENTRIES; /* report this! */
2025                 }
2026
2027                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
2028                         return False;
2029
2030                 for (i = 0; i < num_entries; i++) {
2031                         if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
2032                                 return False;
2033                 }
2034
2035                 if(!prs_align(ps))
2036                         return False;
2037         }
2038
2039         return True;
2040 }
2041
2042 /*******************************************************************
2043  Inits a CONN_INFO_1_STR structure
2044 ********************************************************************/
2045
2046 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const char *net_name)
2047 {
2048         DEBUG(5,("init_srv_conn_info1_str\n"));
2049
2050         init_unistr2(&ss1->uni_usr_name, usr_name, UNI_STR_TERMINATE);
2051         init_unistr2(&ss1->uni_net_name, net_name, UNI_STR_TERMINATE);
2052 }
2053
2054 /*******************************************************************
2055  Reads or writes a structure.
2056 ********************************************************************/
2057
2058 static bool srv_io_conn_info1_str(const char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
2059 {
2060         if (ss1 == NULL)
2061                 return False;
2062
2063         prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
2064         depth++;
2065
2066         if(!prs_align(ps))
2067                 return False;
2068
2069         if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
2070                 return False;
2071         if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
2072                 return False;
2073
2074         return True;
2075 }
2076
2077 /*******************************************************************
2078  Inits a CONN_INFO_1 structure
2079 ********************************************************************/
2080
2081 void init_srv_conn_info1(CONN_INFO_1 *ss1, 
2082                                 uint32 id, uint32 type,
2083                                 uint32 num_opens, uint32 num_users, uint32 open_time,
2084                                 const char *usr_name, const char *net_name)
2085 {
2086         DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
2087
2088         ss1->id        = id       ;
2089         ss1->type      = type     ;
2090         ss1->num_opens = num_opens ;
2091         ss1->num_users = num_users;
2092         ss1->open_time = open_time;
2093
2094         ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
2095         ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
2096 }
2097
2098 /*******************************************************************
2099  Reads or writes a structure.
2100 ********************************************************************/
2101
2102 static bool srv_io_conn_info1(const char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2103 {
2104         if (ss1 == NULL)
2105                 return False;
2106
2107         prs_debug(ps, depth, desc, "srv_io_conn_info1");
2108         depth++;
2109
2110         if(!prs_align(ps))
2111                 return False;
2112
2113         if(!prs_uint32("id          ", ps, depth, &ss1->id))
2114                 return False;
2115         if(!prs_uint32("type        ", ps, depth, &ss1->type))
2116                 return False;
2117         if(!prs_uint32("num_opens   ", ps, depth, &ss1->num_opens))
2118                 return False;
2119         if(!prs_uint32("num_users   ", ps, depth, &ss1->num_users))
2120                 return False;
2121         if(!prs_uint32("open_time   ", ps, depth, &ss1->open_time))
2122                 return False;
2123
2124         if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
2125                 return False;
2126         if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
2127                 return False;
2128
2129         return True;
2130 }
2131
2132 /*******************************************************************
2133  Reads or writes a structure.
2134 ********************************************************************/
2135
2136 static bool srv_io_srv_conn_info_1(const char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2137 {
2138         if (ss1 == NULL)
2139                 return False;
2140
2141         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
2142         depth++;
2143
2144         if(!prs_align(ps))
2145                 return False;
2146
2147         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
2148                 return False;
2149         if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
2150                 return False;
2151
2152         if (ss1->ptr_conn_info != 0) {
2153                 int i;
2154                 int num_entries = ss1->num_entries_read;
2155
2156                 if (num_entries > MAX_CONN_ENTRIES) {
2157                         num_entries = MAX_CONN_ENTRIES; /* report this! */
2158                 }
2159
2160                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
2161                         return False;
2162
2163                 for (i = 0; i < num_entries; i++) {
2164                         if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
2165                                 return False;
2166                 }
2167
2168                 for (i = 0; i < num_entries; i++) {
2169                         if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
2170                                 return False;
2171                 }
2172
2173                 if(!prs_align(ps))
2174                         return False;
2175         }
2176
2177         return True;
2178 }
2179
2180 /*******************************************************************
2181  Reads or writes a structure.
2182 ********************************************************************/
2183
2184 static bool srv_io_srv_conn_ctr(const char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
2185 {
2186         SRV_CONN_INFO_CTR *ctr = *pp_ctr;
2187
2188         prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
2189         depth++;
2190
2191         if (UNMARSHALLING(ps)) {
2192                 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_CONN_INFO_CTR, 1);
2193                 if (ctr == NULL)
2194                         return False;
2195         }
2196                 
2197         if (ctr == NULL)
2198                 return False;
2199
2200         if(!prs_align(ps))
2201                 return False;
2202
2203         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2204                 return False;
2205         if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
2206                 return False;
2207
2208         if (ctr->ptr_conn_ctr != 0) {
2209                 switch (ctr->switch_value) {
2210                 case 0:
2211                         if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
2212                                 return False;
2213                         break;
2214                 case 1:
2215                         if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
2216                                 return False;
2217                         break;
2218                 default:
2219                         DEBUG(5,("%s no connection info at switch_value %d\n",
2220                                  tab_depth(5,depth), ctr->switch_value));
2221                         break;
2222                 }
2223         }
2224
2225         return True;
2226 }
2227
2228 /*******************************************************************
2229   Reads or writes a structure.
2230 ********************************************************************/
2231
2232 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, 
2233                                 const char *srv_name, const char *qual_name,
2234                                 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
2235                                 uint32 preferred_len,
2236                                 ENUM_HND *hnd)
2237 {
2238         DEBUG(5,("init_q_net_conn_enum\n"));
2239
2240         q_n->ctr = ctr;
2241
2242         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
2243         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2244
2245         q_n->conn_level    = conn_level;
2246         q_n->preferred_len = preferred_len;
2247
2248         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2249 }
2250
2251 /*******************************************************************
2252  Reads or writes a structure.
2253 ********************************************************************/
2254
2255 bool srv_io_q_net_conn_enum(const char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
2256 {
2257         if (q_n == NULL)
2258                 return False;
2259
2260         prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
2261         depth++;
2262
2263         if(!prs_align(ps))
2264                 return False;
2265
2266         if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2267                 return False;
2268         if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
2269                 return False;
2270
2271         if(!prs_align(ps))
2272                 return False;
2273
2274         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2275                 return False;
2276         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2277                 return False;
2278
2279         if(!prs_align(ps))
2280                 return False;
2281
2282         if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
2283                 return False;
2284         
2285         if (q_n->conn_level != (uint32)-1) {
2286                 if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
2287                         return False;
2288         }
2289
2290         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2291                 return False;
2292
2293         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2294                 return False;
2295
2296         return True;
2297 }
2298
2299 /*******************************************************************
2300  Reads or writes a structure.
2301 ********************************************************************/
2302
2303 bool srv_io_r_net_conn_enum(const char *desc,  SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
2304 {
2305         if (r_n == NULL)
2306                 return False;
2307
2308         prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
2309         depth++;
2310
2311         if(!prs_align(ps))
2312                 return False;
2313
2314         if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
2315                 return False;
2316
2317         if (r_n->conn_level != (uint32)-1) {
2318                 if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
2319                         return False;
2320         }
2321
2322         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2323                 return False;
2324         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2325                 return False;
2326         if(!prs_werror("status", ps, depth, &r_n->status))
2327                 return False;
2328
2329         return True;
2330 }
2331
2332 /*******************************************************************
2333  Reads or writes a structure.
2334 ********************************************************************/
2335
2336 static bool srv_io_file_info3_str(const char *desc, FILE_INFO_3 *sh1, prs_struct *ps, int depth)
2337 {
2338         if (sh1 == NULL)
2339                 return False;
2340
2341         prs_debug(ps, depth, desc, "srv_io_file_info3_str");
2342         depth++;
2343
2344         if(!prs_align(ps))
2345                 return False;
2346
2347         if ( sh1->path ) {
2348                 if(!smb_io_unistr2("", sh1->path, True, ps, depth))
2349                         return False;
2350         }
2351
2352         if ( sh1->user ) {
2353                 if(!smb_io_unistr2("", sh1->user, True, ps, depth))
2354                         return False;
2355         }
2356
2357         return True;
2358 }
2359
2360 /*******************************************************************
2361  Inits a FILE_INFO_3 structure
2362 ********************************************************************/
2363
2364 void init_srv_file_info3( FILE_INFO_3 *fl3, uint32 id, uint32 perms, uint32 num_locks,
2365                           const char *user_name, const char *path_name )
2366 {
2367         fl3->id        = id;    
2368         fl3->perms     = perms;
2369         fl3->num_locks = num_locks;
2370
2371         if ( path_name ) {
2372                 if ( (fl3->path = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2373                         return;
2374                 init_unistr2(fl3->path, path_name, UNI_STR_TERMINATE);
2375         }
2376
2377         if ( user_name ) {
2378                 if ( (fl3->user = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2379                         return;
2380                 init_unistr2(fl3->user, user_name, UNI_STR_TERMINATE);
2381         }
2382
2383         return;
2384 }
2385
2386 /*******************************************************************
2387  Reads or writes a structure.
2388 ********************************************************************/
2389
2390 static bool srv_io_file_info3(const char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
2391 {
2392         uint32 uni_p;
2393
2394         if (fl3 == NULL)
2395                 return False;
2396
2397         prs_debug(ps, depth, desc, "srv_io_file_info3");
2398         depth++;
2399
2400         if(!prs_align(ps))
2401                 return False;
2402
2403         if(!prs_uint32("id           ", ps, depth, &fl3->id))
2404                 return False;
2405         if(!prs_uint32("perms        ", ps, depth, &fl3->perms))
2406                 return False;
2407         if(!prs_uint32("num_locks    ", ps, depth, &fl3->num_locks))
2408                 return False;
2409
2410         uni_p = fl3->path ? 1 : 0;
2411         if(!prs_uint32("ptr", ps, depth, &uni_p))
2412                 return False;
2413         if (UNMARSHALLING(ps)) {
2414                 if ( (fl3->path = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) {
2415                         return False;
2416                 }
2417         }
2418
2419         uni_p = fl3->user ? 1 : 0;
2420         if(!prs_uint32("ptr", ps, depth, &uni_p))
2421                 return False;
2422         if (UNMARSHALLING(ps)) {
2423                 if ( (fl3->user = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) {
2424                         return False;
2425                 }
2426         }
2427
2428         return True;
2429 }
2430
2431 /*******************************************************************
2432  Reads or writes a structure.
2433 ********************************************************************/
2434
2435 static bool srv_io_srv_file_ctr(const char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
2436 {
2437         if (ctr == NULL)
2438                 return False;
2439
2440         prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
2441         depth++;
2442
2443         if (UNMARSHALLING(ps)) {
2444                 ZERO_STRUCTP(ctr);
2445         }
2446
2447         if(!prs_align(ps))
2448                 return False;
2449
2450         if(!prs_uint32("level", ps, depth, &ctr->level))
2451                 return False;
2452
2453         if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info))
2454                 return False;
2455         if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
2456                 return False;
2457         if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
2458                 return False;
2459
2460         if (ctr->ptr_entries == 0)
2461                 return True;
2462
2463         if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
2464                 return False;
2465
2466         switch (ctr->level) {
2467         case 3: {
2468                 FILE_INFO_3 *info3 = ctr->file.info3;
2469                 int num_entries = ctr->num_entries;
2470                 int i;
2471
2472                 if (UNMARSHALLING(ps) && num_entries) {
2473                         if (!(info3 = PRS_ALLOC_MEM(ps, FILE_INFO_3, num_entries)))
2474                                 return False;
2475                         ctr->file.info3 = info3;
2476                 }
2477
2478                 for (i = 0; i < num_entries; i++) {
2479                         if(!srv_io_file_info3("", &ctr->file.info3[i], ps, depth)) 
2480                                 return False;
2481                 }
2482
2483                 for (i = 0; i < num_entries; i++) {
2484                         if(!srv_io_file_info3_str("", &ctr->file.info3[i], ps, depth))
2485                                 return False;
2486                 }
2487                 break;
2488         }
2489         default:
2490                 DEBUG(5,("%s no file info at switch_value %d\n", tab_depth(5,depth), ctr->level));
2491                 break;
2492         }
2493                         
2494         return True;
2495 }
2496
2497 /*******************************************************************
2498  Inits a SRV_Q_NET_FILE_ENUM structure.
2499 ********************************************************************/
2500
2501 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, 
2502                               const char *srv_name, const char *qual_name, 
2503                               const char *user_name,
2504                               uint32 file_level, SRV_FILE_INFO_CTR *ctr,
2505                               uint32 preferred_len,
2506                               ENUM_HND *hnd)
2507 {
2508         uint32 ptr;
2509
2510         if ( srv_name ) {
2511                 if ( (q_n->servername = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2512                         return;
2513                 init_buf_unistr2(q_n->servername, &ptr, srv_name);
2514         }
2515
2516         if ( qual_name ) {
2517                 if ( (q_n->qualifier = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2518                         return;
2519                 init_buf_unistr2(q_n->qualifier,  &ptr, qual_name);
2520         }
2521
2522         if ( user_name ) {
2523                 if ( (q_n->username = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2524                         return;
2525                 init_buf_unistr2(q_n->username,   &ptr, user_name);
2526         }
2527
2528         q_n->level = q_n->ctr.level = file_level;
2529
2530         q_n->preferred_len = preferred_len;
2531         q_n->ctr.ptr_file_info = 1;
2532         q_n->ctr.num_entries = 0;
2533         q_n->ctr.num_entries2 = 0;
2534
2535         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2536 }
2537
2538 /*******************************************************************
2539  Reads or writes a structure.
2540 ********************************************************************/
2541
2542 bool srv_io_q_net_file_enum(const char *desc, SRV_Q_NET_FILE_ENUM *q_u, prs_struct *ps, int depth)
2543 {
2544         if (q_u == NULL)
2545                 return False;
2546
2547         prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
2548         depth++;
2549
2550         if(!prs_align(ps))
2551                 return False;
2552
2553         if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername,
2554                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
2555                 return False;
2556         if(!prs_align(ps))
2557                 return False;
2558
2559         if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier,
2560                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
2561                 return False;
2562         if(!prs_align(ps))
2563                 return False;
2564
2565         if(!prs_pointer("username", ps, depth, (void*)&q_u->username,
2566                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
2567                 return False;
2568         if(!prs_align(ps))
2569                 return False;
2570
2571         if(!prs_uint32("level", ps, depth, &q_u->level))
2572                 return False;
2573
2574         if (q_u->level != (uint32)-1) {
2575                 if(!srv_io_srv_file_ctr("file_ctr", &q_u->ctr, ps, depth))
2576                         return False;
2577         }
2578
2579         if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len))
2580                 return False;
2581
2582         if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth))
2583                 return False;
2584
2585         return True;
2586 }
2587
2588 /*******************************************************************
2589  Reads or writes a structure.
2590 ********************************************************************/
2591
2592 bool srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
2593 {
2594         if (r_n == NULL)
2595                 return False;
2596
2597         prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
2598         depth++;
2599
2600         if(!prs_align(ps))
2601                 return False;
2602
2603         if(!prs_uint32("level", ps, depth, &r_n->level))
2604                 return False;
2605
2606         if (r_n->level != 0) {
2607                 if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
2608                         return False;
2609         }
2610
2611         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2612                 return False;
2613         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2614                 return False;
2615         if(!prs_werror("status", ps, depth, &r_n->status))
2616                 return False;
2617
2618         return True;
2619 }
2620
2621 /*******************************************************************
2622  Inits a SRV_INFO_100 structure.
2623  ********************************************************************/
2624
2625 void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name)
2626 {
2627         DEBUG(5,("init_srv_info_100\n"));
2628
2629         sv100->platform_id  = platform_id;
2630         init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
2631 }
2632
2633 /*******************************************************************
2634  Reads or writes a SRV_INFO_101 structure.
2635  ********************************************************************/
2636
2637 static bool srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
2638 {
2639         if (sv100 == NULL)
2640                 return False;
2641
2642         prs_debug(ps, depth, desc, "srv_io_info_100");
2643         depth++;
2644
2645         if(!prs_align(ps))
2646                 return False;
2647
2648         if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
2649                 return False;
2650         if(!prs_uint32("ptr_name    ", ps, depth, &sv100->ptr_name))
2651                 return False;
2652
2653         if(!smb_io_unistr2("uni_name    ", &sv100->uni_name, True, ps, depth))
2654                 return False;
2655
2656         return True;
2657 }
2658
2659
2660 /*******************************************************************
2661  Inits a SRV_INFO_101 structure.
2662  ********************************************************************/
2663
2664 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name,
2665                                 uint32 ver_major, uint32 ver_minor,
2666                                 uint32 srv_type, const char *comment)
2667 {
2668         DEBUG(5,("init_srv_info_101\n"));
2669
2670         sv101->platform_id  = platform_id;
2671         init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
2672         sv101->ver_major    = ver_major;
2673         sv101->ver_minor    = ver_minor;
2674         sv101->srv_type     = srv_type;
2675         init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
2676 }
2677
2678 /*******************************************************************
2679  Reads or writes a SRV_INFO_101 structure.
2680  ********************************************************************/
2681
2682 static bool srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
2683 {
2684         if (sv101 == NULL)
2685                 return False;
2686
2687         prs_debug(ps, depth, desc, "srv_io_info_101");
2688         depth++;
2689
2690         if(!prs_align(ps))
2691                 return False;
2692
2693         if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
2694                 return False;
2695         if(!prs_uint32("ptr_name    ", ps, depth, &sv101->ptr_name))
2696                 return False;
2697         if(!prs_uint32("ver_major   ", ps, depth, &sv101->ver_major))
2698                 return False;
2699         if(!prs_uint32("ver_minor   ", ps, depth, &sv101->ver_minor))
2700                 return False;
2701         if(!prs_uint32("srv_type    ", ps, depth, &sv101->srv_type))
2702                 return False;
2703         if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
2704                 return False;
2705
2706         if(!prs_align(ps))
2707                 return False;
2708
2709         if(!smb_io_unistr2("uni_name    ", &sv101->uni_name, True, ps, depth))
2710                 return False;
2711         if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
2712                 return False;
2713
2714         return True;
2715 }
2716
2717 /*******************************************************************
2718  Inits a SRV_INFO_102 structure.
2719  ********************************************************************/
2720
2721 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name,
2722                                 const char *comment, uint32 ver_major, uint32 ver_minor,
2723                                 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
2724                                 uint32 announce, uint32 ann_delta, uint32 licenses,
2725                                 const char *usr_path)
2726 {
2727         DEBUG(5,("init_srv_info_102\n"));
2728
2729         sv102->platform_id  = platform_id;
2730         init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
2731         sv102->ver_major    = ver_major;
2732         sv102->ver_minor    = ver_minor;
2733         sv102->srv_type     = srv_type;
2734         init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
2735
2736         /* same as 101 up to here */
2737
2738         sv102->users        = users;
2739         sv102->disc         = disc;
2740         sv102->hidden       = hidden;
2741         sv102->announce     = announce;
2742         sv102->ann_delta    = ann_delta;
2743         sv102->licenses     = licenses;
2744         init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
2745 }
2746
2747
2748 /*******************************************************************
2749  Reads or writes a SRV_INFO_102 structure.
2750  ********************************************************************/
2751
2752 static bool srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
2753 {
2754         if (sv102 == NULL)
2755                 return False;
2756
2757         prs_debug(ps, depth, desc, "srv_io_info102");
2758         depth++;
2759
2760         if(!prs_align(ps))
2761                 return False;
2762
2763         if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
2764                 return False;
2765         if(!prs_uint32("ptr_name    ", ps, depth, &sv102->ptr_name))
2766                 return False;
2767         if(!prs_uint32("ver_major   ", ps, depth, &sv102->ver_major))
2768                 return False;
2769         if(!prs_uint32("ver_minor   ", ps, depth, &sv102->ver_minor))
2770                 return False;
2771         if(!prs_uint32("srv_type    ", ps, depth, &sv102->srv_type))
2772                 return False;
2773         if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
2774                 return False;
2775
2776         /* same as 101 up to here */
2777
2778         if(!prs_uint32("users       ", ps, depth, &sv102->users))
2779                 return False;
2780         if(!prs_uint32("disc        ", ps, depth, &sv102->disc))
2781                 return False;
2782         if(!prs_uint32("hidden      ", ps, depth, &sv102->hidden))
2783                 return False;
2784         if(!prs_uint32("announce    ", ps, depth, &sv102->announce))
2785                 return False;
2786         if(!prs_uint32("ann_delta   ", ps, depth, &sv102->ann_delta))
2787                 return False;
2788         if(!prs_uint32("licenses    ", ps, depth, &sv102->licenses))
2789                 return False;
2790         if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
2791                 return False;
2792
2793         if(!smb_io_unistr2("uni_name    ", &sv102->uni_name, True, ps, depth))
2794                 return False;
2795         if(!prs_align(ps))
2796                 return False;
2797         if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
2798                 return False;
2799         if(!prs_align(ps))
2800                 return False;
2801         if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
2802                 return False;
2803
2804         return True;
2805 }
2806
2807 /*******************************************************************
2808  Reads or writes a SRV_INFO_102 structure.
2809  ********************************************************************/
2810
2811 static bool srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
2812 {
2813         if (ctr == NULL)
2814                 return False;
2815
2816         prs_debug(ps, depth, desc, "srv_io_info_ctr");
2817         depth++;
2818
2819         if(!prs_align(ps))
2820                 return False;
2821
2822         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2823                 return False;
2824         if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
2825                 return False;
2826
2827         if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
2828                 switch (ctr->switch_value) {
2829                 case 100:
2830                         if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
2831                                 return False;
2832                         break;
2833                 case 101:
2834                         if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
2835                                 return False;
2836                         break;
2837                 case 102:
2838                         if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
2839                                 return False;
2840                         break;
2841                 default:
2842                         DEBUG(5,("%s no server info at switch_value %d\n",
2843                                          tab_depth(5,depth), ctr->switch_value));
2844                         break;
2845                 }
2846                 if(!prs_align(ps))
2847                         return False;
2848         }
2849
2850         return True;
2851 }
2852
2853 /*******************************************************************
2854  Inits a SRV_Q_NET_SRV_GET_INFO structure.
2855  ********************************************************************/
2856
2857 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
2858                                 const char *server_name, uint32 switch_value)
2859 {
2860         DEBUG(5,("init_srv_q_net_srv_get_info\n"));
2861
2862         init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
2863
2864         srv->switch_value = switch_value;
2865 }
2866
2867 /*******************************************************************
2868  Reads or writes a structure.
2869 ********************************************************************/
2870
2871 bool srv_io_q_net_srv_get_info(const char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
2872 {
2873         if (q_n == NULL)
2874                 return False;
2875
2876         prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
2877         depth++;
2878
2879         if(!prs_align(ps))
2880                 return False;
2881
2882         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2883                 return False;
2884         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2885                 return False;
2886
2887         if(!prs_align(ps))
2888                 return False;
2889
2890         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2891                 return False;
2892
2893         return True;
2894 }
2895
2896 /*******************************************************************
2897  Inits a SRV_R_NET_SRV_GET_INFO structure.
2898  ********************************************************************/
2899
2900 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
2901                                 uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status)
2902 {
2903         DEBUG(5,("init_srv_r_net_srv_get_info\n"));
2904
2905         srv->ctr = ctr;
2906
2907         if (W_ERROR_IS_OK(status)) {
2908                 srv->ctr->switch_value = switch_value;
2909                 srv->ctr->ptr_srv_ctr  = 1;
2910         } else {
2911                 srv->ctr->switch_value = 0;
2912                 srv->ctr->ptr_srv_ctr  = 0;
2913         }
2914
2915         srv->status = status;
2916 }
2917
2918 /*******************************************************************
2919  Inits a SRV_R_NET_SRV_SET_INFO structure.
2920  ********************************************************************/
2921
2922 void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
2923                                  uint32 switch_value, WERROR status)
2924 {
2925         DEBUG(5,("init_srv_r_net_srv_set_info\n"));
2926
2927         srv->switch_value = switch_value;
2928         srv->status = status;
2929 }
2930
2931 /*******************************************************************
2932  Reads or writes a structure.
2933 ********************************************************************/
2934
2935 bool srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, 
2936                                prs_struct *ps, int depth)
2937 {
2938         prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
2939         depth++;
2940
2941         if(!prs_align(ps))
2942                 return False;
2943
2944         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2945                 return False;
2946         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2947                 return False;
2948
2949         if(!prs_align(ps))
2950                 return False;
2951
2952         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2953                 return False;
2954
2955         if (UNMARSHALLING(ps)) {
2956                 q_n->ctr = PRS_ALLOC_MEM(ps, SRV_INFO_CTR, 1);
2957
2958                 if (!q_n->ctr)
2959                         return False;
2960         }
2961
2962         if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth))
2963                 return False;
2964
2965         return True;
2966 }
2967
2968 /*******************************************************************
2969  Reads or writes a structure.
2970  ********************************************************************/
2971
2972 bool srv_io_r_net_srv_get_info(const char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
2973 {
2974         if (r_n == NULL)
2975                 return False;
2976
2977         prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
2978         depth++;
2979
2980         if(!prs_align(ps))
2981                 return False;
2982
2983         if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
2984                 return False;
2985
2986         if(!prs_werror("status", ps, depth, &r_n->status))
2987                 return False;
2988
2989         return True;
2990 }
2991
2992 /*******************************************************************
2993  Reads or writes a structure.
2994  ********************************************************************/
2995
2996 bool srv_io_r_net_srv_set_info(const char *desc, SRV_R_NET_SRV_SET_INFO *r_n, 
2997                                prs_struct *ps, int depth)
2998 {
2999         prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info");
3000         depth++;
3001
3002         if(!prs_align(ps))
3003                 return False;
3004
3005         if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value))
3006                 return False;
3007
3008         if(!prs_werror("status", ps, depth, &r_n->status))
3009                 return False;
3010
3011         return True;
3012 }
3013
3014 /*******************************************************************
3015  Reads or writes a structure.
3016  ********************************************************************/
3017
3018 bool srv_io_q_net_remote_tod(const char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
3019 {
3020         if (q_n == NULL)
3021                 return False;
3022
3023         prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
3024         depth++;
3025
3026         if(!prs_align(ps))
3027                 return False;
3028
3029         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
3030                 return False;
3031         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3032                 return False;
3033
3034         return True;
3035 }
3036
3037 /*******************************************************************
3038  Reads or writes a TIME_OF_DAY_INFO structure.
3039  ********************************************************************/
3040
3041 static bool srv_io_time_of_day_info(const char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
3042 {
3043         if (tod == NULL)
3044                 return False;
3045
3046         prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
3047         depth++;
3048
3049         if(!prs_align(ps))
3050                 return False;
3051         
3052         if(!prs_uint32("elapsedt   ", ps, depth, &tod->elapsedt))
3053                 return False;
3054         if(!prs_uint32("msecs      ", ps, depth, &tod->msecs))
3055                 return False;
3056         if(!prs_uint32("hours      ", ps, depth, &tod->hours))
3057                 return False;
3058         if(!prs_uint32("mins       ", ps, depth, &tod->mins))
3059                 return False;
3060         if(!prs_uint32("secs       ", ps, depth, &tod->secs))
3061                 return False;
3062         if(!prs_uint32("hunds      ", ps, depth, &tod->hunds))
3063                 return False;
3064         if(!prs_uint32("timezone   ", ps, depth, &tod->zone))
3065                 return False;
3066         if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
3067                 return False;
3068         if(!prs_uint32("day        ", ps, depth, &tod->day))
3069                 return False;
3070         if(!prs_uint32("month      ", ps, depth, &tod->month))
3071                 return False;
3072         if(!prs_uint32("year       ", ps, depth, &tod->year))
3073                 return False;
3074         if(!prs_uint32("weekday    ", ps, depth, &tod->weekday))
3075                 return False;
3076
3077         return True;
3078 }
3079
3080 /*******************************************************************
3081  Inits a TIME_OF_DAY_INFO structure.
3082  ********************************************************************/
3083
3084 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
3085                            uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
3086                            uint32 zone, uint32 tintervals, uint32 day,
3087                            uint32 month, uint32 year, uint32 weekday)
3088 {
3089         DEBUG(5,("init_time_of_day_info\n"));
3090
3091         tod->elapsedt   = elapsedt;
3092         tod->msecs      = msecs;
3093         tod->hours      = hours;
3094         tod->mins       = mins;
3095         tod->secs       = secs;
3096         tod->hunds      = hunds;
3097         tod->zone       = zone;
3098         tod->tintervals = tintervals;
3099         tod->day        = day;
3100         tod->month      = month;
3101         tod->year       = year;
3102         tod->weekday    = weekday;
3103 }
3104
3105
3106 /*******************************************************************
3107  Reads or writes a structure.
3108  ********************************************************************/
3109
3110 bool srv_io_r_net_remote_tod(const char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
3111 {
3112         if (r_n == NULL)
3113                 return False;
3114
3115         prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
3116         depth++;
3117
3118         if(!prs_align(ps))
3119                 return False;
3120         
3121         if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
3122                 return False;
3123
3124         if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
3125                 return False;
3126
3127         if(!prs_werror("status", ps, depth, &r_n->status))
3128                 return False;
3129
3130         return True;
3131 }
3132
3133 /*******************************************************************
3134  initialises a structure.
3135  ********************************************************************/
3136
3137 bool init_srv_q_net_disk_enum(SRV_Q_NET_DISK_ENUM *q_n,
3138                               const char *srv_name,
3139                               uint32 preferred_len,
3140                               ENUM_HND *enum_hnd
3141         ) 
3142 {
3143   
3144
3145         DEBUG(5,("init_srv_q_net_srv_disk_enum\n"));
3146
3147         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
3148
3149         q_n->disk_enum_ctr.level = 0;
3150         q_n->disk_enum_ctr.disk_info_ptr   = 0;
3151   
3152         q_n->preferred_len = preferred_len;
3153         memcpy(&q_n->enum_hnd, enum_hnd, sizeof(*enum_hnd));
3154
3155         return True;
3156 }
3157
3158 /*******************************************************************
3159  Reads or writes a structure.
3160  ********************************************************************/
3161
3162 bool srv_io_q_net_disk_enum(const char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth)
3163 {
3164         if (q_n == NULL)
3165                 return False;
3166
3167         prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum");
3168         depth++;
3169
3170         if(!prs_align(ps))
3171                 return False;
3172
3173         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3174                 return False;
3175
3176         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3177                 return False;
3178
3179         if(!prs_align(ps))
3180                 return False;
3181
3182         if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level))
3183                 return False;
3184
3185         if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read))
3186                 return False;
3187
3188         if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr))
3189                 return False;
3190
3191         if(!prs_align(ps))
3192                 return False;
3193
3194         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
3195                 return False;
3196         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
3197                 return False;
3198
3199         return True;
3200 }
3201
3202 /*******************************************************************
3203  Reads or writes a structure.
3204  ********************************************************************/
3205
3206 bool srv_io_r_net_disk_enum(const char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth)
3207 {
3208
3209         unsigned int i;
3210         uint32 entries_read, entries_read2, entries_read3;
3211
3212         if (r_n == NULL)
3213                 return False;
3214
3215         prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum");
3216         depth++;
3217
3218         entries_read = entries_read2 = entries_read3 = r_n->disk_enum_ctr.entries_read;
3219
3220         if(!prs_align(ps))
3221                 return False;
3222
3223         if(!prs_uint32("entries_read", ps, depth, &entries_read))
3224                 return False;
3225         if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr))
3226                 return False;
3227
3228         /*this may be max, unknown, actual?*/
3229
3230         if(!prs_uint32("max_elements", ps, depth, &entries_read2))
3231                 return False;
3232         if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown))
3233                 return False;
3234         if(!prs_uint32("actual_elements", ps, depth, &entries_read3))
3235                 return False;
3236
3237         r_n->disk_enum_ctr.entries_read = entries_read3;
3238
3239         if(UNMARSHALLING(ps) && entries_read3) {
3240
3241                 DISK_INFO *dinfo;
3242
3243                 if(!(dinfo = PRS_ALLOC_MEM(ps, DISK_INFO, entries_read3)))
3244                         return False;
3245                 r_n->disk_enum_ctr.disk_info = dinfo;
3246         }
3247
3248         for(i=0; i < entries_read3; i++) {
3249
3250                 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown))
3251                         return False;
3252    
3253                 if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth))
3254                         return False;
3255
3256                 if(!prs_align(ps))
3257                         return False;
3258         }
3259
3260         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
3261                 return False;
3262
3263         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
3264                 return False;
3265
3266         if(!prs_werror("status", ps, depth, &r_n->status))
3267                 return False;
3268
3269         return True;
3270 }
3271
3272 /*******************************************************************
3273  Reads or writes a structure.
3274  ********************************************************************/
3275
3276 bool srv_io_q_net_name_validate(const char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth)
3277 {
3278         if (q_n == NULL)
3279                 return False;
3280
3281         prs_debug(ps, depth, desc, "srv_io_q_net_name_validate");
3282         depth++;
3283
3284         if(!prs_align(ps))
3285                 return False;
3286
3287         if(!prs_pointer("servername", ps, depth, (void*)&q_n->servername,
3288                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
3289                 return False;
3290
3291         if(!prs_align(ps))
3292                 return False;
3293
3294         if(!smb_io_unistr2("", &q_n->sharename, True, ps, depth))
3295                 return False;
3296
3297         if(!prs_align(ps))
3298                 return False;
3299
3300         if(!prs_uint32("type", ps, depth, &q_n->type))
3301                 return False;
3302
3303         if(!prs_uint32("flags", ps, depth, &q_n->flags))
3304                 return False;
3305
3306         return True;
3307 }
3308
3309 /*******************************************************************
3310  Reads or writes a structure.
3311  ********************************************************************/
3312
3313 bool srv_io_r_net_name_validate(const char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth)
3314 {
3315         if (r_n == NULL)
3316                 return False;
3317
3318         prs_debug(ps, depth, desc, "srv_io_r_net_name_validate");
3319         depth++;
3320
3321         if(!prs_align(ps))
3322                 return False;
3323
3324         if(!prs_werror("status", ps, depth, &r_n->status))
3325                 return False;
3326
3327         return True;
3328 }
3329
3330 /*******************************************************************
3331  Reads or writes a structure.
3332 ********************************************************************/
3333
3334 bool srv_io_q_net_file_query_secdesc(const char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth)
3335 {
3336         if (q_n == NULL)
3337                 return False;
3338
3339         prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc");
3340         depth++;
3341
3342         if(!prs_align(ps))
3343                 return False;
3344
3345         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3346                 return False;
3347
3348         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3349                 return False;
3350
3351         if(!prs_align(ps))
3352                 return False;
3353
3354         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3355                 return False;
3356
3357         if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3358                 return False;
3359
3360         if(!prs_align(ps))
3361                 return False;
3362
3363         if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3364                 return False;
3365
3366         if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1))
3367                 return False;
3368
3369         if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2))
3370                 return False;
3371
3372         if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3))
3373                 return False;
3374
3375         return True;
3376 }
3377
3378 /*******************************************************************
3379  Reads or writes a structure.
3380 ********************************************************************/
3381
3382 bool srv_io_r_net_file_query_secdesc(const char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth)
3383 {
3384         if (r_n == NULL)
3385                 return False;
3386
3387         prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc");
3388         depth++;
3389
3390         if(!prs_align(ps))
3391                 return False;
3392
3393         if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response))
3394                 return False;
3395
3396         if(!prs_uint32("size_response", ps, depth, &r_n->size_response))
3397                 return False;
3398
3399         if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc))
3400                 return False;
3401
3402         if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc))
3403                 return False;
3404
3405         if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth))
3406                 return False;
3407
3408         if(!prs_align(ps))
3409                 return False;
3410
3411         if(!prs_werror("status", ps, depth, &r_n->status))
3412                 return False;
3413
3414         return True;
3415 }
3416
3417 /*******************************************************************
3418  Reads or writes a structure.
3419 ********************************************************************/
3420
3421 bool srv_io_q_net_file_set_secdesc(const char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth)
3422 {
3423         if (q_n == NULL)
3424                 return False;
3425
3426         prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc");
3427         depth++;
3428
3429         if(!prs_align(ps))
3430                 return False;
3431
3432         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3433                 return False;
3434
3435         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3436                 return False;
3437
3438         if(!prs_align(ps))
3439                 return False;
3440
3441         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3442                 return False;
3443
3444         if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3445                 return False;
3446
3447         if(!prs_align(ps))
3448                 return False;
3449
3450         if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3451                 return False;
3452
3453         if(!prs_align(ps))
3454                 return False;
3455
3456         if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info))
3457                 return False;
3458
3459         if(!prs_uint32("size_set", ps, depth, &q_n->size_set))
3460                 return False;
3461
3462         if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc))
3463                 return False;
3464
3465         if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc))
3466                 return False;
3467
3468         if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth))
3469                 return False;
3470
3471         return True;
3472 }
3473
3474 /*******************************************************************
3475  Reads or writes a structure.
3476 ********************************************************************/
3477
3478 bool srv_io_r_net_file_set_secdesc(const char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth)
3479 {
3480         if (r_n == NULL)
3481                 return False;
3482
3483         prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc");
3484         depth++;
3485
3486         if(!prs_align(ps))
3487                 return False;
3488
3489         if(!prs_werror("status", ps, depth, &r_n->status))
3490                 return False;
3491
3492         return True;
3493 }
3494
3495 /*******************************************************************
3496  Inits a structure
3497 ********************************************************************/
3498
3499 void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, const char *server)
3500 {
3501         q_u->ptr_srv_name = 1;
3502         init_unistr2(&q_u->uni_srv_name, server, UNI_STR_TERMINATE);
3503 }
3504