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