added a little description of useage and output format since this gives
[Samba/gbeck.git] / examples / misc / swat.pl
blobf6414b634972dece5284bc6822f63abf0e120a7a
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.
11 ## Useage: swat.pl [path_to_loadparm.c]
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.
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.
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.
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.
33 ## --herb@samba.org
35 $lastone = "nothing";
37 if (@ARGV[0]) {
38 $filename = @ARGV[0];
39 } else {
40 $filename = "/usr3/samba20/samba/source/param/loadparm.c";
43 open (INFILE,$filename) || die "unable to open $filename\n";
44 while (not eof(INFILE))
46 $_ = <INFILE>;
47 last if ( /^static struct parm_struct parm_table/) ;
49 print "Option Name Global Page Share Page Printer Page\n";
50 print "---------------------------------------------------------------------";
51 while (not eof(INFILE))
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;
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;
74 else {
75 if ($fields[6] =~ /FLAG_DEPRECATED/) {
76 print "*$fields[0]".' 'x(31-length($fields[0]));
78 else {
79 print "$fields[0]".' 'x(32-length($fields[0]));
82 if (($fields[2] =~ /P_GLOBAL/) || ($fields[6] =~ /FLAG_GLOBAL/)) {
83 if ($fields[6] =~ /FLAG_GLOBAL/) {
84 print "*";
86 else {
87 print " ";
89 if ($fields[6] =~ /FLAG_BASIC/) {
90 print "BASIC ";
92 else {
93 print "ADVANCED ";
96 else {
97 print " no ";
99 if ($fields[6] =~ /FLAG_SHARE/) {
100 if ($fields[6] =~ /FLAG_BASIC/) {
101 print "BASIC ";
103 else {
104 print "ADVANCED ";
107 else {
108 print "no ";
110 if ($fields[6] =~ /FLAG_PRINT/) {
111 if ($fields[6] =~ /FLAG_BASIC/) {
112 print "BASIC";
114 else {
115 print "ADVANCED";
118 else {
119 print "no";
121 print "\n";