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