[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
[sfrench/samba-autobuild/.git] / source3 / rpc_parse / parse_srv.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997,
7  *  Copyright (C) Jeremy Allison                    1999,
8  *  Copyright (C) Nigel Williams                    2001,
9  *  Copyright (C) Jim McDonough (jmcd@us.ibm.com)   2002.
10  *  Copyright (C) Gerald (Jerry) Carter             2006.
11  *  
12  *  This program is free software; you can redistribute it and/or modify
13  *  it under the terms of the GNU General Public License as published by
14  *  the Free Software Foundation; either version 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 = sec_desc_size(sh502->sd);
511
512                         prs_set_offset(ps, old_offset + sh502->reserved);
513                 }
514
515                 prs_align(ps);
516
517                 if(MARSHALLING(ps)) {
518
519                         sh502->ptrs->reserved = sh502->reserved = prs_offset(ps) - old_offset;
520                 }
521             
522                 if(!prs_uint32_post("reserved ", ps, depth, 
523                                     &sh502->reserved, reserved_offset, sh502->reserved))
524                         return False;
525                 if(!prs_uint32_post("reserved ", ps, depth, 
526                                     &sh502->ptrs->reserved, sh502->ptrs->reserved_offset, sh502->ptrs->reserved))
527                         return False;
528         }
529
530         return True;
531 }
532
533 /*******************************************************************
534  Inits a SH_INFO_1004_STR structure
535 ********************************************************************/
536
537 void init_srv_share_info1004_str(SH_INFO_1004_STR *sh1004, const char *remark)
538 {
539         DEBUG(5,("init_srv_share_info1004_str\n"));
540
541         init_unistr2(&sh1004->uni_remark, remark, UNI_STR_TERMINATE);
542 }
543
544 /*******************************************************************
545  Reads or writes a structure.
546 ********************************************************************/
547
548 static BOOL srv_io_share_info1004_str(const char *desc, SH_INFO_1004_STR *sh1004, prs_struct *ps, int depth)
549 {
550         if (sh1004 == NULL)
551                 return False;
552
553         prs_debug(ps, depth, desc, "srv_io_share_info1004_str");
554         depth++;
555
556         if(!prs_align(ps))
557                 return False;
558         if(sh1004->ptrs->ptr_remark)
559                 if(!smb_io_unistr2("", &sh1004->uni_remark, True, ps, depth))
560                         return False;
561
562         return True;
563 }
564
565 /*******************************************************************
566  makes a SH_INFO_1004 structure
567 ********************************************************************/
568
569 void init_srv_share_info1004(SH_INFO_1004 *sh1004, const char *remark)
570 {
571         DEBUG(5,("init_srv_share_info1004: %s\n", remark));
572
573         sh1004->ptr_remark = (remark != NULL) ? 1 : 0;
574 }
575
576 /*******************************************************************
577  Reads or writes a structure.
578 ********************************************************************/
579
580 static BOOL srv_io_share_info1004(const char *desc, SH_INFO_1004 *sh1004, prs_struct *ps, int depth)
581 {
582         if (sh1004 == NULL)
583                 return False;
584
585         prs_debug(ps, depth, desc, "srv_io_share_info1004");
586         depth++;
587
588         if(!prs_align(ps))
589                 return False;
590
591         if(!prs_uint32("ptr_remark", ps, depth, &sh1004->ptr_remark))
592                 return False;
593
594         return True;
595 }
596
597 /*******************************************************************
598  Reads or writes a structure.
599 ********************************************************************/
600
601 static BOOL srv_io_share_info1005(const char* desc, SRV_SHARE_INFO_1005* sh1005, prs_struct* ps, int depth)
602 {
603         if(sh1005 == NULL)
604                 return False;
605
606         prs_debug(ps, depth, desc, "srv_io_share_info1005");
607                 depth++;
608
609         if(!prs_align(ps))
610                 return False;
611
612         if(!prs_uint32("share_info_flags", ps, depth, 
613                        &sh1005->share_info_flags))
614                 return False;
615
616         return True;
617 }   
618
619 /*******************************************************************
620  Reads or writes a structure.
621 ********************************************************************/
622
623 static BOOL srv_io_share_info1006(const char* desc, SRV_SHARE_INFO_1006* sh1006, prs_struct* ps, int depth)
624 {
625         if(sh1006 == NULL)
626                 return False;
627
628         prs_debug(ps, depth, desc, "srv_io_share_info1006");
629         depth++;
630
631         if(!prs_align(ps))
632                 return False;
633
634         if(!prs_uint32("max uses     ", ps, depth, &sh1006->max_uses))
635                 return False;
636
637         return True;
638 }   
639
640 /*******************************************************************
641  Inits a SH_INFO_1007_STR structure
642 ********************************************************************/
643
644 void init_srv_share_info1007_str(SH_INFO_1007_STR *sh1007, const char *alternate_directory_name)
645 {
646         DEBUG(5,("init_srv_share_info1007_str\n"));
647
648         init_unistr2(&sh1007->uni_AlternateDirectoryName, alternate_directory_name, UNI_STR_TERMINATE);
649 }
650
651 /*******************************************************************
652  Reads or writes a structure.
653 ********************************************************************/
654
655 static BOOL srv_io_share_info1007_str(const char *desc, SH_INFO_1007_STR *sh1007, prs_struct *ps, int depth)
656 {
657         if (sh1007 == NULL)
658                 return False;
659
660         prs_debug(ps, depth, desc, "srv_io_share_info1007_str");
661         depth++;
662
663         if(!prs_align(ps))
664                 return False;
665         if(sh1007->ptrs->ptr_AlternateDirectoryName)
666                 if(!smb_io_unistr2("", &sh1007->uni_AlternateDirectoryName, True, ps, depth))
667                         return False;
668
669         return True;
670 }
671
672 /*******************************************************************
673  makes a SH_INFO_1007 structure
674 ********************************************************************/
675
676 void init_srv_share_info1007(SH_INFO_1007 *sh1007, uint32 flags, const char *alternate_directory_name)
677 {
678         DEBUG(5,("init_srv_share_info1007: %s\n", alternate_directory_name));
679
680         sh1007->flags                      = flags;
681         sh1007->ptr_AlternateDirectoryName = (alternate_directory_name != NULL) ? 1 : 0;
682 }
683
684 /*******************************************************************
685  Reads or writes a structure.
686 ********************************************************************/
687
688 static BOOL srv_io_share_info1007(const char *desc, SH_INFO_1007 *sh1007, prs_struct *ps, int depth)
689 {
690         if (sh1007 == NULL)
691                 return False;
692
693         prs_debug(ps, depth, desc, "srv_io_share_info1007");
694         depth++;
695
696         if(!prs_align(ps))
697                 return False;
698
699         if(!prs_uint32("flags      ", ps, depth, &sh1007->flags))
700                 return False;
701         if(!prs_uint32("ptr_Alter..", ps, depth, &sh1007->ptr_AlternateDirectoryName))
702                 return False;
703
704         return True;
705 }
706
707 /*******************************************************************
708  Reads or writes a structure.
709 ********************************************************************/
710
711 static BOOL srv_io_share_info1501(const char* desc, SRV_SHARE_INFO_1501* sh1501,
712                                   prs_struct* ps, int depth)
713 {
714         if(sh1501 == NULL)
715                 return False;
716
717         prs_debug(ps, depth, desc, "srv_io_share_info1501");
718         depth++;
719
720         if(!prs_align(ps))
721                 return False;
722
723         if (!sec_io_desc_buf(desc, &sh1501->sdb, ps, depth))
724                 return False;
725
726         return True;
727 }   
728
729 /*******************************************************************
730  Reads or writes a structure.
731 ********************************************************************/
732
733 static BOOL srv_io_srv_share_ctr(const char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
734 {
735         if (ctr == NULL)
736                 return False;
737
738         prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
739         depth++;
740
741         if (UNMARSHALLING(ps)) {
742                 memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR));
743         }
744
745         if(!prs_align(ps))
746                 return False;
747
748         if(!prs_uint32("info_level", ps, depth, &ctr->info_level))
749                 return False;
750
751         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
752                 return False;
753         if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info))
754                 return False;
755
756         if (ctr->ptr_share_info == 0)
757                 return True;
758
759         if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
760                 return False;
761         if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
762                 return False;
763
764         if (ctr->ptr_entries == 0) {
765                 if (ctr->num_entries == 0)
766                         return True;
767                 else
768                         return False;
769         }
770
771         if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
772                 return False;
773
774         if (ctr->num_entries2 != ctr->num_entries)
775                 return False;
776
777         switch (ctr->switch_value) {
778
779         case 0:
780         {
781                 SRV_SHARE_INFO_0 *info0 = ctr->share.info0;
782                 int num_entries = ctr->num_entries;
783                 int i;
784
785                 if (UNMARSHALLING(ps) && num_entries) {
786                         if (!(info0 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_0, num_entries)))
787                                 return False;
788                         ctr->share.info0 = info0;
789                 }
790
791                 for (i = 0; i < num_entries; i++) {
792                         if(!srv_io_share_info0("", &info0[i].info_0, ps, depth))
793                                 return False;
794                 }
795
796                 for (i = 0; i < num_entries; i++) {
797                         info0[i].info_0_str.ptrs = &info0[i].info_0;
798                         if(!srv_io_share_info0_str("", &info0[i].info_0_str, ps, depth))
799                                 return False;
800                 }
801
802                 break;
803         }
804
805         case 1:
806         {
807                 SRV_SHARE_INFO_1 *info1 = ctr->share.info1;
808                 int num_entries = ctr->num_entries;
809                 int i;
810
811                 if (UNMARSHALLING(ps) && num_entries) {
812                         if (!(info1 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_1, num_entries)))
813                                 return False;
814                         ctr->share.info1 = info1;
815                 }
816
817                 for (i = 0; i < num_entries; i++) {
818                         if(!srv_io_share_info1("", &info1[i].info_1, ps, depth))
819                                 return False;
820                 }
821
822                 for (i = 0; i < num_entries; i++) {
823                         info1[i].info_1_str.ptrs = &info1[i].info_1;
824                         if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth))
825                                 return False;
826                 }
827
828                 break;
829         }
830
831         case 2:
832         {
833                 SRV_SHARE_INFO_2 *info2 = ctr->share.info2;
834                 int num_entries = ctr->num_entries;
835                 int i;
836
837                 if (UNMARSHALLING(ps) && num_entries) {
838                         if (!(info2 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_2,num_entries)))
839                                 return False;
840                         ctr->share.info2 = info2;
841                 }
842
843                 for (i = 0; i < num_entries; i++) {
844                         if(!srv_io_share_info2("", &info2[i].info_2, ps, depth))
845                                 return False;
846                 }
847
848                 for (i = 0; i < num_entries; i++) {
849                         if(!srv_io_share_info2_str("", &info2[i].info_2, &info2[i].info_2_str, ps, depth))
850                                 return False;
851                 }
852
853                 break;
854         }
855
856         case 501:
857         {
858                 SRV_SHARE_INFO_501 *info501 = ctr->share.info501;
859                 int num_entries = ctr->num_entries;
860                 int i;
861
862                 if (UNMARSHALLING(ps) && num_entries) {
863                         if (!(info501 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_501, num_entries)))
864                                 return False;
865                         ctr->share.info501 = info501;
866                 }
867
868                 for (i = 0; i < num_entries; i++) {
869                         if (!srv_io_share_info501("", &info501[i].info_501, ps, depth))
870                                 return False;
871                 }
872
873                 for (i = 0; i < num_entries; i++) {
874                         if (!srv_io_share_info501_str("", &info501[i].info_501_str, ps, depth))
875                                 return False;
876                 }
877
878                 break;
879         }
880
881         case 502:
882         {
883                 SRV_SHARE_INFO_502 *info502 = ctr->share.info502;
884                 int num_entries = ctr->num_entries;
885                 int i;
886
887                 if (UNMARSHALLING(ps) && num_entries) {
888                         if (!(info502 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_502,num_entries)))
889                                 return False;
890                         ctr->share.info502 = info502;
891                 }
892
893                 for (i = 0; i < num_entries; i++) {
894                         if(!srv_io_share_info502("", &info502[i].info_502, ps, depth))
895                                 return False;
896         }
897                 
898                 for (i = 0; i < num_entries; i++) {
899                         info502[i].info_502_str.ptrs = &info502[i].info_502;
900                         if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth))
901                                 return False;
902                 }
903
904                 break;
905         }
906
907         case 1004:
908         {
909                 SRV_SHARE_INFO_1004 *info1004 = ctr->share.info1004;
910                 int num_entries = ctr->num_entries;
911                 int i;
912
913                 if (UNMARSHALLING(ps) && num_entries) {
914                         if (!(info1004 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1004,num_entries)))
915                                 return False;
916                         ctr->share.info1004 = info1004;
917                 }
918
919                 for (i = 0; i < num_entries; i++) {
920                         if(!srv_io_share_info1004("", &info1004[i].info_1004, ps, depth))
921                                 return False;
922                 }
923
924                 for (i = 0; i < num_entries; i++) {
925                         info1004[i].info_1004_str.ptrs = &info1004[i].info_1004;
926                         if(!srv_io_share_info1004_str("", &info1004[i].info_1004_str, ps, depth))
927                                 return False;
928                 }
929
930                 break;
931         }
932
933         case 1005:
934         {
935                 SRV_SHARE_INFO_1005 *info1005 = ctr->share.info1005;
936                 int num_entries = ctr->num_entries;
937                 int i;
938
939                 if (UNMARSHALLING(ps) && num_entries) {
940                         if (!(info1005 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1005,num_entries)))
941                                 return False;
942                         ctr->share.info1005 = info1005;
943                 }
944
945                 for (i = 0; i < num_entries; i++) {
946                         if(!srv_io_share_info1005("", &info1005[i], ps, depth))
947                                 return False;
948                 }
949
950                 break;
951         }
952
953         case 1006:
954         {
955                 SRV_SHARE_INFO_1006 *info1006 = ctr->share.info1006;
956                 int num_entries = ctr->num_entries;
957                 int i;
958
959                 if (UNMARSHALLING(ps) && num_entries) {
960                         if (!(info1006 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1006,num_entries)))
961                                 return False;
962                         ctr->share.info1006 = info1006;
963                 }
964
965                 for (i = 0; i < num_entries; i++) {
966                         if(!srv_io_share_info1006("", &info1006[i], ps, depth))
967                                 return False;
968                 }
969
970                 break;
971         }
972
973         case 1007:
974         {
975                 SRV_SHARE_INFO_1007 *info1007 = ctr->share.info1007;
976                 int num_entries = ctr->num_entries;
977                 int i;
978
979                 if (UNMARSHALLING(ps) && num_entries) {
980                         if (!(info1007 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1007,num_entries)))
981                                 return False;
982                         ctr->share.info1007 = info1007;
983                 }
984
985                 for (i = 0; i < num_entries; i++) {
986                         if(!srv_io_share_info1007("", &info1007[i].info_1007, ps, depth))
987                                 return False;
988                 }
989
990                 for (i = 0; i < num_entries; i++) {
991                         info1007[i].info_1007_str.ptrs = &info1007[i].info_1007;
992                         if(!srv_io_share_info1007_str("", &info1007[i].info_1007_str, ps, depth))
993                                 return False;
994                 }
995
996                 break;
997         }
998
999         case 1501:
1000         {
1001                 SRV_SHARE_INFO_1501 *info1501 = ctr->share.info1501;
1002                 int num_entries = ctr->num_entries;
1003                 int i;
1004
1005                 if (UNMARSHALLING(ps) && num_entries) {
1006                         if (!(info1501 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1501,num_entries)))
1007                                 return False;
1008                         ctr->share.info1501 = info1501;
1009                 }
1010
1011                 for (i = 0; i < num_entries; i++) {
1012                         if(!srv_io_share_info1501("", &info1501[i], ps, depth))
1013                                 return False;
1014                 }
1015
1016                 break;
1017         }
1018
1019         default:
1020                 DEBUG(5,("%s no share info at switch_value %d\n",
1021                          tab_depth(depth), ctr->switch_value));
1022                 break;
1023         }
1024
1025         return True;
1026 }
1027
1028 /*******************************************************************
1029  Inits a SRV_Q_NET_SHARE_ENUM structure.
1030 ********************************************************************/
1031
1032 void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, 
1033                                 const char *srv_name, uint32 info_level,
1034                                 uint32 preferred_len, ENUM_HND *hnd)
1035 {
1036
1037         DEBUG(5,("init_q_net_share_enum\n"));
1038
1039         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1040
1041         q_n->ctr.info_level = q_n->ctr.switch_value = info_level;
1042         q_n->ctr.ptr_share_info = 1;
1043         q_n->ctr.num_entries  = 0;
1044         q_n->ctr.ptr_entries  = 0;
1045         q_n->ctr.num_entries2 = 0;
1046         q_n->preferred_len = preferred_len;
1047
1048         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1049 }
1050
1051 /*******************************************************************
1052  Reads or writes a structure.
1053 ********************************************************************/
1054
1055 BOOL srv_io_q_net_share_enum(const char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
1056 {
1057         if (q_n == NULL)
1058                 return False;
1059
1060         prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
1061         depth++;
1062
1063         if(!prs_align(ps))
1064                 return False;
1065
1066         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1067                 return False;
1068         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1069                 return False;
1070
1071         if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth))
1072                 return False;
1073
1074         if(!prs_align(ps))
1075                 return False;
1076
1077         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1078                 return False;
1079
1080         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1081                 return False;
1082
1083         return True;
1084 }
1085
1086 /*******************************************************************
1087  Reads or writes a structure.
1088 ********************************************************************/
1089
1090 BOOL srv_io_r_net_share_enum(const char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
1091 {
1092         if (r_n == NULL)
1093                 return False;
1094
1095         prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
1096         depth++;
1097
1098         if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth))
1099                 return False;
1100
1101         if(!prs_align(ps))
1102                 return False;
1103
1104         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1105                 return False;
1106
1107         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1108                 return False;
1109
1110         if(!prs_werror("status", ps, depth, &r_n->status))
1111                 return False;
1112
1113         return True;
1114 }
1115
1116 /*******************************************************************
1117  initialises a structure.
1118 ********************************************************************/
1119
1120 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)
1121 {
1122
1123         uint32 ptr_share_name;
1124
1125         DEBUG(5,("init_srv_q_net_share_get_info\n"));
1126
1127         init_buf_unistr2(&q_n->uni_srv_name,   &q_n->ptr_srv_name, srv_name);
1128         init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name,    share_name);
1129
1130         q_n->info_level = info_level;
1131
1132         return True;
1133 }
1134
1135 /*******************************************************************
1136  Reads or writes a structure.
1137 ********************************************************************/
1138
1139 BOOL srv_io_q_net_share_get_info(const char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
1140 {
1141         if (q_n == NULL)
1142                 return False;
1143
1144         prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
1145         depth++;
1146
1147         if(!prs_align(ps))
1148                 return False;
1149
1150         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1151                 return False;
1152         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1153                 return False;
1154
1155         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1156                 return False;
1157
1158         if(!prs_align(ps))
1159                 return False;
1160
1161         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1162                 return False;
1163
1164         return True;
1165 }
1166
1167 /*******************************************************************
1168  Reads or writes a structure.
1169 ********************************************************************/
1170
1171 static BOOL srv_io_srv_share_info(const char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n)
1172 {
1173         if (r_n == NULL)
1174                 return False;
1175
1176         prs_debug(ps, depth, desc, "srv_io_srv_share_info");
1177         depth++;
1178
1179         if(!prs_align(ps))
1180                 return False;
1181
1182         if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
1183                 return False;
1184
1185         if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
1186                 return False;
1187
1188         if (r_n->ptr_share_ctr != 0) {
1189                 switch (r_n->switch_value) {
1190                 case 0:
1191                         if(!srv_io_share_info0("", &r_n->share.info0.info_0, ps, depth))
1192                                 return False;
1193
1194                         /* allow access to pointers in the str part. */
1195                         r_n->share.info0.info_0_str.ptrs = &r_n->share.info0.info_0;
1196
1197                         if(!srv_io_share_info0_str("", &r_n->share.info0.info_0_str, ps, depth))
1198                                 return False;
1199
1200                         break;
1201                 case 1:
1202                         if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
1203                                 return False;
1204
1205                         /* allow access to pointers in the str part. */
1206                         r_n->share.info1.info_1_str.ptrs = &r_n->share.info1.info_1;
1207
1208                         if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
1209                                 return False;
1210
1211                         break;
1212                 case 2:
1213                         if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
1214                                 return False;
1215
1216                         if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth))
1217                                 return False;
1218
1219                         break;
1220                 case 501:
1221                         if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth))
1222                                 return False;
1223                         if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth))
1224                                 return False;
1225                         break;
1226
1227                 case 502:
1228                         if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth))
1229                                 return False;
1230
1231                         /* allow access to pointers in the str part. */
1232                         r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502;
1233
1234                         if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth))
1235                                 return False;
1236                         break;
1237                 case 1004:
1238                         if(!srv_io_share_info1004("", &r_n->share.info1004.info_1004, ps, depth))
1239                                 return False;
1240
1241                         /* allow access to pointers in the str part. */
1242                         r_n->share.info1004.info_1004_str.ptrs = &r_n->share.info1004.info_1004;
1243
1244                         if(!srv_io_share_info1004_str("", &r_n->share.info1004.info_1004_str, ps, depth))
1245                                 return False;
1246                         break;
1247                 case 1005:
1248                         if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth))
1249                                 return False;           
1250                         break;
1251                 case 1006:
1252                         if(!srv_io_share_info1006("", &r_n->share.info1006, ps, depth))
1253                                 return False;           
1254                         break;
1255                 case 1007:
1256                         if(!srv_io_share_info1007("", &r_n->share.info1007.info_1007, ps, depth))
1257                                 return False;
1258
1259                         /* allow access to pointers in the str part. */
1260                         r_n->share.info1007.info_1007_str.ptrs = &r_n->share.info1007.info_1007;
1261
1262                         if(!srv_io_share_info1007_str("", &r_n->share.info1007.info_1007_str, ps, depth))
1263                                 return False;
1264                         break;
1265                 case 1501:
1266                         if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth))
1267                                 return False;
1268                 default:
1269                         DEBUG(5,("%s no share info at switch_value %d\n",
1270                                  tab_depth(depth), r_n->switch_value));
1271                         break;
1272                 }
1273         }
1274
1275         return True;
1276 }
1277
1278 /*******************************************************************
1279  Reads or writes a structure.
1280 ********************************************************************/
1281
1282 BOOL srv_io_r_net_share_get_info(const char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
1283 {
1284         if (r_n == NULL)
1285                 return False;
1286
1287         prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
1288         depth++;
1289
1290         if(!prs_align(ps))
1291                 return False;
1292
1293         if(!srv_io_srv_share_info("info  ", ps, depth, &r_n->info))
1294                 return False;
1295
1296         if(!prs_align(ps))
1297                 return False;
1298
1299         if(!prs_werror("status", ps, depth, &r_n->status))
1300                 return False;
1301
1302         return True;
1303 }
1304
1305 /*******************************************************************
1306  intialises a structure.
1307 ********************************************************************/
1308
1309 BOOL init_srv_q_net_share_set_info(SRV_Q_NET_SHARE_SET_INFO *q_n, 
1310                                    const char *srv_name, 
1311                                    const char *share_name, 
1312                                    uint32 info_level, 
1313                                    const SRV_SHARE_INFO *info) 
1314 {
1315
1316         uint32 ptr_share_name;
1317
1318         DEBUG(5,("init_srv_q_net_share_set_info\n"));
1319
1320         init_buf_unistr2(&q_n->uni_srv_name,   &q_n->ptr_srv_name, srv_name);
1321         init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name,    share_name);
1322
1323         q_n->info_level = info_level;
1324   
1325         q_n->info = *info;
1326
1327         q_n->ptr_parm_error = 1;
1328         q_n->parm_error     = 0;
1329
1330         return True;
1331 }
1332
1333 /*******************************************************************
1334  Reads or writes a structure.
1335 ********************************************************************/
1336
1337 BOOL srv_io_q_net_share_set_info(const char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
1338 {
1339         if (q_n == NULL)
1340                 return False;
1341
1342         prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info");
1343         depth++;
1344
1345         if(!prs_align(ps))
1346                 return False;
1347
1348         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1349                 return False;
1350         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1351                 return False;
1352
1353         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1354                 return False;
1355
1356         if(!prs_align(ps))
1357                 return False;
1358
1359         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1360                 return False;
1361
1362         if(!prs_align(ps))
1363                 return False;
1364
1365         if(!srv_io_srv_share_info("info  ", ps, depth, &q_n->info))
1366                 return False;
1367
1368         if(!prs_align(ps))
1369                 return False;
1370         if(!prs_uint32("ptr_parm_error", ps, depth, &q_n->ptr_parm_error))
1371                 return False;
1372         if(q_n->ptr_parm_error!=0) {
1373                 if(!prs_uint32("parm_error", ps, depth, &q_n->parm_error))
1374                         return False;
1375         }
1376
1377         return True;
1378 }
1379
1380 /*******************************************************************
1381  Reads or writes a structure.
1382 ********************************************************************/
1383
1384 BOOL srv_io_r_net_share_set_info(const char *desc, SRV_R_NET_SHARE_SET_INFO *r_n, prs_struct *ps, int depth)
1385 {
1386         if (r_n == NULL)
1387                 return False;
1388
1389         prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info");
1390         depth++;
1391
1392         if(!prs_align(ps))
1393                 return False;
1394
1395         if(!prs_uint32("ptr_parm_error  ", ps, depth, &r_n->ptr_parm_error))
1396                 return False;
1397
1398         if(r_n->ptr_parm_error) {
1399
1400                 if(!prs_uint32("parm_error  ", ps, depth, &r_n->parm_error))
1401                         return False;
1402         }
1403
1404         if(!prs_werror("status", ps, depth, &r_n->status))
1405                 return False;
1406
1407         return True;
1408 }       
1409
1410
1411 /*******************************************************************
1412  Reads or writes a structure.
1413 ********************************************************************/
1414
1415 BOOL srv_io_q_net_share_add(const char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
1416 {
1417         if (q_n == NULL)
1418                 return False;
1419
1420         prs_debug(ps, depth, desc, "srv_io_q_net_share_add");
1421         depth++;
1422
1423         if(!prs_align(ps))
1424                 return False;
1425
1426         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1427                 return False;
1428         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1429                 return False;
1430
1431         if(!prs_align(ps))
1432                 return False;
1433
1434         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1435                 return False;
1436
1437         if(!prs_align(ps))
1438                 return False;
1439
1440         if(!srv_io_srv_share_info("info  ", ps, depth, &q_n->info))
1441                 return False;
1442
1443         if(!prs_align(ps))
1444                 return False;
1445
1446         if(!prs_uint32("ptr_err_index", ps, depth, &q_n->ptr_err_index))
1447                 return False;
1448         if (q_n->ptr_err_index)
1449                 if (!prs_uint32("err_index", ps, depth, &q_n->err_index))
1450                         return False;
1451
1452         return True;
1453 }
1454
1455 void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, const char *srvname,
1456                               const char *netname, uint32 type, const char *remark, 
1457                               uint32 perms, uint32 max_uses, uint32 num_uses,
1458                               const char *path, const char *passwd, 
1459                               int level, SEC_DESC *sd)
1460 {
1461         switch(level) {
1462         case 502: {
1463                 size_t sd_size = sec_desc_size(sd);
1464                 q->ptr_srv_name = 1;
1465                 init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
1466                 q->info.switch_value = q->info_level = level;
1467                 q->info.ptr_share_ctr = 1;
1468                 init_srv_share_info502(&q->info.share.info502.info_502, netname, type,
1469                                      remark, perms, max_uses, num_uses, path, passwd, sd, sd_size);
1470                 init_srv_share_info502_str(&q->info.share.info502.info_502_str, netname,
1471                                          remark, path, passwd, sd, sd_size);
1472                 q->ptr_err_index = 1;
1473                 q->err_index = 0;
1474                 }
1475                 break;
1476         case 2:
1477         default:
1478                 q->ptr_srv_name = 1;
1479                 init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
1480                 q->info.switch_value = q->info_level = level;
1481                 q->info.ptr_share_ctr = 1;
1482                 init_srv_share_info2(&q->info.share.info2.info_2, netname, type,
1483                                      remark, perms, max_uses, num_uses, path, passwd);
1484                 init_srv_share_info2_str(&q->info.share.info2.info_2_str, netname,
1485                                          remark, path, passwd);
1486                 q->ptr_err_index = 1;
1487                 q->err_index = 0;
1488                 break;
1489         }
1490 }
1491
1492
1493 /*******************************************************************
1494  Reads or writes a structure.
1495 ********************************************************************/
1496
1497 BOOL srv_io_r_net_share_add(const char *desc, SRV_R_NET_SHARE_ADD *r_n, prs_struct *ps, int depth)
1498 {
1499         if (r_n == NULL)
1500                 return False;
1501
1502         prs_debug(ps, depth, desc, "srv_io_r_net_share_add");
1503         depth++;
1504
1505         if(!prs_align(ps))
1506                 return False;
1507
1508         if(!prs_uint32("ptr_parm_error", ps, depth, &r_n->ptr_parm_error))
1509                 return False;
1510
1511         if(r_n->ptr_parm_error) {
1512           
1513                 if(!prs_uint32("parm_error", ps, depth, &r_n->parm_error))
1514                         return False;
1515         }
1516
1517         if(!prs_werror("status", ps, depth, &r_n->status))
1518                 return False;
1519
1520         return True;
1521 }       
1522
1523 /*******************************************************************
1524  initialises a structure.
1525 ********************************************************************/
1526
1527 void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname,
1528                               const char *sharename)
1529 {
1530         del->ptr_srv_name = 1;
1531         init_unistr2(&del->uni_srv_name, srvname, UNI_STR_TERMINATE);
1532         init_unistr2(&del->uni_share_name, sharename, UNI_STR_TERMINATE);
1533 }
1534
1535 /*******************************************************************
1536  Reads or writes a structure.
1537 ********************************************************************/
1538
1539 BOOL srv_io_q_net_share_del(const char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1540 {
1541         if (q_n == NULL)
1542                 return False;
1543
1544         prs_debug(ps, depth, desc, "srv_io_q_net_share_del");
1545         depth++;
1546
1547         if(!prs_align(ps))
1548                 return False;
1549
1550         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1551                 return False;
1552         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1553                 return False;
1554
1555         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1556                 return False;
1557
1558         if(!prs_align(ps))
1559                 return False;
1560         if(!prs_uint32("reserved", ps, depth, &q_n->reserved))
1561                 return False;
1562
1563         return True;
1564 }
1565
1566 /*******************************************************************
1567  Reads or writes a structure.
1568 ********************************************************************/
1569
1570 BOOL srv_io_r_net_share_del(const char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1571 {
1572         if (q_n == NULL)
1573                 return False;
1574
1575         prs_debug(ps, depth, desc, "srv_io_r_net_share_del");
1576         depth++;
1577
1578         if(!prs_align(ps))
1579                 return False;
1580
1581         if(!prs_werror("status", ps, depth, &q_n->status))
1582                 return False;
1583
1584         return True;
1585 }       
1586
1587 /*******************************************************************
1588  Inits a SESS_INFO_0_STR structure
1589 ********************************************************************/
1590
1591 void init_srv_sess_info0( SESS_INFO_0 *ss0, const char *name )
1592 {
1593         ZERO_STRUCTP( ss0 );
1594
1595         if ( name ) {
1596                 if ( (ss0->sharename = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL ) {
1597                         DEBUG(0,("init_srv_sess_info0: talloc failed!\n"));
1598                         return;
1599                 }
1600                 init_unistr2( ss0->sharename, name, UNI_STR_TERMINATE );
1601         }
1602 }
1603
1604 /*******************************************************************
1605  Reads or writes a structure.
1606 ********************************************************************/
1607
1608 static BOOL srv_io_srv_sess_info_0(const char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1609 {
1610         if (ss0 == NULL)
1611                 return False;
1612
1613         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
1614         depth++;
1615
1616         if(!prs_align(ps))
1617                 return False;
1618
1619         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1620                 return False;
1621         if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
1622                 return False;
1623
1624         if (ss0->ptr_sess_info != 0) {
1625                 uint32 i;
1626                 uint32 num_entries = ss0->num_entries_read;
1627
1628                 if (num_entries > MAX_SESS_ENTRIES) {
1629                         num_entries = MAX_SESS_ENTRIES; /* report this! */
1630                 }
1631
1632                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1633                         return False;
1634
1635                 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
1636
1637                 /* first the pointers */
1638                 for (i = 0; i < num_entries; i++) {
1639                         if ( !prs_io_unistr2_p("", ps, depth, &ss0->info_0[i].sharename ) )
1640                                 return False;
1641                 }
1642
1643                 /* now the strings */
1644                 for (i = 0; i < num_entries; i++) {
1645                         if ( !prs_io_unistr2("sharename", ps, depth, ss0->info_0[i].sharename ))
1646                                 return False;
1647                 }
1648
1649                 if(!prs_align(ps))
1650                         return False;
1651         }
1652
1653         return True;
1654 }
1655
1656 /*******************************************************************
1657  Inits a SESS_INFO_1 structure
1658 ********************************************************************/
1659
1660 void init_srv_sess_info1( SESS_INFO_1 *ss1, const char *name, const char *user,
1661                           uint32 num_opens, uint32 open_time, uint32 idle_time,
1662                           uint32 user_flags)
1663 {
1664         DEBUG(5,("init_srv_sess_info1: %s\n", name));
1665
1666         ZERO_STRUCTP( ss1 );
1667
1668         if ( name ) {
1669                 if ( (ss1->sharename = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL ) {
1670                         DEBUG(0,("init_srv_sess_info0: talloc failed!\n"));
1671                         return;
1672                 }
1673                 init_unistr2( ss1->sharename, name, UNI_STR_TERMINATE );
1674         }
1675
1676         if ( user ) {
1677                 if ( (ss1->username = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL ) {
1678                         DEBUG(0,("init_srv_sess_info0: talloc failed!\n"));
1679                         return;
1680                 }
1681                 init_unistr2( ss1->username, user, UNI_STR_TERMINATE );
1682         }
1683
1684         ss1->num_opens  = num_opens;
1685         ss1->open_time  = open_time;
1686         ss1->idle_time  = idle_time;
1687         ss1->user_flags = user_flags;
1688 }
1689
1690
1691 /*******************************************************************
1692  Reads or writes a structure.
1693 ********************************************************************/
1694
1695 static BOOL srv_io_srv_sess_info_1(const char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1696 {
1697         if (ss1 == NULL)
1698                 return False;
1699
1700         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
1701         depth++;
1702
1703         if(!prs_align(ps))
1704                 return False;
1705
1706         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1707                 return False;
1708         if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
1709                 return False;
1710
1711         if (ss1->ptr_sess_info != 0) {
1712                 uint32 i;
1713                 uint32 num_entries = ss1->num_entries_read;
1714
1715                 if (num_entries > MAX_SESS_ENTRIES) {
1716                         num_entries = MAX_SESS_ENTRIES; /* report this! */
1717                 }
1718
1719                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1720                         return False;
1721
1722                 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
1723
1724                 /* first the pointers and flags */
1725
1726                 for (i = 0; i < num_entries; i++) {
1727
1728                         if ( !prs_io_unistr2_p("", ps, depth, &ss1->info_1[i].sharename ))
1729                                 return False;
1730                         if ( !prs_io_unistr2_p("", ps, depth, &ss1->info_1[i].username ))
1731                                 return False;
1732
1733                         if(!prs_uint32("num_opens ", ps, depth, &ss1->info_1[i].num_opens))
1734                                 return False;
1735                         if(!prs_uint32("open_time ", ps, depth, &ss1->info_1[i].open_time))
1736                                 return False;
1737                         if(!prs_uint32("idle_time ", ps, depth, &ss1->info_1[i].idle_time))
1738                                 return False;
1739                         if(!prs_uint32("user_flags", ps, depth, &ss1->info_1[i].user_flags))
1740                                 return False;
1741                 }
1742
1743                 /* now the strings */
1744
1745                 for (i = 0; i < num_entries; i++) {
1746                         if ( !prs_io_unistr2("", ps, depth, ss1->info_1[i].sharename ))
1747                                 return False;
1748                         if ( !prs_io_unistr2("", ps, depth, ss1->info_1[i].username ))
1749                                 return False;
1750                 }
1751
1752                 if(!prs_align(ps))
1753                         return False;
1754         }
1755
1756         return True;
1757 }
1758
1759 /*******************************************************************
1760  Reads or writes a structure.
1761 ********************************************************************/
1762
1763 static BOOL srv_io_srv_sess_ctr(const char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1764 {
1765         SRV_SESS_INFO_CTR *ctr = *pp_ctr;
1766
1767         prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
1768         depth++;
1769
1770         if(UNMARSHALLING(ps)) {
1771                 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_SESS_INFO_CTR, 1);
1772                 if (ctr == NULL)
1773                         return False;
1774         }
1775
1776         if (ctr == NULL)
1777                 return False;
1778
1779         if(!prs_align(ps))
1780                 return False;
1781
1782         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1783                 return False;
1784         if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
1785                 return False;
1786
1787         if (ctr->ptr_sess_ctr != 0) {
1788                 switch (ctr->switch_value) {
1789                 case 0:
1790                         if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
1791                                 return False;
1792                         break;
1793                 case 1:
1794                         if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
1795                                 return False;
1796                         break;
1797                 default:
1798                         DEBUG(5,("%s no session info at switch_value %d\n",
1799                                  tab_depth(depth), ctr->switch_value));
1800                         break;
1801                 }
1802         }
1803
1804         return True;
1805 }
1806
1807 /*******************************************************************
1808  Reads or writes a structure.
1809 ********************************************************************/
1810
1811 BOOL srv_io_q_net_sess_enum(const char *desc, SRV_Q_NET_SESS_ENUM *q_u, prs_struct *ps, int depth)
1812 {
1813         if (q_u == NULL)
1814                 return False;
1815
1816         prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
1817         depth++;
1818
1819         if(!prs_align(ps))
1820                 return False;
1821
1822         if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername,
1823                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
1824                 return False;
1825
1826         if(!prs_align(ps))
1827                 return False;
1828
1829         if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier,
1830                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
1831                 return False;
1832
1833         if(!prs_align(ps))
1834                 return False;
1835
1836         if(!prs_pointer("username", ps, depth, (void*)&q_u->username,
1837                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
1838                 return False;
1839
1840         if(!prs_align(ps))
1841                 return False;
1842
1843         if(!prs_uint32("sess_level", ps, depth, &q_u->sess_level))
1844                 return False;
1845         
1846         if (q_u->sess_level != (uint32)-1) {
1847                 if(!srv_io_srv_sess_ctr("sess_ctr", &q_u->ctr, ps, depth))
1848                         return False;
1849         }
1850
1851         if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len))
1852                 return False;
1853
1854         if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth))
1855                 return False;
1856
1857         return True;
1858 }
1859
1860 /*******************************************************************
1861  Reads or writes a structure.
1862 ********************************************************************/
1863
1864 BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
1865 {
1866         if (r_n == NULL)
1867                 return False;
1868
1869         prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
1870         depth++;
1871
1872         if(!prs_align(ps))
1873                 return False;
1874
1875         if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
1876                 return False;
1877
1878         if (r_n->sess_level != (uint32)-1) {
1879                 if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
1880                         return False;
1881         }
1882
1883         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1884                 return False;
1885         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1886                 return False;
1887         if(!prs_werror("status", ps, depth, &r_n->status))
1888                 return False;
1889
1890         return True;
1891 }
1892
1893 /*******************************************************************
1894  Inits a SRV_Q_NET_SESS_DEL structure.
1895 ********************************************************************/
1896
1897 void init_srv_q_net_sess_del(SRV_Q_NET_SESS_DEL *q_n, const char *srv_name,
1898                               const char *cli_name, const char *user_name)
1899 {
1900         DEBUG(5,("init_q_net_sess_enum\n"));
1901
1902         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1903         init_buf_unistr2(&q_n->uni_cli_name, &q_n->ptr_cli_name, cli_name);
1904         init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
1905 }
1906
1907 /*******************************************************************
1908  Reads or writes a structure.
1909 ********************************************************************/
1910
1911 BOOL srv_io_q_net_sess_del(const char *desc, SRV_Q_NET_SESS_DEL *q_n, prs_struct *ps, int depth)
1912 {
1913         if (q_n == NULL)
1914                 return False;
1915
1916         prs_debug(ps, depth, desc, "srv_io_q_net_sess_del");
1917         depth++;
1918
1919         if(!prs_align(ps))
1920                 return False;
1921
1922         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1923                 return False;
1924         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1925                 return False;
1926
1927         if(!prs_align(ps))
1928                 return False;
1929
1930         if(!prs_uint32("ptr_cli_name", ps, depth, &q_n->ptr_cli_name))
1931                 return False;
1932         if(!smb_io_unistr2("", &q_n->uni_cli_name, q_n->ptr_cli_name, ps, depth))
1933                 return False;
1934
1935         if(!prs_align(ps))
1936                 return False;
1937         if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
1938                 return False;
1939         if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
1940                 return False;
1941
1942         return True;
1943 }
1944
1945 /*******************************************************************
1946  Reads or writes a structure.
1947 ********************************************************************/
1948
1949 BOOL srv_io_r_net_sess_del(const char *desc, SRV_R_NET_SESS_DEL *r_n, prs_struct *ps, int depth)
1950 {
1951         if (r_n == NULL)
1952                 return False;
1953
1954         prs_debug(ps, depth, desc, "srv_io_r_net_sess_del");
1955         depth++;
1956
1957         if(!prs_align(ps))
1958                 return False;
1959
1960         if(!prs_werror("status", ps, depth, &r_n->status))
1961                 return False;
1962
1963         return True;
1964 }
1965
1966 /*******************************************************************
1967  Inits a CONN_INFO_0 structure
1968 ********************************************************************/
1969
1970 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
1971 {
1972         DEBUG(5,("init_srv_conn_info0\n"));
1973
1974         ss0->id = id;
1975 }
1976
1977 /*******************************************************************
1978  Reads or writes a structure.
1979 ********************************************************************/
1980
1981 static BOOL srv_io_conn_info0(const char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1982 {
1983         if (ss0 == NULL)
1984                 return False;
1985
1986         prs_debug(ps, depth, desc, "srv_io_conn_info0");
1987         depth++;
1988
1989         if(!prs_align(ps))
1990                 return False;
1991
1992         if(!prs_uint32("id", ps, depth, &ss0->id))
1993                 return False;
1994
1995         return True;
1996 }
1997
1998 /*******************************************************************
1999  Reads or writes a structure.
2000 ********************************************************************/
2001
2002 static BOOL srv_io_srv_conn_info_0(const char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
2003 {
2004         if (ss0 == NULL)
2005                 return False;
2006
2007         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
2008         depth++;
2009
2010         if(!prs_align(ps))
2011                 return False;
2012
2013         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
2014                 return False;
2015         if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
2016                 return False;
2017
2018         if (ss0->ptr_conn_info != 0) {
2019                 int i;
2020                 int num_entries = ss0->num_entries_read;
2021
2022                 if (num_entries > MAX_CONN_ENTRIES) {
2023                         num_entries = MAX_CONN_ENTRIES; /* report this! */
2024                 }
2025
2026                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
2027                         return False;
2028
2029                 for (i = 0; i < num_entries; i++) {
2030                         if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
2031                                 return False;
2032                 }
2033
2034                 if(!prs_align(ps))
2035                         return False;
2036         }
2037
2038         return True;
2039 }
2040
2041 /*******************************************************************
2042  Inits a CONN_INFO_1_STR structure
2043 ********************************************************************/
2044
2045 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const char *net_name)
2046 {
2047         DEBUG(5,("init_srv_conn_info1_str\n"));
2048
2049         init_unistr2(&ss1->uni_usr_name, usr_name, UNI_STR_TERMINATE);
2050         init_unistr2(&ss1->uni_net_name, net_name, UNI_STR_TERMINATE);
2051 }
2052
2053 /*******************************************************************
2054  Reads or writes a structure.
2055 ********************************************************************/
2056
2057 static BOOL srv_io_conn_info1_str(const char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
2058 {
2059         if (ss1 == NULL)
2060                 return False;
2061
2062         prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
2063         depth++;
2064
2065         if(!prs_align(ps))
2066                 return False;
2067
2068         if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
2069                 return False;
2070         if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
2071                 return False;
2072
2073         return True;
2074 }
2075
2076 /*******************************************************************
2077  Inits a CONN_INFO_1 structure
2078 ********************************************************************/
2079
2080 void init_srv_conn_info1(CONN_INFO_1 *ss1, 
2081                                 uint32 id, uint32 type,
2082                                 uint32 num_opens, uint32 num_users, uint32 open_time,
2083                                 const char *usr_name, const char *net_name)
2084 {
2085         DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
2086
2087         ss1->id        = id       ;
2088         ss1->type      = type     ;
2089         ss1->num_opens = num_opens ;
2090         ss1->num_users = num_users;
2091         ss1->open_time = open_time;
2092
2093         ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
2094         ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
2095 }
2096
2097 /*******************************************************************
2098  Reads or writes a structure.
2099 ********************************************************************/
2100
2101 static BOOL srv_io_conn_info1(const char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2102 {
2103         if (ss1 == NULL)
2104                 return False;
2105
2106         prs_debug(ps, depth, desc, "srv_io_conn_info1");
2107         depth++;
2108
2109         if(!prs_align(ps))
2110                 return False;
2111
2112         if(!prs_uint32("id          ", ps, depth, &ss1->id))
2113                 return False;
2114         if(!prs_uint32("type        ", ps, depth, &ss1->type))
2115                 return False;
2116         if(!prs_uint32("num_opens   ", ps, depth, &ss1->num_opens))
2117                 return False;
2118         if(!prs_uint32("num_users   ", ps, depth, &ss1->num_users))
2119                 return False;
2120         if(!prs_uint32("open_time   ", ps, depth, &ss1->open_time))
2121                 return False;
2122
2123         if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
2124                 return False;
2125         if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
2126                 return False;
2127
2128         return True;
2129 }
2130
2131 /*******************************************************************
2132  Reads or writes a structure.
2133 ********************************************************************/
2134
2135 static BOOL srv_io_srv_conn_info_1(const char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2136 {
2137         if (ss1 == NULL)
2138                 return False;
2139
2140         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
2141         depth++;
2142
2143         if(!prs_align(ps))
2144                 return False;
2145
2146         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
2147                 return False;
2148         if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
2149                 return False;
2150
2151         if (ss1->ptr_conn_info != 0) {
2152                 int i;
2153                 int num_entries = ss1->num_entries_read;
2154
2155                 if (num_entries > MAX_CONN_ENTRIES) {
2156                         num_entries = MAX_CONN_ENTRIES; /* report this! */
2157                 }
2158
2159                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
2160                         return False;
2161
2162                 for (i = 0; i < num_entries; i++) {
2163                         if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
2164                                 return False;
2165                 }
2166
2167                 for (i = 0; i < num_entries; i++) {
2168                         if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
2169                                 return False;
2170                 }
2171
2172                 if(!prs_align(ps))
2173                         return False;
2174         }
2175
2176         return True;
2177 }
2178
2179 /*******************************************************************
2180  Reads or writes a structure.
2181 ********************************************************************/
2182
2183 static BOOL srv_io_srv_conn_ctr(const char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
2184 {
2185         SRV_CONN_INFO_CTR *ctr = *pp_ctr;
2186
2187         prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
2188         depth++;
2189
2190         if (UNMARSHALLING(ps)) {
2191                 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_CONN_INFO_CTR, 1);
2192                 if (ctr == NULL)
2193                         return False;
2194         }
2195                 
2196         if (ctr == NULL)
2197                 return False;
2198
2199         if(!prs_align(ps))
2200                 return False;
2201
2202         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2203                 return False;
2204         if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
2205                 return False;
2206
2207         if (ctr->ptr_conn_ctr != 0) {
2208                 switch (ctr->switch_value) {
2209                 case 0:
2210                         if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
2211                                 return False;
2212                         break;
2213                 case 1:
2214                         if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
2215                                 return False;
2216                         break;
2217                 default:
2218                         DEBUG(5,("%s no connection info at switch_value %d\n",
2219                                  tab_depth(depth), ctr->switch_value));
2220                         break;
2221                 }
2222         }
2223
2224         return True;
2225 }
2226
2227 /*******************************************************************
2228   Reads or writes a structure.
2229 ********************************************************************/
2230
2231 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, 
2232                                 const char *srv_name, const char *qual_name,
2233                                 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
2234                                 uint32 preferred_len,
2235                                 ENUM_HND *hnd)
2236 {
2237         DEBUG(5,("init_q_net_conn_enum\n"));
2238
2239         q_n->ctr = ctr;
2240
2241         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
2242         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2243
2244         q_n->conn_level    = conn_level;
2245         q_n->preferred_len = preferred_len;
2246
2247         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2248 }
2249
2250 /*******************************************************************
2251  Reads or writes a structure.
2252 ********************************************************************/
2253
2254 BOOL srv_io_q_net_conn_enum(const char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
2255 {
2256         if (q_n == NULL)
2257                 return False;
2258
2259         prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
2260         depth++;
2261
2262         if(!prs_align(ps))
2263                 return False;
2264
2265         if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2266                 return False;
2267         if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
2268                 return False;
2269
2270         if(!prs_align(ps))
2271                 return False;
2272
2273         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2274                 return False;
2275         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2276                 return False;
2277
2278         if(!prs_align(ps))
2279                 return False;
2280
2281         if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
2282                 return False;
2283         
2284         if (q_n->conn_level != (uint32)-1) {
2285                 if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
2286                         return False;
2287         }
2288
2289         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2290                 return False;
2291
2292         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2293                 return False;
2294
2295         return True;
2296 }
2297
2298 /*******************************************************************
2299  Reads or writes a structure.
2300 ********************************************************************/
2301
2302 BOOL srv_io_r_net_conn_enum(const char *desc,  SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
2303 {
2304         if (r_n == NULL)
2305                 return False;
2306
2307         prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
2308         depth++;
2309
2310         if(!prs_align(ps))
2311                 return False;
2312
2313         if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
2314                 return False;
2315
2316         if (r_n->conn_level != (uint32)-1) {
2317                 if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
2318                         return False;
2319         }
2320
2321         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2322                 return False;
2323         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2324                 return False;
2325         if(!prs_werror("status", ps, depth, &r_n->status))
2326                 return False;
2327
2328         return True;
2329 }
2330
2331 /*******************************************************************
2332  Reads or writes a structure.
2333 ********************************************************************/
2334
2335 static BOOL srv_io_file_info3_str(const char *desc, FILE_INFO_3 *sh1, prs_struct *ps, int depth)
2336 {
2337         if (sh1 == NULL)
2338                 return False;
2339
2340         prs_debug(ps, depth, desc, "srv_io_file_info3_str");
2341         depth++;
2342
2343         if(!prs_align(ps))
2344                 return False;
2345
2346         if ( sh1->path ) {
2347                 if(!smb_io_unistr2("", sh1->path, True, ps, depth))
2348                         return False;
2349         }
2350
2351         if ( sh1->user ) {
2352                 if(!smb_io_unistr2("", sh1->user, True, ps, depth))
2353                         return False;
2354         }
2355
2356         return True;
2357 }
2358
2359 /*******************************************************************
2360  Inits a FILE_INFO_3 structure
2361 ********************************************************************/
2362
2363 void init_srv_file_info3( FILE_INFO_3 *fl3, uint32 id, uint32 perms, uint32 num_locks,
2364                           const char *user_name, const char *path_name )
2365 {
2366         fl3->id        = id;    
2367         fl3->perms     = perms;
2368         fl3->num_locks = num_locks;
2369
2370         if ( path_name ) {
2371                 if ( (fl3->path = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2372                         return;
2373                 init_unistr2(fl3->path, path_name, UNI_STR_TERMINATE);
2374         }
2375
2376         if ( user_name ) {
2377                 if ( (fl3->user = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2378                         return;
2379                 init_unistr2(fl3->user, user_name, UNI_STR_TERMINATE);
2380         }
2381
2382         return;
2383 }
2384
2385 /*******************************************************************
2386  Reads or writes a structure.
2387 ********************************************************************/
2388
2389 static BOOL srv_io_file_info3(const char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
2390 {
2391         uint32 uni_p;
2392
2393         if (fl3 == NULL)
2394                 return False;
2395
2396         prs_debug(ps, depth, desc, "srv_io_file_info3");
2397         depth++;
2398
2399         if(!prs_align(ps))
2400                 return False;
2401
2402         if(!prs_uint32("id           ", ps, depth, &fl3->id))
2403                 return False;
2404         if(!prs_uint32("perms        ", ps, depth, &fl3->perms))
2405                 return False;
2406         if(!prs_uint32("num_locks    ", ps, depth, &fl3->num_locks))
2407                 return False;
2408
2409         uni_p = fl3->path ? 1 : 0;
2410         if(!prs_uint32("ptr", ps, depth, &uni_p))
2411                 return False;
2412         if (UNMARSHALLING(ps)) {
2413                 if ( (fl3->path = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) {
2414                         return False;
2415                 }
2416         }
2417
2418         uni_p = fl3->user ? 1 : 0;
2419         if(!prs_uint32("ptr", ps, depth, &uni_p))
2420                 return False;
2421         if (UNMARSHALLING(ps)) {
2422                 if ( (fl3->user = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) {
2423                         return False;
2424                 }
2425         }
2426
2427         return True;
2428 }
2429
2430 /*******************************************************************
2431  Reads or writes a structure.
2432 ********************************************************************/
2433
2434 static BOOL srv_io_srv_file_ctr(const char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
2435 {
2436         if (ctr == NULL)
2437                 return False;
2438
2439         prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
2440         depth++;
2441
2442         if (UNMARSHALLING(ps)) {
2443                 ZERO_STRUCTP(ctr);
2444         }
2445
2446         if(!prs_align(ps))
2447                 return False;
2448
2449         if(!prs_uint32("level", ps, depth, &ctr->level))
2450                 return False;
2451
2452         if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info))
2453                 return False;
2454         if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
2455                 return False;
2456         if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
2457                 return False;
2458
2459         if (ctr->ptr_entries == 0)
2460                 return True;
2461
2462         if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
2463                 return False;
2464
2465         switch (ctr->level) {
2466         case 3: {
2467                 FILE_INFO_3 *info3 = ctr->file.info3;
2468                 int num_entries = ctr->num_entries;
2469                 int i;
2470
2471                 if (UNMARSHALLING(ps) && num_entries) {
2472                         if (!(info3 = PRS_ALLOC_MEM(ps, FILE_INFO_3, num_entries)))
2473                                 return False;
2474                         ctr->file.info3 = info3;
2475                 }
2476
2477                 for (i = 0; i < num_entries; i++) {
2478                         if(!srv_io_file_info3("", &ctr->file.info3[i], ps, depth)) 
2479                                 return False;
2480                 }
2481
2482                 for (i = 0; i < num_entries; i++) {
2483                         if(!srv_io_file_info3_str("", &ctr->file.info3[i], ps, depth))
2484                                 return False;
2485                 }
2486                 break;
2487         }
2488         default:
2489                 DEBUG(5,("%s no file info at switch_value %d\n", tab_depth(depth), ctr->level));
2490                 break;
2491         }
2492                         
2493         return True;
2494 }
2495
2496 /*******************************************************************
2497  Inits a SRV_Q_NET_FILE_ENUM structure.
2498 ********************************************************************/
2499
2500 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, 
2501                               const char *srv_name, const char *qual_name, 
2502                               const char *user_name,
2503                               uint32 file_level, SRV_FILE_INFO_CTR *ctr,
2504                               uint32 preferred_len,
2505                               ENUM_HND *hnd)
2506 {
2507         uint32 ptr;
2508
2509         if ( srv_name ) {
2510                 if ( (q_n->servername = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2511                         return;
2512                 init_buf_unistr2(q_n->servername, &ptr, srv_name);
2513         }
2514
2515         if ( qual_name ) {
2516                 if ( (q_n->qualifier = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2517                         return;
2518                 init_buf_unistr2(q_n->qualifier,  &ptr, qual_name);
2519         }
2520
2521         if ( user_name ) {
2522                 if ( (q_n->username = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
2523                         return;
2524                 init_buf_unistr2(q_n->username,   &ptr, user_name);
2525         }
2526
2527         q_n->level = q_n->ctr.level = file_level;
2528
2529         q_n->preferred_len = preferred_len;
2530         q_n->ctr.ptr_file_info = 1;
2531         q_n->ctr.num_entries = 0;
2532         q_n->ctr.num_entries2 = 0;
2533
2534         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2535 }
2536
2537 /*******************************************************************
2538  Reads or writes a structure.
2539 ********************************************************************/
2540
2541 BOOL srv_io_q_net_file_enum(const char *desc, SRV_Q_NET_FILE_ENUM *q_u, prs_struct *ps, int depth)
2542 {
2543         if (q_u == NULL)
2544                 return False;
2545
2546         prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
2547         depth++;
2548
2549         if(!prs_align(ps))
2550                 return False;
2551
2552         if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername,
2553                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
2554                 return False;
2555         if(!prs_align(ps))
2556                 return False;
2557
2558         if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier,
2559                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
2560                 return False;
2561         if(!prs_align(ps))
2562                 return False;
2563
2564         if(!prs_pointer("username", ps, depth, (void*)&q_u->username,
2565                         sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
2566                 return False;
2567         if(!prs_align(ps))
2568                 return False;
2569
2570         if(!prs_uint32("level", ps, depth, &q_u->level))
2571                 return False;
2572
2573         if (q_u->level != (uint32)-1) {
2574                 if(!srv_io_srv_file_ctr("file_ctr", &q_u->ctr, ps, depth))
2575                         return False;
2576         }
2577
2578         if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len))
2579                 return False;
2580
2581         if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth))
2582                 return False;
2583
2584         return True;
2585 }
2586
2587 /*******************************************************************
2588  Reads or writes a structure.
2589 ********************************************************************/
2590
2591 BOOL srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
2592 {
2593         if (r_n == NULL)
2594                 return False;
2595
2596         prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
2597         depth++;
2598
2599         if(!prs_align(ps))
2600                 return False;
2601
2602         if(!prs_uint32("level", ps, depth, &r_n->level))
2603                 return False;
2604
2605         if (r_n->level != 0) {
2606                 if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
2607                         return False;
2608         }
2609
2610         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2611                 return False;
2612         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2613                 return False;
2614         if(!prs_werror("status", ps, depth, &r_n->status))
2615                 return False;
2616
2617         return True;
2618 }
2619
2620 /*******************************************************************
2621  Inits a SRV_INFO_100 structure.
2622  ********************************************************************/
2623
2624 void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name)
2625 {
2626         DEBUG(5,("init_srv_info_100\n"));
2627
2628         sv100->platform_id  = platform_id;
2629         init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
2630 }
2631
2632 /*******************************************************************
2633  Reads or writes a SRV_INFO_101 structure.
2634  ********************************************************************/
2635
2636 static BOOL srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
2637 {
2638         if (sv100 == NULL)
2639                 return False;
2640
2641         prs_debug(ps, depth, desc, "srv_io_info_100");
2642         depth++;
2643
2644         if(!prs_align(ps))
2645                 return False;
2646
2647         if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
2648                 return False;
2649         if(!prs_uint32("ptr_name    ", ps, depth, &sv100->ptr_name))
2650                 return False;
2651
2652         if(!smb_io_unistr2("uni_name    ", &sv100->uni_name, True, ps, depth))
2653                 return False;
2654
2655         return True;
2656 }
2657
2658
2659 /*******************************************************************
2660  Inits a SRV_INFO_101 structure.
2661  ********************************************************************/
2662
2663 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name,
2664                                 uint32 ver_major, uint32 ver_minor,
2665                                 uint32 srv_type, const char *comment)
2666 {
2667         DEBUG(5,("init_srv_info_101\n"));
2668
2669         sv101->platform_id  = platform_id;
2670         init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
2671         sv101->ver_major    = ver_major;
2672         sv101->ver_minor    = ver_minor;
2673         sv101->srv_type     = srv_type;
2674         init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
2675 }
2676
2677 /*******************************************************************
2678  Reads or writes a SRV_INFO_101 structure.
2679  ********************************************************************/
2680
2681 static BOOL srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
2682 {
2683         if (sv101 == NULL)
2684                 return False;
2685
2686         prs_debug(ps, depth, desc, "srv_io_info_101");
2687         depth++;
2688
2689         if(!prs_align(ps))
2690                 return False;
2691
2692         if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
2693                 return False;
2694         if(!prs_uint32("ptr_name    ", ps, depth, &sv101->ptr_name))
2695                 return False;
2696         if(!prs_uint32("ver_major   ", ps, depth, &sv101->ver_major))
2697                 return False;
2698         if(!prs_uint32("ver_minor   ", ps, depth, &sv101->ver_minor))
2699                 return False;
2700         if(!prs_uint32("srv_type    ", ps, depth, &sv101->srv_type))
2701                 return False;
2702         if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
2703                 return False;
2704
2705         if(!prs_align(ps))
2706                 return False;
2707
2708         if(!smb_io_unistr2("uni_name    ", &sv101->uni_name, True, ps, depth))
2709                 return False;
2710         if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
2711                 return False;
2712
2713         return True;
2714 }
2715
2716 /*******************************************************************
2717  Inits a SRV_INFO_102 structure.
2718  ********************************************************************/
2719
2720 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name,
2721                                 const char *comment, uint32 ver_major, uint32 ver_minor,
2722                                 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
2723                                 uint32 announce, uint32 ann_delta, uint32 licenses,
2724                                 const char *usr_path)
2725 {
2726         DEBUG(5,("init_srv_info_102\n"));
2727
2728         sv102->platform_id  = platform_id;
2729         init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
2730         sv102->ver_major    = ver_major;
2731         sv102->ver_minor    = ver_minor;
2732         sv102->srv_type     = srv_type;
2733         init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
2734
2735         /* same as 101 up to here */
2736
2737         sv102->users        = users;
2738         sv102->disc         = disc;
2739         sv102->hidden       = hidden;
2740         sv102->announce     = announce;
2741         sv102->ann_delta    = ann_delta;
2742         sv102->licenses     = licenses;
2743         init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
2744 }
2745
2746
2747 /*******************************************************************
2748  Reads or writes a SRV_INFO_102 structure.
2749  ********************************************************************/
2750
2751 static BOOL srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
2752 {
2753         if (sv102 == NULL)
2754                 return False;
2755
2756         prs_debug(ps, depth, desc, "srv_io_info102");
2757         depth++;
2758
2759         if(!prs_align(ps))
2760                 return False;
2761
2762         if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
2763                 return False;
2764         if(!prs_uint32("ptr_name    ", ps, depth, &sv102->ptr_name))
2765                 return False;
2766         if(!prs_uint32("ver_major   ", ps, depth, &sv102->ver_major))
2767                 return False;
2768         if(!prs_uint32("ver_minor   ", ps, depth, &sv102->ver_minor))
2769                 return False;
2770         if(!prs_uint32("srv_type    ", ps, depth, &sv102->srv_type))
2771                 return False;
2772         if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
2773                 return False;
2774
2775         /* same as 101 up to here */
2776
2777         if(!prs_uint32("users       ", ps, depth, &sv102->users))
2778                 return False;
2779         if(!prs_uint32("disc        ", ps, depth, &sv102->disc))
2780                 return False;
2781         if(!prs_uint32("hidden      ", ps, depth, &sv102->hidden))
2782                 return False;
2783         if(!prs_uint32("announce    ", ps, depth, &sv102->announce))
2784                 return False;
2785         if(!prs_uint32("ann_delta   ", ps, depth, &sv102->ann_delta))
2786                 return False;
2787         if(!prs_uint32("licenses    ", ps, depth, &sv102->licenses))
2788                 return False;
2789         if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
2790                 return False;
2791
2792         if(!smb_io_unistr2("uni_name    ", &sv102->uni_name, True, ps, depth))
2793                 return False;
2794         if(!prs_align(ps))
2795                 return False;
2796         if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
2797                 return False;
2798         if(!prs_align(ps))
2799                 return False;
2800         if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
2801                 return False;
2802
2803         return True;
2804 }
2805
2806 /*******************************************************************
2807  Reads or writes a SRV_INFO_102 structure.
2808  ********************************************************************/
2809
2810 static BOOL srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
2811 {
2812         if (ctr == NULL)
2813                 return False;
2814
2815         prs_debug(ps, depth, desc, "srv_io_info_ctr");
2816         depth++;
2817
2818         if(!prs_align(ps))
2819                 return False;
2820
2821         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2822                 return False;
2823         if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
2824                 return False;
2825
2826         if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
2827                 switch (ctr->switch_value) {
2828                 case 100:
2829                         if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
2830                                 return False;
2831                         break;
2832                 case 101:
2833                         if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
2834                                 return False;
2835                         break;
2836                 case 102:
2837                         if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
2838                                 return False;
2839                         break;
2840                 default:
2841                         DEBUG(5,("%s no server info at switch_value %d\n",
2842                                          tab_depth(depth), ctr->switch_value));
2843                         break;
2844                 }
2845                 if(!prs_align(ps))
2846                         return False;
2847         }
2848
2849         return True;
2850 }
2851
2852 /*******************************************************************
2853  Inits a SRV_Q_NET_SRV_GET_INFO structure.
2854  ********************************************************************/
2855
2856 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
2857                                 const char *server_name, uint32 switch_value)
2858 {
2859         DEBUG(5,("init_srv_q_net_srv_get_info\n"));
2860
2861         init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
2862
2863         srv->switch_value = switch_value;
2864 }
2865
2866 /*******************************************************************
2867  Reads or writes a structure.
2868 ********************************************************************/
2869
2870 BOOL srv_io_q_net_srv_get_info(const char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
2871 {
2872         if (q_n == NULL)
2873                 return False;
2874
2875         prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
2876         depth++;
2877
2878         if(!prs_align(ps))
2879                 return False;
2880
2881         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2882                 return False;
2883         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2884                 return False;
2885
2886         if(!prs_align(ps))
2887                 return False;
2888
2889         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2890                 return False;
2891
2892         return True;
2893 }
2894
2895 /*******************************************************************
2896  Inits a SRV_R_NET_SRV_GET_INFO structure.
2897  ********************************************************************/
2898
2899 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
2900                                 uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status)
2901 {
2902         DEBUG(5,("init_srv_r_net_srv_get_info\n"));
2903
2904         srv->ctr = ctr;
2905
2906         if (W_ERROR_IS_OK(status)) {
2907                 srv->ctr->switch_value = switch_value;
2908                 srv->ctr->ptr_srv_ctr  = 1;
2909         } else {
2910                 srv->ctr->switch_value = 0;
2911                 srv->ctr->ptr_srv_ctr  = 0;
2912         }
2913
2914         srv->status = status;
2915 }
2916
2917 /*******************************************************************
2918  Inits a SRV_R_NET_SRV_SET_INFO structure.
2919  ********************************************************************/
2920
2921 void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
2922                                  uint32 switch_value, WERROR status)
2923 {
2924         DEBUG(5,("init_srv_r_net_srv_set_info\n"));
2925
2926         srv->switch_value = switch_value;
2927         srv->status = status;
2928 }
2929
2930 /*******************************************************************
2931  Reads or writes a structure.
2932 ********************************************************************/
2933
2934 BOOL srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, 
2935                                prs_struct *ps, int depth)
2936 {
2937         prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
2938         depth++;
2939
2940         if(!prs_align(ps))
2941                 return False;
2942
2943         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2944                 return False;
2945         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2946                 return False;
2947
2948         if(!prs_align(ps))
2949                 return False;
2950
2951         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2952                 return False;
2953
2954         if (UNMARSHALLING(ps)) {
2955                 q_n->ctr = PRS_ALLOC_MEM(ps, SRV_INFO_CTR, 1);
2956
2957                 if (!q_n->ctr)
2958                         return False;
2959         }
2960
2961         if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth))
2962                 return False;
2963
2964         return True;
2965 }
2966
2967 /*******************************************************************
2968  Reads or writes a structure.
2969  ********************************************************************/
2970
2971 BOOL srv_io_r_net_srv_get_info(const char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
2972 {
2973         if (r_n == NULL)
2974                 return False;
2975
2976         prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
2977         depth++;
2978
2979         if(!prs_align(ps))
2980                 return False;
2981
2982         if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
2983                 return False;
2984
2985         if(!prs_werror("status", ps, depth, &r_n->status))
2986                 return False;
2987
2988         return True;
2989 }
2990
2991 /*******************************************************************
2992  Reads or writes a structure.
2993  ********************************************************************/
2994
2995 BOOL srv_io_r_net_srv_set_info(const char *desc, SRV_R_NET_SRV_SET_INFO *r_n, 
2996                                prs_struct *ps, int depth)
2997 {
2998         prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info");
2999         depth++;
3000
3001         if(!prs_align(ps))
3002                 return False;
3003
3004         if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value))
3005                 return False;
3006
3007         if(!prs_werror("status", ps, depth, &r_n->status))
3008                 return False;
3009
3010         return True;
3011 }
3012
3013 /*******************************************************************
3014  Reads or writes a structure.
3015  ********************************************************************/
3016
3017 BOOL srv_io_q_net_remote_tod(const char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
3018 {
3019         if (q_n == NULL)
3020                 return False;
3021
3022         prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
3023         depth++;
3024
3025         if(!prs_align(ps))
3026                 return False;
3027
3028         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
3029                 return False;
3030         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3031                 return False;
3032
3033         return True;
3034 }
3035
3036 /*******************************************************************
3037  Reads or writes a TIME_OF_DAY_INFO structure.
3038  ********************************************************************/
3039
3040 static BOOL srv_io_time_of_day_info(const char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
3041 {
3042         if (tod == NULL)
3043                 return False;
3044
3045         prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
3046         depth++;
3047
3048         if(!prs_align(ps))
3049                 return False;
3050         
3051         if(!prs_uint32("elapsedt   ", ps, depth, &tod->elapsedt))
3052                 return False;
3053         if(!prs_uint32("msecs      ", ps, depth, &tod->msecs))
3054                 return False;
3055         if(!prs_uint32("hours      ", ps, depth, &tod->hours))
3056                 return False;
3057         if(!prs_uint32("mins       ", ps, depth, &tod->mins))
3058                 return False;
3059         if(!prs_uint32("secs       ", ps, depth, &tod->secs))
3060                 return False;
3061         if(!prs_uint32("hunds      ", ps, depth, &tod->hunds))
3062                 return False;
3063         if(!prs_uint32("timezone   ", ps, depth, &tod->zone))
3064                 return False;
3065         if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
3066                 return False;
3067         if(!prs_uint32("day        ", ps, depth, &tod->day))
3068                 return False;
3069         if(!prs_uint32("month      ", ps, depth, &tod->month))
3070                 return False;
3071         if(!prs_uint32("year       ", ps, depth, &tod->year))
3072                 return False;
3073         if(!prs_uint32("weekday    ", ps, depth, &tod->weekday))
3074                 return False;
3075
3076         return True;
3077 }
3078
3079 /*******************************************************************
3080  Inits a TIME_OF_DAY_INFO structure.
3081  ********************************************************************/
3082
3083 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
3084                            uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
3085                            uint32 zone, uint32 tintervals, uint32 day,
3086                            uint32 month, uint32 year, uint32 weekday)
3087 {
3088         DEBUG(5,("init_time_of_day_info\n"));
3089
3090         tod->elapsedt   = elapsedt;
3091         tod->msecs      = msecs;
3092         tod->hours      = hours;
3093         tod->mins       = mins;
3094         tod->secs       = secs;
3095         tod->hunds      = hunds;
3096         tod->zone       = zone;
3097         tod->tintervals = tintervals;
3098         tod->day        = day;
3099         tod->month      = month;
3100         tod->year       = year;
3101         tod->weekday    = weekday;
3102 }
3103
3104
3105 /*******************************************************************
3106  Reads or writes a structure.
3107  ********************************************************************/
3108
3109 BOOL srv_io_r_net_remote_tod(const char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
3110 {
3111         if (r_n == NULL)
3112                 return False;
3113
3114         prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
3115         depth++;
3116
3117         if(!prs_align(ps))
3118                 return False;
3119         
3120         if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
3121                 return False;
3122
3123         if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
3124                 return False;
3125
3126         if(!prs_werror("status", ps, depth, &r_n->status))
3127                 return False;
3128
3129         return True;
3130 }
3131
3132 /*******************************************************************
3133  initialises a structure.
3134  ********************************************************************/
3135
3136 BOOL init_srv_q_net_disk_enum(SRV_Q_NET_DISK_ENUM *q_n,
3137                               const char *srv_name,
3138                               uint32 preferred_len,
3139                               ENUM_HND *enum_hnd
3140         ) 
3141 {
3142   
3143
3144         DEBUG(5,("init_srv_q_net_srv_disk_enum\n"));
3145
3146         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
3147
3148         q_n->disk_enum_ctr.level = 0;
3149         q_n->disk_enum_ctr.disk_info_ptr   = 0;
3150   
3151         q_n->preferred_len = preferred_len;
3152         memcpy(&q_n->enum_hnd, enum_hnd, sizeof(*enum_hnd));
3153
3154         return True;
3155 }
3156
3157 /*******************************************************************
3158  Reads or writes a structure.
3159  ********************************************************************/
3160
3161 BOOL srv_io_q_net_disk_enum(const char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth)
3162 {
3163         if (q_n == NULL)
3164                 return False;
3165
3166         prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum");
3167         depth++;
3168
3169         if(!prs_align(ps))
3170                 return False;
3171
3172         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3173                 return False;
3174