f399b7fc031aebce7ebda8491467413ac39a2174
[samba.git] / source3 / rpcclient / display.c
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    Samba utility functions
5    Copyright (C) Andrew Tridgell 1992-1998
6    Copyright (C) Luke Kenneth Casson Leighton 1996 - 1998
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24
25
26 /****************************************************************************
27 convert a share mode to a string
28 ****************************************************************************/
29 char *get_file_mode_str(uint32 share_mode)
30 {
31         static fstring mode;
32
33         switch ((share_mode>>4)&0xF)
34         {
35                 case DENY_NONE : fstrcpy(mode, "DENY_NONE  "); break;
36                 case DENY_ALL  : fstrcpy(mode, "DENY_ALL   "); break;
37                 case DENY_DOS  : fstrcpy(mode, "DENY_DOS   "); break;
38                 case DENY_READ : fstrcpy(mode, "DENY_READ  "); break;
39                 case DENY_WRITE: fstrcpy(mode, "DENY_WRITE "); break;
40                 default        : fstrcpy(mode, "DENY_????  "); break;
41         }
42
43         switch (share_mode & 0xF)
44         {
45                 case 0 : fstrcat(mode, "RDONLY"); break;
46                 case 1 : fstrcat(mode, "WRONLY"); break;
47                 case 2 : fstrcat(mode, "RDWR  "); break;
48                 default: fstrcat(mode, "R??W??"); break;
49         }
50
51         return mode;
52 }
53
54 /****************************************************************************
55 convert an oplock mode to a string
56 ****************************************************************************/
57 char *get_file_oplock_str(uint32 op_type)
58 {
59         static fstring oplock;
60         BOOL excl  = IS_BITS_SET_ALL(op_type, EXCLUSIVE_OPLOCK);
61         BOOL batch = IS_BITS_SET_ALL(op_type, BATCH_OPLOCK    );
62
63         oplock[0] = 0;
64
65         if (excl           ) fstrcat(oplock, "EXCLUSIVE");
66         if (excl  &&  batch) fstrcat(oplock, "+");
67         if (          batch) fstrcat(oplock, "BATCH");
68         if (!excl && !batch) fstrcat(oplock, "NONE");
69
70         return oplock;
71 }
72
73 /****************************************************************************
74 convert a share type enum to a string
75 ****************************************************************************/
76 char *get_share_type_str(uint32 type)
77 {
78         static fstring typestr;
79
80         switch (type)
81         {
82                 case STYPE_DISKTREE: fstrcpy(typestr, "Disk"   ); break;
83                 case STYPE_PRINTQ  : fstrcpy(typestr, "Printer"); break;              
84                 case STYPE_DEVICE  : fstrcpy(typestr, "Device" ); break;
85                 case STYPE_IPC     : fstrcpy(typestr, "IPC"    ); break;      
86                 default            : fstrcpy(typestr, "????"   ); break;      
87         }
88         return typestr;
89 }
90
91 /****************************************************************************
92 convert a server type enum to a string
93 ****************************************************************************/
94 char *get_server_type_str(uint32 type)
95 {
96         static fstring typestr;
97
98         if (type == SV_TYPE_ALL)
99         {
100                 fstrcpy(typestr, "All");
101         }
102         else
103         {
104                 int i;
105                 typestr[0] = 0;
106                 for (i = 0; i < 32; i++)
107                 {
108                         if (IS_BITS_SET_ALL(type, 1 << i))
109                         {
110                                 switch (1 << i)
111                                 {
112                                         case SV_TYPE_WORKSTATION      : fstrcat(typestr, "Wk " ); break;
113                                         case SV_TYPE_SERVER           : fstrcat(typestr, "Sv " ); break;
114                                         case SV_TYPE_SQLSERVER        : fstrcat(typestr, "Sql "); break;
115                                         case SV_TYPE_DOMAIN_CTRL      : fstrcat(typestr, "PDC "); break;
116                                         case SV_TYPE_DOMAIN_BAKCTRL   : fstrcat(typestr, "BDC "); break;
117                                         case SV_TYPE_TIME_SOURCE      : fstrcat(typestr, "Tim "); break;
118                                         case SV_TYPE_AFP              : fstrcat(typestr, "AFP "); break;
119                                         case SV_TYPE_NOVELL           : fstrcat(typestr, "Nov "); break;
120                                         case SV_TYPE_DOMAIN_MEMBER    : fstrcat(typestr, "Dom "); break;
121                                         case SV_TYPE_PRINTQ_SERVER    : fstrcat(typestr, "PrQ "); break;
122                                         case SV_TYPE_DIALIN_SERVER    : fstrcat(typestr, "Din "); break;
123                                         case SV_TYPE_SERVER_UNIX      : fstrcat(typestr, "Unx "); break;
124                                         case SV_TYPE_NT               : fstrcat(typestr, "NT " ); break;
125                                         case SV_TYPE_WFW              : fstrcat(typestr, "Wfw "); break;
126                                         case SV_TYPE_SERVER_MFPN      : fstrcat(typestr, "Mfp "); break;
127                                         case SV_TYPE_SERVER_NT        : fstrcat(typestr, "SNT "); break;
128                                         case SV_TYPE_POTENTIAL_BROWSER: fstrcat(typestr, "PtB "); break;
129                                         case SV_TYPE_BACKUP_BROWSER   : fstrcat(typestr, "BMB "); break;
130                                         case SV_TYPE_MASTER_BROWSER   : fstrcat(typestr, "LMB "); break;
131                                         case SV_TYPE_DOMAIN_MASTER    : fstrcat(typestr, "DMB "); break;
132                                         case SV_TYPE_SERVER_OSF       : fstrcat(typestr, "OSF "); break;
133                                         case SV_TYPE_SERVER_VMS       : fstrcat(typestr, "VMS "); break;
134                                         case SV_TYPE_WIN95_PLUS       : fstrcat(typestr, "W95 "); break;
135                                         case SV_TYPE_ALTERNATE_XPORT  : fstrcat(typestr, "Xpt "); break;
136                                         case SV_TYPE_LOCAL_LIST_ONLY  : fstrcat(typestr, "Dom "); break;
137                                         case SV_TYPE_DOMAIN_ENUM      : fstrcat(typestr, "Loc "); break;
138                                 }
139                         }
140                 }
141                 i = strlen(typestr)-1;
142                 if (typestr[i] == ' ') typestr[i] = 0;
143
144         }
145         return typestr;
146 }
147
148 /****************************************************************************
149 server info level 101 display function
150 ****************************************************************************/
151 void display_srv_info_101(FILE *out_hnd, enum action_type action,
152                 SRV_INFO_101 *sv101)
153 {
154         if (sv101 == NULL)
155         {
156                 return;
157         }
158
159         switch (action)
160         {
161                 case ACTION_HEADER:
162                 {
163                         fprintf(out_hnd, "Server Info Level 101:\n");
164
165                         break;
166                 }
167                 case ACTION_ENUMERATE:
168                 {
169                         fstring name;
170                         fstring comment;
171
172                         fstrcpy(name    , unistrn2(sv101->uni_name    .buffer, sv101->uni_name    .uni_str_len));
173                         fstrcpy(comment , unistrn2(sv101->uni_comment .buffer, sv101->uni_comment .uni_str_len));
174
175                         display_server(out_hnd, action, name, sv101->srv_type, comment);
176
177                         fprintf(out_hnd, "\tplatform_id     : %d\n"    , sv101->platform_id);
178                         fprintf(out_hnd, "\tos version      : %d.%d\n" , sv101->ver_major, sv101->ver_minor);
179
180                         break;
181                 }
182                 case ACTION_FOOTER:
183                 {
184                         break;
185                 }
186         }
187
188 }
189
190 /****************************************************************************
191 server info level 102 display function
192 ****************************************************************************/
193 void display_srv_info_102(FILE *out_hnd, enum action_type action,SRV_INFO_102 *sv102)
194 {
195         if (sv102 == NULL)
196         {
197                 return;
198         }
199
200         switch (action)
201         {
202                 case ACTION_HEADER:
203                 {
204                         fprintf(out_hnd, "Server Info Level 102:\n");
205
206                         break;
207                 }
208                 case ACTION_ENUMERATE:
209                 {
210                         fstring name;
211                         fstring comment;
212                         fstring usr_path;
213
214                         fstrcpy(name    , unistrn2(sv102->uni_name    .buffer, sv102->uni_name    .uni_str_len));
215                         fstrcpy(comment , unistrn2(sv102->uni_comment .buffer, sv102->uni_comment .uni_str_len));
216                         fstrcpy(usr_path, unistrn2(sv102->uni_usr_path.buffer, sv102->uni_usr_path.uni_str_len));
217
218                         display_server(out_hnd, action, name, sv102->srv_type, comment);
219
220                         fprintf(out_hnd, "\tplatform_id     : %d\n"    , sv102->platform_id);
221                         fprintf(out_hnd, "\tos version      : %d.%d\n" , sv102->ver_major, sv102->ver_minor);
222
223                         fprintf(out_hnd, "\tusers           : %x\n"    , sv102->users      );
224                         fprintf(out_hnd, "\tdisc, hidden    : %x,%x\n" , sv102->disc     , sv102->hidden   );
225                         fprintf(out_hnd, "\tannounce, delta : %d, %d\n", sv102->announce , sv102->ann_delta);
226                         fprintf(out_hnd, "\tlicenses        : %d\n"    , sv102->licenses   );
227                         fprintf(out_hnd, "\tuser path       : %s\n"    , usr_path);
228
229                         break;
230                 }
231                 case ACTION_FOOTER:
232                 {
233                         break;
234                 }
235         }
236 }
237
238 /****************************************************************************
239 server info container display function
240 ****************************************************************************/
241 void display_srv_info_ctr(FILE *out_hnd, enum action_type action,SRV_INFO_CTR *ctr)
242 {
243         if (ctr == NULL || ctr->ptr_srv_ctr == 0)
244         {
245                 fprintf(out_hnd, "Server Information: unavailable due to an error\n");
246                 return;
247         }
248
249         switch (ctr->switch_value)
250         {
251                 case 101:
252                 {
253                         display_srv_info_101(out_hnd, action, &(ctr->srv.sv101));
254                         break;
255                 }
256                 case 102:
257                 {
258                         display_srv_info_102(out_hnd, action, &(ctr->srv.sv102));
259                         break;
260                 }
261                 default:
262                 {
263                         fprintf(out_hnd, "Server Information: Unknown Info Level\n");
264                         break;
265                 }
266         }
267 }
268
269 /****************************************************************************
270 connection info level 0 display function
271 ****************************************************************************/
272 void display_conn_info_0(FILE *out_hnd, enum action_type action,
273                 CONN_INFO_0 *info0)
274 {
275         if (info0 == NULL)
276         {
277                 return;
278         }
279
280         switch (action)
281         {
282                 case ACTION_HEADER:
283                 {
284                         fprintf(out_hnd, "Connection Info Level 0:\n");
285
286                         break;
287                 }
288                 case ACTION_ENUMERATE:
289                 {
290                         fprintf(out_hnd, "\tid: %d\n", info0->id);
291
292                         break;
293                 }
294                 case ACTION_FOOTER:
295                 {
296                         fprintf(out_hnd, "\n");
297                         break;
298                 }
299         }
300
301 }
302
303 /****************************************************************************
304 connection info level 1 display function
305 ****************************************************************************/
306 void display_conn_info_1(FILE *out_hnd, enum action_type action,
307                 CONN_INFO_1 *info1, CONN_INFO_1_STR *str1)
308 {
309         if (info1 == NULL || str1 == NULL)
310         {
311                 return;
312         }
313
314         switch (action)
315         {
316                 case ACTION_HEADER:
317                 {
318                         fprintf(out_hnd, "Connection Info Level 1:\n");
319
320                         break;
321                 }
322                 case ACTION_ENUMERATE:
323                 {
324                         fstring usr_name;
325                         fstring net_name;
326
327                         fstrcpy(usr_name, unistrn2(str1->uni_usr_name.buffer, str1->uni_usr_name.uni_str_len));
328                         fstrcpy(net_name, unistrn2(str1->uni_net_name.buffer, str1->uni_net_name.uni_str_len));
329
330                         fprintf(out_hnd, "\tid       : %d\n", info1->id);
331                         fprintf(out_hnd, "\ttype     : %s\n", get_share_type_str(info1->type));
332                         fprintf(out_hnd, "\tnum_opens: %d\n", info1->num_opens);
333                         fprintf(out_hnd, "\tnum_users: %d\n", info1->num_users);
334                         fprintf(out_hnd, "\topen_time: %d\n", info1->open_time);
335
336                         fprintf(out_hnd, "\tuser name: %s\n", usr_name);
337                         fprintf(out_hnd, "\tnet  name: %s\n", net_name);
338
339                         break;
340                 }
341                 case ACTION_FOOTER:
342                 {
343                         fprintf(out_hnd, "\n");
344                         break;
345                 }
346         }
347
348 }
349
350 /****************************************************************************
351 connection info level 0 container display function
352 ****************************************************************************/
353 void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action,
354                                 SRV_CONN_INFO_0 *ctr)
355 {
356         if (ctr == NULL)
357         {
358                 fprintf(out_hnd, "display_srv_conn_info_0_ctr: unavailable due to an internal error\n");
359                 return;
360         }
361
362         switch (action)
363         {
364                 case ACTION_HEADER:
365                 {
366                         break;
367                 }
368                 case ACTION_ENUMERATE:
369                 {
370                         int i;
371
372                         for (i = 0; i < ctr->num_entries_read; i++)
373                         {
374                                 display_conn_info_0(out_hnd, ACTION_HEADER   , &(ctr->info_0[i]));
375                                 display_conn_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]));
376                                 display_conn_info_0(out_hnd, ACTION_FOOTER   , &(ctr->info_0[i]));
377                         }
378                         break;
379                 }
380                 case ACTION_FOOTER:
381                 {
382                         break;
383                 }
384         }
385 }
386
387 /****************************************************************************
388 connection info level 1 container display function
389 ****************************************************************************/
390 void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
391                                 SRV_CONN_INFO_1 *ctr)
392 {
393         if (ctr == NULL)
394         {
395                 fprintf(out_hnd, "display_srv_conn_info_1_ctr: unavailable due to an internal error\n");
396                 return;
397         }
398
399         switch (action)
400         {
401                 case ACTION_HEADER:
402                 {
403                         break;
404                 }
405                 case ACTION_ENUMERATE:
406                 {
407                         int i;
408
409                         for (i = 0; i < ctr->num_entries_read; i++)
410                         {
411                                 display_conn_info_1(out_hnd, ACTION_HEADER   , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
412                                 display_conn_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i]));
413                                 display_conn_info_1(out_hnd, ACTION_FOOTER   , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
414                         }
415                         break;
416                 }
417                 case ACTION_FOOTER:
418                 {
419                         break;
420                 }
421         }
422 }
423
424 /****************************************************************************
425 connection info container display function
426 ****************************************************************************/
427 void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
428                                 SRV_CONN_INFO_CTR *ctr)
429 {
430         if (ctr == NULL || ctr->ptr_conn_ctr == 0)
431         {
432                 fprintf(out_hnd, "display_srv_conn_info_ctr: unavailable due to an internal error\n");
433                 return;
434         }
435
436         switch (ctr->switch_value)
437         {
438                 case 0:
439                 {
440                         display_srv_conn_info_0_ctr(out_hnd, action,
441                                            &(ctr->conn.info0));
442                         break;
443                 }
444                 case 1:
445                 {
446                         display_srv_conn_info_1_ctr(out_hnd, action,
447                                            &(ctr->conn.info1));
448                         break;
449                 }
450                 default:
451                 {
452                         fprintf(out_hnd, "display_srv_conn_info_ctr: Unknown Info Level\n");
453                         break;
454                 }
455         }
456 }
457
458
459 /****************************************************************************
460 share info level 1 display function
461 ****************************************************************************/
462 void display_share_info_1(FILE *out_hnd, enum action_type action,
463                 SH_INFO_1 *info1, SH_INFO_1_STR *str1)
464 {
465         if (info1 == NULL || str1 == NULL)
466         {
467                 return;
468         }
469
470         switch (action)
471         {
472                 case ACTION_HEADER:
473                 {
474                         fprintf(out_hnd, "Share Info Level 1:\n");
475
476                         break;
477                 }
478                 case ACTION_ENUMERATE:
479                 {
480                         fstring remark  ;
481                         fstring net_name;
482
483                         fstrcpy(net_name, unistrn2(str1->uni_netname.buffer, str1->uni_netname.uni_str_len));
484                         fstrcpy(remark  , unistrn2(str1->uni_remark .buffer, str1->uni_remark .uni_str_len));
485
486                         display_share(out_hnd, action, net_name, info1->type, remark);
487
488                         break;
489                 }
490                 case ACTION_FOOTER:
491                 {
492                         fprintf(out_hnd, "\n");
493                         break;
494                 }
495         }
496
497 }
498
499 /****************************************************************************
500 share info level 2 display function
501 ****************************************************************************/
502 void display_share_info_2(FILE *out_hnd, enum action_type action,
503                 SH_INFO_2 *info2, SH_INFO_2_STR *str2)
504 {
505         if (info2 == NULL || str2 == NULL)
506         {
507                 return;
508         }
509
510         switch (action)
511         {
512                 case ACTION_HEADER:
513                 {
514                         fprintf(out_hnd, "Share Info Level 2:\n");
515
516                         break;
517                 }
518                 case ACTION_ENUMERATE:
519                 {
520                         fstring remark  ;
521                         fstring net_name;
522                         fstring path    ;
523                         fstring passwd  ;
524
525                         fstrcpy(net_name, unistrn2(str2->uni_netname.buffer, str2->uni_netname.uni_str_len));
526                         fstrcpy(remark  , unistrn2(str2->uni_remark .buffer, str2->uni_remark .uni_str_len));
527                         fstrcpy(path    , unistrn2(str2->uni_path   .buffer, str2->uni_path   .uni_str_len));
528                         fstrcpy(passwd  , unistrn2(str2->uni_passwd .buffer, str2->uni_passwd .uni_str_len));
529
530                         display_share2(out_hnd, action, net_name, info2->type, remark,
531                                                               info2->perms, info2->max_uses, info2->num_uses,
532                                                               path, passwd);
533
534                         break;
535                 }
536                 case ACTION_FOOTER:
537                 {
538                         fprintf(out_hnd, "\n");
539                         break;
540                 }
541         }
542
543 }
544
545 /****************************************************************************
546 share info level 1 container display function
547 ****************************************************************************/
548 void display_srv_share_info_1_ctr(FILE *out_hnd, enum action_type action,
549                                 SRV_SHARE_INFO_1 *ctr)
550 {
551         if (ctr == NULL)
552         {
553                 fprintf(out_hnd, "display_srv_share_info_1_ctr: unavailable due to an internal error\n");
554                 return;
555         }
556
557         switch (action)
558         {
559                 case ACTION_HEADER:
560                 {
561                         break;
562                 }
563                 case ACTION_ENUMERATE:
564                 {
565                         int i;
566
567                         for (i = 0; i < ctr->num_entries_read; i++)
568                         {
569                                 display_share_info_1(out_hnd, ACTION_HEADER   , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
570                                 display_share_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i]));
571                                 display_share_info_1(out_hnd, ACTION_FOOTER   , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
572                         }
573                         break;
574                 }
575                 case ACTION_FOOTER:
576                 {
577                         break;
578                 }
579         }
580 }
581
582 /****************************************************************************
583 share info level 2 container display function
584 ****************************************************************************/
585 void display_srv_share_info_2_ctr(FILE *out_hnd, enum action_type action,
586                                 SRV_SHARE_INFO_2 *ctr)
587 {
588         if (ctr == NULL)
589         {
590                 fprintf(out_hnd, "display_srv_share_info_2_ctr: unavailable due to an internal error\n");
591                 return;
592         }
593
594         switch (action)
595         {
596                 case ACTION_HEADER:
597                 {
598                         break;
599                 }
600                 case ACTION_ENUMERATE:
601                 {
602                         int i;
603
604                         for (i = 0; i < ctr->num_entries_read; i++)
605                         {
606                                 display_share_info_2(out_hnd, ACTION_HEADER   , &(ctr->info_2[i]), &(ctr->info_2_str[i]));
607                                 display_share_info_2(out_hnd, ACTION_ENUMERATE, &(ctr->info_2[i]), &(ctr->info_2_str[i]));
608                                 display_share_info_2(out_hnd, ACTION_FOOTER   , &(ctr->info_2[i]), &(ctr->info_2_str[i]));
609                         }
610                         break;
611                 }
612                 case ACTION_FOOTER:
613                 {
614                         break;
615                 }
616         }
617 }
618
619 /****************************************************************************
620 share info container display function
621 ****************************************************************************/
622 void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
623                                 SRV_SHARE_INFO_CTR *ctr)
624 {
625         if (ctr == NULL || ctr->ptr_share_ctr == 0)
626         {
627                 fprintf(out_hnd, "display_srv_share_info_ctr: unavailable due to an internal error\n");
628                 return;
629         }
630
631         switch (ctr->switch_value)
632         {
633                 case 1:
634                 {
635                         display_srv_share_info_1_ctr(out_hnd, action,
636                                            &(ctr->share.info1));
637                         break;
638                 }
639                 case 2:
640                 {
641                         display_srv_share_info_2_ctr(out_hnd, action,
642                                            &(ctr->share.info2));
643                         break;
644                 }
645                 default:
646                 {
647                         fprintf(out_hnd, "display_srv_share_info_ctr: Unknown Info Level\n");
648                         break;
649                 }
650         }
651 }
652
653
654 /****************************************************************************
655 file info level 3 display function
656 ****************************************************************************/
657 void display_file_info_3(FILE *out_hnd, enum action_type action,
658                 FILE_INFO_3 *info3, FILE_INFO_3_STR *str3)
659 {
660         if (info3 == NULL || str3 == NULL)
661         {
662                 return;
663         }
664
665         switch (action)
666         {
667                 case ACTION_HEADER:
668                 {
669                         fprintf(out_hnd, "File Info Level 3:\n");
670
671                         break;
672                 }
673                 case ACTION_ENUMERATE:
674                 {
675                         fstring path_name;
676                         fstring user_name;
677
678                         fstrcpy(path_name, unistrn2(str3->uni_path_name.buffer, str3->uni_path_name.uni_str_len));
679                         fstrcpy(user_name, unistrn2(str3->uni_user_name.buffer, str3->uni_user_name.uni_str_len));
680
681                         fprintf(out_hnd, "\tid       : %d\n", info3->id);
682                         fprintf(out_hnd, "\tperms    : %s\n", get_file_mode_str(info3->perms));
683                         fprintf(out_hnd, "\tnum_locks: %d\n", info3->num_locks);
684
685                         fprintf(out_hnd, "\tpath name: %s\n", path_name);
686                         fprintf(out_hnd, "\tuser name: %s\n", user_name);
687
688                         break;
689                 }
690                 case ACTION_FOOTER:
691                 {
692                         fprintf(out_hnd, "\n");
693                         break;
694                 }
695         }
696
697 }
698
699 /****************************************************************************
700 file info level 3 container display function
701 ****************************************************************************/
702 void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action,
703                                 SRV_FILE_INFO_3 *ctr)
704 {
705         if (ctr == NULL)
706         {
707                 fprintf(out_hnd, "display_srv_file_info_3_ctr: unavailable due to an internal error\n");
708                 return;
709         }
710
711         switch (action)
712         {
713                 case ACTION_HEADER:
714                 {
715                         break;
716                 }
717                 case ACTION_ENUMERATE:
718                 {
719                         int i;
720
721                         for (i = 0; i < ctr->num_entries_read; i++)
722                         {
723                                 display_file_info_3(out_hnd, ACTION_HEADER   , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
724                                 display_file_info_3(out_hnd, ACTION_ENUMERATE, &(ctr->info_3[i]), &(ctr->info_3_str[i]));
725                                 display_file_info_3(out_hnd, ACTION_FOOTER   , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
726                         }
727                         break;
728                 }
729                 case ACTION_FOOTER:
730                 {
731                         break;
732                 }
733         }
734 }
735
736 /****************************************************************************
737 file info container display function
738 ****************************************************************************/
739 void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
740                                 SRV_FILE_INFO_CTR *ctr)
741 {
742         if (ctr == NULL || ctr->ptr_file_ctr == 0)
743         {
744                 fprintf(out_hnd, "display_srv_file_info_ctr: unavailable due to an internal error\n");
745                 return;
746         }
747
748         switch (ctr->switch_value)
749         {
750                 case 3:
751                 {
752                         display_srv_file_info_3_ctr(out_hnd, action,
753                                            &(ctr->file.info3));
754                         break;
755                 }
756                 default:
757                 {
758                         fprintf(out_hnd, "display_srv_file_info_ctr: Unknown Info Level\n");
759                         break;
760                 }
761         }
762 }
763
764 /****************************************************************************
765  print browse connection on a host
766  ****************************************************************************/
767 void display_server(FILE *out_hnd, enum action_type action,
768                                 char *sname, uint32 type, char *comment)
769 {
770         switch (action)
771         {
772                 case ACTION_HEADER:
773                 {
774                         break;
775                 }
776                 case ACTION_ENUMERATE:
777                 {
778                         fprintf(out_hnd, "\t%-15.15s%-20s %s\n",
779                                          sname, get_server_type_str(type), comment);
780                         break;
781                 }
782                 case ACTION_FOOTER:
783                 {
784                         break;
785                 }
786         }
787 }
788
789 /****************************************************************************
790 print shares on a host
791 ****************************************************************************/
792 void display_share(FILE *out_hnd, enum action_type action,
793                                 char *sname, uint32 type, char *comment)
794 {
795         switch (action)
796         {
797                 case ACTION_HEADER:
798                 {
799                         break;
800                 }
801                 case ACTION_ENUMERATE:
802                 {
803                         fprintf(out_hnd, "\t%-15.15s%-10.10s%s\n",
804                                          sname, get_share_type_str(type), comment);
805                         break;
806                 }
807                 case ACTION_FOOTER:
808                 {
809                         break;
810                 }
811         }
812 }
813
814
815 /****************************************************************************
816 print shares on a host, level 2
817 ****************************************************************************/
818 void display_share2(FILE *out_hnd, enum action_type action,
819                                 char *sname, uint32 type, char *comment,
820                                 uint32 perms, uint32 max_uses, uint32 num_uses,
821                                 char *path, char *passwd)
822 {
823         switch (action)
824         {
825                 case ACTION_HEADER:
826                 {
827                         break;
828                 }
829                 case ACTION_ENUMERATE:
830                 {
831                         fprintf(out_hnd, "\t%-15.15s%-10.10s%s %x %x %x %s %s\n",
832                                          sname, get_share_type_str(type), comment,
833                                          perms, max_uses, num_uses, path, passwd);
834                         break;
835                 }
836                 case ACTION_FOOTER:
837                 {
838                         break;
839                 }
840         }
841 }
842
843
844 /****************************************************************************
845 print name info
846 ****************************************************************************/
847 void display_name(FILE *out_hnd, enum action_type action,
848                                 char *sname)
849 {
850         switch (action)
851         {
852                 case ACTION_HEADER:
853                 {
854                         break;
855                 }
856                 case ACTION_ENUMERATE:
857                 {
858                         fprintf(out_hnd, "\t%-21.21s\n", sname);
859                         break;
860                 }
861                 case ACTION_FOOTER:
862                 {
863                         break;
864                 }
865         }
866 }
867
868
869 /****************************************************************************
870  display group rid info
871  ****************************************************************************/
872 void display_group_rid_info(FILE *out_hnd, enum action_type action,
873                                 uint32 num_gids, DOM_GID *gid)
874 {
875         switch (action)
876         {
877                 case ACTION_HEADER:
878                 {
879                         if (num_gids == 0)
880                         {
881                                 fprintf(out_hnd, "\tNo Groups\n");
882                         }
883                         else
884                         {
885                                 fprintf(out_hnd, "\tGroup Info\n");
886                                 fprintf(out_hnd, "\t----------\n");
887                         }
888                         break;
889                 }
890                 case ACTION_ENUMERATE:
891                 {
892                         int i;
893
894                         for (i = 0; i < num_gids; i++)
895                         {
896                                 fprintf(out_hnd, "\tGroup RID: %8x attr: %x\n",
897                                                                   gid[i].g_rid, gid[i].attr);
898                         }
899
900                         break;
901                 }
902                 case ACTION_FOOTER:
903                 {
904                         fprintf(out_hnd, "\n");
905                         break;
906                 }
907         }
908 }
909
910
911 /****************************************************************************
912  display alias name info
913  ****************************************************************************/
914 void display_alias_name_info(FILE *out_hnd, enum action_type action,
915                                 uint32 num_aliases, fstring *alias_name, uint32 *num_als_usrs)
916 {
917         switch (action)
918         {
919                 case ACTION_HEADER:
920                 {
921                         if (num_aliases == 0)
922                         {
923                                 fprintf(out_hnd, "\tNo Aliases\n");
924                         }
925                         else
926                         {
927                                 fprintf(out_hnd, "\tAlias Names\n");
928                                 fprintf(out_hnd, "\t----------- \n");
929                         }
930                         break;
931                 }
932                 case ACTION_ENUMERATE:
933                 {
934                         int i;
935
936                         for (i = 0; i < num_aliases; i++)
937                         {
938                                 fprintf(out_hnd, "\tAlias Name: %s Attributes: %3d\n",
939                                                                   alias_name[i], num_als_usrs[i]);
940                         }
941
942                         break;
943                 }
944                 case ACTION_FOOTER:
945                 {
946                         fprintf(out_hnd, "\n");
947                         break;
948                 }
949         }
950 }
951
952
953 /****************************************************************************
954  display sam_user_info_21 structure
955  ****************************************************************************/
956 void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *usr)
957 {
958         switch (action)
959         {
960                 case ACTION_HEADER:
961                 {
962                         fprintf(out_hnd, "\tUser Info, Level 0x15\n");
963                         fprintf(out_hnd, "\t---------------------\n");
964
965                         break;
966                 }
967                 case ACTION_ENUMERATE:
968                 {
969                         fprintf(out_hnd, "\t\tUser Name   : %s\n", unistrn2(usr->uni_user_name   .buffer, usr->uni_user_name   .uni_str_len)); /* username unicode string */
970                         fprintf(out_hnd, "\t\tFull Name   : %s\n", unistrn2(usr->uni_full_name   .buffer, usr->uni_full_name   .uni_str_len)); /* user's full name unicode string */
971                         fprintf(out_hnd, "\t\tHome Drive  : %s\n", unistrn2(usr->uni_home_dir    .buffer, usr->uni_home_dir    .uni_str_len)); /* home directory unicode string */
972                         fprintf(out_hnd, "\t\tDir Drive   : %s\n", unistrn2(usr->uni_dir_drive   .buffer, usr->uni_dir_drive   .uni_str_len)); /* home directory drive unicode string */
973                         fprintf(out_hnd, "\t\tProfile Path: %s\n", unistrn2(usr->uni_profile_path.buffer, usr->uni_profile_path.uni_str_len)); /* profile path unicode string */
974                         fprintf(out_hnd, "\t\tLogon Script: %s\n", unistrn2(usr->uni_logon_script.buffer, usr->uni_logon_script.uni_str_len)); /* logon script unicode string */
975                         fprintf(out_hnd, "\t\tDescription : %s\n", unistrn2(usr->uni_acct_desc   .buffer, usr->uni_acct_desc   .uni_str_len)); /* user description unicode string */
976                         fprintf(out_hnd, "\t\tWorkstations: %s\n", unistrn2(usr->uni_workstations.buffer, usr->uni_workstations.uni_str_len)); /* workstaions unicode string */
977                         fprintf(out_hnd, "\t\tUnknown Str : %s\n", unistrn2(usr->uni_unknown_str .buffer, usr->uni_unknown_str .uni_str_len)); /* unknown string unicode string */
978                         fprintf(out_hnd, "\t\tRemote Dial : %s\n", unistrn2(usr->uni_munged_dial .buffer, usr->uni_munged_dial .uni_str_len)); /* munged remote access unicode string */
979
980                         fprintf(out_hnd, "\t\tLogon Time               : %s\n", http_timestring(interpret_nt_time(&(usr->logon_time           ))));
981                         fprintf(out_hnd, "\t\tLogoff Time              : %s\n", http_timestring(interpret_nt_time(&(usr->logoff_time          ))));
982                         fprintf(out_hnd, "\t\tKickoff Time             : %s\n", http_timestring(interpret_nt_time(&(usr->kickoff_time         ))));
983                         fprintf(out_hnd, "\t\tPassword last set Time   : %s\n", http_timestring(interpret_nt_time(&(usr->pass_last_set_time   ))));
984                         fprintf(out_hnd, "\t\tPassword can change Time : %s\n", http_timestring(interpret_nt_time(&(usr->pass_can_change_time ))));
985                         fprintf(out_hnd, "\t\tPassword must change Time: %s\n", http_timestring(interpret_nt_time(&(usr->pass_must_change_time))));
986                         
987                         fprintf(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
988
989                         fprintf(out_hnd, "\t\tuser_rid : %x\n"  , usr->user_rid ); /* User ID */
990                         fprintf(out_hnd, "\t\tgroup_rid: %x\n"  , usr->group_rid); /* Group ID */
991                         fprintf(out_hnd, "\t\tacb_info : %04x\n", usr->acb_info ); /* Account Control Info */
992
993                         fprintf(out_hnd, "\t\tunknown_3: %08x\n", usr->unknown_3); /* 0x00ff ffff */
994                         fprintf(out_hnd, "\t\tlogon_divs: %d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
995                         fprintf(out_hnd, "\t\tunknown_5: %08x\n", usr->unknown_5); /* 0x0002 0000 */
996
997                         fprintf(out_hnd, "\t\tpadding1[0..7]...\n");
998
999                         if (usr->ptr_logon_hrs)
1000                         {
1001                                 fprintf(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
1002                         }
1003
1004                         break;
1005                 }
1006                 case ACTION_FOOTER:
1007                 {
1008                         fprintf(out_hnd, "\n");
1009                         break;
1010                 }
1011         }
1012 }
1013