return results on prs_xxxxx() and all xxx_io_xxx() routines.
[vlendec/samba-autobuild/.git] / source3 / rpc_parse / parse_srv.c
1
2 /* 
3  *  Unix SMB/Netbios implementation.
4  *  Version 1.9.
5  *  RPC Pipe client / server routines
6  *  Copyright (C) Andrew Tridgell              1992-1999,
7  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
8  *  Copyright (C) Paul Ashton                  1997-1999.
9  *  
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *  
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *  
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24
25
26 #include "includes.h"
27
28 extern int DEBUGLEVEL;
29
30
31 /*******************************************************************
32  makes a SH_INFO_1_STR structure
33 ********************************************************************/
34 BOOL make_srv_share_info1_str(SH_INFO_1_STR *sh1, char *net_name, char *remark)
35 {
36         if (sh1 == NULL) return False;
37
38         DEBUG(5,("make_srv_share_info1_str\n"));
39
40         make_unistr2(&(sh1->uni_netname), net_name, strlen(net_name)+1);
41         make_unistr2(&(sh1->uni_remark ), remark  , strlen(remark  )+1);
42
43         return True;
44 }
45
46 /*******************************************************************
47 reads or writes a structure.
48 ********************************************************************/
49 static BOOL srv_io_share_info1_str(char *desc,  SH_INFO_1_STR *sh1, prs_struct *ps, int depth)
50 {
51         if (sh1 == NULL) return False;
52
53         prs_debug(ps, depth, desc, "srv_io_share_info1_str");
54         depth++;
55
56         prs_align(ps);
57
58         smb_io_unistr2("", &(sh1->uni_netname), True, ps, depth); 
59         smb_io_unistr2("", &(sh1->uni_remark ), True, ps, depth); 
60
61         return True;
62 }
63
64 /*******************************************************************
65  makes a SH_INFO_1 structure
66 ********************************************************************/
67 BOOL make_srv_share_info1(SH_INFO_1 *sh1, char *net_name, uint32 type, char *remark)
68 {
69         if (sh1 == NULL) return False;
70
71         DEBUG(5,("make_srv_share_info1: %s %8x %s\n", net_name, type, remark));
72
73         sh1->ptr_netname = net_name != NULL ? 1 : 0;
74         sh1->type        = type;
75         sh1->ptr_remark  = remark   != NULL ? 1 : 0;
76
77         return True;
78 }
79
80 /*******************************************************************
81 reads or writes a structure.
82 ********************************************************************/
83 static BOOL srv_io_share_info1(char *desc,  SH_INFO_1 *sh1, prs_struct *ps, int depth)
84 {
85         if (sh1 == NULL) return False;
86
87         prs_debug(ps, depth, desc, "srv_io_share_info1");
88         depth++;
89
90         prs_align(ps);
91
92         prs_uint32("ptr_netname", ps, depth, &(sh1->ptr_netname));
93         prs_uint32("type       ", ps, depth, &(sh1->type       ));
94         prs_uint32("ptr_remark ", ps, depth, &(sh1->ptr_remark));
95
96         return True;
97 }
98
99 /*******************************************************************
100 reads or writes a structure.
101 ********************************************************************/
102 static BOOL srv_io_srv_share_info_1(char *desc,  SRV_SHARE_INFO_1 *ctr, prs_struct *ps, int depth)
103 {
104         if (ctr == NULL) return False;
105
106         prs_debug(ps, depth, desc, "srv_io_share_1_ctr");
107         depth++;
108
109         prs_align(ps);
110
111         prs_uint32("num_entries_read", ps, depth, &(ctr->num_entries_read));
112         prs_uint32("ptr_share_info", ps, depth, &(ctr->ptr_share_info));
113
114         if (ctr->ptr_share_info != 0)
115         {
116                 int i;
117                 int num_entries = ctr->num_entries_read;
118                 if (num_entries > MAX_SHARE_ENTRIES)
119                 {
120                         num_entries = MAX_SHARE_ENTRIES; /* report this! */
121                 }
122
123                 prs_uint32("num_entries_read2", ps, depth, &(ctr->num_entries_read2));
124
125                 SMB_ASSERT_ARRAY(ctr->info_1, num_entries);
126
127                 for (i = 0; i < num_entries; i++)
128                 {
129                         prs_grow(ps);
130                         srv_io_share_info1("", &(ctr->info_1[i]), ps, depth); 
131                 }
132
133                 for (i = 0; i < num_entries; i++)
134                 {
135                         prs_grow(ps);
136                         srv_io_share_info1_str("", &(ctr->info_1_str[i]), ps, depth); 
137                 }
138
139                 prs_align(ps);
140         }
141
142         return True;
143 }
144
145 /*******************************************************************
146  makes a SH_INFO_2_STR structure
147 ********************************************************************/
148 BOOL make_srv_share_info2_str(SH_INFO_2_STR *sh2,
149                                 char *net_name, char *remark,
150                                 char *path, char *passwd)
151 {
152         if (sh2 == NULL) return False;
153
154         DEBUG(5,("make_srv_share_info2_str\n"));
155
156         make_unistr2(&(sh2->uni_netname), net_name, strlen(net_name)+1);
157         make_unistr2(&(sh2->uni_remark ), remark  , strlen(remark  )+1);
158         make_unistr2(&(sh2->uni_path   ), path    , strlen(path    )+1);
159         make_unistr2(&(sh2->uni_passwd ), passwd  , strlen(passwd  )+1);
160
161         return True;
162 }
163
164 /*******************************************************************
165 reads or writes a structure.
166 ********************************************************************/
167 static BOOL srv_io_share_info2_str(char *desc,  SH_INFO_2_STR *sh2, prs_struct *ps, int depth)
168 {
169         if (sh2 == NULL) return False;
170
171         prs_debug(ps, depth, desc, "srv_io_share_info2_str");
172         depth++;
173
174         prs_align(ps);
175
176         smb_io_unistr2("", &(sh2->uni_netname), True, ps, depth); 
177         smb_io_unistr2("", &(sh2->uni_remark ), True, ps, depth); 
178         smb_io_unistr2("", &(sh2->uni_path   ), True, ps, depth); 
179         smb_io_unistr2("", &(sh2->uni_passwd ), True, ps, depth); 
180
181         return True;
182 }
183
184 /*******************************************************************
185  makes a SH_INFO_2 structure
186 ********************************************************************/
187 BOOL make_srv_share_info2(SH_INFO_2 *sh2,
188                                 char *net_name, uint32 type, char *remark,
189                                 uint32 perms, uint32 max_uses, uint32 num_uses,
190                                 char *path, char *passwd)
191 {
192         if (sh2 == NULL) return False;
193
194         DEBUG(5,("make_srv_share_info2: %s %8x %s\n", net_name, type, remark));
195
196         sh2->ptr_netname = net_name != NULL ? 1 : 0;
197         sh2->type        = type;
198         sh2->ptr_remark  = remark   != NULL ? 1 : 0;
199         sh2->perms       = perms;
200         sh2->max_uses    = max_uses;
201         sh2->num_uses    = num_uses;
202         sh2->type        = type;
203         sh2->ptr_path    = path     != NULL ? 1 : 0;
204         sh2->ptr_passwd  = passwd   != NULL ? 1 : 0;
205
206         return True;
207 }
208
209 /*******************************************************************
210 reads or writes a structure.
211 ********************************************************************/
212 static BOOL srv_io_share_info2(char *desc,  SH_INFO_2 *sh2, prs_struct *ps, int depth)
213 {
214         if (sh2 == NULL) return False;
215
216         prs_debug(ps, depth, desc, "srv_io_share_info2");
217         depth++;
218
219         prs_align(ps);
220
221         prs_uint32("ptr_netname", ps, depth, &(sh2->ptr_netname));
222         prs_uint32("type       ", ps, depth, &(sh2->type       ));
223         prs_uint32("ptr_remark ", ps, depth, &(sh2->ptr_remark ));
224         prs_uint32("perms      ", ps, depth, &(sh2->perms      ));
225         prs_uint32("max_uses   ", ps, depth, &(sh2->max_uses   ));
226         prs_uint32("num_uses   ", ps, depth, &(sh2->num_uses   ));
227         prs_uint32("ptr_path   ", ps, depth, &(sh2->ptr_path   ));
228         prs_uint32("ptr_passwd ", ps, depth, &(sh2->ptr_passwd ));
229
230         return True;
231 }
232
233 /*******************************************************************
234 reads or writes a structure.
235 ********************************************************************/
236 static BOOL srv_io_srv_share_info_2(char *desc,  SRV_SHARE_INFO_2 *ctr, prs_struct *ps, int depth)
237 {
238         if (ctr == NULL) return False;
239
240         prs_debug(ps, depth, desc, "srv_io_share_2_ctr");
241         depth++;
242
243         prs_align(ps);
244
245         prs_uint32("num_entries_read", ps, depth, &(ctr->num_entries_read));
246         prs_uint32("ptr_share_info", ps, depth, &(ctr->ptr_share_info));
247
248         if (ctr->ptr_share_info != 0)
249         {
250                 int i;
251                 int num_entries = ctr->num_entries_read;
252                 if (num_entries > MAX_SHARE_ENTRIES)
253                 {
254                         num_entries = MAX_SHARE_ENTRIES; /* report this! */
255                 }
256
257                 prs_uint32("num_entries_read2", ps, depth, &(ctr->num_entries_read2));
258
259                 SMB_ASSERT_ARRAY(ctr->info_2, num_entries);
260
261                 for (i = 0; i < num_entries; i++)
262                 {
263                         prs_grow(ps);
264                         srv_io_share_info2("", &(ctr->info_2[i]), ps, depth); 
265                 }
266
267                 for (i = 0; i < num_entries; i++)
268                 {
269                         prs_grow(ps);
270                         srv_io_share_info2_str("", &(ctr->info_2_str[i]), ps, depth); 
271                 }
272
273                 prs_align(ps);
274         }
275
276         return True;
277 }
278
279 /*******************************************************************
280 reads or writes a structure.
281 ********************************************************************/
282 static BOOL srv_io_srv_share_ctr(char *desc,  SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
283 {
284         if (ctr == NULL) return False;
285
286         prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
287         depth++;
288
289         prs_align(ps);
290
291         prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
292         prs_uint32("ptr_share_ctr", ps, depth, &(ctr->ptr_share_ctr));
293
294         if (ctr->ptr_share_ctr != 0)
295         {
296                 switch (ctr->switch_value)
297                 {
298                         case 2:
299                         {
300                                 srv_io_srv_share_info_2("", &(ctr->share.info2), ps, depth); 
301                                 break;
302                         }
303                         case 1:
304                         {
305                                 srv_io_srv_share_info_1("", &(ctr->share.info1), ps, depth); 
306                                 break;
307                         }
308                         default:
309                         {
310                                 DEBUG(5,("%s no share info at switch_value %d\n",
311                                          tab_depth(depth), ctr->switch_value));
312                                 break;
313                         }
314                 }
315         }
316
317         return True;
318 }
319
320 /*******************************************************************
321 reads or writes a structure.
322 ********************************************************************/
323 BOOL make_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, 
324                                 char *srv_name, 
325                                 uint32 share_level, SRV_SHARE_INFO_CTR *ctr,
326                                 uint32 preferred_len,
327                                 ENUM_HND *hnd)
328 {
329         if (q_n == NULL || ctr == NULL || hnd == NULL) return False;
330
331         q_n->ctr = ctr;
332
333         DEBUG(5,("make_q_net_share_enum\n"));
334
335         make_buf_unistr2(&(q_n->uni_srv_name), &(q_n->ptr_srv_name), srv_name);
336
337         q_n->share_level    = share_level;
338         q_n->preferred_len = preferred_len;
339
340         memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
341
342         return True;
343 }
344
345 /*******************************************************************
346 reads or writes a structure.
347 ********************************************************************/
348 BOOL srv_io_q_net_share_enum(char *desc,  SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
349 {
350         if (q_n == NULL) return False;
351
352         prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
353         depth++;
354
355         prs_align(ps);
356
357         prs_uint32("ptr_srv_name", ps, depth, &(q_n->ptr_srv_name));
358         smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth); 
359
360         prs_align(ps);
361
362         prs_uint32("share_level", ps, depth, &(q_n->share_level  ));
363
364         if (q_n->share_level != -1)
365         {
366                 srv_io_srv_share_ctr("share_ctr", q_n->ctr, ps, depth);
367         }
368
369         prs_uint32("preferred_len", ps, depth, &(q_n->preferred_len));
370
371         smb_io_enum_hnd("enum_hnd", &(q_n->enum_hnd), ps, depth); 
372
373         return True;
374 }
375
376 /*******************************************************************
377 reads or writes a structure.
378 ********************************************************************/
379 BOOL srv_io_r_net_share_enum(char *desc,  SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
380 {
381         if (r_n == NULL) return False;
382
383         prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
384         depth++;
385
386         prs_align(ps);
387
388         prs_uint32("share_level", ps, depth, &(r_n->share_level));
389
390         if (r_n->share_level != 0)
391         {
392                 srv_io_srv_share_ctr("share_ctr", r_n->ctr, ps, depth);
393         }
394
395         prs_uint32("total_entries", ps, depth, &(r_n->total_entries));
396         smb_io_enum_hnd("enum_hnd", &(r_n->enum_hnd), ps, depth); 
397         prs_uint32("status     ", ps, depth, &(r_n->status));
398
399         return True;
400 }
401
402 /*******************************************************************
403  makes a SESS_INFO_0_STR structure
404 ********************************************************************/
405 BOOL make_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name)
406 {
407         if (ss0 == NULL) return False;
408
409         DEBUG(5,("make_srv_sess_info0_str\n"));
410
411         make_unistr2(&(ss0->uni_name), name, strlen(name)+1);
412
413         return True;
414 }
415
416 /*******************************************************************
417 reads or writes a structure.
418 ********************************************************************/
419 static BOOL srv_io_sess_info0_str(char *desc,  SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
420 {
421         if (ss0 == NULL) return False;
422
423         prs_debug(ps, depth, desc, "srv_io_sess_info0_str");
424         depth++;
425
426         prs_align(ps);
427
428         smb_io_unistr2("", &(ss0->uni_name), True, ps, depth); 
429
430         return True;
431 }
432
433 /*******************************************************************
434  makes a SESS_INFO_0 structure
435 ********************************************************************/
436 BOOL make_srv_sess_info0(SESS_INFO_0 *ss0, char *name)
437 {
438         if (ss0 == NULL) return False;
439
440         DEBUG(5,("make_srv_sess_info0: %s\n", name));
441
442         ss0->ptr_name = name != NULL ? 1 : 0;
443
444         return True;
445 }
446
447 /*******************************************************************
448 reads or writes a structure.
449 ********************************************************************/
450 static BOOL srv_io_sess_info0(char *desc,  SESS_INFO_0 *ss0, prs_struct *ps, int depth)
451 {
452         if (ss0 == NULL) return False;
453
454         prs_debug(ps, depth, desc, "srv_io_sess_info0");
455         depth++;
456
457         prs_align(ps);
458
459         prs_uint32("ptr_name", ps, depth, &(ss0->ptr_name));
460
461         return True;
462 }
463
464 /*******************************************************************
465 reads or writes a structure.
466 ********************************************************************/
467 static BOOL srv_io_srv_sess_info_0(char *desc,  SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
468 {
469         if (ss0 == NULL) return False;
470
471         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
472         depth++;
473
474         prs_align(ps);
475
476         prs_uint32("num_entries_read", ps, depth, &(ss0->num_entries_read));
477         prs_uint32("ptr_sess_info", ps, depth, &(ss0->ptr_sess_info));
478
479         if (ss0->ptr_sess_info != 0)
480         {
481                 int i;
482                 int num_entries = ss0->num_entries_read;
483                 if (num_entries > MAX_SESS_ENTRIES)
484                 {
485                         num_entries = MAX_SESS_ENTRIES; /* report this! */
486                 }
487
488                 prs_uint32("num_entries_read2", ps, depth, &(ss0->num_entries_read2));
489
490                 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
491
492                 for (i = 0; i < num_entries; i++)
493                 {
494                         prs_grow(ps);
495                         srv_io_sess_info0("", &(ss0->info_0[i]), ps, depth); 
496                 }
497
498                 for (i = 0; i < num_entries; i++)
499                 {
500                         prs_grow(ps);
501                         srv_io_sess_info0_str("", &(ss0->info_0_str[i]), ps, depth); 
502                 }
503
504                 prs_align(ps);
505         }
506
507         return True;
508 }
509
510 /*******************************************************************
511  makes a SESS_INFO_1_STR structure
512 ********************************************************************/
513 BOOL make_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char *user)
514 {
515         if (ss1 == NULL) return False;
516
517         DEBUG(5,("make_srv_sess_info1_str\n"));
518
519         make_unistr2(&(ss1->uni_name), name, strlen(name)+1);
520         make_unistr2(&(ss1->uni_user), name, strlen(user)+1);
521
522         return True;
523 }
524
525 /*******************************************************************
526 reads or writes a structure.
527 ********************************************************************/
528 static BOOL srv_io_sess_info1_str(char *desc,  SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
529 {
530         if (ss1 == NULL) return False;
531
532         prs_debug(ps, depth, desc, "srv_io_sess_info1_str");
533         depth++;
534
535         prs_align(ps);
536
537         smb_io_unistr2("", &(ss1->uni_name), True, ps, depth); 
538         smb_io_unistr2("", &(ss1->uni_user), True, ps, depth); 
539
540         return True;
541 }
542
543 /*******************************************************************
544  makes a SESS_INFO_1 structure
545 ********************************************************************/
546 BOOL make_srv_sess_info1(SESS_INFO_1 *ss1, 
547                                 char *name, char *user,
548                                 uint32 num_opens, uint32 open_time, uint32 idle_time,
549                                 uint32 user_flags)
550 {
551         if (ss1 == NULL) return False;
552
553         DEBUG(5,("make_srv_sess_info1: %s\n", name));
554
555         ss1->ptr_name = name != NULL ? 1 : 0;
556         ss1->ptr_user = user != NULL ? 1 : 0;
557
558         ss1->num_opens  = num_opens;
559         ss1->open_time  = open_time;
560         ss1->idle_time  = idle_time;
561         ss1->user_flags = user_flags;
562
563         return True;
564 }
565
566 /*******************************************************************
567 reads or writes a structure.
568 ********************************************************************/
569 static BOOL srv_io_sess_info1(char *desc,  SESS_INFO_1 *ss1, prs_struct *ps, int depth)
570 {
571         if (ss1 == NULL) return False;
572
573         prs_debug(ps, depth, desc, "srv_io_sess_info1");
574         depth++;
575
576         prs_align(ps);
577
578         prs_uint32("ptr_name  ", ps, depth, &(ss1->ptr_name  ));
579         prs_uint32("ptr_user  ", ps, depth, &(ss1->ptr_user  ));
580
581         prs_uint32("num_opens ", ps, depth, &(ss1->num_opens ));
582         prs_uint32("open_time ", ps, depth, &(ss1->open_time ));
583         prs_uint32("idle_time ", ps, depth, &(ss1->idle_time ));
584         prs_uint32("user_flags", ps, depth, &(ss1->user_flags));
585
586         return True;
587 }
588
589 /*******************************************************************
590 reads or writes a structure.
591 ********************************************************************/
592 static BOOL srv_io_srv_sess_info_1(char *desc,  SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
593 {
594         if (ss1 == NULL) return False;
595
596         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
597         depth++;
598
599         prs_align(ps);
600
601         prs_uint32("num_entries_read", ps, depth, &(ss1->num_entries_read));
602         prs_uint32("ptr_sess_info", ps, depth, &(ss1->ptr_sess_info));
603
604         if (ss1->ptr_sess_info != 0)
605         {
606                 int i;
607                 int num_entries = ss1->num_entries_read;
608                 if (num_entries > MAX_SESS_ENTRIES)
609                 {
610                         num_entries = MAX_SESS_ENTRIES; /* report this! */
611                 }
612
613                 prs_uint32("num_entries_read2", ps, depth, &(ss1->num_entries_read2));
614
615                 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
616
617                 for (i = 0; i < num_entries; i++)
618                 {
619                         prs_grow(ps);
620                         srv_io_sess_info1("", &(ss1->info_1[i]), ps, depth); 
621                 }
622
623                 for (i = 0; i < num_entries; i++)
624                 {
625                         prs_grow(ps);
626                         srv_io_sess_info1_str("", &(ss1->info_1_str[i]), ps, depth); 
627                 }
628
629                 prs_align(ps);
630         }
631
632         return True;
633 }
634
635 /*******************************************************************
636 reads or writes a structure.
637 ********************************************************************/
638 static BOOL srv_io_srv_sess_ctr(char *desc,  SRV_SESS_INFO_CTR *ctr, prs_struct *ps, int depth)
639 {
640         if (ctr == NULL) return False;
641
642         prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
643         depth++;
644
645         prs_align(ps);
646
647         prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
648         prs_uint32("ptr_sess_ctr", ps, depth, &(ctr->ptr_sess_ctr));
649
650         if (ctr->ptr_sess_ctr != 0)
651         {
652                 switch (ctr->switch_value)
653                 {
654                         case 0:
655                         {
656                                 srv_io_srv_sess_info_0("", &(ctr->sess.info0), ps, depth); 
657                                 break;
658                         }
659                         case 1:
660                         {
661                                 srv_io_srv_sess_info_1("", &(ctr->sess.info1), ps, depth); 
662                                 break;
663                         }
664                         default:
665                         {
666                                 DEBUG(5,("%s no session info at switch_value %d\n",
667                                          tab_depth(depth), ctr->switch_value));
668                                 break;
669                         }
670                 }
671         }
672
673         return True;
674 }
675
676 /*******************************************************************
677 reads or writes a structure.
678 ********************************************************************/
679 BOOL make_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, 
680                                 char *srv_name, char *qual_name,
681                                 char *user_name,
682                                 uint32 sess_level, SRV_SESS_INFO_CTR *ctr,
683                                 uint32 preferred_len,
684                                 ENUM_HND *hnd)
685 {
686         if (q_n == NULL || ctr == NULL || hnd == NULL) return False;
687
688         q_n->ctr = ctr;
689
690         DEBUG(5,("make_q_net_sess_enum\n"));
691
692         make_buf_unistr2(&(q_n->uni_srv_name), &(q_n->ptr_srv_name), srv_name);
693         make_buf_unistr2(&(q_n->uni_qual_name), &(q_n->ptr_qual_name), qual_name);
694         make_buf_unistr2(&(q_n->uni_user_name), &(q_n->ptr_user_name), user_name);
695
696         q_n->sess_level    = sess_level;
697         q_n->preferred_len = preferred_len;
698
699         memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
700
701         return True;
702 }
703
704 /*******************************************************************
705 reads or writes a structure.
706 ********************************************************************/
707 BOOL srv_io_q_net_sess_enum(char *desc,  SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
708 {
709         if (q_n == NULL) return False;
710
711         prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
712         depth++;
713
714         prs_align(ps);
715
716         prs_uint32("ptr_srv_name", ps, depth, &(q_n->ptr_srv_name));
717         smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth); 
718
719         prs_align(ps);
720
721         prs_uint32("ptr_qual_name", ps, depth, &(q_n->ptr_qual_name));
722         smb_io_unistr2("", &(q_n->uni_qual_name), q_n->ptr_qual_name, ps, depth); 
723         prs_align(ps);
724
725         prs_uint32("ptr_user_name", ps, depth, &(q_n->ptr_user_name));
726         smb_io_unistr2("", &(q_n->uni_user_name), q_n->ptr_user_name, ps, depth); 
727         prs_align(ps);
728
729         prs_uint32("sess_level", ps, depth, &(q_n->sess_level  ));
730         
731         if (q_n->sess_level != -1)
732         {
733                 srv_io_srv_sess_ctr("sess_ctr", q_n->ctr, ps, depth);
734         }
735
736         prs_uint32("preferred_len", ps, depth, &(q_n->preferred_len));
737
738         smb_io_enum_hnd("enum_hnd", &(q_n->enum_hnd), ps, depth); 
739
740         return True;
741 }
742
743 /*******************************************************************
744 reads or writes a structure.
745 ********************************************************************/
746 BOOL srv_io_r_net_sess_enum(char *desc,  SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
747 {
748         if (r_n == NULL) return False;
749
750         prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
751         depth++;
752
753         prs_align(ps);
754
755         prs_uint32("sess_level", ps, depth, &(r_n->sess_level));
756
757         if (r_n->sess_level != -1)
758         {
759                 srv_io_srv_sess_ctr("sess_ctr", r_n->ctr, ps, depth);
760         }
761
762         prs_uint32("total_entries", ps, depth, &(r_n->total_entries));
763         smb_io_enum_hnd("enum_hnd", &(r_n->enum_hnd), ps, depth); 
764         prs_uint32("status     ", ps, depth, &(r_n->status));
765
766         return True;
767 }
768
769 /*******************************************************************
770  makes a CONN_INFO_0 structure
771 ********************************************************************/
772 BOOL make_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
773 {
774         if (ss0 == NULL) return False;
775
776         DEBUG(5,("make_srv_conn_info0\n"));
777
778         ss0->id = id;
779
780         return True;
781 }
782
783 /*******************************************************************
784 reads or writes a structure.
785 ********************************************************************/
786 static BOOL srv_io_conn_info0(char *desc,  CONN_INFO_0 *ss0, prs_struct *ps, int depth)
787 {
788         if (ss0 == NULL) return False;
789
790         prs_debug(ps, depth, desc, "srv_io_conn_info0");
791         depth++;
792
793         prs_align(ps);
794
795         prs_uint32("id", ps, depth, &(ss0->id));
796
797         return True;
798 }
799
800 /*******************************************************************
801 reads or writes a structure.
802 ********************************************************************/
803 static BOOL srv_io_srv_conn_info_0(char *desc,  SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
804 {
805         if (ss0 == NULL) return False;
806
807         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
808         depth++;
809
810         prs_align(ps);
811
812         prs_uint32("num_entries_read", ps, depth, &(ss0->num_entries_read));
813         prs_uint32("ptr_conn_info", ps, depth, &(ss0->ptr_conn_info));
814
815         if (ss0->ptr_conn_info != 0)
816         {
817                 int i;
818                 int num_entries = ss0->num_entries_read;
819                 if (num_entries > MAX_CONN_ENTRIES)
820                 {
821                         num_entries = MAX_CONN_ENTRIES; /* report this! */
822                 }
823
824                 prs_uint32("num_entries_read2", ps, depth, &(ss0->num_entries_read2));
825
826                 for (i = 0; i < num_entries; i++)
827                 {
828                         prs_grow(ps);
829                         srv_io_conn_info0("", &(ss0->info_0[i]), ps, depth); 
830                 }
831
832                 prs_align(ps);
833         }
834
835         return True;
836 }
837
838 /*******************************************************************
839  makes a CONN_INFO_1_STR structure
840 ********************************************************************/
841 BOOL make_srv_conn_info1_str(CONN_INFO_1_STR *ss1, char *usr_name, char *net_name)
842 {
843         if (ss1 == NULL) return False;
844
845         DEBUG(5,("make_srv_conn_info1_str\n"));
846
847         make_unistr2(&(ss1->uni_usr_name), usr_name, strlen(usr_name)+1);
848         make_unistr2(&(ss1->uni_net_name), net_name, strlen(net_name)+1);
849
850         return True;
851 }
852
853 /*******************************************************************
854 reads or writes a structure.
855 ********************************************************************/
856 static BOOL srv_io_conn_info1_str(char *desc,  CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
857 {
858         if (ss1 == NULL) return False;
859
860         prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
861         depth++;
862
863         prs_align(ps);
864
865         smb_io_unistr2("", &(ss1->uni_usr_name), True, ps, depth); 
866         smb_io_unistr2("", &(ss1->uni_net_name), True, ps, depth); 
867
868         return True;
869 }
870
871 /*******************************************************************
872  makes a CONN_INFO_1 structure
873 ********************************************************************/
874 BOOL make_srv_conn_info1(CONN_INFO_1 *ss1, 
875                                 uint32 id, uint32 type,
876                                 uint32 num_opens, uint32 num_users, uint32 open_time,
877                                 char *usr_name, char *net_name)
878 {
879         if (ss1 == NULL) return False;
880
881         DEBUG(5,("make_srv_conn_info1: %s %s\n", usr_name, net_name));
882
883         ss1->id        = id       ;
884         ss1->type      = type     ;
885         ss1->num_opens = num_opens ;
886         ss1->num_users = num_users;
887         ss1->open_time = open_time;
888
889         ss1->ptr_usr_name = usr_name != NULL ? 1 : 0;
890         ss1->ptr_net_name = net_name != NULL ? 1 : 0;
891
892         return True;
893 }
894
895 /*******************************************************************
896 reads or writes a structure.
897 ********************************************************************/
898 static BOOL srv_io_conn_info1(char *desc,  CONN_INFO_1 *ss1, prs_struct *ps, int depth)
899 {
900         if (ss1 == NULL) return False;
901
902         prs_debug(ps, depth, desc, "srv_io_conn_info1");
903         depth++;
904
905         prs_align(ps);
906
907         prs_uint32("id          ", ps, depth, &(ss1->id        ));
908         prs_uint32("type        ", ps, depth, &(ss1->type      ));
909         prs_uint32("num_opens   ", ps, depth, &(ss1->num_opens ));
910         prs_uint32("num_users   ", ps, depth, &(ss1->num_users ));
911         prs_uint32("open_time   ", ps, depth, &(ss1->open_time ));
912
913         prs_uint32("ptr_usr_name", ps, depth, &(ss1->ptr_usr_name));
914         prs_uint32("ptr_net_name", ps, depth, &(ss1->ptr_net_name));
915
916         return True;
917 }
918
919 /*******************************************************************
920 reads or writes a structure.
921 ********************************************************************/
922 static BOOL srv_io_srv_conn_info_1(char *desc,  SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
923 {
924         if (ss1 == NULL) return False;
925
926         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
927         depth++;
928
929         prs_align(ps);
930
931         prs_uint32("num_entries_read", ps, depth, &(ss1->num_entries_read));
932         prs_uint32("ptr_conn_info", ps, depth, &(ss1->ptr_conn_info));
933
934         if (ss1->ptr_conn_info != 0)
935         {
936                 int i;
937                 int num_entries = ss1->num_entries_read;
938                 if (num_entries > MAX_CONN_ENTRIES)
939                 {
940                         num_entries = MAX_CONN_ENTRIES; /* report this! */
941                 }
942
943                 prs_uint32("num_entries_read2", ps, depth, &(ss1->num_entries_read2));
944
945                 for (i = 0; i < num_entries; i++)
946                 {
947                         prs_grow(ps);
948                         srv_io_conn_info1("", &(ss1->info_1[i]), ps, depth); 
949                 }
950
951                 for (i = 0; i < num_entries; i++)
952                 {
953                         prs_grow(ps);
954                         srv_io_conn_info1_str("", &(ss1->info_1_str[i]), ps, depth); 
955                 }
956
957                 prs_align(ps);
958         }
959
960         return True;
961 }
962
963 /*******************************************************************
964 reads or writes a structure.
965 ********************************************************************/
966 static BOOL srv_io_srv_conn_ctr(char *desc,  SRV_CONN_INFO_CTR *ctr, prs_struct *ps, int depth)
967 {
968         if (ctr == NULL) return False;
969
970         prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
971         depth++;
972
973         prs_align(ps);
974
975         prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
976         prs_uint32("ptr_conn_ctr", ps, depth, &(ctr->ptr_conn_ctr));
977
978         if (ctr->ptr_conn_ctr != 0)
979         {
980                 switch (ctr->switch_value)
981                 {
982                         case 0:
983                         {
984                                 srv_io_srv_conn_info_0("", &(ctr->conn.info0), ps, depth); 
985                                 break;
986                         }
987                         case 1:
988                         {
989                                 srv_io_srv_conn_info_1("", &(ctr->conn.info1), ps, depth); 
990                                 break;
991                         }
992                         default:
993                         {
994                                 DEBUG(5,("%s no connection info at switch_value %d\n",
995                                          tab_depth(depth), ctr->switch_value));
996                                 break;
997                         }
998                 }
999         }
1000
1001         return True;
1002 }
1003
1004 /*******************************************************************
1005 reads or writes a structure.
1006 ********************************************************************/
1007 BOOL make_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, 
1008                                 char *srv_name, char *qual_name,
1009                                 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
1010                                 uint32 preferred_len,
1011                                 ENUM_HND *hnd)
1012 {
1013         if (q_n == NULL || ctr == NULL || hnd == NULL) return False;
1014
1015         q_n->ctr = ctr;
1016
1017         DEBUG(5,("make_q_net_conn_enum\n"));
1018
1019         make_buf_unistr2(&(q_n->uni_srv_name ), &(q_n->ptr_srv_name ), srv_name );
1020         make_buf_unistr2(&(q_n->uni_qual_name), &(q_n->ptr_qual_name), qual_name);
1021
1022         q_n->conn_level    = conn_level;
1023         q_n->preferred_len = preferred_len;
1024
1025         memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
1026
1027         return True;
1028 }
1029
1030 /*******************************************************************
1031 reads or writes a structure.
1032 ********************************************************************/
1033 BOOL srv_io_q_net_conn_enum(char *desc,  SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
1034 {
1035         if (q_n == NULL) return False;
1036
1037         prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
1038         depth++;
1039
1040         prs_align(ps);
1041
1042         prs_uint32("ptr_srv_name ", ps, depth, &(q_n->ptr_srv_name));
1043         smb_io_unistr2("", &(q_n->uni_srv_name), q_n->ptr_srv_name, ps, depth); 
1044
1045         prs_align(ps);
1046
1047         prs_uint32("ptr_qual_name", ps, depth, &(q_n->ptr_qual_name));
1048         smb_io_unistr2("", &(q_n->uni_qual_name), q_n->ptr_qual_name, ps, depth); 
1049
1050         prs_align(ps);
1051
1052         prs_uint32("conn_level", ps, depth, &(q_n->conn_level  ));
1053         
1054         if (q_n->conn_level != -1)
1055         {
1056                 srv_io_srv_conn_ctr("conn_ctr", q_n->ctr, ps, depth);
1057         }
1058
1059         prs_uint32("preferred_len", ps, depth, &(q_n->preferred_len));
1060
1061         smb_io_enum_hnd("enum_hnd", &(q_n->enum_hnd), ps, depth); 
1062
1063         return True;
1064 }
1065
1066 /*******************************************************************
1067 reads or writes a structure.
1068 ********************************************************************/
1069 BOOL srv_io_r_net_conn_enum(char *desc,  SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
1070 {
1071         if (r_n == NULL) return False;
1072
1073         prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
1074         depth++;
1075
1076         prs_align(ps);
1077
1078         prs_uint32("conn_level", ps, depth, &(r_n->conn_level));
1079
1080         if (r_n->conn_level != -1)
1081         {
1082                 srv_io_srv_conn_ctr("conn_ctr", r_n->ctr, ps, depth);
1083         }
1084
1085         prs_uint32("total_entries", ps, depth, &(r_n->total_entries));
1086         smb_io_enum_hnd("enum_hnd", &(r_n->enum_hnd), ps, depth); 
1087         prs_uint32("status     ", ps, depth, &(r_n->status));
1088
1089         return True;
1090 }
1091
1092 /*******************************************************************
1093  makes a FILE_INFO_3_STR structure
1094 ********************************************************************/
1095 BOOL make_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name)
1096 {
1097         if (fi3 == NULL) return False;
1098
1099         DEBUG(5,("make_srv_file_info3_str\n"));
1100
1101         make_unistr2(&(fi3->uni_path_name), path_name, strlen(path_name)+1);
1102         make_unistr2(&(fi3->uni_user_name), user_name, strlen(user_name)+1);
1103
1104         return True;
1105 }
1106
1107 /*******************************************************************
1108 reads or writes a structure.
1109 ********************************************************************/
1110 static BOOL srv_io_file_info3_str(char *desc,  FILE_INFO_3_STR *sh1, prs_struct *ps, int depth)
1111 {
1112         if (sh1 == NULL) return False;
1113
1114         prs_debug(ps, depth, desc, "srv_io_file_info3_str");
1115         depth++;
1116
1117         prs_align(ps);
1118
1119         smb_io_unistr2("", &(sh1->uni_path_name), True, ps, depth); 
1120         smb_io_unistr2("", &(sh1->uni_user_name), True, ps, depth); 
1121
1122         return True;
1123 }
1124
1125 /*******************************************************************
1126  makes a FILE_INFO_3 structure
1127 ********************************************************************/
1128 BOOL make_srv_file_info3(FILE_INFO_3 *fl3,
1129                                 uint32 id, uint32 perms, uint32 num_locks,
1130                                 char *path_name, char *user_name)
1131 {
1132         if (fl3 == NULL) return False;
1133
1134         DEBUG(5,("make_srv_file_info3: %s %s\n", path_name, user_name));
1135
1136         fl3->id        = id;    
1137         fl3->perms     = perms;
1138         fl3->num_locks = num_locks;
1139
1140         fl3->ptr_path_name = path_name != NULL ? 1 : 0;
1141         fl3->ptr_user_name = user_name != NULL ? 1 : 0;
1142
1143         return True;
1144 }
1145
1146 /*******************************************************************
1147 reads or writes a structure.
1148 ********************************************************************/
1149 static BOOL srv_io_file_info3(char *desc,  FILE_INFO_3 *fl3, prs_struct *ps, int depth)
1150 {
1151         if (fl3 == NULL) return False;
1152
1153         prs_debug(ps, depth, desc, "srv_io_file_info3");
1154         depth++;
1155
1156         prs_align(ps);
1157
1158         prs_uint32("id           ", ps, depth, &(fl3->id           ));
1159         prs_uint32("perms        ", ps, depth, &(fl3->perms        ));
1160         prs_uint32("num_locks    ", ps, depth, &(fl3->num_locks    ));
1161         prs_uint32("ptr_path_name", ps, depth, &(fl3->ptr_path_name));
1162         prs_uint32("ptr_user_name", ps, depth, &(fl3->ptr_user_name));
1163
1164         return True;
1165 }
1166
1167 /*******************************************************************
1168 reads or writes a structure.
1169 ********************************************************************/
1170 static BOOL srv_io_srv_file_info_3(char *desc,  SRV_FILE_INFO_3 *fl3, prs_struct *ps, int depth)
1171 {
1172         if (fl3 == NULL) return False;
1173
1174         prs_debug(ps, depth, desc, "srv_io_file_3_fl3");
1175         depth++;
1176
1177         prs_align(ps);
1178
1179         prs_uint32("num_entries_read", ps, depth, &(fl3->num_entries_read));
1180         prs_uint32("ptr_file_fl3", ps, depth, &(fl3->ptr_file_info));
1181         if (fl3->ptr_file_info != 0)
1182         {
1183                 int i;
1184                 int num_entries = fl3->num_entries_read;
1185                 if (num_entries > MAX_FILE_ENTRIES)
1186                 {
1187                         num_entries = MAX_FILE_ENTRIES; /* report this! */
1188                 }
1189
1190                 prs_uint32("num_entries_read2", ps, depth, &(fl3->num_entries_read2));
1191
1192                 for (i = 0; i < num_entries; i++)
1193                 {
1194                         prs_grow(ps);
1195                         srv_io_file_info3("", &(fl3->info_3[i]), ps, depth); 
1196                 }
1197
1198                 for (i = 0; i < num_entries; i++)
1199                 {
1200                         prs_grow(ps);
1201                         srv_io_file_info3_str("", &(fl3->info_3_str[i]), ps, depth); 
1202                 }
1203
1204                 prs_align(ps);
1205         }
1206
1207         return True;
1208 }
1209
1210 /*******************************************************************
1211 reads or writes a structure.
1212 ********************************************************************/
1213 static BOOL srv_io_srv_file_ctr(char *desc,  SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
1214 {
1215         if (ctr == NULL) return False;
1216
1217         prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
1218         depth++;
1219
1220         prs_align(ps);
1221
1222         prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
1223         prs_uint32("ptr_file_ctr", ps, depth, &(ctr->ptr_file_ctr));
1224
1225         if (ctr->ptr_file_ctr != 0)
1226         {
1227                 switch (ctr->switch_value)
1228                 {
1229                         case 3:
1230                         {
1231                                 srv_io_srv_file_info_3("", &(ctr->file.info3), ps, depth); 
1232                                 break;
1233                         }
1234                         default:
1235                         {
1236                                 DEBUG(5,("%s no file info at switch_value %d\n",
1237                                          tab_depth(depth), ctr->switch_value));
1238                                 break;
1239                         }
1240                 }
1241         }
1242
1243         return True;
1244 }
1245
1246 /*******************************************************************
1247 reads or writes a structure.
1248 ********************************************************************/
1249 BOOL make_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, 
1250                                 char *srv_name, char *qual_name, uint32 file_id,
1251                                 uint32 file_level, SRV_FILE_INFO_CTR *ctr,
1252                                 uint32 preferred_len,
1253                                 ENUM_HND *hnd)
1254 {
1255         if (q_n == NULL || ctr == NULL || hnd == NULL) return False;
1256
1257         q_n->ctr = ctr;
1258
1259         DEBUG(5,("make_q_net_file_enum\n"));
1260
1261         make_buf_unistr2(&(q_n->uni_srv_name), &(q_n->ptr_srv_name), srv_name);
1262         make_buf_unistr2(&(q_n->uni_qual_name), &(q_n->ptr_qual_name), qual_name);
1263
1264         q_n->file_id       = file_id;
1265         q_n->file_level    = file_level;
1266         q_n->preferred_len = preferred_len;
1267
1268         memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
1269
1270         return True;
1271 }
1272
1273 /*******************************************************************
1274 reads or writes a structure.
1275 ********************************************************************/
1276 BOOL srv_io_q_net_file_enum(char *desc,  SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
1277 {
1278         if (q_n == NULL) return False;
1279
1280         prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
1281         depth++;
1282
1283         prs_align(ps);
1284
1285         prs_uint32("ptr_srv_name", ps, depth, &(q_n->ptr_srv_name));
1286         smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth); 
1287
1288         prs_align(ps);
1289
1290         prs_uint32("ptr_qual_name", ps, depth, &(q_n->ptr_qual_name));
1291         smb_io_unistr2("", &(q_n->uni_qual_name), q_n->ptr_qual_name, ps, depth); 
1292
1293         prs_align(ps);
1294
1295         prs_uint32("file_id   ", ps, depth, &(q_n->file_id   ));
1296         prs_uint32("file_level", ps, depth, &(q_n->file_level));
1297
1298         if (q_n->file_level != -1)
1299         {
1300                 srv_io_srv_file_ctr("file_ctr", q_n->ctr, ps, depth);
1301         }
1302
1303         prs_uint32("preferred_len", ps, depth, &(q_n->preferred_len));
1304
1305         smb_io_enum_hnd("enum_hnd", &(q_n->enum_hnd), ps, depth); 
1306
1307         return True;
1308 }
1309
1310 /*******************************************************************
1311 reads or writes a structure.
1312 ********************************************************************/
1313 BOOL srv_io_r_net_file_enum(char *desc,  SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
1314 {
1315         if (r_n == NULL) return False;
1316
1317         prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
1318         depth++;
1319
1320         prs_align(ps);
1321
1322         prs_uint32("file_level", ps, depth, &(r_n->file_level));
1323
1324         if (r_n->file_level != 0)
1325         {
1326                 srv_io_srv_file_ctr("file_ctr", r_n->ctr, ps, depth);
1327         }
1328
1329         prs_uint32("total_entries", ps, depth, &(r_n->total_entries));
1330         smb_io_enum_hnd("enum_hnd", &(r_n->enum_hnd), ps, depth); 
1331         prs_uint32("status     ", ps, depth, &(r_n->status));
1332
1333         return True;
1334 }
1335
1336 /*******************************************************************
1337  makes a SRV_INFO_101 structure.
1338  ********************************************************************/
1339 BOOL make_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
1340                                 uint32 ver_major, uint32 ver_minor,
1341                                 uint32 srv_type, char *comment)
1342 {
1343         if (sv101 == NULL) return False;
1344
1345         DEBUG(5,("make_srv_info_101\n"));
1346
1347         sv101->platform_id  = platform_id;
1348         make_buf_unistr2(&(sv101->uni_name    ), &(sv101->ptr_name   ) , name    );
1349         sv101->ver_major    = ver_major;
1350         sv101->ver_minor    = ver_minor;
1351         sv101->srv_type     = srv_type;
1352         make_buf_unistr2(&(sv101->uni_comment ), &(sv101->ptr_comment) , comment );
1353
1354         return True;
1355 }
1356
1357
1358 /*******************************************************************
1359  reads or writes a SRV_INFO_101 structure.
1360  ********************************************************************/
1361 static BOOL srv_io_info_101(char *desc,  SRV_INFO_101 *sv101, prs_struct *ps, int depth)
1362 {
1363         if (sv101 == NULL) return False;
1364
1365         prs_debug(ps, depth, desc, "srv_io_info_101");
1366         depth++;
1367
1368         prs_align(ps);
1369
1370         prs_uint32("platform_id ", ps, depth, &(sv101->platform_id ));
1371         prs_uint32("ptr_name    ", ps, depth, &(sv101->ptr_name    ));
1372         prs_uint32("ver_major   ", ps, depth, &(sv101->ver_major   ));
1373         prs_uint32("ver_minor   ", ps, depth, &(sv101->ver_minor   ));
1374         prs_uint32("srv_type    ", ps, depth, &(sv101->srv_type    ));
1375         prs_uint32("ptr_comment ", ps, depth, &(sv101->ptr_comment ));
1376
1377         prs_align(ps);
1378
1379         smb_io_unistr2("uni_name    ", &(sv101->uni_name    ), True, ps, depth); 
1380         smb_io_unistr2("uni_comment ", &(sv101->uni_comment ), True, ps, depth); 
1381
1382         return True;
1383 }
1384
1385 /*******************************************************************
1386  makes a SRV_INFO_102 structure.
1387  ********************************************************************/
1388 BOOL make_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
1389                                 char *comment, uint32 ver_major, uint32 ver_minor,
1390                                 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
1391                                 uint32 announce, uint32 ann_delta, uint32 licenses,
1392                                 char *usr_path)
1393 {
1394         if (sv102 == NULL) return False;
1395
1396         DEBUG(5,("make_srv_info_102\n"));
1397
1398         sv102->platform_id  = platform_id;
1399         make_buf_unistr2(&(sv102->uni_name    ), &(sv102->ptr_name    ), name    );
1400         sv102->ver_major    = ver_major;
1401         sv102->ver_minor    = ver_minor;
1402         sv102->srv_type     = srv_type;
1403         make_buf_unistr2(&(sv102->uni_comment ), &(sv102->ptr_comment ), comment );
1404
1405         /* same as 101 up to here */
1406
1407         sv102->users        = users;
1408         sv102->disc         = disc;
1409         sv102->hidden       = hidden;
1410         sv102->announce     = announce;
1411         sv102->ann_delta    =ann_delta;
1412         sv102->licenses     = licenses;
1413         make_buf_unistr2(&(sv102->uni_usr_path), &(sv102->ptr_usr_path), usr_path);
1414
1415         return True;
1416 }
1417
1418
1419 /*******************************************************************
1420  reads or writes a SRV_INFO_102 structure.
1421  ********************************************************************/
1422 static BOOL srv_io_info_102(char *desc,  SRV_INFO_102 *sv102, prs_struct *ps, int depth)
1423 {
1424         if (sv102 == NULL) return False;
1425
1426         prs_debug(ps, depth, desc, "srv_io_info102");
1427         depth++;
1428
1429         prs_align(ps);
1430
1431         prs_uint32("platform_id ", ps, depth, &(sv102->platform_id ));
1432         prs_uint32("ptr_name    ", ps, depth, &(sv102->ptr_name    ));
1433         prs_uint32("ver_major   ", ps, depth, &(sv102->ver_major   ));
1434         prs_uint32("ver_minor   ", ps, depth, &(sv102->ver_minor   ));
1435         prs_uint32("srv_type    ", ps, depth, &(sv102->srv_type    ));
1436         prs_uint32("ptr_comment ", ps, depth, &(sv102->ptr_comment ));
1437
1438         /* same as 101 up to here */
1439
1440         prs_uint32("users       ", ps, depth, &(sv102->users       ));
1441         prs_uint32("disc        ", ps, depth, &(sv102->disc        ));
1442         prs_uint32("hidden      ", ps, depth, &(sv102->hidden      ));
1443         prs_uint32("announce    ", ps, depth, &(sv102->announce    ));
1444         prs_uint32("ann_delta   ", ps, depth, &(sv102->ann_delta   ));
1445         prs_uint32("licenses    ", ps, depth, &(sv102->licenses    ));
1446         prs_uint32("ptr_usr_path", ps, depth, &(sv102->ptr_usr_path));
1447
1448         smb_io_unistr2("uni_name    ", &(sv102->uni_name    ), True, ps, depth); 
1449         prs_align(ps);
1450         smb_io_unistr2("uni_comment ", &(sv102->uni_comment ), True, ps, depth); 
1451         prs_align(ps);
1452         smb_io_unistr2("uni_usr_path", &(sv102->uni_usr_path), True, ps, depth); 
1453
1454         return True;
1455 }
1456
1457 /*******************************************************************
1458  reads or writes a SRV_INFO_102 structure.
1459  ********************************************************************/
1460 static BOOL srv_io_info_ctr(char *desc,  SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
1461 {
1462         if (ctr == NULL) return False;
1463
1464         prs_debug(ps, depth, desc, "srv_io_info_ctr");
1465         depth++;
1466
1467         prs_align(ps);
1468
1469         prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
1470         prs_uint32("ptr_srv_ctr ", ps, depth, &(ctr->ptr_srv_ctr ));
1471
1472         if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL)
1473         {
1474                 switch (ctr->switch_value)
1475                 {
1476                         case 101:
1477                         {
1478                                 srv_io_info_101("sv101", &(ctr->srv.sv101), ps, depth); 
1479                                 break;
1480                         }
1481                         case 102:
1482                         {
1483                                 srv_io_info_102("sv102", &(ctr->srv.sv102), ps, depth); 
1484                                 break;
1485                         }
1486                         default:
1487                         {
1488                                 DEBUG(5,("%s no server info at switch_value %d\n",
1489                                                  tab_depth(depth), ctr->switch_value));
1490                                 break;
1491                         }
1492                 }
1493                 prs_align(ps);
1494         }
1495
1496         return True;
1497 }
1498
1499 /*******************************************************************
1500  makes a SRV_Q_NET_SRV_GET_INFO structure.
1501  ********************************************************************/
1502 BOOL make_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
1503                                 char *server_name, uint32 switch_value)
1504 {
1505         if (srv == NULL) return False;
1506
1507         DEBUG(5,("make_srv_q_net_srv_get_info\n"));
1508
1509         make_buf_unistr2(&(srv->uni_srv_name), &(srv->ptr_srv_name), server_name);
1510
1511         srv->switch_value = switch_value;
1512
1513         return True;
1514 }
1515
1516 /*******************************************************************
1517 reads or writes a structure.
1518 ********************************************************************/
1519 BOOL srv_io_q_net_srv_get_info(char *desc,  SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
1520 {
1521         if (q_n == NULL) return False;
1522
1523         prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
1524         depth++;
1525
1526         prs_align(ps);
1527
1528         prs_uint32("ptr_srv_name  ", ps, depth, &(q_n->ptr_srv_name));
1529         smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth); 
1530
1531         prs_align(ps);
1532
1533         prs_uint32("switch_value  ", ps, depth, &(q_n->switch_value));
1534
1535         return True;
1536 }
1537
1538 /*******************************************************************
1539  makes a SRV_R_NET_SRV_GET_INFO structure.
1540  ********************************************************************/
1541 BOOL make_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
1542                                 uint32 switch_value, SRV_INFO_CTR *ctr, uint32 status)
1543 {
1544         if (srv == NULL) return False;
1545
1546         DEBUG(5,("make_srv_r_net_srv_get_info\n"));
1547
1548         srv->ctr = ctr;
1549
1550         if (status == 0x0)
1551         {
1552                 srv->ctr->switch_value = switch_value;
1553                 srv->ctr->ptr_srv_ctr  = 1;
1554         }
1555         else
1556         {
1557                 srv->ctr->switch_value = 0;
1558                 srv->ctr->ptr_srv_ctr  = 0;
1559         }
1560
1561         srv->status = status;
1562
1563         return True;
1564 }
1565
1566 /*******************************************************************
1567  reads or writes a structure.
1568  ********************************************************************/
1569 BOOL srv_io_r_net_srv_get_info(char *desc,  SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
1570 {
1571         if (r_n == NULL) return False;
1572
1573         prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
1574         depth++;
1575
1576         prs_align(ps);
1577
1578         srv_io_info_ctr("ctr", r_n->ctr, ps, depth); 
1579
1580         prs_uint32("status      ", ps, depth, &(r_n->status      ));
1581
1582         return True;
1583 }
1584
1585 /*******************************************************************
1586  makes a SRV_Q_NET_REMOTE_TOD structure.
1587  ********************************************************************/
1588 BOOL make_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_t, char *server_name)
1589 {
1590         if (q_t == NULL) return False;
1591
1592         DEBUG(5,("make_srv_q_net_remote_tod\n"));
1593
1594         make_buf_unistr2(&(q_t->uni_srv_name), &(q_t->ptr_srv_name), server_name);
1595
1596         return True;
1597 }
1598
1599 /*******************************************************************
1600  reads or writes a structure.
1601  ********************************************************************/
1602 BOOL srv_io_q_net_remote_tod(char *desc,  SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
1603 {
1604         if (q_n == NULL) return False;
1605
1606         prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
1607         depth++;
1608
1609         prs_align(ps);
1610
1611         prs_uint32("ptr_srv_name  ", ps, depth, &(q_n->ptr_srv_name));
1612         smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth); 
1613
1614         return True;
1615 }
1616
1617 /*******************************************************************
1618  reads or writes a TIME_OF_DAY_INFO structure.
1619  ********************************************************************/
1620 static BOOL srv_io_time_of_day_info(char *desc, TIME_OF_DAY_INFO  *tod, prs_struct *ps, int depth)
1621 {
1622         if (tod == NULL) return False;
1623
1624         prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
1625         depth++;
1626
1627         prs_align(ps);
1628         
1629         prs_uint32("elapsedt   ", ps, depth, &(tod->elapsedt  ));
1630         prs_uint32("msecs      ", ps, depth, &(tod->msecs     ));
1631         prs_uint32("hours      ", ps, depth, &(tod->hours     ));
1632         prs_uint32("mins       ", ps, depth, &(tod->mins      ));
1633         prs_uint32("secs       ", ps, depth, &(tod->secs      ));
1634         prs_uint32("hunds      ", ps, depth, &(tod->hunds     ));
1635         prs_uint32("timezone   ", ps, depth, &(tod->zone  ));
1636         prs_uint32("tintervals ", ps, depth, &(tod->tintervals));
1637         prs_uint32("day        ", ps, depth, &(tod->day       ));
1638         prs_uint32("month      ", ps, depth, &(tod->month     ));
1639         prs_uint32("year       ", ps, depth, &(tod->year      ));
1640         prs_uint32("weekday    ", ps, depth, &(tod->weekday   ));
1641
1642
1643         return True;
1644 }
1645
1646 /*******************************************************************
1647  makes a TIME_OF_DAY_INFO structure.
1648  ********************************************************************/
1649 BOOL make_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
1650                            uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
1651                            uint32 zone, uint32 tintervals, uint32 day,
1652                            uint32 month, uint32 year, uint32 weekday)
1653 {
1654         if (tod == NULL) return False;
1655
1656         DEBUG(5,("make_time_of_day_info\n"));
1657
1658         tod->elapsedt   = elapsedt;
1659         tod->msecs      = msecs;
1660         tod->hours      = hours;
1661         tod->mins       = mins;
1662         tod->secs       = secs;
1663         tod->hunds      = hunds;
1664         tod->zone       = zone;
1665         tod->tintervals = tintervals;
1666         tod->day        = day;
1667         tod->month      = month;
1668         tod->year       = year;
1669         tod->weekday    = weekday;
1670
1671         return True;
1672 }
1673
1674
1675 /*******************************************************************
1676  reads or writes a structure.
1677  ********************************************************************/
1678 BOOL srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
1679 {
1680         if (r_n == NULL) return False;
1681
1682         prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
1683         depth++;
1684
1685         prs_align(ps);
1686         
1687         prs_uint32("ptr_srv_tod ", ps, depth, &(r_n->ptr_srv_tod));
1688
1689         srv_io_time_of_day_info("tod", r_n->tod, ps, depth); 
1690
1691         prs_uint32("status      ", ps, depth, &(r_n->status));
1692
1693         return True;
1694 }