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