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