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