This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.
[kai/samba.git] / examples / misc / swat.pl
1 #! /usr/bin/perl5
2 ##
3 ## This is a simple script written by Herb Lewis @ SGI <herb@samba.org>
4 ## for reporting which parameters are supported by loadparm.c but 
5 ## not by SWAT I just thought it looked fun and might be of interest to others
6 ## --jerry@samba.org
7 ##
8 ## Here is a little info on the usage and output format so you don't have
9 ## to dig through the code to understand what is printed.
10 ##
11 ## Useage: swat.pl [path_to_loadparm.c]
12 ##
13 ## The output consists of 4 columns of information
14 ##     Option Name, Global Page, Share Page, Printer Page
15 ## The section separaters will also be printed (preceded by 16 *) to show
16 ## which options are grouped in the various sections.
17 ##
18 ## If the option name is preceded by an * it means this is a deprecated option.
19 ## If the option name is preceded by 5 spaces it means this is an alias for the
20 ## previous option.
21 ##
22 ## Under the Global Page, Share Page, and Printer Page columns there will be
23 ## one of 3 entries, BASIC, ADVANCED, or no. "BASIC" indicates this option will
24 ## show in the Basic View of that page in SWAT. "ADVANCED" indicates this
25 ## option will show in the Advanced View of that page in SWAT. "No" indicates
26 ## that this option is not available on that page in SWAT.
27 ##
28 ## Under the Global Page column, if an entry begins with an * it indicates that
29 ## this is actually specified in Samba as a "service parameter" not a "global
30 ## parameter" but you can set a default value for this on the Global Page in
31 ## SWAT.
32 ##
33 ## --herb@samba.org
34
35 $lastone = "nothing";
36
37 if (@ARGV[0]) {
38         $filename = @ARGV[0];
39 } else {
40         $filename = "/usr3/samba20/samba/source/param/loadparm.c";
41 }
42
43 open (INFILE,$filename) || die "unable to open $filename\n";
44 while (not eof(INFILE))
45 {
46         $_ = <INFILE>;
47         last if ( /^static struct parm_struct parm_table/) ;
48 }
49 print "Option Name                     Global Page  Share Page  Printer Page\n";
50 print "---------------------------------------------------------------------";
51 while (not eof(INFILE))
52 {
53         $_ = <INFILE>;
54         last if (/};/);
55         @fields = split(/,/,$_);
56         next if not ($fields[0] =~ /^.*{"/);
57         $fields[0] =~ s/.*{"//;
58         $fields[0] =~ s/"//;
59         if ($fields[3] eq $lastone) {
60                 print "     $fields[0]\n";
61                 next;
62         }
63         $lastone = $fields[3];
64         $fields[2] =~ s/^\s+//;
65         $fields[2] =~ s/\s+$//;
66         $fields[2] =~ s/}.*$//;
67         $fields[6] =~ s/^\s+//;
68         $fields[6] =~ s/\s+$//;
69         $fields[6] =~ s/}.*$//;
70         if ($fields[2] =~ /P_SEPARATOR/) {
71                 print "\n****************$fields[0]\n";
72                 next;
73         }
74         else {
75                 if ($fields[6] =~ /FLAG_DEPRECATED/) {
76                         print "*$fields[0]".' 'x(31-length($fields[0]));
77                 }
78                 else {
79                         print "$fields[0]".' 'x(32-length($fields[0]));
80                 }
81         }
82         if (($fields[2] =~ /P_GLOBAL/) || ($fields[6] =~ /FLAG_GLOBAL/)) {
83                 if ($fields[6] =~ /FLAG_GLOBAL/) {
84                         print "*";
85                 }
86                 else {
87                         print " ";
88                 }
89                 if ($fields[6] =~ /FLAG_BASIC/) {
90                         print "BASIC       ";
91                 }
92                 else {
93                         print "ADVANCED    ";
94                 }
95         }
96         else {
97                 print " no          ";
98         }
99         if ($fields[6] =~ /FLAG_SHARE/) {
100                 if ($fields[6] =~ /FLAG_BASIC/) {
101                         print "BASIC       ";
102                 }
103                 else {
104                         print "ADVANCED    ";
105                 }
106         }
107         else {
108                 print "no          ";
109         }
110         if ($fields[6] =~ /FLAG_PRINT/) {
111                 if ($fields[6] =~ /FLAG_BASIC/) {
112                         print "BASIC";
113                 }
114                 else {
115                         print "ADVANCED";
116                 }
117         }
118         else {
119                 print "no";
120         }
121         print "\n";
122 }