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