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