home *** CD-ROM | disk | FTP | other *** search
- #!/usr/sbin/perl
-
- # This is a script to dynamically create the Buttonfly menus
-
- # Grab the basic information
- require "/usr/demos/Demo_Interfaces/Web/cgi-scripts/DEMO_base.cgi";
-
-
- # Set the colors
- $color = ".9 .5 .9";
- $highcolor = "1.0 .7 1.0";
-
-
- # Grab the argument
- $switch = shift(@ARGV);
- @args = @ARGV;
-
-
- # Set DISPLAY
- $ENV{'DISPLAY'} = "localhost:0.0";
-
- # Go to the right process
-
- if ("$switch" eq "first" ) {
- &first;
- }
-
- if ("$switch" eq "hardware") {
- &hardware;
- }
- if ("$switch" eq "features") {
- &features;
- }
- if ("$switch" eq "industries") {
- &industries;
- }
- if ("$switch" eq "info") {
- &info;
- }
- if ("$switch" eq "man") {
- &man;
- }
- if ("$switch" eq "related") {
- &related;
- }
- if ("$switch" eq "howto") {
- &howto;
- }
-
-
-
- sub first {
- print <<END
-
- Features
- $basedir/Demo_Interfaces/Buttonfly/mkmenu features one
- .menu. -
- .popup. Features %t
- .color. $color
- .highcolor. $highcolor
- Hardware
- $basedir/Demo_Interfaces/Buttonfly/mkmenu hardware one
- .menu. -
- .popup. Hardware %t
-
- .color. $color
- .highcolor. $highcolor
- Industries
- $basedir/Demo_Interfaces/Buttonfly/mkmenu industries one
- .menu. -
- .popup. Industries %t
- .color. $color
- .highcolor. $highcolor
- END
- ;
-
- if (open(APP, "/usr/sbin/slaunch")) {
- close(APP);
- print <<EOF
- Find a Demo
- $basedir/Demo_Interfaces/Buttonfly/demofind
- .menu. -
- .popup. Find a Demo %t
- .color. $color
- .highcolor. $highcolor
- EOF
- ;
- }
- chdir("$basedir");
- opendir(DIR, "$basedir/Buttonfly");
- @allfiles = readdir(DIR);
- closedir(DIR);
- for (@allfiles) {
- push(@alldirs, $_) if chdir("$basedir/Buttonfly/$_");
- }
- @dirs = grep(!/^\.\.?$/, @alldirs);
- for (@dirs) {
- print <<END
- $_
- .cd. $basedir/Buttonfly/$_
- cat ./.m*
- .menu. -
- .popup. $_ %t
- .color. $color
- .highcolor. $highcolor
- END
- ;
- }
- }
-
- sub hardware {
-
- if ( "$args[0]" eq "one" ) {
- open(INDEX, "$basedir/Demo_Interfaces/Web/tables/hardware.index");
- while(<INDEX>) {
- chop;
- @type = split (/<br>/, $_);
- $key = shift(@type);
- if (@type) {
- push(@hardware, $key);
- }
- }
- foreach $i ( 0 .. $#hardware ) {
- if ( "$hardware[$i]" eq "ALL SYSTEMS" ) {
- next;
- } else {
- $title = "$hardware[$i]";
- $title =~ s/-/ - /;
- $title =~ s/SYSTEMS//;
- print "$title\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu hardware $hardware[$i]\n";
- print "\t.menu. -\n";
- print "\t.popup. $title %t\n";
- print "\t.color. $color\n";
- print "\t.highcolor. $highcolor\n";
- }
- }
- close(INDEX);
- } else {
- $index = "@args";
- open(INDEX, "$basedir/Demo_Interfaces/Web/tables/hardware.index");
- while(<INDEX>) {
- chop;
- @type = split (/<br>/, $_);
- $key = shift(@type);
- if (grep(/<br>$key<br>/, "<br>$index<br>")) {
- foreach $num ( 0 .. $#type ) {
- chdir("$basedir/General_Demos");
- opendir(DIR, "$basedir/General_Demos/$type[$num]");
- if(grep(/\.m_.*/, readdir(DIR))) {
- $execute = "$basedir/Demo_Interfaces/Buttonfly/mkmenu related $type[$num]";
- $type = "top";
- } else {
- $execute = "$basedir/General_Demos/$type[$num]/RUN";
- $type = "bottom";
- }
- close(DIR);
- print "$type[$num]\n";
- print "\t.cd. $basedir/General_Demos/$type[$num]\n";
- print "\t$execute\n";
- if ( "$type" eq "top" ) {
- print "\t.menu. -\n";
- print "\t.popup. $type[$num] %t\n";
- print "\t.color. $color\n";
- print "\t.highcolor. $highcolor\n";
- } else {
- print "\t.popup. $type[$num] %t\n";
- print "\t.popup. Manual\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu man $type[$num]\n";
- print "\t.popup. Information\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu info $type[$num]\n";
- }
- }
- }
- }
- close(INDEX);
- }
- }
-
- sub features {
-
- if ( "$args[0]" eq "one" ) {
- open(INDEX, "$basedir/Demo_Interfaces/Web/tables/features.index");
- while(<INDEX>) {
- chop;
- @type = split (/<br>/, $_);
- $key = shift(@type);
- if (@type) {
- push(@features, $key);
- }
- }
- foreach $i ( 0 .. $#features ) {
- $title = "$features[$i]";
- $title =~ s/-/ - /;
- print "$title\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu features $features[$i]\n";
- print "\t.menu. -\n";
- print "\t.popup. $title %t\n";
- print "\t.color. $color\n";
- print "\t.highcolor. $highcolor\n";
- }
- close(INDEX);
- } else {
- $index = "@args";
- open(INDEX, "$basedir/Demo_Interfaces/Web/tables/features.index");
- while(<INDEX>) {
- chop;
- @type = split (/<br>/, $_);
- $key = shift(@type);
- if (grep(/<br>$key<br>/, "<br>$index<br>")) {
- foreach $num ( 0 .. $#type ) {
- chdir("$basedir/General_Demos");
- opendir(DIR, "$basedir/General_Demos/$type[$num]");
- if(grep(/\.m_.*/, readdir(DIR))) {
- $execute = "$basedir/Demo_Interfaces/Buttonfly/mkmenu related $type[$num]";
- $type = "top";
- } else {
- $execute = "$basedir/General_Demos/$type[$num]/RUN";
- $type = "bottom";
- }
- close(DIR);
- print "$type[$num]\n";
- print "\t.cd. $basedir/General_Demos/$type[$num]\n";
- print "\t$execute\n";
- if ( "$type" eq "top" ) {
- print "\t.menu. -\n";
- print "\t.popup. $type[$num] %t\n";
- print "\t.color. $color\n";
- print "\t.highcolor. $highcolor\n";
- } else {
- print "\t.popup. $type[$num] %t\n";
- print "\t.popup. Manual\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu man $type[$num]\n";
- print "\t.popup. Information\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu info $type[$num]\n";
- }
- }
- }
- }
- close(INDEX);
- }
- }
-
- sub industries {
-
- if ( "$args[0]" eq "one" ) {
- open(INDEX, "$basedir/Demo_Interfaces/Web/tables/markets.index");
- while(<INDEX>) {
- chop;
- @type = split (/<br>/, $_);
- $key = shift(@type);
- if (@type) {
- push(@markets, $key);
- }
- }
- foreach $i ( 0 .. $#markets ) {
- $title = "$markets[$i]";
- $title =~ s/-/ - /;
- print "$title\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu industries $markets[$i]\n";
- print "\t.menu. -\n";
- print "\t.popup. $title %t\n";
- print "\t.color. $color\n";
- print "\t.highcolor. $highcolor\n";
- }
- close(INDEX);
- } else {
- $index = "@args";
- open(INDEX, "$basedir/Demo_Interfaces/Web/tables/markets.index");
- while(<INDEX>) {
- chop;
- @type = split (/<br>/, $_);
- $key = shift(@type);
- if (grep(/<br>$key<br>/, "<br>$index<br>")) {
- foreach $num ( 0 .. $#type ) {
- chdir("$basedir/General_Demos");
- opendir(DIR, "$basedir/General_Demos/$type[$num]");
- if(grep(/\.m_.*/, readdir(DIR))) {
- $execute = "$basedir/Demo_Interfaces/Buttonfly/mkmenu related $type[$num]";
- $type = "top";
- } else {
- $execute = "$basedir/General_Demos/$type[$num]/RUN";
- $type = "bottom";
- }
- close(DIR);
- print "$type[$num]\n";
- print "\t.cd. $basedir/General_Demos/$type[$num]\n";
- print "\t$execute\n";
- if ( "$type" eq "top" ) {
- print "\t.menu. -\n";
- print "\t.popup. $type[$num] %t\n";
- print "\t.color. $color\n";
- print "\t.highcolor. $highcolor\n";
- } else {
- print "\t.popup. $type[$num] %t\n";
- print "\t.popup. Manual\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu man $type[$num]\n";
- print "\t.popup. Information\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu info $type[$num]\n";
- }
- }
- }
- }
- close(INDEX);
- }
- }
-
-
-
-
-
- sub info {
- &infodemo("$basedir/General_Demos/$args[0]/.index");
- open(TMP, ">/tmp/demotmp");
- print TMP "$tags{'DESCRIPTION'}\n";
- close(TMP);
- print "$state";
- `/usr/sbin/fmt -60 /tmp/demotmp>/tmp/demoinfo`;
- `/usr/bin/X11/xconfirm -useslider -file "/tmp/demoinfo" -icon info`;
- `/sbin/rm /tmp/demotmp <<y`;
- `/sbin/rm /tmp/demoinfo <<y`;
- }
-
-
- sub man {
- $demo = $args[0];
- open(MAN, "/usr/bin/man $demo |");
- read(MAN, $out, 200);
- close(MAN);
- chop $out;
- if (grep(/No manual entry found for/, $out)) {
- `/usr/bin/X11/xconfirm -t "No Manual For $demo" -icon error>/dev/null&`;
- } else {
- open(CMD, "|/usr/bin/wsh -c man 6 $demo>/dev/null&");
- close(CMD);
- }
- }
-
- sub related {
- $demo = $args[0];
- chdir("$basedir/General_Demos");
- opendir(DIR, "$basedir/General_Demos/$demo");
- @menus = grep(/\.m_.*/, readdir(DIR));
- closedir(DIR);
- foreach $i ( 0 .. $#menus) {
- open(MENU, "$basedir/General_Demos/$demo/$menus[$i]");
- while (<MENU>) {
- print "$_"
- }
- close(MENU)
- }
- print "\n";
- print "$demo\n";
- print "\t.cd. $basedir/General_Demos/$demo\n";
- print "\t$basedir/General_Demos/$demo/RUN\n";
- print "\t.popup. $demo %t\n";
- print "\t.popup. Manual\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu man $demo\n";
- print "\t.popup. Information\n";
- print "\t$basedir/Demo_Interfaces/Buttonfly/mkmenu info $demo\n";
- }
-
-
- sub howto {
- `/usr/bin/X11/xconfirm -useslider -file "$basedir/Demo_Interfaces/Buttonfly/buttonfly.info" -icon info>/dev/null&`;
- }
-
-
-
-
-
- # Begin Subroutine
- sub infodemo {
-
- # Set the file to parse
- $file = $_[0];
-
- # Clear out the array %tags
- %tags = "";
-
- # Open the document
- open(DOC, "$file") || ($state = "bad");
-
- # Take each line and parse
- while (<DOC>) {
- if (grep(/\bEND_HTMLUI\s*/, $_)) {
- close(DOC);
- return scalar(@tags);
- exit;
- }
- $btw .= $_;
-
- # Remove newline
- chop;
-
- if ( &endmatch($_) ) {
- $junk .= $btw;
- $btw = "";
- }
-
-
- # Test to see if it is one of the tags
- if ( $endtag = &match($_) ) {
-
- # If it is, make sure it is not a "noparse" tag
- if (&avoid($_)) {
-
- $btw = "";
-
- #Grab the next line
- $_ = <DOC>;
-
- # Remove newline
- chop;
-
- # Remove commented lines
- if (grep(/^#/, $_)) {
- $_ = <DOC>;
- }
-
- # Keep feeding the lines into the array
- # as long as we don't hit the endtag
- while (!/$endtag((.|\s)*)/){
-
- # add the line to the array
-
- $key = $endtag;
- $key =~ s/END_//;
-
- # Add a newline if its your
- # first time around
- $_ = "\n$_" if (!$times);
- $tags{$key} .= "$_\n";
- local($times);
- $times = 1;
-
-
- # if we somehow hit another tag
- # (the endtag is missing or mispelled)
- # start over, not parsing for
- # the offending tag
- if ((&match($_)) ) {
- $junk .= $tags{$key};
- $tags{$key} .= "";
- push(@noparse, "$key:");
- &infodemo("$file");
- return scalar(@tags);
- }
-
- #Grab the next line
- $_ = <DOC>;
-
- # Remove newline
- chop;
-
- # Remove commented lines
- if (grep(/^#/, $_)) {
- $_ = <DOC>;
- chop;
- }
- }
- } else {
- $_ = <DOC>;
- }
- }
-
- }
- close(DOC);
- return scalar(@tags);
- }
-
-
- # Check the line against all possible elements
- sub match {
- $line = $_[0];
- foreach $tag ( @elements ) {
- $_ = $line;
- if (/\b$tag:\s*/) {
- return "END_$tag";
- }
- }
- return 0;
- }
-
- sub endmatch {
- $line = $_[0];
- foreach $tag ( @elements ) {
- $_ = $line;
- if (/\bEND_$tag\s*/) {
- return 1;
- }
- }
- return 0;
- }
-
-
-
- # Check to see if this is a tag we should avoid
- sub avoid {
- $line = $_[0];
- foreach $each ( @noparse ) {
- $_ = $line;
- if (/\b$each\s*/) {
- return 0;
- }
- }
- return 1;
- }
-
-
-
-