This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.
[kai/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, 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(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, 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(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, char *net_name, 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(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, char *net_name, uint32 type, 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(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                                 char *net_name, char *remark,
183                                 char *path, 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(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                                 char *net_name, uint32 type, char *remark,
240                                 uint32 perms, uint32 max_uses, uint32 num_uses,
241                                 char *path, 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(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                                 char *net_name, 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, char *net_name, uint32 type, 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(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(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, char *remark,
380                                 uint32 perms, uint32 max_uses, uint32 num_uses,
381                                 char *path, 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(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                                 char *net_name, char *remark,
445                                 char *path, 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(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, 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(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, 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(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(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(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(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(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(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(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                                 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(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(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(r_n->total_entries != 0) {
1123                 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1124                         return False;
1125         }
1126
1127         if(!prs_werror("status", ps, depth, &r_n->status))
1128                 return False;
1129
1130         return True;
1131 }
1132
1133 /*******************************************************************
1134  initialises a structure.
1135 ********************************************************************/
1136
1137 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)
1138 {
1139
1140         uint32 ptr_share_name;
1141
1142         DEBUG(5,("init_srv_q_net_share_get_info\n"));
1143
1144         init_buf_unistr2(&q_n->uni_srv_name,   &q_n->ptr_srv_name, srv_name);
1145         init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name,    share_name);
1146
1147         q_n->info_level = info_level;
1148
1149         return True;
1150 }
1151
1152 /*******************************************************************
1153  Reads or writes a structure.
1154 ********************************************************************/
1155
1156 BOOL srv_io_q_net_share_get_info(char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
1157 {
1158         if (q_n == NULL)
1159                 return False;
1160
1161         prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
1162         depth++;
1163
1164         if(!prs_align(ps))
1165                 return False;
1166
1167         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1168                 return False;
1169         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1170                 return False;
1171
1172         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1173                 return False;
1174
1175         if(!prs_align(ps))
1176                 return False;
1177
1178         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1179                 return False;
1180
1181         return True;
1182 }
1183
1184 /*******************************************************************
1185  Reads or writes a structure.
1186 ********************************************************************/
1187
1188 static BOOL srv_io_srv_share_info(char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n)
1189 {
1190         if (r_n == NULL)
1191                 return False;
1192
1193         prs_debug(ps, depth, desc, "srv_io_srv_share_info");
1194         depth++;
1195
1196         if(!prs_align(ps))
1197                 return False;
1198
1199         if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
1200                 return False;
1201
1202         if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
1203                 return False;
1204
1205         if (r_n->ptr_share_ctr != 0) {
1206                 switch (r_n->switch_value) {
1207                 case 0:
1208                         if(!srv_io_share_info0("", &r_n->share.info0.info_0, ps, depth))
1209                                 return False;
1210
1211                         /* allow access to pointers in the str part. */
1212                         r_n->share.info0.info_0_str.ptrs = &r_n->share.info0.info_0;
1213
1214                         if(!srv_io_share_info0_str("", &r_n->share.info0.info_0_str, ps, depth))
1215                                 return False;
1216
1217                         break;
1218                 case 1:
1219                         if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
1220                                 return False;
1221
1222                         /* allow access to pointers in the str part. */
1223                         r_n->share.info1.info_1_str.ptrs = &r_n->share.info1.info_1;
1224
1225                         if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
1226                                 return False;
1227
1228                         break;
1229                 case 2:
1230                         if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
1231                                 return False;
1232
1233                         if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth))
1234                                 return False;
1235
1236                         break;
1237                 case 501:
1238                         if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth))
1239                                 return False;
1240                         if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth))
1241                                 return False;
1242                         break;
1243
1244                 case 502:
1245                         if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth))
1246                                 return False;
1247
1248                         /* allow access to pointers in the str part. */
1249                         r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502;
1250
1251                         if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth))
1252                                 return False;
1253                         break;
1254                 case 1004:
1255                         if(!srv_io_share_info1004("", &r_n->share.info1004.info_1004, ps, depth))
1256                                 return False;
1257
1258                         /* allow access to pointers in the str part. */
1259                         r_n->share.info1004.info_1004_str.ptrs = &r_n->share.info1004.info_1004;
1260
1261                         if(!srv_io_share_info1004_str("", &r_n->share.info1004.info_1004_str, ps, depth))
1262                                 return False;
1263                         break;
1264                 case 1005:
1265                         if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth))
1266                                 return False;           
1267                         break;
1268                 case 1006:
1269                         if(!srv_io_share_info1006("", &r_n->share.info1006, ps, depth))
1270                                 return False;           
1271                         break;
1272                 case 1007:
1273                         if(!srv_io_share_info1007("", &r_n->share.info1007.info_1007, ps, depth))
1274                                 return False;
1275
1276                         /* allow access to pointers in the str part. */
1277                         r_n->share.info1007.info_1007_str.ptrs = &r_n->share.info1007.info_1007;
1278
1279                         if(!srv_io_share_info1007_str("", &r_n->share.info1007.info_1007_str, ps, depth))
1280                                 return False;
1281                         break;
1282                 case 1501:
1283                         if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth))
1284                                 return False;
1285                 default:
1286                         DEBUG(5,("%s no share info at switch_value %d\n",
1287                                  tab_depth(depth), r_n->switch_value));
1288                         break;
1289                 }
1290         }
1291
1292         return True;
1293 }
1294
1295 /*******************************************************************
1296  Reads or writes a structure.
1297 ********************************************************************/
1298
1299 BOOL srv_io_r_net_share_get_info(char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
1300 {
1301         if (r_n == NULL)
1302                 return False;
1303
1304         prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
1305         depth++;
1306
1307         if(!prs_align(ps))
1308                 return False;
1309
1310         if(!srv_io_srv_share_info("info  ", ps, depth, &r_n->info))
1311                 return False;
1312
1313         if(!prs_align(ps))
1314                 return False;
1315
1316         if(!prs_werror("status", ps, depth, &r_n->status))
1317                 return False;
1318
1319         return True;
1320 }
1321
1322 /*******************************************************************
1323  intialises a structure.
1324 ********************************************************************/
1325
1326 BOOL init_srv_q_net_share_set_info(SRV_Q_NET_SHARE_SET_INFO *q_n, 
1327                                    const char *srv_name, 
1328                                    const char *share_name, 
1329                                    uint32 info_level, 
1330                                    const SRV_SHARE_INFO *info) 
1331 {
1332
1333         uint32 ptr_share_name;
1334
1335         DEBUG(5,("init_srv_q_net_share_set_info\n"));
1336
1337         init_buf_unistr2(&q_n->uni_srv_name,   &q_n->ptr_srv_name, srv_name);
1338         init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name,    share_name);
1339
1340         q_n->info_level = info_level;
1341   
1342         q_n->info = *info;
1343
1344         q_n->ptr_parm_error = 1;
1345         q_n->parm_error     = 0;
1346
1347         return True;
1348 }
1349
1350 /*******************************************************************
1351  Reads or writes a structure.
1352 ********************************************************************/
1353
1354 BOOL srv_io_q_net_share_set_info(char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
1355 {
1356         if (q_n == NULL)
1357                 return False;
1358
1359         prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info");
1360         depth++;
1361
1362         if(!prs_align(ps))
1363                 return False;
1364
1365         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1366                 return False;
1367         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1368                 return False;
1369
1370         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1371                 return False;
1372
1373         if(!prs_align(ps))
1374                 return False;
1375
1376         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1377                 return False;
1378
1379         if(!prs_align(ps))
1380                 return False;
1381
1382         if(!srv_io_srv_share_info("info  ", ps, depth, &q_n->info))
1383                 return False;
1384
1385         if(!prs_align(ps))
1386                 return False;
1387         if(!prs_uint32("ptr_parm_error", ps, depth, &q_n->ptr_parm_error))
1388                 return False;
1389         if(q_n->ptr_parm_error!=0) {
1390                 if(!prs_uint32("parm_error", ps, depth, &q_n->parm_error))
1391                         return False;
1392         }
1393
1394         return True;
1395 }
1396
1397 /*******************************************************************
1398  Reads or writes a structure.
1399 ********************************************************************/
1400
1401 BOOL srv_io_r_net_share_set_info(char *desc, SRV_R_NET_SHARE_SET_INFO *r_n, prs_struct *ps, int depth)
1402 {
1403         if (r_n == NULL)
1404                 return False;
1405
1406         prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info");
1407         depth++;
1408
1409         if(!prs_align(ps))
1410                 return False;
1411
1412         if(!prs_uint32("ptr_parm_error  ", ps, depth, &r_n->ptr_parm_error))
1413                 return False;
1414
1415         if(r_n->ptr_parm_error) {
1416
1417                 if(!prs_uint32("parm_error  ", ps, depth, &r_n->parm_error))
1418                         return False;
1419         }
1420
1421         if(!prs_werror("status", ps, depth, &r_n->status))
1422                 return False;
1423
1424         return True;
1425 }       
1426
1427
1428 /*******************************************************************
1429  Reads or writes a structure.
1430 ********************************************************************/
1431
1432 BOOL srv_io_q_net_share_add(char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
1433 {
1434         if (q_n == NULL)
1435                 return False;
1436
1437         prs_debug(ps, depth, desc, "srv_io_q_net_share_add");
1438         depth++;
1439
1440         if(!prs_align(ps))
1441                 return False;
1442
1443         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1444                 return False;
1445         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1446                 return False;
1447
1448         if(!prs_align(ps))
1449                 return False;
1450
1451         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1452                 return False;
1453
1454         if(!prs_align(ps))
1455                 return False;
1456
1457         if(!srv_io_srv_share_info("info  ", ps, depth, &q_n->info))
1458                 return False;
1459
1460         if(!prs_align(ps))
1461                 return False;
1462
1463         if(!prs_uint32("ptr_err_index", ps, depth, &q_n->ptr_err_index))
1464                 return False;
1465         if (q_n->ptr_err_index)
1466                 if (!prs_uint32("err_index", ps, depth, &q_n->err_index))
1467                         return False;
1468
1469         return True;
1470 }
1471
1472 void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, char *srvname,
1473                               char *netname, uint32 type, char *remark, 
1474                               uint32 perms, uint32 max_uses, uint32 num_uses,
1475                               char *path, char *passwd)
1476 {
1477         q->ptr_srv_name = 1;
1478         init_unistr2(&q->uni_srv_name, srvname, strlen(srvname) +1);
1479         q->info.switch_value = q->info_level = 2;
1480
1481         q->info.ptr_share_ctr = 1;
1482         init_srv_share_info2(&q->info.share.info2.info_2, netname, type,
1483                              remark, perms, max_uses, num_uses, path, passwd);
1484         init_srv_share_info2_str(&q->info.share.info2.info_2_str, netname,
1485                                  remark, path, passwd);
1486         q->ptr_err_index = 1;
1487         q->err_index = 0;
1488 }
1489
1490
1491 /*******************************************************************
1492  Reads or writes a structure.
1493 ********************************************************************/
1494
1495 BOOL srv_io_r_net_share_add(char *desc, SRV_R_NET_SHARE_ADD *r_n, prs_struct *ps, int depth)
1496 {
1497         if (r_n == NULL)
1498                 return False;
1499
1500         prs_debug(ps, depth, desc, "srv_io_r_net_share_add");
1501         depth++;
1502
1503         if(!prs_align(ps))
1504                 return False;
1505
1506         if(!prs_uint32("ptr_parm_error", ps, depth, &r_n->ptr_parm_error))
1507                 return False;
1508
1509         if(r_n->ptr_parm_error) {
1510           
1511                 if(!prs_uint32("parm_error", ps, depth, &r_n->parm_error))
1512                         return False;
1513         }
1514
1515         if(!prs_werror("status", ps, depth, &r_n->status))
1516                 return False;
1517
1518         return True;
1519 }       
1520
1521 /*******************************************************************
1522  initialises a structure.
1523 ********************************************************************/
1524
1525 void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname,
1526                               const char *sharename)
1527 {
1528         del->ptr_srv_name = 1;
1529         init_unistr2(&del->uni_srv_name, srvname, strlen(srvname) +1 );
1530         init_unistr2(&del->uni_share_name, sharename, strlen(sharename) + 1);
1531 }
1532
1533 /*******************************************************************
1534  Reads or writes a structure.
1535 ********************************************************************/
1536
1537 BOOL srv_io_q_net_share_del(char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1538 {
1539         if (q_n == NULL)
1540                 return False;
1541
1542         prs_debug(ps, depth, desc, "srv_io_q_net_share_del");
1543         depth++;
1544
1545         if(!prs_align(ps))
1546                 return False;
1547
1548         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1549                 return False;
1550         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1551                 return False;
1552
1553         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1554                 return False;
1555
1556         if(!prs_align(ps))
1557                 return False;
1558         if(!prs_uint32("reserved", ps, depth, &q_n->reserved))
1559                 return False;
1560
1561         return True;
1562 }
1563
1564 /*******************************************************************
1565  Reads or writes a structure.
1566 ********************************************************************/
1567
1568 BOOL srv_io_r_net_share_del(char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1569 {
1570         if (q_n == NULL)
1571                 return False;
1572
1573         prs_debug(ps, depth, desc, "srv_io_r_net_share_del");
1574         depth++;
1575
1576         if(!prs_align(ps))
1577                 return False;
1578
1579         if(!prs_werror("status", ps, depth, &q_n->status))
1580                 return False;
1581
1582         return True;
1583 }       
1584
1585 /*******************************************************************
1586  Inits a SESS_INFO_0_STR structure
1587 ********************************************************************/
1588
1589 void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name)
1590 {
1591         DEBUG(5,("init_srv_sess_info0_str\n"));
1592
1593         init_unistr2(&ss0->uni_name, name, strlen(name)+1);
1594 }
1595
1596 /*******************************************************************
1597  Reads or writes a structure.
1598 ********************************************************************/
1599
1600 static BOOL srv_io_sess_info0_str(char *desc,  SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
1601 {
1602         if (ss0 == NULL)
1603                 return False;
1604
1605         prs_debug(ps, depth, desc, "srv_io_sess_info0_str");
1606         depth++;
1607
1608         if(!prs_align(ps))
1609                 return False;
1610
1611         if(!smb_io_unistr2("", &ss0->uni_name, True, ps, depth))
1612                 return False;
1613
1614         return True;
1615 }
1616
1617 /*******************************************************************
1618  Inits a SESS_INFO_0 structure
1619 ********************************************************************/
1620
1621 void init_srv_sess_info0(SESS_INFO_0 *ss0, char *name)
1622 {
1623         DEBUG(5,("init_srv_sess_info0: %s\n", name));
1624
1625         ss0->ptr_name = (name != NULL) ? 1 : 0;
1626 }
1627
1628 /*******************************************************************
1629  Reads or writes a structure.
1630 ********************************************************************/
1631
1632 static BOOL srv_io_sess_info0(char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1633 {
1634         if (ss0 == NULL)
1635                 return False;
1636
1637         prs_debug(ps, depth, desc, "srv_io_sess_info0");
1638         depth++;
1639
1640         if(!prs_align(ps))
1641                 return False;
1642
1643         if(!prs_uint32("ptr_name", ps, depth, &ss0->ptr_name))
1644                 return False;
1645
1646         return True;
1647 }
1648
1649 /*******************************************************************
1650  Reads or writes a structure.
1651 ********************************************************************/
1652
1653 static BOOL srv_io_srv_sess_info_0(char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1654 {
1655         if (ss0 == NULL)
1656                 return False;
1657
1658         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
1659         depth++;
1660
1661         if(!prs_align(ps))
1662                 return False;
1663
1664         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1665                 return False;
1666         if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
1667                 return False;
1668
1669         if (ss0->ptr_sess_info != 0) {
1670                 int i;
1671                 int num_entries = ss0->num_entries_read;
1672
1673                 if (num_entries > MAX_SESS_ENTRIES) {
1674                         num_entries = MAX_SESS_ENTRIES; /* report this! */
1675                 }
1676
1677                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1678                         return False;
1679
1680                 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
1681
1682                 for (i = 0; i < num_entries; i++) {
1683                         if(!srv_io_sess_info0("", &ss0->info_0[i], ps, depth))
1684                                 return False;
1685                 }
1686
1687                 for (i = 0; i < num_entries; i++) {
1688                         if(!srv_io_sess_info0_str("", &ss0->info_0_str[i], ps, depth))
1689                                 return False;
1690                 }
1691
1692                 if(!prs_align(ps))
1693                         return False;
1694         }
1695
1696         return True;
1697 }
1698
1699 /*******************************************************************
1700  Inits a SESS_INFO_1_STR structure
1701 ********************************************************************/
1702
1703 void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char *user)
1704 {
1705         DEBUG(5,("init_srv_sess_info1_str\n"));
1706
1707         init_unistr2(&ss1->uni_name, name, strlen(name)+1);
1708         init_unistr2(&ss1->uni_user, user, strlen(user)+1);
1709 }
1710
1711 /*******************************************************************
1712  Reads or writes a structure.
1713 ********************************************************************/
1714
1715 static BOOL srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
1716 {
1717         if (ss1 == NULL)
1718                 return False;
1719
1720         prs_debug(ps, depth, desc, "srv_io_sess_info1_str");
1721         depth++;
1722
1723         if(!prs_align(ps))
1724                 return False;
1725
1726         if(!smb_io_unistr2("", &ss1->uni_name, True, ps, depth))
1727                 return False;
1728         if(!smb_io_unistr2("", &(ss1->uni_user), True, ps, depth))
1729                 return False;
1730
1731         return True;
1732 }
1733
1734 /*******************************************************************
1735  Inits a SESS_INFO_1 structure
1736 ********************************************************************/
1737
1738 void init_srv_sess_info1(SESS_INFO_1 *ss1, 
1739                                 char *name, char *user,
1740                                 uint32 num_opens, uint32 open_time, uint32 idle_time,
1741                                 uint32 user_flags)
1742 {
1743         DEBUG(5,("init_srv_sess_info1: %s\n", name));
1744
1745         ss1->ptr_name = (name != NULL) ? 1 : 0;
1746         ss1->ptr_user = (user != NULL) ? 1 : 0;
1747
1748         ss1->num_opens  = num_opens;
1749         ss1->open_time  = open_time;
1750         ss1->idle_time  = idle_time;
1751         ss1->user_flags = user_flags;
1752 }
1753
1754 /*******************************************************************
1755 reads or writes a structure.
1756 ********************************************************************/
1757
1758 static BOOL srv_io_sess_info1(char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1759 {
1760         if (ss1 == NULL)
1761                 return False;
1762
1763         prs_debug(ps, depth, desc, "srv_io_sess_info1");
1764         depth++;
1765
1766         if(!prs_align(ps))
1767                 return False;
1768
1769         if(!prs_uint32("ptr_name  ", ps, depth, &ss1->ptr_name))
1770                 return False;
1771         if(!prs_uint32("ptr_user  ", ps, depth, &ss1->ptr_user))
1772                 return False;
1773
1774         if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
1775                 return False;
1776         if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
1777                 return False;
1778         if(!prs_uint32("idle_time ", ps, depth, &ss1->idle_time))
1779                 return False;
1780         if(!prs_uint32("user_flags", ps, depth, &ss1->user_flags))
1781                 return False;
1782
1783         return True;
1784 }
1785
1786 /*******************************************************************
1787  Reads or writes a structure.
1788 ********************************************************************/
1789
1790 static BOOL srv_io_srv_sess_info_1(char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1791 {
1792         if (ss1 == NULL)
1793                 return False;
1794
1795         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
1796         depth++;
1797
1798         if(!prs_align(ps))
1799                 return False;
1800
1801         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1802                 return False;
1803         if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
1804                 return False;
1805
1806         if (ss1->ptr_sess_info != 0) {
1807                 int i;
1808                 int num_entries = ss1->num_entries_read;
1809
1810                 if (num_entries > MAX_SESS_ENTRIES) {
1811                         num_entries = MAX_SESS_ENTRIES; /* report this! */
1812                 }
1813
1814                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1815                         return False;
1816
1817                 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
1818
1819                 for (i = 0; i < num_entries; i++) {
1820                         if(!srv_io_sess_info1("", &ss1->info_1[i], ps, depth))
1821                                 return False;
1822                 }
1823
1824                 for (i = 0; i < num_entries; i++) {
1825                         if(!srv_io_sess_info1_str("", &ss1->info_1_str[i], ps, depth))
1826                                 return False;
1827                 }
1828
1829                 if(!prs_align(ps))
1830                         return False;
1831         }
1832
1833         return True;
1834 }
1835
1836 /*******************************************************************
1837  Reads or writes a structure.
1838 ********************************************************************/
1839
1840 static BOOL srv_io_srv_sess_ctr(char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1841 {
1842         SRV_SESS_INFO_CTR *ctr = *pp_ctr;
1843
1844         prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
1845         depth++;
1846
1847         if(UNMARSHALLING(ps)) {
1848                 ctr = *pp_ctr = (SRV_SESS_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_SESS_INFO_CTR));
1849                 if (ctr == NULL)
1850                         return False;
1851         }
1852
1853         if (ctr == NULL)
1854                 return False;
1855
1856         if(!prs_align(ps))
1857                 return False;
1858
1859         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1860                 return False;
1861         if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
1862                 return False;
1863
1864         if (ctr->ptr_sess_ctr != 0) {
1865                 switch (ctr->switch_value) {
1866                 case 0:
1867                         if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
1868                                 return False;
1869                         break;
1870                 case 1:
1871                         if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
1872                                 return False;
1873                         break;
1874                 default:
1875                         DEBUG(5,("%s no session info at switch_value %d\n",
1876                                  tab_depth(depth), ctr->switch_value));
1877                         break;
1878                 }
1879         }
1880
1881         return True;
1882 }
1883
1884 /*******************************************************************
1885  Inits a SRV_Q_NET_SESS_ENUM structure.
1886 ********************************************************************/
1887
1888 void init_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, 
1889                               char *srv_name, char *qual_name,
1890                               char *user_name, uint32 sess_level, 
1891                               SRV_SESS_INFO_CTR *ctr, uint32 preferred_len,
1892                               ENUM_HND *hnd)
1893 {
1894         q_n->ctr = ctr;
1895
1896         DEBUG(5,("init_q_net_sess_enum\n"));
1897
1898         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1899         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1900         init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
1901
1902         q_n->sess_level    = sess_level;
1903         q_n->preferred_len = preferred_len;
1904
1905         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1906 }
1907
1908 /*******************************************************************
1909  Reads or writes a structure.
1910 ********************************************************************/
1911
1912 BOOL srv_io_q_net_sess_enum(char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
1913 {
1914         if (q_n == NULL)
1915                 return False;
1916
1917         prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
1918         depth++;
1919
1920         if(!prs_align(ps))
1921                 return False;
1922
1923         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1924                 return False;
1925         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1926                 return False;
1927
1928         if(!prs_align(ps))
1929                 return False;
1930
1931         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1932                 return False;
1933         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1934                 return False;
1935
1936         if(!prs_align(ps))
1937                 return False;
1938         if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
1939                 return False;
1940         if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
1941                 return False;
1942
1943         if(!prs_align(ps))
1944                 return False;
1945
1946         if(!prs_uint32("sess_level", ps, depth, &q_n->sess_level))
1947                 return False;
1948         
1949         if (q_n->sess_level != -1) {
1950                 if(!srv_io_srv_sess_ctr("sess_ctr", &q_n->ctr, ps, depth))
1951                         return False;
1952         }
1953
1954         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1955                 return False;
1956
1957         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1958                 return False;
1959
1960         return True;
1961 }
1962
1963 /*******************************************************************
1964  Reads or writes a structure.
1965 ********************************************************************/
1966
1967 BOOL srv_io_r_net_sess_enum(char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
1968 {
1969         if (r_n == NULL)
1970                 return False;
1971
1972         prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
1973         depth++;
1974
1975         if(!prs_align(ps))
1976                 return False;
1977
1978         if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
1979                 return False;
1980
1981         if (r_n->sess_level != -1) {
1982                 if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
1983                         return False;
1984         }
1985
1986         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1987                 return False;
1988         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1989                 return False;
1990         if(!prs_werror("status", ps, depth, &r_n->status))
1991                 return False;
1992
1993         return True;
1994 }
1995
1996 /*******************************************************************
1997  Inits a CONN_INFO_0 structure
1998 ********************************************************************/
1999
2000 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
2001 {
2002         DEBUG(5,("init_srv_conn_info0\n"));
2003
2004         ss0->id = id;
2005 }
2006
2007 /*******************************************************************
2008  Reads or writes a structure.
2009 ********************************************************************/
2010
2011 static BOOL srv_io_conn_info0(char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
2012 {
2013         if (ss0 == NULL)
2014                 return False;
2015
2016         prs_debug(ps, depth, desc, "srv_io_conn_info0");
2017         depth++;
2018
2019         if(!prs_align(ps))
2020                 return False;
2021
2022         if(!prs_uint32("id", ps, depth, &ss0->id))
2023                 return False;
2024
2025         return True;
2026 }
2027
2028 /*******************************************************************
2029  Reads or writes a structure.
2030 ********************************************************************/
2031
2032 static BOOL srv_io_srv_conn_info_0(char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
2033 {
2034         if (ss0 == NULL)
2035                 return False;
2036
2037         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
2038         depth++;
2039
2040         if(!prs_align(ps))
2041                 return False;
2042
2043         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
2044                 return False;
2045         if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
2046                 return False;
2047
2048         if (ss0->ptr_conn_info != 0) {
2049                 int i;
2050                 int num_entries = ss0->num_entries_read;
2051
2052                 if (num_entries > MAX_CONN_ENTRIES) {
2053                         num_entries = MAX_CONN_ENTRIES; /* report this! */
2054                 }
2055
2056                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
2057                         return False;
2058
2059                 for (i = 0; i < num_entries; i++) {
2060                         if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
2061                                 return False;
2062                 }
2063
2064                 if(!prs_align(ps))
2065                         return False;
2066         }
2067
2068         return True;
2069 }
2070
2071 /*******************************************************************
2072  Inits a CONN_INFO_1_STR structure
2073 ********************************************************************/
2074
2075 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, char *usr_name, char *net_name)
2076 {
2077         DEBUG(5,("init_srv_conn_info1_str\n"));
2078
2079         init_unistr2(&ss1->uni_usr_name, usr_name, strlen(usr_name)+1);
2080         init_unistr2(&ss1->uni_net_name, net_name, strlen(net_name)+1);
2081 }
2082
2083 /*******************************************************************
2084  Reads or writes a structure.
2085 ********************************************************************/
2086
2087 static BOOL srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
2088 {
2089         if (ss1 == NULL)
2090                 return False;
2091
2092         prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
2093         depth++;
2094
2095         if(!prs_align(ps))
2096                 return False;
2097
2098         if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
2099                 return False;
2100         if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
2101                 return False;
2102
2103         return True;
2104 }
2105
2106 /*******************************************************************
2107  Inits a CONN_INFO_1 structure
2108 ********************************************************************/
2109
2110 void init_srv_conn_info1(CONN_INFO_1 *ss1, 
2111                                 uint32 id, uint32 type,
2112                                 uint32 num_opens, uint32 num_users, uint32 open_time,
2113                                 char *usr_name, char *net_name)
2114 {
2115         DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
2116
2117         ss1->id        = id       ;
2118         ss1->type      = type     ;
2119         ss1->num_opens = num_opens ;
2120         ss1->num_users = num_users;
2121         ss1->open_time = open_time;
2122
2123         ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
2124         ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
2125 }
2126
2127 /*******************************************************************
2128  Reads or writes a structure.
2129 ********************************************************************/
2130
2131 static BOOL srv_io_conn_info1(char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2132 {
2133         if (ss1 == NULL)
2134                 return False;
2135
2136         prs_debug(ps, depth, desc, "srv_io_conn_info1");
2137         depth++;
2138
2139         if(!prs_align(ps))
2140                 return False;
2141
2142         if(!prs_uint32("id          ", ps, depth, &ss1->id))
2143                 return False;
2144         if(!prs_uint32("type        ", ps, depth, &ss1->type))
2145                 return False;
2146         if(!prs_uint32("num_opens   ", ps, depth, &ss1->num_opens))
2147                 return False;
2148         if(!prs_uint32("num_users   ", ps, depth, &ss1->num_users))
2149                 return False;
2150         if(!prs_uint32("open_time   ", ps, depth, &ss1->open_time))
2151                 return False;
2152
2153         if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
2154                 return False;
2155         if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
2156                 return False;
2157
2158         return True;
2159 }
2160
2161 /*******************************************************************
2162  Reads or writes a structure.
2163 ********************************************************************/
2164
2165 static BOOL srv_io_srv_conn_info_1(char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2166 {
2167         if (ss1 == NULL)
2168                 return False;
2169
2170         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
2171         depth++;
2172
2173         if(!prs_align(ps))
2174                 return False;
2175
2176         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
2177                 return False;
2178         if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
2179                 return False;
2180
2181         if (ss1->ptr_conn_info != 0) {
2182                 int i;
2183                 int num_entries = ss1->num_entries_read;
2184
2185                 if (num_entries > MAX_CONN_ENTRIES) {
2186                         num_entries = MAX_CONN_ENTRIES; /* report this! */
2187                 }
2188
2189                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
2190                         return False;
2191
2192                 for (i = 0; i < num_entries; i++) {
2193                         if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
2194                                 return False;
2195                 }
2196
2197                 for (i = 0; i < num_entries; i++) {
2198                         if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
2199                                 return False;
2200                 }
2201
2202                 if(!prs_align(ps))
2203                         return False;
2204         }
2205
2206         return True;
2207 }
2208
2209 /*******************************************************************
2210  Reads or writes a structure.
2211 ********************************************************************/
2212
2213 static BOOL srv_io_srv_conn_ctr(char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
2214 {
2215         SRV_CONN_INFO_CTR *ctr = *pp_ctr;
2216
2217         prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
2218         depth++;
2219
2220         if (UNMARSHALLING(ps)) {
2221                 ctr = *pp_ctr = (SRV_CONN_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_CONN_INFO_CTR));
2222                 if (ctr == NULL)
2223                         return False;
2224         }
2225                 
2226         if (ctr == NULL)
2227                 return False;
2228
2229         if(!prs_align(ps))
2230                 return False;
2231
2232         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2233                 return False;
2234         if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
2235                 return False;
2236
2237         if (ctr->ptr_conn_ctr != 0) {
2238                 switch (ctr->switch_value) {
2239                 case 0:
2240                         if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
2241                                 return False;
2242                         break;
2243                 case 1:
2244                         if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
2245                                 return False;
2246                         break;
2247                 default:
2248                         DEBUG(5,("%s no connection info at switch_value %d\n",
2249                                  tab_depth(depth), ctr->switch_value));
2250                         break;
2251                 }
2252         }
2253
2254         return True;
2255 }
2256
2257 /*******************************************************************
2258   Reads or writes a structure.
2259 ********************************************************************/
2260
2261 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, 
2262                                 char *srv_name, char *qual_name,
2263                                 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
2264                                 uint32 preferred_len,
2265                                 ENUM_HND *hnd)
2266 {
2267         DEBUG(5,("init_q_net_conn_enum\n"));
2268
2269         q_n->ctr = ctr;
2270
2271         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
2272         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2273
2274         q_n->conn_level    = conn_level;
2275         q_n->preferred_len = preferred_len;
2276
2277         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2278 }
2279
2280 /*******************************************************************
2281  Reads or writes a structure.
2282 ********************************************************************/
2283
2284 BOOL srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
2285 {
2286         if (q_n == NULL)
2287                 return False;
2288
2289         prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
2290         depth++;
2291
2292         if(!prs_align(ps))
2293                 return False;
2294
2295         if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2296                 return False;
2297         if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
2298                 return False;
2299
2300         if(!prs_align(ps))
2301                 return False;
2302
2303         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2304                 return False;
2305         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2306                 return False;
2307
2308         if(!prs_align(ps))
2309                 return False;
2310
2311         if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
2312                 return False;
2313         
2314         if (q_n->conn_level != -1) {
2315                 if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
2316                         return False;
2317         }
2318
2319         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2320                 return False;
2321
2322         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2323                 return False;
2324
2325         return True;
2326 }
2327
2328 /*******************************************************************
2329  Reads or writes a structure.
2330 ********************************************************************/
2331
2332 BOOL srv_io_r_net_conn_enum(char *desc,  SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
2333 {
2334         if (r_n == NULL)
2335                 return False;
2336
2337         prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
2338         depth++;
2339
2340         if(!prs_align(ps))
2341                 return False;
2342
2343         if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
2344                 return False;
2345
2346         if (r_n->conn_level != -1) {
2347                 if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
2348                         return False;
2349         }
2350
2351         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2352                 return False;
2353         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2354                 return False;
2355         if(!prs_werror("status", ps, depth, &r_n->status))
2356                 return False;
2357
2358         return True;
2359 }
2360
2361 /*******************************************************************
2362  Inits a FILE_INFO_3_STR structure
2363 ********************************************************************/
2364
2365 void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name)
2366 {
2367         DEBUG(5,("init_srv_file_info3_str\n"));
2368
2369         init_unistr2(&fi3->uni_path_name, path_name, strlen(path_name)+1);
2370         init_unistr2(&fi3->uni_user_name, user_name, strlen(user_name)+1);
2371 }
2372
2373 /*******************************************************************
2374  Reads or writes a structure.
2375 ********************************************************************/
2376
2377 static BOOL srv_io_file_info3_str(char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth)
2378 {
2379         if (sh1 == NULL)
2380                 return False;
2381
2382         prs_debug(ps, depth, desc, "srv_io_file_info3_str");
2383         depth++;
2384
2385         if(!prs_align(ps))
2386                 return False;
2387
2388         if(!smb_io_unistr2("", &sh1->uni_path_name, True, ps, depth))
2389                 return False;
2390         if(!smb_io_unistr2("", &sh1->uni_user_name, True, ps, depth))
2391                 return False;
2392
2393         return True;
2394 }
2395
2396 /*******************************************************************
2397  Inits a FILE_INFO_3 structure
2398 ********************************************************************/
2399
2400 void init_srv_file_info3(FILE_INFO_3 *fl3,
2401                          uint32 id, uint32 perms, uint32 num_locks,
2402                          char *path_name, char *user_name)
2403 {
2404         DEBUG(5,("init_srv_file_info3: %s %s\n", path_name, user_name));
2405
2406         fl3->id        = id;    
2407         fl3->perms     = perms;
2408         fl3->num_locks = num_locks;
2409
2410         fl3->ptr_path_name = (path_name != NULL) ? 1 : 0;
2411         fl3->ptr_user_name = (user_name != NULL) ? 1 : 0;
2412 }
2413
2414 /*******************************************************************
2415  Reads or writes a structure.
2416 ********************************************************************/
2417
2418 static BOOL srv_io_file_info3(char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
2419 {
2420         if (fl3 == NULL)
2421                 return False;
2422
2423         prs_debug(ps, depth, desc, "srv_io_file_info3");
2424         depth++;
2425
2426         if(!prs_align(ps))
2427                 return False;
2428
2429         if(!prs_uint32("id           ", ps, depth, &fl3->id))
2430                 return False;
2431         if(!prs_uint32("perms        ", ps, depth, &fl3->perms))
2432                 return False;
2433         if(!prs_uint32("num_locks    ", ps, depth, &fl3->num_locks))
2434                 return False;
2435         if(!prs_uint32("ptr_path_name", ps, depth, &fl3->ptr_path_name))
2436                 return False;
2437         if(!prs_uint32("ptr_user_name", ps, depth, &fl3->ptr_user_name))
2438                 return False;
2439
2440         return True;
2441 }
2442
2443 /*******************************************************************
2444  Reads or writes a structure.
2445 ********************************************************************/
2446
2447 static BOOL srv_io_srv_file_ctr(char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
2448 {
2449         if (ctr == NULL)
2450                 return False;
2451
2452         prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
2453         depth++;
2454
2455         if (UNMARSHALLING(ps)) {
2456                 memset(ctr, '\0', sizeof(SRV_FILE_INFO_CTR));
2457         }
2458
2459         if(!prs_align(ps))
2460                 return False;
2461
2462         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2463                 return False;
2464         if (ctr->switch_value != 3) {
2465                 DEBUG(5,("%s File info %d level not supported\n",
2466                          tab_depth(depth), ctr->switch_value));
2467         }
2468         if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info))
2469                 return False;
2470         if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
2471                 return False;
2472         if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
2473                 return False;
2474         if (ctr->ptr_entries == 0)
2475                 return True;
2476         if(!prs_uint32("num_entries2", ps, depth, 
2477                        &ctr->num_entries2))
2478                 return False;
2479
2480         switch (ctr->switch_value) {
2481         case 3: {
2482                 SRV_FILE_INFO_3 *info3 = ctr->file.info3;
2483                 int num_entries = ctr->num_entries;
2484                 int i;
2485
2486                 if (UNMARSHALLING(ps)) {
2487                         if (!(info3 = (SRV_FILE_INFO_3 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_FILE_INFO_3))))
2488                                 return False;
2489                         ctr->file.info3 = info3;
2490                 }
2491
2492                 for (i = 0; i < num_entries; i++) {
2493                         if(!srv_io_file_info3("", &ctr->file.info3[i].info_3, ps, depth))
2494                                 return False;
2495                 }
2496                 for (i = 0; i < num_entries; i++) {
2497                         if(!srv_io_file_info3_str("", &ctr->file.info3[i].info_3_str, ps, depth))
2498                                 return False;
2499                 }
2500                 break;
2501         }
2502         default:
2503                 DEBUG(5,("%s no file info at switch_value %d\n",
2504                          tab_depth(depth), ctr->switch_value));
2505                 break;
2506         }
2507                         
2508         return True;
2509 }
2510
2511 /*******************************************************************
2512  Inits a SRV_Q_NET_FILE_ENUM structure.
2513 ********************************************************************/
2514
2515 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, 
2516                               const char *srv_name, const char *qual_name, 
2517                               const char *user_name,
2518                               uint32 file_level, SRV_FILE_INFO_CTR *ctr,
2519                               uint32 preferred_len,
2520                               ENUM_HND *hnd)
2521 {
2522         DEBUG(5,("init_q_net_file_enum\n"));
2523
2524         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
2525         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2526         init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
2527
2528         q_n->file_level    = q_n->ctr.switch_value = file_level;
2529         q_n->preferred_len = preferred_len;
2530         q_n->ctr.ptr_file_info = 1;
2531         q_n->ctr.num_entries = 0;
2532         q_n->ctr.num_entries2 = 0;
2533
2534         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2535 }
2536
2537 /*******************************************************************
2538  Reads or writes a structure.
2539 ********************************************************************/
2540
2541 BOOL srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
2542 {
2543         if (q_n == NULL)
2544                 return False;
2545
2546         prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
2547         depth++;
2548
2549         if(!prs_align(ps))
2550                 return False;
2551
2552         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2553                 return False;
2554         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2555                 return False;
2556
2557         if(!prs_align(ps))
2558                 return False;
2559
2560         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2561                 return False;
2562         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2563                 return False;
2564
2565         if(!prs_align(ps))
2566                 return False;
2567
2568         if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
2569                 return False;
2570         if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
2571                 return False;
2572
2573         if(!prs_align(ps))
2574                 return False;
2575         if(!prs_uint32("file_level", ps, depth, &q_n->file_level))
2576                 return False;
2577
2578         if (q_n->file_level != -1) {
2579                 if(!srv_io_srv_file_ctr("file_ctr", &q_n->ctr, ps, depth))
2580                         return False;
2581         }
2582
2583         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2584                 return False;
2585
2586         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2587                 return False;
2588
2589         return True;
2590 }
2591
2592 /*******************************************************************
2593  Reads or writes a structure.
2594 ********************************************************************/
2595
2596 BOOL srv_io_r_net_file_enum(char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
2597 {
2598         if (r_n == NULL)
2599                 return False;
2600
2601         prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
2602         depth++;
2603
2604         if(!prs_align(ps))
2605                 return False;
2606
2607         if(!prs_uint32("file_level", ps, depth, &r_n->file_level))
2608                 return False;
2609
2610         if (r_n->file_level != 0) {
2611                 if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
2612                         return False;
2613         }
2614
2615         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2616                 return False;
2617         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2618                 return False;
2619         if(!prs_werror("status", ps, depth, &r_n->status))
2620                 return False;
2621
2622         return True;
2623 }
2624
2625 /*******************************************************************
2626  Initialize a net file close request
2627 ********************************************************************/
2628 void init_srv_q_net_file_close(SRV_Q_NET_FILE_CLOSE *q_n, char *server,
2629                                uint32 file_id)
2630 {
2631         q_n->ptr_srv_name = 1;
2632         init_unistr2(&q_n->uni_srv_name, server, strlen(server) + 1);
2633         q_n->file_id = file_id;
2634 }
2635
2636 /*******************************************************************
2637  Reads or writes a structure.
2638 ********************************************************************/
2639 BOOL srv_io_q_net_file_close(char *desc, SRV_Q_NET_FILE_CLOSE *q_n,
2640                              prs_struct *ps, int depth)
2641 {
2642         if (q_n == NULL)
2643                 return False;
2644
2645         prs_debug(ps, depth, desc, "srv_io_q_net_file_close");
2646         depth++;
2647
2648         if(!prs_align(ps))
2649                 return False;
2650
2651         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2652                 return False;
2653         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2654                 return False;
2655
2656         if(!prs_align(ps))
2657                 return False;
2658
2659         if(!prs_uint32("file_id", ps, depth, &q_n->file_id))
2660                 return False;
2661
2662         return True;
2663 }
2664
2665 /*******************************************************************
2666  Reads or writes a structure.
2667 ********************************************************************/
2668
2669 BOOL srv_io_r_net_file_close(char *desc, SRV_R_NET_FILE_CLOSE *q_n, 
2670                              prs_struct *ps, int depth)
2671 {
2672         if (q_n == NULL)
2673                 return False;
2674
2675         prs_debug(ps, depth, desc, "srv_io_r_net_file_close");
2676         depth++;
2677
2678         if(!prs_align(ps))
2679                 return False;
2680
2681         if(!prs_werror("status", ps, depth, &q_n->status))
2682                 return False;
2683
2684         return True;
2685 }       
2686
2687 /*******************************************************************
2688  Inits a SRV_INFO_100 structure.
2689  ********************************************************************/
2690
2691 void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, char *name)
2692 {
2693         DEBUG(5,("init_srv_info_100\n"));
2694
2695         sv100->platform_id  = platform_id;
2696         init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
2697 }
2698
2699 /*******************************************************************
2700  Reads or writes a SRV_INFO_101 structure.
2701  ********************************************************************/
2702
2703 static BOOL srv_io_info_100(char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
2704 {
2705         if (sv100 == NULL)
2706                 return False;
2707
2708         prs_debug(ps, depth, desc, "srv_io_info_100");
2709         depth++;
2710
2711         if(!prs_align(ps))
2712                 return False;
2713
2714         if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
2715                 return False;
2716         if(!prs_uint32("ptr_name    ", ps, depth, &sv100->ptr_name))
2717                 return False;
2718
2719         if(!smb_io_unistr2("uni_name    ", &sv100->uni_name, True, ps, depth))
2720                 return False;
2721
2722         return True;
2723 }
2724
2725
2726 /*******************************************************************
2727  Inits a SRV_INFO_101 structure.
2728  ********************************************************************/
2729
2730 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
2731                                 uint32 ver_major, uint32 ver_minor,
2732                                 uint32 srv_type, char *comment)
2733 {
2734         DEBUG(5,("init_srv_info_101\n"));
2735
2736         sv101->platform_id  = platform_id;
2737         init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
2738         sv101->ver_major    = ver_major;
2739         sv101->ver_minor    = ver_minor;
2740         sv101->srv_type     = srv_type;
2741         init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
2742 }
2743
2744 /*******************************************************************
2745  Reads or writes a SRV_INFO_101 structure.
2746  ********************************************************************/
2747
2748 static BOOL srv_io_info_101(char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
2749 {
2750         if (sv101 == NULL)
2751                 return False;
2752
2753         prs_debug(ps, depth, desc, "srv_io_info_101");
2754         depth++;
2755
2756         if(!prs_align(ps))
2757                 return False;
2758
2759         if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
2760                 return False;
2761         if(!prs_uint32("ptr_name    ", ps, depth, &sv101->ptr_name))
2762                 return False;
2763         if(!prs_uint32("ver_major   ", ps, depth, &sv101->ver_major))
2764                 return False;
2765         if(!prs_uint32("ver_minor   ", ps, depth, &sv101->ver_minor))
2766                 return False;
2767         if(!prs_uint32("srv_type    ", ps, depth, &sv101->srv_type))
2768                 return False;
2769         if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
2770                 return False;
2771
2772         if(!prs_align(ps))
2773                 return False;
2774
2775         if(!smb_io_unistr2("uni_name    ", &sv101->uni_name, True, ps, depth))
2776                 return False;
2777         if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
2778                 return False;
2779
2780         return True;
2781 }
2782
2783 /*******************************************************************
2784  Inits a SRV_INFO_102 structure.
2785  ********************************************************************/
2786
2787 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
2788                                 char *comment, uint32 ver_major, uint32 ver_minor,
2789                                 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
2790                                 uint32 announce, uint32 ann_delta, uint32 licenses,
2791                                 char *usr_path)
2792 {
2793         DEBUG(5,("init_srv_info_102\n"));
2794
2795         sv102->platform_id  = platform_id;
2796         init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
2797         sv102->ver_major    = ver_major;
2798         sv102->ver_minor    = ver_minor;
2799         sv102->srv_type     = srv_type;
2800         init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
2801
2802         /* same as 101 up to here */
2803
2804         sv102->users        = users;
2805         sv102->disc         = disc;
2806         sv102->hidden       = hidden;
2807         sv102->announce     = announce;
2808         sv102->ann_delta    = ann_delta;
2809         sv102->licenses     = licenses;
2810         init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
2811 }
2812
2813
2814 /*******************************************************************
2815  Reads or writes a SRV_INFO_102 structure.
2816  ********************************************************************/
2817
2818 static BOOL srv_io_info_102(char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
2819 {
2820         if (sv102 == NULL)
2821                 return False;
2822
2823         prs_debug(ps, depth, desc, "srv_io_info102");
2824         depth++;
2825
2826         if(!prs_align(ps))
2827                 return False;
2828
2829         if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
2830                 return False;
2831         if(!prs_uint32("ptr_name    ", ps, depth, &sv102->ptr_name))
2832                 return False;
2833         if(!prs_uint32("ver_major   ", ps, depth, &sv102->ver_major))
2834                 return False;
2835         if(!prs_uint32("ver_minor   ", ps, depth, &sv102->ver_minor))
2836                 return False;
2837         if(!prs_uint32("srv_type    ", ps, depth, &sv102->srv_type))
2838                 return False;
2839         if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
2840                 return False;
2841
2842         /* same as 101 up to here */
2843
2844         if(!prs_uint32("users       ", ps, depth, &sv102->users))
2845                 return False;
2846         if(!prs_uint32("disc        ", ps, depth, &sv102->disc))
2847                 return False;
2848         if(!prs_uint32("hidden      ", ps, depth, &sv102->hidden))
2849                 return False;
2850         if(!prs_uint32("announce    ", ps, depth, &sv102->announce))
2851                 return False;
2852         if(!prs_uint32("ann_delta   ", ps, depth, &sv102->ann_delta))
2853                 return False;
2854         if(!prs_uint32("licenses    ", ps, depth, &sv102->licenses))
2855                 return False;
2856         if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
2857                 return False;
2858
2859         if(!smb_io_unistr2("uni_name    ", &sv102->uni_name, True, ps, depth))
2860                 return False;
2861         if(!prs_align(ps))
2862                 return False;
2863         if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
2864                 return False;
2865         if(!prs_align(ps))
2866                 return False;
2867         if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
2868                 return False;
2869
2870         return True;
2871 }
2872
2873 /*******************************************************************
2874  Reads or writes a SRV_INFO_102 structure.
2875  ********************************************************************/
2876
2877 static BOOL srv_io_info_ctr(char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
2878 {
2879         if (ctr == NULL)
2880                 return False;
2881
2882         prs_debug(ps, depth, desc, "srv_io_info_ctr");
2883         depth++;
2884
2885         if(!prs_align(ps))
2886                 return False;
2887
2888         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2889                 return False;
2890         if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
2891                 return False;
2892
2893         if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
2894                 switch (ctr->switch_value) {
2895                 case 100:
2896                         if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
2897                                 return False;
2898                         break;
2899                 case 101:
2900                         if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
2901                                 return False;
2902                         break;
2903                 case 102:
2904                         if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
2905                                 return False;
2906                         break;
2907                 default:
2908                         DEBUG(5,("%s no server info at switch_value %d\n",
2909                                          tab_depth(depth), ctr->switch_value));
2910                         break;
2911                 }
2912                 if(!prs_align(ps))
2913                         return False;
2914         }
2915
2916         return True;
2917 }
2918
2919 /*******************************************************************
2920  Inits a SRV_Q_NET_SRV_GET_INFO structure.
2921  ********************************************************************/
2922
2923 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
2924                                 char *server_name, uint32 switch_value)
2925 {
2926         DEBUG(5,("init_srv_q_net_srv_get_info\n"));
2927
2928         init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
2929
2930         srv->switch_value = switch_value;
2931 }
2932
2933 /*******************************************************************
2934  Reads or writes a structure.
2935 ********************************************************************/
2936
2937 BOOL srv_io_q_net_srv_get_info(char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
2938 {
2939         if (q_n == NULL)
2940                 return False;
2941
2942         prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
2943         depth++;
2944
2945         if(!prs_align(ps))
2946                 return False;
2947
2948         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2949                 return False;
2950         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2951                 return False;
2952
2953         if(!prs_align(ps))
2954                 return False;
2955
2956         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2957                 return False;
2958
2959         return True;
2960 }
2961
2962 /*******************************************************************
2963  Inits a SRV_R_NET_SRV_GET_INFO structure.
2964  ********************************************************************/
2965
2966 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
2967                                 uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status)
2968 {
2969         DEBUG(5,("init_srv_r_net_srv_get_info\n"));
2970
2971         srv->ctr = ctr;
2972
2973         if (W_ERROR_IS_OK(status)) {
2974                 srv->ctr->switch_value = switch_value;
2975                 srv->ctr->ptr_srv_ctr  = 1;
2976         } else {
2977                 srv->ctr->switch_value = 0;
2978                 srv->ctr->ptr_srv_ctr  = 0;
2979         }
2980
2981         srv->status = status;
2982 }
2983
2984 /*******************************************************************
2985  Inits a SRV_R_NET_SRV_SET_INFO structure.
2986  ********************************************************************/
2987
2988 void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
2989                                  uint32 switch_value, WERROR status)
2990 {
2991         DEBUG(5,("init_srv_r_net_srv_set_info\n"));
2992
2993         srv->switch_value = switch_value;
2994         srv->status = status;
2995 }
2996
2997 /*******************************************************************
2998  Reads or writes a structure.
2999 ********************************************************************/
3000
3001 BOOL srv_io_q_net_srv_set_info(char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, 
3002                                prs_struct *ps, int depth)
3003 {
3004         prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
3005         depth++;
3006
3007         if(!prs_align(ps))
3008                 return False;
3009
3010         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
3011                 return False;
3012         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3013                 return False;
3014
3015         if(!prs_align(ps))
3016                 return False;
3017
3018         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
3019                 return False;
3020
3021         if (UNMARSHALLING(ps)) {
3022                 q_n->ctr = (SRV_INFO_CTR *)
3023                         prs_alloc_mem(ps, sizeof(SRV_INFO_CTR));
3024
3025                 if (!q_n->ctr)
3026                         return False;
3027         }
3028
3029         if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth))
3030                 return False;
3031
3032         return True;
3033 }
3034
3035 /*******************************************************************
3036  Reads or writes a structure.
3037  ********************************************************************/
3038
3039 BOOL srv_io_r_net_srv_get_info(char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
3040 {
3041         if (r_n == NULL)
3042                 return False;
3043
3044         prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
3045         depth++;
3046
3047         if(!prs_align(ps))
3048                 return False;
3049
3050         if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
3051                 return False;
3052
3053         if(!prs_werror("status", ps, depth, &r_n->status))
3054                 return False;
3055
3056         return True;
3057 }
3058
3059 /*******************************************************************
3060  Reads or writes a structure.
3061  ********************************************************************/
3062
3063 BOOL srv_io_r_net_srv_set_info(char *desc, SRV_R_NET_SRV_SET_INFO *r_n, 
3064                                prs_struct *ps, int depth)
3065 {
3066         prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info");
3067         depth++;
3068
3069         if(!prs_align(ps))
3070                 return False;
3071
3072         if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value))
3073                 return False;
3074
3075         if(!prs_werror("status", ps, depth, &r_n->status))
3076                 return False;
3077
3078         return True;
3079 }
3080
3081 /*******************************************************************
3082  Reads or writes a structure.
3083  ********************************************************************/
3084
3085 BOOL srv_io_q_net_remote_tod(char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
3086 {
3087         if (q_n == NULL)
3088                 return False;
3089
3090         prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
3091         depth++;
3092
3093         if(!prs_align(ps))
3094                 return False;
3095
3096         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
3097                 return False;
3098         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3099                 return False;
3100
3101         return True;
3102 }
3103
3104 /*******************************************************************
3105  Reads or writes a TIME_OF_DAY_INFO structure.
3106  ********************************************************************/
3107
3108 static BOOL srv_io_time_of_day_info(char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
3109 {
3110         if (tod == NULL)
3111                 return False;
3112
3113         prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
3114         depth++;
3115
3116         if(!prs_align(ps))
3117                 return False;
3118         
3119         if(!prs_uint32("elapsedt   ", ps, depth, &tod->elapsedt))
3120                 return False;
3121         if(!prs_uint32("msecs      ", ps, depth, &tod->msecs))
3122                 return False;
3123         if(!prs_uint32("hours      ", ps, depth, &tod->hours))
3124                 return False;
3125         if(!prs_uint32("mins       ", ps, depth, &tod->mins))
3126                 return False;
3127         if(!prs_uint32("secs       ", ps, depth, &tod->secs))
3128                 return False;
3129         if(!prs_uint32("hunds      ", ps, depth, &tod->hunds))
3130                 return False;
3131         if(!prs_uint32("timezone   ", ps, depth, &tod->zone))
3132                 return False;
3133         if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
3134                 return False;
3135         if(!prs_uint32("day        ", ps, depth, &tod->day))
3136                 return False;
3137         if(!prs_uint32("month      ", ps, depth, &tod->month))
3138                 return False;
3139         if(!prs_uint32("year       ", ps, depth, &tod->year))
3140                 return False;
3141         if(!prs_uint32("weekday    ", ps, depth, &tod->weekday))
3142                 return False;
3143
3144         return True;
3145 }
3146
3147 /*******************************************************************
3148  Inits a TIME_OF_DAY_INFO structure.
3149  ********************************************************************/
3150
3151 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
3152                            uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
3153                            uint32 zone, uint32 tintervals, uint32 day,
3154                            uint32 month, uint32 year, uint32 weekday)
3155 {
3156         DEBUG(5,("init_time_of_day_info\n"));
3157
3158         tod->elapsedt   = elapsedt;
3159         tod->msecs      = msecs;
3160         tod->hours      = hours;
3161         tod->mins       = mins;
3162         tod->secs       = secs;
3163         tod->hunds      = hunds;
3164         tod->zone       = zone;
3165         tod->tintervals = tintervals;
3166         tod->day        = day;
3167         tod->month      = month;
3168         tod->year       = year;
3169         tod->weekday    = weekday;
3170 }
3171
3172
3173 /*******************************************************************
3174  Reads or writes a structure.
3175  ********************************************************************/
3176
3177 BOOL srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
3178 {
3179         if (r_n == NULL)
3180                 return False;
3181
3182         prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
3183         depth++;
3184
3185         if(!prs_align(ps))
3186                 return False;
3187         
3188         if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
3189                 return False;
3190
3191         if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
3192                 return False;
3193
3194         if(!prs_werror("status", ps, depth, &r_n->status))
3195                 return False;
3196
3197         return True;
3198 }
3199
3200 /*******************************************************************
3201  initialises a structure.
3202  ********************************************************************/
3203
3204 BOOL init_srv_q_net_disk_enum(SRV_Q_NET_DISK_ENUM *q_n,
3205                               const char *srv_name,
3206                               uint32 preferred_len,
3207                               ENUM_HND *enum_hnd
3208         ) 
3209 {
3210   
3211
3212         DEBUG(5,("init_srv_q_net_srv_disk_enum\n"));
3213
3214         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
3215
3216         q_n->disk_enum_ctr.level = 0;
3217         q_n->disk_enum_ctr.disk_info_ptr   = 0;
3218   
3219         q_n->preferred_len = preferred_len;
3220         memcpy(&q_n->enum_hnd, enum_hnd, sizeof(*enum_hnd));
3221
3222         return True;
3223 }
3224
3225 /*******************************************************************
3226  Reads or writes a structure.
3227  ********************************************************************/
3228
3229 BOOL srv_io_q_net_disk_enum(char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth)
3230 {
3231         if (q_n == NULL)
3232                 return False;
3233
3234         prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum");
3235         depth++;
3236
3237         if(!prs_align(ps))
3238                 return False;
3239
3240         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3241                 return False;
3242
3243         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3244                 return False;
3245
3246         if(!prs_align(ps))
3247                 return False;
3248
3249         if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level))
3250                 return False;
3251
3252         if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read))
3253                 return False;
3254
3255         if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr))
3256                 return False;
3257
3258         if(!prs_align(ps))
3259                 return False;
3260
3261         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
3262                 return False;
3263         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
3264                 return False;
3265
3266         return True;
3267 }
3268
3269 /*******************************************************************
3270  Reads or writes a structure.
3271  ********************************************************************/
3272
3273 BOOL srv_io_r_net_disk_enum(char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth)
3274 {
3275
3276         int i;
3277         uint32 entries_read, entries_read2, entries_read3;
3278
3279         if (r_n == NULL)
3280                 return False;
3281
3282         prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum");
3283         depth++;
3284
3285         entries_read = entries_read2 = entries_read3 = r_n->disk_enum_ctr.entries_read;
3286
3287         if(!prs_align(ps))
3288                 return False;
3289
3290         if(!prs_uint32("entries_read", ps, depth, &entries_read))
3291                 return False;
3292         if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr))
3293                 return False;
3294
3295         /*this may be max, unknown, actual?*/
3296
3297         if(!prs_uint32("max_elements", ps, depth, &entries_read2))
3298                 return False;
3299         if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown))
3300                 return False;
3301         if(!prs_uint32("actual_elements", ps, depth, &entries_read3))
3302                 return False;
3303
3304         r_n->disk_enum_ctr.entries_read = entries_read3;
3305
3306         if(UNMARSHALLING(ps)) {
3307
3308                 DISK_INFO *dinfo;
3309
3310                 if(!(dinfo = (DISK_INFO *)prs_alloc_mem(ps, sizeof(*dinfo) * entries_read3)))
3311                 return False;
3312                 r_n->disk_enum_ctr.disk_info = dinfo;
3313         }
3314
3315         for(i=0; i < r_n->disk_enum_ctr.entries_read; i++) {
3316
3317                 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown))
3318                         return False;
3319    
3320                 if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth))
3321                         return False;
3322
3323                 if(!prs_align(ps))
3324                         return False;
3325         }
3326
3327         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
3328                 return False;
3329
3330         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
3331                 return False;
3332
3333         if(!prs_werror("status", ps, depth, &r_n->status))
3334                 return False;
3335
3336         return True;
3337 }
3338
3339 /*******************************************************************
3340  initialises a structure.
3341  ********************************************************************/
3342
3343 BOOL init_srv_q_net_name_validate(SRV_Q_NET_NAME_VALIDATE *q_n, const char *srv_name, const char *share_name, int type) 
3344 {
3345         uint32 ptr_share_name;
3346
3347         DEBUG(5,("init_srv_q_net_name_validate\n"));
3348   
3349         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
3350         init_buf_unistr2(&q_n->uni_name,     &ptr_share_name,    share_name);
3351
3352         q_n->type  = type;
3353         q_n->flags = 0;
3354
3355         return True;
3356 }
3357
3358 /*******************************************************************
3359  Reads or writes a structure.
3360  ********************************************************************/
3361
3362 BOOL srv_io_q_net_name_validate(char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth)
3363 {
3364         if (q_n == NULL)
3365                 return False;
3366
3367         prs_debug(ps, depth, desc, "srv_io_q_net_name_validate");
3368         depth++;
3369
3370         if(!prs_align(ps))
3371                 return False;
3372
3373         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3374                 return False;
3375
3376         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3377                 return False;
3378
3379         if(!prs_align(ps))
3380                 return False;
3381
3382         if(!smb_io_unistr2("", &q_n->uni_name, True, ps, depth))
3383                 return False;
3384
3385         if(!prs_align(ps))
3386                 return False;
3387
3388         if(!prs_uint32("type", ps, depth, &q_n->type))
3389                 return False;
3390
3391         if(!prs_uint32("flags", ps, depth, &q_n->flags))
3392                 return False;
3393
3394         return True;
3395 }
3396
3397 /*******************************************************************
3398  Reads or writes a structure.
3399  ********************************************************************/
3400
3401 BOOL srv_io_r_net_name_validate(char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth)
3402 {
3403         if (r_n == NULL)
3404                 return False;
3405
3406         prs_debug(ps, depth, desc, "srv_io_r_net_name_validate");
3407         depth++;
3408
3409         if(!prs_align(ps))
3410                 return False;
3411
3412         if(!prs_werror("status", ps, depth, &r_n->status))
3413                 return False;
3414
3415         return True;
3416 }
3417
3418 /*******************************************************************
3419  Reads or writes a structure.
3420 ********************************************************************/
3421
3422 BOOL srv_io_q_net_file_query_secdesc(char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth)
3423 {
3424         if (q_n == NULL)
3425                 return False;
3426
3427         prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc");
3428         depth++;
3429
3430         if(!prs_align(ps))
3431                 return False;
3432
3433         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3434                 return False;
3435
3436         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3437                 return False;
3438
3439         if(!prs_align(ps))
3440                 return False;
3441
3442         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3443                 return False;
3444
3445         if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3446                 return False;
3447
3448         if(!prs_align(ps))
3449                 return False;
3450
3451         if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3452                 return False;
3453
3454         if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1))
3455                 return False;
3456
3457         if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2))
3458                 return False;
3459
3460         if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3))
3461                 return False;
3462
3463         return True;
3464 }
3465
3466 /*******************************************************************
3467  Reads or writes a structure.
3468 ********************************************************************/
3469
3470 BOOL srv_io_r_net_file_query_secdesc(char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth)
3471 {
3472         if (r_n == NULL)
3473                 return False;
3474
3475         prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc");
3476         depth++;
3477
3478         if(!prs_align(ps))
3479                 return False;
3480
3481         if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response))
3482                 return False;
3483
3484         if(!prs_uint32("size_response", ps, depth, &r_n->size_response))
3485                 return False;
3486
3487         if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc))
3488                 return False;
3489
3490         if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc))
3491                 return False;
3492
3493         if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth))
3494                 return False;
3495
3496         if(!prs_align(ps))
3497                 return False;
3498
3499         if(!prs_werror("status", ps, depth, &r_n->status))
3500                 return False;
3501
3502         return True;
3503 }
3504
3505 /*******************************************************************
3506  Reads or writes a structure.
3507 ********************************************************************/
3508
3509 BOOL srv_io_q_net_file_set_secdesc(char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth)
3510 {
3511         if (q_n == NULL)
3512                 return False;
3513
3514         prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc");
3515         depth++;
3516
3517         if(!prs_align(ps))
3518                 return False;
3519
3520         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3521                 return False;
3522
3523         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3524                 return False;
3525
3526         if(!prs_align(ps))
3527                 return False;
3528
3529         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3530                 return False;
3531
3532         if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3533                 return False;
3534
3535         if(!prs_align(ps))
3536                 return False;
3537
3538         if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3539                 return False;
3540
3541         if(!prs_align(ps))
3542                 return False;
3543
3544         if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info))
3545                 return False;
3546
3547         if(!prs_uint32("size_set", ps, depth, &q_n->size_set))
3548                 return False;
3549
3550         if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc))
3551                 return False;
3552
3553         if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc))
3554                 return False;
3555
3556         if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth))
3557                 return False;
3558
3559         return True;
3560 }
3561
3562 /*******************************************************************
3563  Reads or writes a structure.
3564 ********************************************************************/
3565
3566 BOOL srv_io_r_net_file_set_secdesc(char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth)
3567 {
3568         if (r_n == NULL)
3569                 return False;
3570
3571         prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc");
3572         depth++;
3573
3574         if(!prs_align(ps))
3575                 return False;
3576
3577         if(!prs_werror("status", ps, depth, &r_n->status))
3578                 return False;
3579
3580         return True;
3581 }
3582
3583 /*******************************************************************
3584  Inits a structure
3585 ********************************************************************/
3586
3587 void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, char *server)
3588 {
3589         q_u->ptr_srv_name = 1;
3590         init_unistr2(&q_u->uni_srv_name, server, strlen(server) + 1);
3591 }
3592