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