f43aea029a881073e9903e956696341e3207ae3b
[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 where 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
9 $lastone = "nothing";
10
11 if (@ARGV[0]) {
12         $filename = @ARGV[0];
13 } else {
14         $filename = "/usr3/samba20/samba/source/param/loadparm.c";
15 }
16
17 open (INFILE,$filename) || die "unable to open $filename\n";
18 while (not eof(INFILE))
19 {
20         $_ = <INFILE>;
21         last if ( /^static struct parm_struct parm_table/) ;
22 }
23 print "Option Name                     Global Page  Share Page  Printer Page\n";
24 print "---------------------------------------------------------------------";
25 while (not eof(INFILE))
26 {
27         $_ = <INFILE>;
28         last if (/};/);
29         @fields = split(/,/,$_);
30         next if not ($fields[0] =~ /^.*{"/);
31         $fields[0] =~ s/.*{"//;
32         $fields[0] =~ s/"//;
33         if ($fields[3] eq $lastone) {
34                 print "     $fields[0]\n";
35                 next;
36         }
37         $lastone = $fields[3];
38         $fields[2] =~ s/^\s+//;
39         $fields[2] =~ s/\s+$//;
40         $fields[2] =~ s/}.*$//;
41         $fields[6] =~ s/^\s+//;
42         $fields[6] =~ s/\s+$//;
43         $fields[6] =~ s/}.*$//;
44         if ($fields[2] =~ /P_SEPARATOR/) {
45                 print "\n****************$fields[0]\n";
46                 next;
47         }
48         else {
49                 if ($fields[6] =~ /FLAG_DEPRECATED/) {
50                         print "*$fields[0]".' 'x(31-length($fields[0]));
51                 }
52                 else {
53                         print "$fields[0]".' 'x(32-length($fields[0]));
54                 }
55         }
56         if (($fields[2] =~ /P_GLOBAL/) || ($fields[6] =~ /FLAG_GLOBAL/)) {
57                 if ($fields[6] =~ /FLAG_GLOBAL/) {
58                         print "*";
59                 }
60                 else {
61                         print " ";
62                 }
63                 if ($fields[6] =~ /FLAG_BASIC/) {
64                         print "BASIC       ";
65                 }
66                 else {
67                         print "ADVANCED    ";
68                 }
69         }
70         else {
71                 print " no          ";
72         }
73         if ($fields[6] =~ /FLAG_SHARE/) {
74                 if ($fields[6] =~ /FLAG_BASIC/) {
75                         print "BASIC       ";
76                 }
77                 else {
78                         print "ADVANCED    ";
79                 }
80         }
81         else {
82                 print "no          ";
83         }
84         if ($fields[6] =~ /FLAG_PRINT/) {
85                 if ($fields[6] =~ /FLAG_BASIC/) {
86                         print "BASIC";
87                 }
88                 else {
89                         print "ADVANCED";
90                 }
91         }
92         else {
93                 print "no";
94         }
95         print "\n";
96 }